:root {
  --bg: #e9edf9;
  --panel: #ffffff;
  --panel-soft: #f7f8fd;
  --ink: #171a2f;
  --muted: #737891;
  --faint: #aeb4c8;
  --line: #e8ebf5;
  --primary: #6671cf;
  --primary-dark: #505bb5;
  --accent: #83b8d7;
  --warm: #f2b58e;
  --shadow: 0 22px 60px rgba(78, 89, 140, 0.18);
  --soft-shadow: 0 14px 30px rgba(86, 95, 145, 0.12);
  --hover-lift: translateY(-4px);
  --transition-fast: 180ms ease;
  --transition-smooth: 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background:
    radial-gradient(circle at 32% 0%, rgba(255,255,255,0.72), transparent 32%),
    linear-gradient(135deg, #dfe5f7 0%, #f3f6fb 58%, #e5ebf8 100%);
}

button, input { font: inherit; }
button { cursor: pointer; }

.page-shell {
  width: min(1180px, calc(100% - 40px));
  min-height: 720px;
  margin: 7vh auto;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 300px;
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(255,255,255,0.78);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.sidebar, .insights { background: rgba(255,255,255,0.82); }

.sidebar {
  padding: 44px 28px 28px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(231,234,246,0.85);
}

.brand {
  display: flex; gap: 12px; align-items: center;
  color: var(--ink); text-decoration: none; margin-bottom: 44px;
}

.brand-mark {
  width: 38px; height: 38px; border-radius: 13px;
  display: grid; place-items: center;
  color: #fff; font-weight: 800;
  background: linear-gradient(145deg, var(--primary), var(--accent));
  box-shadow: 0 10px 24px rgba(102,113,207,0.28);
}

.brand strong { display: block; font-size: 18px; }
.brand small, .nav-item small, .sidebar-footer small, .section-heading p, .eyebrow {
  display: block; color: var(--muted); font-size: 11px; line-height: 1.4;
}

.nav-list { display: grid; gap: 10px; }

.nav-item {
  min-height: 44px; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 12px; color: #363a54; text-decoration: none;
  transition: background var(--transition-fast);
}
.nav-item:hover { background: #f5f6fc; }
.nav-item.is-active { color: var(--primary-dark); background: #f0f2ff; }

.nav-icon {
  width: 26px; height: 26px; border-radius: 9px;
  display: grid; place-items: center;
  background: #f7f8fe; border: 1px solid #edf0fa;
  font-size: 15px;
}

.sidebar-footer {
  margin-top: auto; display: flex; gap: 10px; align-items: center;
  padding: 12px; border-radius: 16px; background: var(--panel-soft);
}

.status-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: #7bc79a; box-shadow: 0 0 0 6px rgba(123,199,154,0.14);
}

.workspace { min-width: 0; padding: 38px 36px; background: rgba(244,246,253,0.68); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 30px;
}

.topbar-actions { display: flex; gap: 10px; }

.eyebrow { margin: 0 0 7px; text-transform: uppercase; letter-spacing: 0.08em; }

h1, h2, p { margin: 0; }
h1 { font-size: clamp(26px,4vw,38px); line-height: 1.05; }
h1 span { display: block; color: var(--muted); font-size: 16px; font-weight: 500; margin-top: 8px; }
h2 { font-size: 17px; }

.primary-button, .ghost-button { border: 0; white-space: nowrap; }

.primary-button {
  min-height: 42px; display: inline-flex; align-items: center; gap: 9px;
  padding: 0 18px; border-radius: 999px; color: #fff;
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  box-shadow: 0 12px 24px rgba(80,91,181,0.28);
  font-size: 12px; font-weight: 700;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.primary-button:hover { transform: scale(1.03); box-shadow: 0 14px 28px rgba(80,91,181,0.35); }
.primary-button:active { transform: scale(0.98); }
.primary-button span { font-size: 18px; line-height: 1; }

.ghost-button {
  height: 34px; padding: 0 14px; border-radius: 999px;
  color: var(--muted); background: rgba(255,255,255,0.72);
  border: 1px solid var(--line); font-size: 11px;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.ghost-button:hover { background: rgba(255,255,255,0.95); color: var(--ink); }

.section-heading { margin-bottom: 16px; }
.section-heading.compact { margin-bottom: 14px; }

/* 游戏区域 */
.game-area { animation: fadeIn 200ms ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 颜色对比区 */
.color-display-section { margin-bottom: 28px; }

.color-blocks {
  display: flex; align-items: center; justify-content: center; gap: 24px;
}

.color-block-wrapper { text-align: center; }

.color-label {
  font-size: 12px; color: var(--muted); margin-bottom: 8px; text-transform: uppercase;
  letter-spacing: 0.05em;
}

.color-block {
  width: 140px; height: 140px; border-radius: 18px;
  background: rgb(128,128,128);
  box-shadow: var(--soft-shadow), inset 0 2px 4px rgba(255,255,255,0.3);
  border: 3px solid rgba(255,255,255,0.6);
  transition: background 0.2s ease;
}

.vs-badge {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--panel); color: var(--muted);
  font-size: 12px; font-weight: 700;
  box-shadow: var(--soft-shadow);
}

.color-name { font-size: 13px; color: var(--muted); margin-top: 8px; min-height: 20px; }

/* 滑块区 */
.sliders-section {
  padding: 24px; border-radius: 18px;
  background: rgba(255,255,255,0.62);
  box-shadow: 0 10px 28px rgba(86,95,145,0.08);
  margin-bottom: 20px;
}

.slider-group { margin-bottom: 18px; }
.slider-group:last-child { margin-bottom: 0; }

.slider-label {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}

.slider-name {
  font-size: 14px; font-weight: 700; width: 20px; height: 20px;
  display: inline-grid; place-items: center; border-radius: 6px;
  background: rgba(255,255,255,0.8);
}

.slider-value {
  font-size: 14px; font-weight: 600; color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.slider {
  width: 100%; height: 8px; -webkit-appearance: none; appearance: none;
  border-radius: 999px; outline: none; cursor: pointer;
  background: linear-gradient(90deg, #000, var(--primary));
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(102,113,207,0.3);
}

.slider::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  cursor: pointer;
}

.slider-r { background: linear-gradient(90deg, #000, #f87171); }
.slider-r::-webkit-slider-thumb { border-color: #f87171; }
.slider-r::-moz-range-thumb { border-color: #f87171; }

.slider-g { background: linear-gradient(90deg, #000, #4ade80); }
.slider-g::-webkit-slider-thumb { border-color: #4ade80; }
.slider-g::-moz-range-thumb { border-color: #4ade80; }

.slider-b { background: linear-gradient(90deg, #000, #60a5fa); }
.slider-b::-webkit-slider-thumb { border-color: #60a5fa; }
.slider-b::-moz-range-thumb { border-color: #60a5fa; }

/* 提交按钮 */
.submit-section { text-align: center; margin-bottom: 24px; }

.submit-btn { min-width: 200px; }

/* 结果 */
.result-section {
  text-align: center; padding: 24px; border-radius: 18px;
  background: rgba(255,255,255,0.72);
  box-shadow: var(--soft-shadow);
  animation: fadeIn 300ms ease;
}

.result-card { margin-bottom: 16px; }

.result-score {
  font-size: 56px; font-weight: 800; color: var(--primary);
  line-height: 1; margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.result-label { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.result-detail { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* 右侧栏 */
.insights { padding: 34px 28px; border-left: 1px solid rgba(231,234,246,0.85); }

.storage-card {
  padding: 18px; border-radius: 20px;
  background: var(--panel); box-shadow: var(--soft-shadow);
}

.storage-card + .storage-card { margin-top: 16px; }

.stat-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-top: 1px solid var(--line);
  font-size: 13px;
}
.stat-row:first-of-type { border-top: 0; }
.stat-row span { color: var(--muted); }
.stat-row strong { color: var(--ink); font-variant-numeric: tabular-nums; }

.color-info {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
}

.color-info-swatch {
  width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
  background: var(--primary);
  border: 2px solid rgba(255,255,255,0.6);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.color-info strong { display: block; font-size: 14px; }
.color-info p { margin: 2px 0 0; font-size: 12px; color: var(--muted); font-family: monospace; }

.history-list { max-height: 200px; overflow-y: auto; }

.history-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.history-item:last-child { border-bottom: 0; }

.history-swatch {
  width: 20px; height: 20px; border-radius: 6px; flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.6);
}

.history-score { font-weight: 700; color: var(--primary); margin-left: auto; }
.history-round { color: var(--muted); }

.empty-hint { color: var(--muted); font-size: 12px; text-align: center; padding: 12px; }

/* 难度按钮 */
.difficulty-options { display: flex; gap: 8px; }

.diff-btn {
  flex: 1; padding: 10px 0; border: 1px solid var(--line);
  border-radius: 10px; background: rgba(255,255,255,0.72);
  color: var(--muted); font-size: 12px; font-weight: 600;
  transition: all var(--transition-fast);
}
.diff-btn:hover { background: rgba(255,255,255,0.95); color: var(--ink); }
.diff-btn.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(102,113,207,0.25);
}

/* 弹窗 */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: none; place-items: center;
  background: rgba(0,0,0,0.25); backdrop-filter: blur(6px);
  animation: modalFadeIn 200ms ease;
}
.modal-overlay.is-open { display: grid; }

.modal-box {
  width: min(400px, calc(100% - 48px)); padding: 32px;
  border-radius: 20px; background: rgba(255,255,255,0.92);
  backdrop-filter: blur(24px); border: 1px solid rgba(255,255,255,0.6);
  box-shadow: 0 24px 64px rgba(0,0,0,0.12);
  text-align: center; animation: modalSlideUp 280ms cubic-bezier(0.4,0,0.2,1);
}

.modal-icon {
  width: 52px; height: 52px; margin: 0 auto 18px;
  display: grid; place-items: center; border-radius: 50%;
  font-size: 24px; font-weight: 700; color: #fff;
  background: linear-gradient(145deg, var(--primary), var(--accent));
  box-shadow: 0 8px 20px rgba(102,113,207,0.3);
}

.modal-title { font-size: 18px; font-weight: 700; color: var(--ink); margin-bottom: 12px; }
.modal-text { font-size: 14px; color: var(--muted); line-height: 1.6; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-confirm { min-width: 120px; }

@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 响应式 */
@media (max-width: 1040px) {
  .page-shell { grid-template-columns: 190px minmax(0,1fr); }
  .insights {
    grid-column: 1/-1; border-left: 0; border-top: 1px solid rgba(231,234,246,0.85);
    display: grid; grid-template-columns: repeat(2,1fr); gap: 16px;
  }
}

@media (max-width: 760px) {
  .page-shell { width: min(100% - 24px, 560px); margin: 18px auto; grid-template-columns: 1fr; border-radius: 22px; }
  .sidebar { padding: 22px; border-right: 0; border-bottom: 1px solid rgba(231,234,246,0.85); }
  .workspace, .insights { padding: 22px; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .topbar-actions { width: 100%; }
  .topbar-actions .primary-button, .topbar-actions .ghost-button { flex: 1; justify-content: center; }
  .color-blocks { flex-direction: column; gap: 16px; }
  .color-block { width: 120px; height: 120px; }
  .insights { grid-template-columns: 1fr; }
}
.autof-legal { position: fixed; right: 18px; bottom: 10px; z-index: 10; font-size: 11px; color: #64748b; }
.autof-legal a { color: inherit; text-decoration: none; }
