/* ============================================================
   洞真 · 纸墨设计系统
   基调：宣纸暖底 + 墨字 + 朱砂印章点睛（Anthropic 式暖纸学派，
   东方「验真」气质）。零外链零 CDN：全部系统字体栈与内联资源。
   token 三层：色板 / 字阶 / 间距，改皮肤只动 :root。
   ============================================================ */

:root {
  /* 纸与墨 */
  --paper: #f6f3ea;
  --paper-deep: #efe9d9;
  --surface: #fdfbf5;
  --ink: #24211a;
  --ink-soft: #3c372b;
  --muted: #6f6a58;
  --faint: #99917c;
  --line: #e4decb;
  --line-strong: #cfc7ae;
  /* 朱砂（印章） */
  --seal: #b23b28;
  --seal-bright: #c04430;
  --seal-deep: #8e2b1c;
  --seal-soft: #f7e8e1;
  --seal-wash: #fbf3ec;
  /* 竹青（本地/安全）与信号色 */
  --leaf: #47714f;
  --leaf-soft: #eaf0e2;
  --leaf-line: #cbd9c2;
  --amber: #8f6510;
  --amber-soft: #f6ecd4;
  --amber-line: #e8d9ae;
  --danger: #9e2b20;
  --danger-soft: #f9e9e4;
  --danger-line: #ecd0c8;
  /* 字阶 */
  --font-sans: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", system-ui, sans-serif;
  --font-serif: Georgia, "Times New Roman", "Noto Serif SC", "Source Han Serif SC", "Songti SC", STSong, SimSun, serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, "Courier New", monospace;
  /* 节奏 */
  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 14px;
  --shadow-card: 0 1px 2px rgba(36, 33, 26, .05);
  --shadow-lift: 0 6px 18px rgba(36, 33, 26, .09);
}

/* ---- 基底 ---- */

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
/* 宣纸颗粒：内联 SVG 噪点覆层，极低透明度，给纸面一点呼吸 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: .04;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}
::selection { background: var(--seal-soft); color: var(--seal-deep); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .5; }
a:focus-visible, button:focus-visible, textarea:focus-visible { outline: 2px solid var(--seal); outline-offset: 2px; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(1turn); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ---- 顶栏：纸面毛玻璃 ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 4vw, 28px);
  background: rgba(246, 243, 234, .85);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.product-name, .topbar-status { display: flex; align-items: center; gap: 11px; }
/* 印章 Logo：朱砂方印，白文「真」 */
.product-seal, .product-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  color: #fdfbf5;
  background: linear-gradient(160deg, var(--seal-bright), var(--seal-deep));
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(253, 251, 245, .22), 0 1px 3px rgba(142, 43, 28, .3);
}
.product-name strong { font-family: var(--font-serif); font-size: 17px; letter-spacing: 3px; font-weight: 700; }
.topbar-status { color: var(--muted); font-size: 12px; letter-spacing: .5px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: pulse 1.4s ease-in-out infinite; }
body[data-bank-state="ready"] .status-dot { background: var(--leaf); animation: none; box-shadow: 0 0 0 3px rgba(71, 113, 79, .15); }
body[data-bank-state="error"] .status-dot { background: var(--danger); animation: none; }

/* ---- 主列与诗境 ---- */

.main-content, .static-main { min-width: 0; max-width: 920px; margin: 0 auto; padding: 0 24px 88px; }

.hero { position: relative; padding: clamp(38px, 7vh, 66px) 0 8px; text-align: center; }
/* 「精」之微光：印章暖晕，极淡 */
.hero::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -30px;
  width: min(640px, 92%);
  height: 250px;
  transform: translateX(-50%);
  background: radial-gradient(55% 65% at 50% 42%, rgba(192, 68, 48, .075), transparent 72%);
  pointer-events: none;
}
/* 底纹大字「真」：宣纸压印，几乎不可见只余质感 */
.hero::after {
  content: "真";
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  font-family: var(--font-serif);
  font-size: clamp(200px, 30vw, 320px);
  line-height: 1;
  color: rgba(178, 59, 40, .045);
  pointer-events: none;
  user-select: none;
}
.verse { position: relative; }
.verse-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 3vw, 24px);
  margin: 0;
}
.verse-line::before, .verse-line::after {
  content: "";
  height: 1px;
  width: clamp(36px, 8vw, 96px);
  flex: 0 0 auto;
}
.verse-line::before { background: linear-gradient(to right, transparent, var(--line-strong)); }
.verse-line::after { background: linear-gradient(to left, transparent, var(--line-strong)); }
.verse-half {
  display: inline-block;
  color: var(--ink-soft);
  font-family: var(--font-serif);
  font-size: clamp(16px, 2.2vw, 21px);
  font-weight: 600;
  letter-spacing: clamp(3px, .55vw, 7px);
  white-space: nowrap;
  padding: 0 2px 3px;
}
/* 下联「其精甚真，其中有信」压一道极淡朱砂笔洗（不改文字本体，只衬背景） */
.verse-half + .verse-half {
  background: linear-gradient(to top, rgba(178, 59, 40, .12) 34%, transparent 34%);
}
.verse-source {
  margin: 15px 0 0;
  padding-left: 6px;
  color: var(--faint);
  font-size: 11px;
  letter-spacing: 6px;
}

