/* =========================================================
   结构化思维训练 · 暗色水墨工坊设计系统
   ========================================================= */

:root {
  /* 墨色层阶 */
  --ink-900: #0b0c0f;
  --ink-850: #101116;
  --ink-800: #16181d;
  --ink-750: #1c1f25;
  --ink-700: #24272e;

  /* 纸色文字 */
  --paper:   #ece6d8;
  --paper-2: #b9b2a4;
  --paper-3: #807a6f;

  /* 金铜强调 */
  --gold:    #c9a96e;
  --gold-2:  #e4c883;
  --gold-3:  #9a7b45;

  /* 语义色（去饱和，贴合暗金调） */
  --jade:  #84b393;
  --amber: #d9a441;
  --rose:  #d2715f;

  /* 线条 */
  --hairline: rgba(236, 230, 216, 0.09);
  --hairline-2: rgba(236, 230, 216, 0.14);
  --gold-line: rgba(201, 169, 110, 0.22);

  /* 渐变 */
  --grad-gold: linear-gradient(135deg, #e4c883 0%, #c9a96e 55%, #9a7b45 100%);
  --grad-panel: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0));
  --grad-bg:
    radial-gradient(1100px 620px at 78% -8%, rgba(201,169,110,0.12), transparent 58%),
    radial-gradient(820px 480px at 8% 4%, rgba(86,98,128,0.07), transparent 55%),
    var(--ink-900);

  /* 字体 */
  --font-display: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --font-sans: "Noto Sans SC", -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-num: "Fraunces", "Noto Serif SC", serif;

  /* 间距（8pt） */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  /* 圆角 */
  --r1: 8px; --r2: 14px; --r3: 20px; --pill: 999px;

  /* 阴影 /  elevation */
  --elev-1: 0 1px 2px rgba(0,0,0,.4);
  --elev-2: 0 10px 34px rgba(0,0,0,.45);
  --elev-3: 0 24px 70px rgba(0,0,0,.55);
  --glow-gold: 0 0 0 1px rgba(201,169,110,.35), 0 10px 34px rgba(201,169,110,.14);

  /* 动效 */
  --t-fast: .18s;
  --t: .28s;
  --t-slow: .55s;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* 分数环 */
  --ring-c: 326.7; /* 2*pi*52 */
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--grad-bg);
  background-attachment: fixed;
  color: var(--paper);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

::selection { background: rgba(201,169,110,.28); color: #fff; }

/* ---------- 屏幕切换 ---------- */
.screen { display: none; min-height: 100dvh; flex-direction: column; }
.screen.is-active { display: flex; animation: screenIn var(--t-slow) var(--ease); }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- 通用文字 ---------- */
.eyebrow {
  font-size: 12px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--gold); font-weight: 500;
}
.field-label {
  display: block; font-size: 13px; font-weight: 500; color: var(--paper-2);
  margin: var(--s4) 0 var(--s2);
}
.field-label:first-child { margin-top: 0; }

