/* 与你灵魂契合的诗词 · 宣纸水墨 */
:root {
  --paper: #f4f0e6;
  --paper-2: #efe9db;
  --ink: #23201c;
  --ink-soft: #4a453e;
  --ink-dim: #8b8477;
  --seal: #a8342a;
  --seal-soft: #c05a4a;
  --jade: #5f7a68;
  --line: rgba(35, 32, 28, .12);
  --card: rgba(255, 255, 255, .55);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { overflow: hidden; }

#app {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  height: 100%;
  overflow: hidden;
}

/* 宣纸纹理 */
.paper-texture {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(168, 52, 42, .035), transparent 42%),
    radial-gradient(circle at 82% 78%, rgba(95, 122, 104, .05), transparent 48%),
    linear-gradient(180deg, #f6f2e9 0%, #f1ebdd 55%, #eee7d8 100%);
}
.paper-texture::after {
  content: ''; position: absolute; inset: 0; opacity: .5;
  background-image: repeating-linear-gradient(0deg, rgba(35,32,28,.018) 0 1px, transparent 1px 3px);
}

/* ---------- 屏幕 ---------- */
.screen { position: absolute; inset: 0; display: none; flex-direction: column; z-index: 1; }
.screen.active { display: flex; }

/* ---------- 首页 ---------- */
.home-inner {
  margin: auto; width: 100%;
  padding: calc(48px + env(safe-area-inset-top)) 30px 40px;
  text-align: center;
}
.home-eyebrow {
  font-size: 12px; letter-spacing: .34em; color: var(--ink-dim);
  margin-bottom: 22px;
}
.home-title {
  font-family: "Songti SC", "SimSun", "Source Han Serif SC", serif;
  font-size: 40px; font-weight: 600; line-height: 1.42; letter-spacing: .08em;
  color: var(--ink);
}
.home-title span { display: block; }
.home-title em {
  font-style: normal; color: var(--seal);
  border-bottom: 2px solid rgba(168, 52, 42, .25); padding-bottom: 2px;
}
.home-sub {
  margin-top: 20px; font-size: 13px; line-height: 2.1; color: var(--ink-dim);
  font-family: "Songti SC", "SimSun", serif;
}
.home-scene { height: 108px; margin: 18px -10px 8px; opacity: .9; }
.home-scene svg { width: 100%; height: 100%; }

.btn {
  display: block; width: 100%; padding: 14px 0; border: 0; border-radius: 4px;
  font-size: 16px; font-weight: 600; font-family: inherit; cursor: pointer;
  color: var(--ink); background: rgba(35, 32, 28, .07);
  transition: transform .15s;
}
.btn:active { transform: scale(.985); }
.btn-primary {
  color: #fdfaf3;
  background: linear-gradient(135deg, #b23c30, #8f2b22);
  box-shadow: 0 8px 22px rgba(168, 52, 42, .22);
  letter-spacing: .18em;
}
.btn-lg { margin-top: 22px; padding: 16px 0; font-size: 16px; }
.btn-ghost {
  margin-top: 12px; background: transparent; border: 1px solid var(--line);
  color: var(--ink-soft); font-weight: 500; font-size: 13px; padding: 11px 0;
}

.home-meta {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--line);
}
.meta-item b {
  display: block; font-size: 19px; color: var(--seal); font-weight: 600;
  font-family: "Songti SC", serif;
}
.meta-item span { font-size: 11px; color: var(--ink-dim); }
.home-tip { margin-top: 18px; font-size: 11px; color: var(--ink-dim); }

/* ---------- 答题 ---------- */
.quiz-top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 10px;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .6); color: var(--ink-soft);
  font-size: 18px; cursor: pointer; line-height: 1;
}
.quiz-progress { flex: 1; height: 3px; border-radius: 2px; background: rgba(35, 32, 28, .1); overflow: hidden; }
.quiz-progress-bar { height: 100%; width: 3%; background: var(--seal); transition: width .35s ease; }
.quiz-count { font-size: 11px; color: var(--ink-dim); min-width: 46px; text-align: right; font-variant-numeric: tabular-nums; }