/* ---- 工作区 ---- */

.workspace { display: none; max-width: 100%; margin: 0 auto; }
.workspace.active { display: block; }
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  margin: clamp(26px, 4.5vh, 40px) 0 22px;
}
.page-header h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(24px, 3.4vw, 31px);
  font-weight: 600;
  letter-spacing: 4px;
  line-height: 1.25;
}
.page-sub { margin: 9px 0 0; color: var(--muted); font-size: 13px; letter-spacing: .5px; }
.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  color: var(--leaf);
  background: var(--leaf-soft);
  border: 1px solid var(--leaf-line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  white-space: nowrap;
}
.privacy-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--leaf); }

/* ---- 按钮：朱砂印章 = 主行动 ---- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.5px;
  transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease, border-color .18s ease, color .18s ease;
}
.button.primary {
  position: relative;
  min-height: 46px;
  padding: 0 30px;
  color: #fdf8f2;
  background: linear-gradient(172deg, var(--seal-bright), var(--seal-deep));
  border-color: var(--seal-deep);
  border-radius: 10px;
  font-size: 14px;
  letter-spacing: 5px;
  text-indent: 5px;
  box-shadow: 0 2px 8px rgba(142, 43, 28, .26), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.button.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(142, 43, 28, .32), inset 0 1px 0 rgba(255, 255, 255, .18);
}
/* 按下如盖印 */
.button.primary:active:not(:disabled) { transform: translateY(1px) scale(.985); box-shadow: 0 1px 4px rgba(142, 43, 28, .3); }
.button.primary:disabled { opacity: .45; transform: none; box-shadow: none; }
.button.primary.is-loading { color: transparent; pointer-events: none; }
.button.primary.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(253, 248, 242, .35);
  border-top-color: #fdf8f2;
  animation: spin .7s linear infinite;
}
.button.secondary { color: var(--ink-soft); background: var(--surface); border-color: var(--line-strong); }
.button.secondary:hover:not(:disabled) { color: var(--ink); border-color: var(--ink); transform: translateY(-1px); }
.button.secondary:active:not(:disabled) { transform: none; }

/* ---- 三次挑战 ---- */

.panel-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.panel-toolbar strong {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 3px;
  color: var(--ink);
}
.panel-toolbar strong::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--seal);
  transform: rotate(45deg);
}
.challenge-list { display: grid; gap: 14px; padding: 15px 0 18px; }
.challenge-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: border-color .18s ease, box-shadow .18s ease;
  animation: rise .45s ease backwards;
}
.challenge-item:hover { border-color: var(--line-strong); box-shadow: var(--shadow-lift); }
.challenge-item:nth-child(1) { animation-delay: .04s; }
.challenge-item:nth-child(2) { animation-delay: .11s; }
.challenge-item:nth-child(3) { animation-delay: .18s; }
.challenge-header {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  background: #f4efe2;
  border-bottom: 1px solid var(--line);
}
.challenge-header strong { font-size: 13px; letter-spacing: 2px; }
.challenge-header > span { color: var(--faint); font-size: 11px; font-family: var(--font-mono); }
.challenge-header button {
  justify-self: end;
  padding: 6px 9px;
  color: var(--seal);
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  transition: background-color .18s ease, transform .12s ease;
}
.challenge-header button:hover { background: var(--seal-soft); }
.challenge-header button:active { transform: scale(.96); }
.challenge-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 15px 16px; }
.challenge-columns > div { min-width: 0; }
label, .challenge-columns label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
}
pre, textarea {
  width: 100%;
  margin: 0;
  border-radius: var(--radius-s);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
pre {
  min-height: 142px;
  padding: 12px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink-soft);
  background: var(--paper-deep);
  border: 1px solid var(--line);
  font: 11.5px/1.7 var(--font-mono);
}
textarea {
  min-height: 142px;
  padding: 12px;
  resize: vertical;
  color: var(--ink);
  background: #fffef9;
  border: 1px solid var(--line-strong);
  font: 12px/1.7 var(--font-mono);
}
textarea::placeholder { color: var(--faint); }
textarea:focus { border-color: var(--seal); box-shadow: 0 0 0 3px rgba(178, 59, 40, .12); }
.action-row { display: flex; justify-content: flex-end; align-items: center; gap: 20px; }