/* ---------- 按钮 ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s2); min-height: 44px; padding: 0 var(--s5);
  font-family: var(--font-sans); font-size: 15px; font-weight: 500;
  border: 1px solid transparent; border-radius: var(--pill);
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: transform var(--t-fast) var(--ease), background var(--t), border-color var(--t), box-shadow var(--t), color var(--t);
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 3px; }
.btn[disabled] { cursor: not-allowed; opacity: .6; }

.btn-primary {
  color: #1a1408; background: var(--grad-gold);
  box-shadow: var(--glow-gold); font-weight: 700;
}
.btn-primary:hover:not([disabled]) { box-shadow: 0 0 0 1px rgba(201,169,110,.5), 0 14px 40px rgba(201,169,110,.28); }

.btn-ghost {
  color: var(--paper-2); background: transparent; border-color: var(--hairline-2);
}
.btn-ghost:hover:not([disabled]) { color: var(--paper); border-color: var(--gold-line); background: rgba(201,169,110,.06); }

.btn-dashed {
  color: var(--gold); background: rgba(201,169,110,.05);
  border: 1px dashed var(--gold-line); width: 100%;
}
.btn-dashed:hover { background: rgba(201,169,110,.1); }

.btn-block { width: 100%; padding: 0 var(--s5); }

/* spinner */
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(26,20,8,.35); border-top-color: #1a1408;
  display: none; animation: spin .7s linear infinite;
}
.btn[disabled] .spinner { display: inline-block; }
.btn[disabled] .btn-label { opacity: .85; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 表单 ---------- */
.field-input {
  width: 100%; padding: var(--s3) var(--s4);
  font-family: var(--font-sans); font-size: 15px; color: var(--paper);
  background: rgba(255,255,255,.03);
  border: 1px solid var(--hairline-2); border-radius: var(--r2);
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
.field-input::placeholder { color: var(--paper-3); }
.field-input:focus {
  outline: none; border-color: var(--gold);
  background: rgba(201,169,110,.06);
  box-shadow: 0 0 0 3px rgba(201,169,110,.12);
}
.ta { resize: vertical; min-height: 44px; line-height: 1.6; }

.check { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s4); font-size: 13px; color: var(--paper-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--gold); }

.field-error { margin-top: var(--s3); font-size: 13px; color: var(--rose); }

/* ---------- 图标 ---------- */
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic-lg { width: 46px; height: 46px; stroke: var(--paper-3); }

/* =========================================================
   屏 1 · 登录
   ========================================================= */
.login-shell {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--s7) var(--s4); gap: var(--s5); text-align: center;
}
.brand { display: flex; align-items: center; gap: var(--s3); }
.brand-mark { width: 42px; height: 42px; }
.bm-ring { fill: none; stroke: var(--gold); stroke-width: 1.4; opacity: .8; }
.bm-needle { fill: var(--gold); opacity: .9; }
.bm-core { fill: var(--paper); }
.brand-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.brand-cn { font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: .04em; }
.brand-en { font-size: 10px; letter-spacing: .26em; color: var(--paper-3); }

.login-card {
  width: 100%; max-width: 420px; padding: var(--s7) var(--s6);
  background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.01));
  border: 1px solid var(--hairline); border-radius: var(--r3);
  box-shadow: var(--elev-2); backdrop-filter: blur(8px);
  animation: cardIn var(--t-slow) var(--ease) .08s both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
.login-title { font-family: var(--font-display); font-size: 28px; font-weight: 600; letter-spacing: .02em; }
.login-sub { margin-top: var(--s3); color: var(--paper-2); font-size: 14px; }
.login-form { margin-top: var(--s6); text-align: left; }
.login-points { list-style: none; margin-top: var(--s6); display: flex; flex-direction: column; gap: var(--s2); text-align: left; }
.login-points li { display: flex; align-items: center; gap: var(--s3); font-size: 13px; color: var(--paper-2); }
.login-points .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); flex: none; box-shadow: 0 0 8px rgba(201,169,110,.6); }
.login-foot { font-size: 12px; color: var(--paper-3); letter-spacing: .04em; }

/* =========================================================
   顶栏
   ========================================================= */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s4) var(--s5); border-bottom: 1px solid var(--hairline);
  background: rgba(11,12,15,.6); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20;
}
.topbar-user { display: flex; align-items: center; gap: var(--s2); font-size: 14px; color: var(--paper); }
.topbar-user .ic { color: var(--gold); }
.score-pill {
  margin-left: var(--s3); padding: 4px 12px; font-size: 12px; color: var(--gold-2);
  background: rgba(201,169,110,.1); border: 1px solid var(--gold-line); border-radius: var(--pill);
}
.topbar-spacer { width: 96px; }

/* =========================================================
   屏 2 · 设定
   ========================================================= */
