:root {
  --paper: #F3ECDD;
  --paper-2: #EBE2CE;
  --card: #FBF8F0;
  --ink: #2A2521;
  --ink-2: #5B5047;
  --line: #D9CDB4;
  --ochre: #A8741F;
  --teal: #4F6F6C;
  --teal-d: #3A5A57;
  --seal: #A8432F;
  --serif: "Songti SC", "STSong", "Source Han Serif SC", "Noto Serif CJK SC", "Noto Serif SC", "SimSun", "Songti TC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.75;
  background: var(--paper);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(255,255,255,.55), transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(168,116,31,.07), transparent 50%);
  background-attachment: fixed;
  min-height: 100vh; min-height: 100dvh;
}
#app { max-width: 560px; margin: 0 auto; padding: 0 20px calc(32px + env(safe-area-inset-bottom)); min-height: 100vh; min-height: 100dvh; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; margin: 0; letter-spacing: .04em; }
p { margin: 0 0 .8em; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; border-radius: 6px; }
[tabindex="-1"]:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 24px; text-align: center; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 28px; border-radius: 999px; border: 1px solid var(--ink);
  background: var(--ink); color: #FBF3E4; font-family: var(--serif); font-size: 18px; letter-spacing: .15em; font-weight: 600;
  transition: transform .15s, background .2s;
}
.btn:active { transform: scale(.98); }
.btn:hover { background: #3a332d; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--ink-2); font-weight: 500; }
.btn.ghost:hover { background: rgba(42,37,33,.06); }
.btn.small { min-height: 44px; font-size: 15px; padding: 0 20px; letter-spacing: .08em; }
.linkbtn { background: none; border: 0; color: var(--ink-2); text-decoration: underline; text-underline-offset: 4px; min-height: 44px; padding: 0 8px; font-size: 15px; }

/* 状态页 */
.state-center { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; color: var(--ink-2); padding: 0 12px; }
.state-center h2 { font-size: 22px; color: var(--ink); margin-bottom: 4px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--seal); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.state-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; width: 100%; max-width: 280px; }
.banner { background: #F3E3C2; border: 1px solid #D9BF86; color: #5B4410; border-radius: 10px; padding: 10px 14px; font-size: 14px; margin: 14px 0 0; line-height: 1.6; }

/* 首页 */
.home { padding-top: calc(36px + env(safe-area-inset-top)); animation: rise .6s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.kicker { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 14px; letter-spacing: .3em; }
.seal-mark { display: inline-grid; place-items: center; width: 26px; height: 26px; background: var(--seal); color: #FBF3E4; border-radius: 4px; font-family: var(--serif); font-size: 14px; letter-spacing: 0; }
.home h1 { font-size: 46px; line-height: 1.2; margin: 22px 0 6px; letter-spacing: .12em; }
.home .sub { font-family: var(--serif); font-size: 18px; color: var(--ink-2); letter-spacing: .2em; margin: 0 0 22px; }
.hero-pyr { display: block; width: 92px; height: auto; margin: 0 0 22px; opacity: .9; }
.lede { font-size: 17px; line-height: 1.9; border-left: 2px solid var(--seal); padding: 2px 0 2px 14px; margin: 0 0 18px; }
.meta { color: var(--ink-2); font-size: 14px; margin-bottom: 22px; }
.meta span + span::before { content: "·"; margin: 0 8px; }
.home-actions { display: flex; flex-direction: column; gap: 10px; }
.concepts { margin: 42px 0 8px; }
.concepts h2 { font-size: 20px; margin-bottom: 4px; }
.concepts .hint { color: var(--ink-2); font-size: 14px; margin-bottom: 14px; }
.concept { padding: 14px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 3.2em 1fr; gap: 6px; }
.concept b { font-family: var(--serif); font-size: 20px; color: var(--seal); letter-spacing: .1em; }
.concept span { font-size: 15.5px; line-height: 1.8; }
.pyr-note { margin-top: 26px; font-size: 14px; color: var(--ink-2); border-top: 1px solid var(--line); padding-top: 14px; }

/* 提示页 */
.tips { padding-top: calc(32px + env(safe-area-inset-top)); animation: rise .5s ease both; }
.tips h2 { font-size: 28px; margin: 20px 0 12px; line-height: 1.5; }
.tips .big { font-family: var(--serif); font-size: 21px; line-height: 1.8; padding: 18px 18px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin: 0 0 18px; }
.scale-legend { list-style: none; padding: 0; margin: 0 0 26px; display: grid; gap: 8px; }
.scale-legend li { display: flex; align-items: center; gap: 12px; font-size: 16px; }
.scale-legend .n { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--ink-2); display: grid; place-items: center; font-family: var(--serif); font-size: 15px; }

/* 答题 */
.quiz { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; padding-top: env(safe-area-inset-top); }
.topbar { position: sticky; top: 0; z-index: 5; background: linear-gradient(var(--paper) 80%, transparent); padding: 12px 0 10px; margin: 0 -20px; padding-left: 20px; padding-right: 20px; }
.topbar-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--ink-2); }
.topbar-row .linkbtn { min-height: 36px; padding: 0; font-size: 14px; }
.bar { height: 5px; background: var(--paper-2); border-radius: 3px; overflow: hidden; margin-top: 6px; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--ochre)); transition: width .35s ease; border-radius: 3px; }
.q-body { flex: 1; padding-top: 22px; animation: rise .35s ease both; }
.q-no { font-family: var(--serif); color: var(--seal); letter-spacing: .2em; font-size: 15px; margin-bottom: 10px; }
.q-text { font-family: var(--serif); font-size: 23px; line-height: 1.75; font-weight: 600; margin: 0 0 26px; letter-spacing: .03em; }
.opts { display: grid; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  min-height: 56px; padding: 8px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  font-size: 17px; transition: background .15s, border-color .15s, transform .1s;
}
.opt .n { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--ink-2); display: grid; place-items: center; font-family: var(--serif); font-size: 15px; color: var(--ink-2); }
.opt:hover { border-color: var(--teal); }
.opt:active { transform: scale(.985); }
.opt[aria-checked="true"] { background: var(--teal-d); border-color: var(--teal-d); color: #FBF8F0; }
.opt[aria-checked="true"] .n { background: #FBF8F0; color: var(--teal-d); border-color: #FBF8F0; font-weight: 700; }
.q-nav { display: flex; justify-content: space-between; align-items: center; padding: 18px 0 8px; }
.q-nav .btn { min-height: 46px; font-size: 16px; }
.q-nav .btn[disabled] { opacity: .35; pointer-events: none; }

/* 结果 */
.report { padding-top: calc(28px + env(safe-area-inset-top)); animation: rise .6s ease both; }
.report .kicker { margin-bottom: 8px; }
.report h1 { font-size: 30px; line-height: 1.4; margin: 6px 0 14px; }
.opening { font-family: var(--serif); font-size: 18px; line-height: 1.95; margin: 0 0 14px; }
.opening em { font-style: normal; color: var(--seal); font-weight: 700; }
.total-chip { display: inline-flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; font-size: 13.5px; color: var(--ink-2); border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 14px; margin: 0 0 6px; line-height: 1.6; }
.total-chip b { color: var(--ink); font-size: 15px; }
.section { margin-top: 34px; }
.section > h2 { font-size: 21px; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.section > h2::before { content: ""; width: 8px; height: 8px; background: var(--seal); display: inline-block; transform: rotate(45deg); }
.section > .cap { color: var(--ink-2); font-size: 14px; margin-bottom: 8px; }
.chart { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 10px 6px 6px; }
.chart svg { display: block; width: 100%; height: auto; font-family: var(--sans); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--ink-2); padding: 8px 10px 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.15); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; margin-top: 12px; }
.card h3 { font-size: 18px; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card p:last-child { margin-bottom: 0; }
.tag { font-family: var(--sans); font-size: 12px; font-weight: 600; letter-spacing: .05em; padding: 1px 10px; border-radius: 999px; line-height: 1.7; }
.tag.good { background: #DCE8E3; color: #2F5550; }
.tag.leak { background: #F2D8CC; color: #8A3320; }
.tag.neutral { background: var(--paper-2); color: var(--ink-2); }
.card.leak { border-color: #D9A58F; background: #FBF1EA; }
.card.good { border-color: #A9C4BB; background: #F1F6F3; }
.score-big { font-family: var(--serif); font-size: 30px; font-weight: 700; margin-right: 4px; }
.rel { border-left: 3px solid var(--ochre); padding-left: 14px; margin-top: 14px; }
.rel h3 { font-size: 16px; color: var(--ochre); margin-bottom: 4px; }
.practice-sentence { font-family: var(--serif); font-size: 21px; line-height: 1.8; padding: 14px 16px; background: var(--paper-2); border-radius: 12px; margin: 8px 0 12px; border: 1px dashed #B9AC92; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 12px 0 4px; }
.day { min-height: 48px; border-radius: 12px; border: 1px solid var(--ink-2); background: transparent; font-size: 13px; line-height: 1.2; padding: 4px 0; }
.day b { display: block; font-family: var(--serif); font-size: 17px; }
.day[aria-pressed="true"] { background: var(--teal-d); color: #FBF8F0; border-color: var(--teal-d); }
.dimlist { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 12px; }
.dimlist li { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.dimrow { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.dimrow b { font-family: var(--serif); font-size: 17px; }
.dimrow span { font-size: 13px; color: var(--ink-2); }
.dimbar { height: 8px; border-radius: 4px; background: var(--paper-2); margin: 6px 0 4px; overflow: hidden; }
.dimbar i { display: block; height: 100%; border-radius: 4px; }
.dimlist small { color: var(--ink-2); font-size: 13px; }
.talk { margin-top: 38px; text-align: center; padding: 28px 12px 26px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.talk h2 { font-size: 22px; margin-bottom: 8px; }
.talk p { color: var(--ink-2); font-size: 15.5px; line-height: 1.85; }
.qr-thumb { display: block; margin: 16px auto 8px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 18px; width: min(230px, 66%); box-shadow: 0 6px 18px rgba(42,37,33,.08); }
.qr-thumb img, .qr-big { display: block; width: 100%; height: auto; border-radius: 10px; -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; }
.qr-note { font-size: 14px !important; margin: 4px 0 14px; }
.qr-note b { color: var(--seal); font-size: 17px; letter-spacing: .08em; }
.qr-big { width: min(300px, 78%); margin: 10px auto 6px; border: 1px solid var(--line); background: #fff; padding: 6px; }
.za-share { margin-top: 22px; text-align: center; }
.za-share .btn[disabled], .za-share .btn:disabled { opacity: .55; cursor: default; }
.za-share .za-retry { display: inline-block; margin-top: 8px; }
.za-note { color: var(--ink-2); font-size: 13.5px; margin: 8px 0 0; line-height: 1.6; }
.za-note.warn { color: var(--seal); }
.save-box { margin-top: 28px; text-align: center; }
.save-box .btn { width: 100%; }
.save-hint { color: var(--ink-2); font-size: 13.5px; margin: 8px 0 0; }
.img-dlg { max-width: 460px; max-height: 92dvh; padding: 18px 16px 14px; }
.img-dlg[open] { display: flex; flex-direction: column; }
.img-dlg h2 { font-size: 20px; margin-bottom: 6px; }
.img-tip { font-size: 14.5px; margin: 0 0 8px; color: var(--ink-2); } .img-tip b { color: var(--seal); }
.img-scroll { overflow: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); flex: 1; min-height: 200px; max-height: 66dvh; }
.img-scroll img { display: block; width: 100%; height: auto; -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; }
.img-actions { display: flex; gap: 10px; margin-top: 12px; }
.img-actions .btn { flex: 1; min-height: 46px; font-size: 16px; text-decoration: none; }
.pyr3d { position: relative; width: 100%; aspect-ratio: 400 / 404; touch-action: pan-y; cursor: grab; -webkit-user-select: none; user-select: none; outline-offset: -3px; }
.pyr3d.grabbing { cursor: grabbing; }
.pyr3d svg { display: block; width: 100%; height: 100%; font-family: var(--sans); overflow: visible; }
.drag-tip { text-align: center; font-size: 12.5px; color: #8A7E70; margin: 0 0 6px; letter-spacing: .1em; }
.end-actions { display: grid; gap: 10px; margin-top: 28px; }
.footnote { margin-top: 30px; font-size: 13px; color: var(--ink-2); text-align: center; line-height: 1.8; padding: 0 6px; }
dialog { border: 1px solid var(--line); border-radius: 20px; background: var(--card); color: var(--ink); max-width: 420px; width: calc(100% - 40px); padding: 26px 22px 20px; }
dialog::backdrop { background: rgba(42,37,33,.45); }
dialog h2 { font-size: 22px; margin-bottom: 10px; }
dialog ul { padding-left: 1.2em; margin: 0 0 16px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #FBF3E4; padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 20; max-width: 90vw; }

@media (min-width: 760px) {
  #app { max-width: 640px; }
  .home h1 { font-size: 56px; }
  .q-text { font-size: 26px; }
  .home-actions, .end-actions { flex-direction: row; }
  .home-actions .btn, .end-actions .btn { flex: 1; }
  .end-actions { display: flex; }
}
@media (max-width: 360px) {
  .home h1 { font-size: 40px; }
  .q-text { font-size: 21px; }
  .days { gap: 4px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