/* ---- 状态条 ---- */

.message {
  margin-top: 16px;
  padding: 12px 15px;
  border: 1px solid;
  border-radius: 10px;
  font-size: 12.5px;
  letter-spacing: .3px;
  animation: rise .3s ease;
}
.message.error { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-line); }
.message.success { color: var(--leaf); background: var(--leaf-soft); border-color: var(--leaf-line); }
.message.working { display: flex; align-items: center; gap: 9px; color: var(--amber); background: var(--amber-soft); border-color: var(--amber-line); }
.message.working::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.2s ease-in-out infinite;
}

/* ---- 结果区：钤印定谳 ---- */

.result-panel {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-top: 2px solid var(--seal);
  border-radius: var(--radius-l);
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(36, 33, 26, .08);
  overflow: hidden;
  scroll-margin-top: 84px;
  animation: rise .5s ease;
}
.result-summary { display: grid; grid-template-columns: 1.4fr 1fr 1.2fr 1fr; border-bottom: 1px solid var(--line); }
.result-summary > div { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; }
.result-summary > div + div { border-left: 1px solid var(--line); }
.result-summary span { color: var(--faint); font-size: 10px; letter-spacing: 2.5px; }
.result-summary strong { font-family: var(--font-serif); font-size: 19px; letter-spacing: .5px; }
.diagnostics { display: flex; flex-wrap: wrap; gap: 8px; padding: 13px 18px; border-bottom: 1px solid var(--line); background: #fbf8ee; }
.diagnostic { padding: 5px 10px; border-radius: 999px; font-size: 10.5px; font-family: var(--font-mono); }
.diagnostic.accepted { color: var(--leaf); background: var(--leaf-soft); }
.diagnostic.rejected { color: var(--danger); background: var(--danger-soft); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  color: var(--faint);
  background: #f6f2e6;
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 2px;
  text-align: left;
}
th, td { padding: 11px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.winner { background: var(--seal-wash); box-shadow: inset 3px 0 0 var(--seal); }
tbody tr.winner td strong { color: var(--seal-deep); }
.probability-cell { display: flex; align-items: center; gap: 10px; min-width: 230px; }
.probability-cell > span { width: 160px; height: 6px; overflow: hidden; background: #eae4d2; border-radius: 99px; }
.probability-cell i { display: block; height: 100%; background: linear-gradient(90deg, #c9573f, var(--seal)); border-radius: inherit; }
.probability-cell strong { font-family: var(--font-mono); font-size: 12px; }
td { font-variant-numeric: tabular-nums; }
.result-guidance { padding: 13px 18px; color: var(--muted); font-size: 11.5px; line-height: 1.8; border-top: 1px solid var(--line); }
.result-guidance p { margin: 0; }
.result-guidance p + p { margin-top: 4px; }

/* ---- 页脚小字 ---- */

.ai-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 30px 0 0;
  color: var(--faint);
  font-size: 11px;
  letter-spacing: 1.5px;
}
.ai-hint::before, .ai-hint::after { content: ""; height: 1px; width: 38px; background: var(--line); }

/* ---- 响应式 ---- */

@media (max-width: 900px) {
  .challenge-columns { grid-template-columns: 1fr; }
  .result-summary { grid-template-columns: 1fr 1fr; }
  .result-summary > div:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .result-summary > div:nth-child(4) { border-top: 1px solid var(--line); }
}

@media (max-width: 640px) {
  .topbar { height: 54px; padding: 0 14px; }
  .main-content, .static-main { padding: 0 14px 64px; }
  .hero { padding-top: 30px; }
  /* 窄屏按「；」断成两行，对联式居中 */
  .verse-line { flex-direction: column; gap: 10px; }
  .verse-line::before, .verse-line::after { display: none; }
  .verse-half { font-size: 15px; letter-spacing: 3.5px; line-height: 1.9; }
  .verse-source { margin-top: 11px; }
  .page-header, .panel-toolbar, .action-row { align-items: stretch; flex-direction: column; }
  .panel-toolbar { gap: 12px; }
  .privacy-badge { align-self: flex-start; }
  .button, .button.primary { width: 100%; letter-spacing: 3px; text-indent: 3px; }
  .probability-cell > span { width: 110px; }
  .probability-cell { min-width: 0; }
}

/* ---- 动效克制：偏好减弱时全部静止 ---- */

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