.setup-main { flex: 1; width: 100%; max-width: 680px; margin: 0 auto; padding: var(--s7) var(--s4) var(--s8); }
.setup-head { margin-bottom: var(--s6); }
.setup-head h2 { font-family: var(--font-display); font-size: 26px; font-weight: 600; margin: var(--s3) 0; }
.setup-hint { color: var(--paper-2); font-size: 14px; }
.situation-list { display: flex; flex-direction: column; gap: var(--s4); }
.situation-item {
  padding: var(--s4); border: 1px solid var(--hairline); border-radius: var(--r2);
  background: var(--grad-panel); animation: cardIn var(--t) var(--ease) both;
}
.situation-item .si-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s2); }
.si-label { font-size: 13px; font-weight: 600; color: var(--gold); }
.si-del { background: none; border: none; color: var(--paper-3); cursor: pointer; padding: 4px; border-radius: 6px; }
.si-del:hover { color: var(--rose); background: rgba(210,113,95,.1); }
.setup-actions { display: flex; gap: var(--s3); margin-top: var(--s6); }
.setup-actions .btn-ghost { flex: 0 0 auto; }
.setup-actions .btn-primary { flex: 1; }

/* =========================================================
   屏 3 · 训练
   ========================================================= */
.train-main { flex: 1; display: flex; min-height: 0; }
.question-panel {
  flex: 0 0 40%; max-width: 560px; padding: var(--s6) var(--s6);
  border-right: 1px solid var(--hairline); overflow-y: auto;
  display: flex; flex-direction: column;
}
.q-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.q-type {
  padding: 5px 14px; font-size: 13px; font-weight: 600; color: var(--gold-2);
  background: rgba(201,169,110,.1); border: 1px solid var(--gold-line); border-radius: var(--pill);
}
.q-index { font-family: var(--font-num); font-size: 15px; color: var(--paper-3); letter-spacing: .04em; }
.q-progress { height: 3px; margin: var(--s4) 0 var(--s5); background: var(--hairline); border-radius: var(--pill); overflow: hidden; }
#q-progress-bar { display: block; height: 100%; width: 0; background: var(--grad-gold); border-radius: var(--pill); transition: width var(--t-slow) var(--ease); }
.q-title { font-family: var(--font-display); font-size: 23px; font-weight: 600; line-height: 1.5; }
.q-body { margin-top: var(--s4); color: var(--paper-2); font-size: 15px; white-space: pre-wrap; }
.q-cat { margin-top: var(--s5); font-size: 12px; color: var(--paper-3); letter-spacing: .04em; }

.answer-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.tabs { display: flex; gap: var(--s2); padding: var(--s4) var(--s5) 0; border-bottom: 1px solid var(--hairline); }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  padding: var(--s3) var(--s2) var(--s4); background: none; border: none; cursor: pointer;
  font-family: var(--font-sans); font-size: 14px; font-weight: 500; color: var(--paper-3);
  border-bottom: 2px solid transparent; transition: color var(--t), border-color var(--t);
}
.tab .tab-no { font-family: var(--font-num); color: var(--gold); }
.tab.is-active { color: var(--paper); border-bottom-color: var(--gold); }
.tab-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--hairline-2); transition: background var(--t); }
.tab-dot.done { background: var(--jade); box-shadow: 0 0 8px rgba(132,179,147,.6); }

.tab-body { flex: 1; overflow-y: auto; padding: var(--s5) var(--s5) var(--s4); }
.pane { display: none; animation: fadeIn var(--t) var(--ease); }
.pane.is-active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.action-bar {
  display: flex; gap: var(--s3); justify-content: flex-end; padding: var(--s4) var(--s5);
  border-top: 1px solid var(--hairline); background: rgba(11,12,15,.5);
}

/* =========================================================
   屏 4 · 记录
   ========================================================= */