.quiz-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 10px 22px calc(30px + var(--safe-b));
}
.quiz-dim {
  display: flex; align-items: center; gap: 7px; justify-content: center;
  margin-bottom: 20px; font-size: 12px; color: var(--ink-dim);
}
.dim-icon { font-size: 15px; }
.dim-name { color: var(--seal); letter-spacing: .2em; }

.quiz-card { animation: fadeUp .34s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.quiz-question {
  font-family: "Songti SC", "SimSun", serif;
  font-size: 20px; line-height: 1.72; font-weight: 600; margin-bottom: 26px;
  letter-spacing: .02em;
}
.quiz-options { display: flex; flex-direction: column; gap: 11px; }
.opt {
  display: flex; align-items: center; gap: 13px; text-align: left;
  padding: 15px 16px; border-radius: 3px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .5);
  color: var(--ink-soft); font-size: 15px; line-height: 1.55;
  font-family: inherit; cursor: pointer; transition: all .18s ease;
}
.opt:active { transform: scale(.988); }
.opt-letter {
  flex: none; width: 24px; height: 24px; border-radius: 2px;
  display: grid; place-items: center;
  border: 1px solid rgba(35, 32, 28, .18); color: var(--ink-dim);
  font-size: 12px; font-family: "Songti SC", serif;
}
.opt.picked { border-color: rgba(168, 52, 42, .5); background: rgba(168, 52, 42, .06); color: var(--ink); }
.opt.picked .opt-letter { background: var(--seal); border-color: var(--seal); color: #fdfaf3; }
.quiz-foot { margin-top: 26px; text-align: center; font-size: 11px; color: var(--ink-dim); }

/* ---------- 分析 ---------- */
.analysis-box { margin: auto; text-align: center; padding: 30px; }
.ink-orb {
  width: 110px; height: 110px; margin: 0 auto 30px; border-radius: 50%;
  border: 1px solid rgba(35, 32, 28, .14);
  display: grid; place-items: center; position: relative;
  animation: breathe 2.6s ease-in-out infinite;
}
.ink-orb::before {
  content: ''; position: absolute; inset: 14px; border-radius: 50%;
  border: 1px dashed rgba(168, 52, 42, .3);
  animation: spin 9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.ink-dot {
  width: 42px; height: 42px; border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #4a453e, #23201c 68%);
  opacity: .82; animation: blur 2.4s ease-in-out infinite;
}
@keyframes blur { 0%, 100% { filter: blur(0); opacity: .82; } 50% { filter: blur(5px); opacity: .5; } }
.analysis-text {
  font-family: "Songti SC", serif; font-size: 15px; color: var(--ink-soft);
  margin-bottom: 18px; min-height: 24px; letter-spacing: .08em;
}
.analysis-bar { width: 180px; height: 2px; margin: 0 auto; background: rgba(35, 32, 28, .1); overflow: hidden; }
.analysis-bar-fill { height: 100%; width: 0; background: var(--seal); transition: width .3s ease; }
.analysis-sub { margin-top: 16px; font-size: 11px; color: var(--ink-dim); }

/* ---------- 结果 ---------- */
.scroll-area { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 12px; }

.result-hero {
  position: relative; padding: calc(30px + env(safe-area-inset-top)) 28px 30px;
  text-align: center; overflow: hidden;
}
.hero-scene { position: absolute; inset: 0; opacity: .55; }
.hero-scene svg { width: 100%; height: 100%; }
.hero-home { position: absolute; top: calc(14px + env(safe-area-inset-top)); left: 16px; z-index: 2; }
.hero-label {
  position: relative; font-size: 11px; letter-spacing: .3em; color: var(--ink-dim);
  margin-bottom: 20px;
}
.hero-poem {
  position: relative;
  font-family: "Songti SC", "SimSun", "Source Han Serif SC", serif;
  font-size: 26px; line-height: 1.86; font-weight: 600; letter-spacing: .05em;
  color: var(--ink); padding: 0 4px;
}
.hero-poem .sep { color: var(--seal); opacity: .5; margin: 0 2px; }
.hero-from {
  position: relative; margin-top: 16px; font-size: 12px; color: var(--ink-dim);
  letter-spacing: .1em;
}
.hero-match { position: relative; margin-top: 24px; }
.match-num {
  font-family: "Songti SC", serif; font-size: 54px; font-weight: 600; color: var(--seal);
  line-height: 1;
}
.match-pct { font-size: 20px; color: var(--seal); opacity: .7; }
.hero-match small { display: block; margin-top: 6px; font-size: 11px; color: var(--ink-dim); letter-spacing: .2em; }
.hero-type {
  position: relative; margin-top: 18px;
}
.hero-type span {
  display: inline-block; padding: 6px 18px; border: 1px solid rgba(168, 52, 42, .3);
  border-radius: 2px; font-size: 13px; color: var(--seal); letter-spacing: .14em;
  background: rgba(168, 52, 42, .04);
}

.panel {
  margin: 0 16px 14px; padding: 22px 20px; border-radius: 3px;
  background: rgba(255, 255, 255, .5); border: 1px solid var(--line);
}
.panel-title {
  font-family: "Songti SC", serif; font-size: 15px; font-weight: 600;
  letter-spacing: .1em; margin-bottom: 16px; color: var(--ink);
}
.panel-title small {
  display: block; margin-top: 6px; font-size: 11px; font-weight: 400;
  color: var(--ink-dim); letter-spacing: .04em;
}

.radar-wrap { display: grid; place-items: center; }
#radar-canvas { width: 100%; max-width: 310px; height: auto; }
.radar-legend { display: flex; flex-wrap: wrap; gap: 7px 13px; margin-top: 12px; justify-content: center; }
.radar-legend span { font-size: 11px; color: var(--ink-dim); display: flex; align-items: center; gap: 5px; }
.radar-legend i { width: 7px; height: 7px; border-radius: 1px; display: inline-block; }

.reason-lead {
  font-size: 13px; line-height: 1.95; color: var(--ink-soft); margin-bottom: 18px;
  font-family: "Songti SC", serif;
}
.dim-list { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.dim-row-top { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.dim-row-top b { font-weight: 600; }
.dim-row-top .dim-score { margin-left: auto; color: var(--seal); font-size: 12px; font-variant-numeric: tabular-nums; }
.dim-row .dim-desc { margin-top: 5px; font-size: 11px; color: var(--ink-dim); line-height: 1.7; }
.dim-bar { margin-top: 7px; height: 3px; background: rgba(35, 32, 28, .08); overflow: hidden; }
.dim-bar i { display: block; height: 100%; background: linear-gradient(90deg, rgba(95,122,104,.7), var(--seal)); }

.alt-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.alt-item {
  padding: 12px 0; border-bottom: 1px dashed rgba(35, 32, 28, .1);
  cursor: pointer; transition: opacity .2s;
}
.alt-item:last-child { border-bottom: 0; }
.alt-item:active { opacity: .6; }
.alt-line {
  font-family: "Songti SC", serif; font-size: 15px; line-height: 1.7; color: var(--ink);
}
.alt-meta {
  display: flex; justify-content: space-between; margin-top: 5px;
  font-size: 11px; color: var(--ink-dim);
}
.alt-meta .alt-match { color: var(--seal); opacity: .8; }
.alt-item.on .alt-line { color: var(--seal); }

.panel-seal { background: rgba(168, 52, 42, .045); border-color: rgba(168, 52, 42, .18); text-align: center; }
.seal-text {
  font-family: "Songti SC", serif; font-size: 13px; line-height: 2; color: var(--ink-soft);
}
.seal-sub { margin-top: 12px; font-size: 10px; color: var(--ink-dim); letter-spacing: .18em; }

.result-spacer { height: 10px; }

/* ---------- 底部操作 ---------- */
.action-bar {
  display: flex; gap: 9px; padding: 12px 16px calc(12px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: rgba(246, 242, 233, .94);
  backdrop-filter: blur(8px);
}
.action-btn {
  flex: 1; padding: 12px 0; border-radius: 3px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .6); color: var(--ink-soft);
  font-size: 14px; font-weight: 500; font-family: inherit; cursor: pointer;
}
.action-btn:active { transform: scale(.985); }
.action-primary { color: #fdfaf3; border: 0; background: linear-gradient(135deg, #b23c30, #8f2b22); }

/* ---------- 海报 ---------- */
.modal {
  position: absolute; inset: 0; display: none; place-items: center;
  background: rgba(30, 26, 22, .85); z-index: 50; padding: 20px;
}
.modal.active { display: grid; }
.poster-wrap { width: 100%; max-width: 310px; text-align: center; }
.poster-img { display: block; width: 100%; height: auto; border-radius: 2px; box-shadow: 0 12px 40px rgba(0,0,0,.4); }
.poster-hint { margin: 14px 0; font-size: 11px; color: rgba(255,255,255,.6); }
.poster-actions { display: flex; flex-direction: column; gap: 9px; }
.poster-actions .btn { text-decoration: none; text-align: center; background: rgba(255,255,255,.14); color: #f4f0e6; }
.poster-actions .btn-primary { background: linear-gradient(135deg, #b23c30, #8f2b22); color: #fdfaf3; }

/* ---------- Toast ---------- */
.toast {
  position: absolute; left: 50%; bottom: calc(86px + var(--safe-b));
  transform: translate(-50%, 12px);
  max-width: 82%; padding: 10px 18px; border-radius: 2px;
  background: rgba(35, 32, 28, .9); color: #f4f0e6; font-size: 12px;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 60; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 截图/调试用：内容自然展开，便于整页截图 */
body.flat, body.flat #app { height: auto; overflow: visible; }
body.flat .screen { position: relative; display: none; }
body.flat .screen.active { display: block; }
body.flat .scroll-area { overflow: visible; }
body.flat .quiz-body { overflow: visible; }

/* ---------- 授权码 ---------- */
.code-inner {
  margin: auto; width: 100%; max-width: 340px;
  padding: 40px 28px; text-align: center; position: relative;
}
.code-back { position: absolute; top: 24px; left: 20px; }
.code-badge { font-size: 32px; margin-bottom: 12px; }
.code-title {
  font-family: "Songti SC", "SimSun", serif;
  font-size: 24px; font-weight: 600; letter-spacing: .1em;
}
.code-sub { margin-top: 10px; font-size: 12px; color: var(--ink-dim); line-height: 1.8; }
.code-sub b { color: var(--seal); }
.code-input {
  width: 100%; margin-top: 24px; padding: 15px 16px;
  background: rgba(255, 255, 255, .7); border: 1px solid var(--line); border-radius: 3px;
  color: var(--ink); font-size: 17px; letter-spacing: .12em; text-align: center;
  font-family: ui-monospace, Consolas, monospace;
}
.code-input:focus { outline: none; border-color: rgba(168, 52, 42, .5); background: #fff; }
.code-msg { min-height: 20px; margin: 10px 0 4px; font-size: 12px; color: var(--ink-dim); }
.code-msg.err { color: #b03a2e; }
.code-msg.ok { color: #4a7c59; }
.code-tip { margin: 16px 0 0; font-size: 11px; line-height: 1.7; color: var(--ink-dim); }

/* 首页提示可点（换授权码） */
.home-tip.tip-link { color: var(--seal); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* 结果页本次消耗 */
.hero-cost {
  position: relative; margin-top: 12px; font-size: 11px; color: var(--ink-dim);
}

/* hidden 属性必须压过 .btn 的 display:block，否则「查看上次结果」等按钮首次就会露面 */
[hidden] { display: none !important; }