.history-main { flex: 1; width: 100%; max-width: 880px; margin: 0 auto; padding: var(--s6) var(--s4) var(--s8); }
.history-h { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.history-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s4); margin: var(--s5) 0 var(--s6); }
.stat-card { padding: var(--s4) var(--s5); border: 1px solid var(--hairline); border-radius: var(--r2); background: var(--grad-panel); }
.stat-label { font-size: 12px; color: var(--paper-3); letter-spacing: .04em; }
.stat-value { font-family: var(--font-num); font-size: 28px; font-weight: 600; color: var(--paper); margin-top: 4px; }
.stat-value.gold { color: var(--gold-2); }

.history-list { display: flex; flex-direction: column; gap: var(--s4); }
.history-item { padding: var(--s5); border: 1px solid var(--hairline); border-radius: var(--r2); background: var(--grad-panel); transition: border-color var(--t); }
.history-item:hover { border-color: var(--gold-line); }
.hi-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); }
.hi-title { font-size: 16px; font-weight: 600; color: var(--paper); }
.hi-score { font-family: var(--font-num); font-size: 20px; font-weight: 600; color: var(--gold-2); flex: none; }
.hi-meta { margin-top: 4px; font-size: 12px; color: var(--paper-3); display: flex; gap: var(--s3); }
.hi-detail { margin-top: var(--s4); padding-top: var(--s4); border-top: 1px dashed var(--hairline); display: grid; gap: var(--s3); }
.hi-row { font-size: 13px; color: var(--paper-2); }
.hi-row b { color: var(--paper); font-weight: 600; }
.hi-ma { white-space: pre-wrap; font-size: 13px; color: var(--paper-2); background: rgba(0,0,0,.25); padding: var(--s3); border-radius: var(--r1); border: 1px solid var(--hairline); }
.history-empty { text-align: center; padding: var(--s8) var(--s4); color: var(--paper-3); }
.history-empty p { margin-top: var(--s4); font-size: 14px; }

/* =========================================================
   结果覆盖层
   ========================================================= */
.overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: var(--s4); }
.overlay[hidden] { display: none; }
.overlay-backdrop { position: absolute; inset: 0; background: rgba(6,7,9,.72); backdrop-filter: blur(6px); animation: fadeIn var(--t) var(--ease); }
.result-card {
  position: relative; width: 100%; max-width: 600px; max-height: 90dvh; overflow-y: auto;
  padding: var(--s7) var(--s6) var(--s6); border: 1px solid var(--gold-line); border-radius: var(--r3);
  background: linear-gradient(180deg, rgba(28,31,37,.98), rgba(16,17,22,.98));
  box-shadow: var(--elev-3); animation: resultIn var(--t-slow) var(--ease);
}
@keyframes resultIn { from { opacity: 0; transform: translateY(24px) scale(.97); } to { opacity: 1; transform: none; } }
.overlay-close { position: absolute; top: var(--s4); right: var(--s4); width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; background: none; border: 1px solid var(--hairline); border-radius: 50%; color: var(--paper-2); cursor: pointer; transition: var(--t); }
.overlay-close:hover { color: var(--paper); border-color: var(--gold-line); }

.result-head { display: flex; align-items: center; gap: var(--s5); margin-bottom: var(--s5); }
.score-ring { position: relative; width: 120px; height: 120px; flex: none; }
.score-ring svg { width: 120px; height: 120px; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: rgba(236,230,216,.08); stroke-width: 8; }
.ring-fill { fill: none; stroke: var(--ring-color, var(--gold)); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1s var(--ease), stroke var(--t); }
.score-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-num { font-family: var(--font-num); font-size: 40px; font-weight: 600; line-height: 1; color: var(--ring-color, var(--gold)); }
.score-den { font-size: 12px; color: var(--paper-3); }

.result-meta { min-width: 0; }
.result-meta .eyebrow { display: block; }
.result-level { font-family: var(--font-display); font-size: 24px; font-weight: 600; margin: 2px 0 6px; color: var(--paper); }
.result-qtitle { font-size: 14px; color: var(--paper-2); }

.result-dims { display: grid; gap: var(--s3); margin-bottom: var(--s5); }
.dim { padding: var(--s4); border: 1px solid var(--hairline); border-radius: var(--r2); background: rgba(255,255,255,.02); }
.dim-top { display: flex; align-items: center; justify-content: space-between; font-size: 14px; color: var(--paper); margin-bottom: var(--s2); }
.dim-top b { font-family: var(--font-num); font-size: 18px; color: var(--gold-2); }
.dim p { font-size: 14px; color: var(--paper-2); line-height: 1.7; }

.result-tags { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); margin-bottom: var(--s5); }
.tag-block { padding: var(--s4); border: 1px solid var(--hairline); border-radius: var(--r2); }
.tag-h { display: block; font-size: 13px; font-weight: 600; color: var(--gold); margin-bottom: var(--s2); }
.tag-block ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.tag-block li { font-size: 13px; color: var(--paper-2); line-height: 1.6; }

.model-answer { margin-bottom: var(--s5); }
.model-answer .tag-h { margin-bottom: var(--s2); }
#model-answer-content { white-space: pre-wrap; font-family: var(--font-sans); font-size: 13px; line-height: 1.8; color: var(--paper-2); background: rgba(0,0,0,.28); padding: var(--s4); border-radius: var(--r2); border: 1px solid var(--hairline); }

.result-actions { display: flex; gap: var(--s3); justify-content: flex-end; }

/* 分数档位配色 */
.band-excellent { --ring-color: var(--gold-2); }
.band-good { --ring-color: var(--jade); }
.band-mid { --ring-color: var(--amber); }
.band-weak { --ring-color: var(--rose); }

/* =========================================================
   Toast
   ========================================================= */
.toast-root { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: var(--s2); align-items: center; pointer-events: none; }
.toast {
  padding: 12px 20px; border-radius: var(--pill); font-size: 14px; color: var(--paper);
  background: rgba(28,31,37,.96); border: 1px solid var(--gold-line); box-shadow: var(--elev-2);
  backdrop-filter: blur(8px); animation: toastIn var(--t) var(--ease);
}
.toast.err { border-color: rgba(210,113,95,.5); color: #f0c4bb; }
.toast.ok { border-color: rgba(132,179,147,.5); color: #cfe3d3; }
.toast.info { border-color: rgba(201,169,110,.55); color: var(--gold); }
.toast.warn { border-color: rgba(214,178,110,.6); color: #f1d9a8; }
.btn-submitting { opacity: .8; cursor: progress; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.toast.out { animation: toastOut var(--t) var(--ease) forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateY(12px); } }

/* =========================================================
   响应式
   ========================================================= */
@media (max-width: 1080px) {
  .train-main { flex-direction: column; }
  .question-panel { flex: none; max-width: none; border-right: none; border-bottom: 1px solid var(--hairline); max-height: 42vh; }
  .answer-panel { flex: 1; }
}
@media (max-width: 680px) {
  :root { --s7: 40px; }
  .login-card { padding: var(--s6) var(--s5); }
  .login-title { font-size: 24px; }
  .setup-main, .history-main { padding-left: var(--s4); padding-right: var(--s4); }
  .history-stats { grid-template-columns: repeat(2, 1fr); }
  .result-tags { grid-template-columns: 1fr; }
  .topbar { padding: var(--s3) var(--s4); }
  .question-panel { padding: var(--s5) var(--s4); }
  .tabs { padding-left: var(--s4); padding-right: var(--s4); }
  .tab-body { padding: var(--s4); }
  .action-bar { padding: var(--s3) var(--s4); }
  .result-card { padding: var(--s6) var(--s4) var(--s5); }
  .result-head { flex-direction: column; text-align: center; gap: var(--s3); }
  .setup-actions { flex-direction: column-reverse; }
  .setup-actions .btn-primary { width: 100%; }
  .score-pill { display: none; }
}
@media (max-width: 420px) {
  .history-stats { grid-template-columns: 1fr 1fr; }
  .login-shell { padding: var(--s5) var(--s3); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
