/* 红笔答卷 — calm paper look, one red accent, phone first. */
:root {
  color-scheme: light;
  --bg: #f5f3ee; --card: #ffffff; --raise: #fbfaf7; --ink: #1d1b18; --muted: #6b665d; --faint: #9a958b; --line: #e6e1d6;
  --red: #c8321e; --red-ink: #b02a17; --red-soft: #fbe9e5; --green: #2e7d4f; --green-soft: #e4f3e9; --amber: #a96500; --amber-soft: #fff2d9;
  --blue: #2457a6;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --track: #d9e7f8;
  --shadow: 0 1px 2px rgba(40, 30, 10, .05), 0 6px 24px rgba(40, 30, 10, .06);
  --shadow-lift: 0 2px 4px rgba(40, 30, 10, .06), 0 12px 32px rgba(40, 30, 10, .10);
  --radius: 16px; --ease: cubic-bezier(.2, .7, .2, 1);
  --hand: "Kaiti SC", "STKaiti", "KaiTi", "Kaiti", serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #151412; --card: #1f1d1a; --raise: #262420; --ink: #ece8e1; --muted: #a39d92; --faint: #7d786f; --line: #34312c;
    --red: #ff6f5a; --red-ink: #ff8a77; --red-soft: #3a211c; --green: #6fcf95; --green-soft: #1b3125; --amber: #f0a73a; --amber-soft: #382a15;
    --blue: #8fb4ff; --s1: #3987e5; --s2: #d95926; --s3: #199e70; --track: #22344d; --shadow: none; --shadow-lift: 0 0 0 1px #3d3a34;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151412; --card: #1f1d1a; --raise: #262420; --ink: #ece8e1; --muted: #a39d92; --faint: #7d786f; --line: #34312c;
  --red: #ff6f5a; --red-ink: #ff8a77; --red-soft: #3a211c; --green: #6fcf95; --green-soft: #1b3125; --amber: #f0a73a; --amber-soft: #382a15;
  --blue: #8fb4ff; --s1: #3987e5; --s2: #d95926; --s3: #199e70; --track: #22344d; --shadow: none; --shadow-lift: 0 0 0 1px #3d3a34;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
       -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; min-height: 100vh; }
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 6px; }

/* ---------- header */
.bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
       padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
       background: color-mix(in srgb, var(--card) 86%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
       border-bottom: 1px solid var(--line); }
.brand { color: var(--ink); font-weight: 700; letter-spacing: .5px; display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 17px; }
.brand svg { width: 22px; height: 22px; }
nav { display: flex; gap: 2px; justify-content: flex-end; align-items: center; min-width: 0; }
nav a { padding: 7px 10px; border-radius: 10px; color: var(--muted); font-size: 14px; white-space: nowrap; position: relative; transition: color .2s, background .2s; }
nav a:hover { color: var(--ink); }
nav a.on { color: var(--ink); background: var(--bg); font-weight: 600; }
.pip { display: inline-block; vertical-align: 1px; margin-left: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--red); color: #fff;
       font-size: 11px; line-height: 16px; text-align: center; font-weight: 700; }

main { max-width: 1120px; margin: 0 auto; padding: 18px 16px calc(40px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { main { padding: 28px 28px 60px; } }
h1 { font-size: 22px; line-height: 1.35; margin: 4px 0 4px; letter-spacing: .3px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.lead { color: var(--muted); font-size: 14px; margin: 0 0 18px; }

/* ---------- entrance motion (one short rise per view) */
.view > * { animation: rise .42s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- surfaces */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.flat { box-shadow: none; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 13px; } .num { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.cols { display: grid; gap: 16px; grid-template-columns: 1fr; }
/* result: phone = title card, answered pages, then the folds; desktop = pages left, a sticky side column right */
.cols.result .side { display: contents; }
.cols.result .side > * { order: 3; }
.cols.result .side > .lead-card { order: 1; }
.cols.result .pages { order: 2; }
@media (min-width: 900px) { .cols.home { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; }
                            .cols.result { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
                            .cols.result .side { display: block; order: 2; position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; }
                            .cols.result .pages { order: 1; } }

/* ---------- controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line);
       background: var(--card); cursor: pointer; font-weight: 600; min-height: 44px; transition: transform .12s var(--ease), background .2s, border-color .2s, box-shadow .2s, opacity .2s; }
.btn:hover { border-color: var(--faint); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--red) 28%, transparent); }
.btn.primary:hover { background: var(--red-ink); border-color: var(--red-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--bg); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; font-weight: 500; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; transform: none; box-shadow: none; }
.btn svg { width: 18px; height: 18px; flex: none; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input, .field input, .field select, .field textarea { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--raise);
       min-height: 46px; transition: border-color .2s, box-shadow .2s; }
.field textarea { min-height: 96px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 18%, transparent); }
.err { color: var(--red); font-size: 14px; min-height: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--raise); padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: 14px; transition: all .18s var(--ease); }
.chip:hover { border-color: var(--faint); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- login */
.login-wrap { min-height: calc(100vh - 40px); display: grid; place-items: center; padding: 20px 0; }
.login { width: 100%; max-width: 380px; padding: 30px 24px; }
.login .logo-wrap { display: grid; place-items: center; margin-bottom: 8px; }
.login .logo-wrap svg { width: 56px; height: 56px; }
.login h1 { text-align: center; margin-bottom: 2px; }
.login .lead { text-align: center; margin-bottom: 22px; }

/* ---------- upload */
.drop { position: relative; border: 1.5px dashed color-mix(in srgb, var(--faint) 70%, transparent); border-radius: var(--radius); padding: 28px 16px; text-align: center;
        cursor: pointer; background: var(--raise); transition: border-color .25s, background .25s, transform .25s var(--ease); }
.drop:hover { border-color: var(--red); }
.drop.over { border-color: var(--red); background: var(--red-soft); transform: scale(1.01); }
.drop .icon { width: 44px; height: 44px; margin: 0 auto 8px; display: grid; place-items: center; border-radius: 50%; background: var(--red-soft); color: var(--red); }
.drop .icon svg { width: 22px; height: 22px; }
.drop b { display: block; font-size: 17px; margin-bottom: 2px; }
.files { list-style: none; padding: 0; margin: 14px 0 0; }
.files li { display: flex; align-items: center; gap: 8px; padding: 8px 2px; border-bottom: 1px solid var(--line); font-size: 14px; animation: rise .3s var(--ease) both; }
.files li:last-child { border-bottom: 0; }
.files .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iconbtn { border: 0; background: none; padding: 6px; cursor: pointer; color: var(--muted); border-radius: 8px; min-width: 36px; min-height: 36px; display: grid; place-items: center; }
.iconbtn:hover { background: var(--bg); color: var(--ink); }
.upbar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 12px; }
.upbar i { display: block; height: 100%; width: 0; background: var(--red); border-radius: 2px; transition: width .25s var(--ease); }

/* ---------- job list */
.jobs { list-style: none; padding: 0; margin: 0; }
.jobs li + li { margin-top: 8px; }
.joblink { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; color: var(--ink); background: var(--raise); border: 1px solid transparent;
           transition: transform .2s var(--ease), box-shadow .2s, border-color .2s; }
@media (hover: hover) { .joblink:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--line); } }
.joblink .thumb { width: 40px; height: 40px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; color: var(--red); flex: none; }
.joblink .thumb svg { width: 20px; height: 20px; }
.jobs .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; padding: 26px 10px; color: var(--muted); font-size: 14px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 9px; border-radius: 999px; white-space: nowrap; font-weight: 600; }
.badge.done { background: var(--green-soft); color: var(--green); }
.badge.running, .badge.queued, .badge.new { background: var(--amber-soft); color: var(--amber); }
.badge.failed, .badge.cancelled { background: var(--red-soft); color: var(--red); }
.badge.neutral { background: var(--bg); color: var(--muted); }
.badge.running::before, .badge.queued::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- processing */
.working { text-align: center; padding: 30px 20px 24px; }
.pen { width: 180px; height: 70px; margin: 0 auto 6px; display: block; color: var(--red); }
.pen path.ink { stroke-dasharray: 300; stroke-dashoffset: 300; animation: write 2.8s var(--ease) infinite; }
@keyframes write { 0% { stroke-dashoffset: 300; opacity: 1; } 65% { stroke-dashoffset: 0; opacity: 1; } 85%, 100% { stroke-dashoffset: 0; opacity: 0; } }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 22px 0 10px; text-align: center; }
.steps .s { font-size: 13px; color: var(--faint); transition: color .3s; }
.steps .s i { display: block; height: 4px; border-radius: 2px; background: var(--line); margin-bottom: 8px; overflow: hidden; position: relative; }
.steps .s i::after { content: ''; position: absolute; inset: 0; width: 0; background: var(--green); transition: width .6s var(--ease); }
.steps .s.done { color: var(--ink); } .steps .s.done i::after { width: 100%; }
.steps .s.now { color: var(--ink); font-weight: 600; }
.steps .s.now i::after { width: 45%; background: var(--red); animation: creep 2.4s ease-in-out infinite; }
@keyframes creep { 0% { width: 12%; } 50% { width: 70%; } 100% { width: 12%; } }

/* ---------- result */
.hero { display: flex; gap: 14px; align-items: flex-start; }
.hero .grow h1 { word-break: break-word; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.fact { background: var(--raise); border-radius: 12px; padding: 10px 12px; }
.fact b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; line-height: 1.3; }
.fact span { font-size: 12px; color: var(--muted); }
.actions { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.note { font-size: 12px; color: var(--faint); margin: 10px 0 0; }
.page { position: relative; margin: 0 0 16px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow); }
.page .zoomer { cursor: zoom-in; overflow: hidden; }
.page .inner { position: relative; transition: width .3s var(--ease); width: 100%; }
.page img { display: block; width: 100%; height: auto; opacity: 0; transition: opacity .5s var(--ease); }
.page img.ready { opacity: 1; }
.page.zoomed .zoomer { overflow: auto; cursor: zoom-out; max-height: 82vh; -webkit-overflow-scrolling: touch; }
.page.zoomed .inner { width: 220%; }
@media (min-width: 900px) { .page.zoomed .inner { width: 160%; } }
.page .tag { position: absolute; left: 10px; top: 10px; background: rgba(20, 18, 15, .62); color: #fff; font-size: 12px; padding: 3px 10px; border-radius: 999px; backdrop-filter: blur(4px); }
.page .swap { position: absolute; right: 10px; top: 10px; background: rgba(255, 255, 255, .92); color: #1d1b18; border-color: transparent; }
.skeleton { background: linear-gradient(100deg, var(--raise) 30%, var(--line) 50%, var(--raise) 70%); background-size: 300% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }
.mark { position: absolute; border: 2px solid var(--amber); border-radius: 4px; background: rgba(255, 170, 0, .12); pointer-events: none; }
.mark.flash { animation: flash 1.2s ease 2; }
@keyframes flash { 50% { background: rgba(255, 170, 0, .5); box-shadow: 0 0 0 6px rgba(255, 170, 0, .3); } }

.answers { list-style: none; margin: 0; padding: 0; }
.answers li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.answers li:last-child { border-bottom: 0; }
.answers .q { font-weight: 700; margin-right: 6px; }
.answers .p { color: var(--muted); font-size: 13px; }
.answers .a { color: var(--red); font-family: var(--hand); font-size: 19px; white-space: pre-wrap; word-break: break-word; line-height: 1.45; margin-top: 2px; }
.answers details { font-size: 13px; color: var(--muted); margin-top: 2px; }
.answers summary { cursor: pointer; }
.why { font-size: 13px; color: var(--amber); margin-top: 2px; }
.verdict { display: flex; gap: 6px; margin-top: 6px; }
.verdict button { border: 1px solid var(--line); background: var(--card); border-radius: 9px; padding: 3px 10px; cursor: pointer; font-size: 13px; min-height: 32px; transition: all .15s; }
.verdict button.right.on { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.verdict button.wrong.on { background: var(--red-soft); border-color: var(--red); color: var(--red); }
details.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: ''; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .25s var(--ease); margin-right: 4px; }
details.fold[open] > summary::after { transform: rotate(-135deg); }
details.fold[open] > summary + * { animation: rise .3s var(--ease) both; }
.reports { list-style: none; margin: 10px 0 0; padding: 0; }
.reports li { background: var(--raise); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.reports li + li { margin-top: 8px; }
.reply { margin-top: 6px; padding-left: 10px; border-left: 3px solid var(--green); color: var(--muted); }

/* ---------- sheet (feedback) */
.sheet-bg { position: fixed; inset: 0; z-index: 40; background: rgba(20, 18, 15, .38); display: flex; align-items: flex-end; justify-content: center; animation: fade .25s ease both; }
.sheet { width: 100%; max-width: 520px; background: var(--card); border-radius: 20px 20px 0 0; padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
         box-shadow: 0 -10px 40px rgba(0, 0, 0, .2); animation: up .34s var(--ease) both; max-height: 92vh; overflow: auto; }
.sheet .grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 14px; }
@media (min-width: 640px) { .sheet-bg { align-items: center; } .sheet { border-radius: 20px; padding: 22px 24px; animation: pop .3s var(--ease) both; } .sheet .grip { display: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }

/* ---------- admin */
.tabs { display: flex; gap: 6px; margin: 4px 0 16px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 1px solid var(--line); background: var(--card); padding: 7px 16px; border-radius: 999px; cursor: pointer; white-space: nowrap; font-size: 14px;
               transition: all .2s var(--ease); position: relative; }
.tabs button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tabs .count { margin-left: 6px; font-size: 12px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; }
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1040px) { .grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.chart { display: flex; gap: 18px; align-items: center; justify-content: center; flex-wrap: wrap; position: relative; }
.ring { width: 150px; height: 150px; flex: none; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring circle { fill: none; transition: stroke-dasharray .9s var(--ease), stroke-width .2s; cursor: pointer; }
.ring circle.track { cursor: default; }
.ring circle.seg:hover, .ring circle.seg.hot { stroke-width: 20; }
.ring .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.ring .center b { font-size: 22px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.ring .center span { font-size: 12px; color: var(--muted); }
.legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 190px; font-size: 13px; }
.legend span:nth-child(2) { white-space: nowrap; }
.legend li { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); }
.legend li:last-child { border-bottom: 0; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.legend .v { font-variant-numeric: tabular-nums; text-align: right; }
.legend .v small { color: var(--muted); margin-left: 4px; }
.tip { position: absolute; z-index: 5; pointer-events: none; background: var(--ink); color: var(--bg); font-size: 12px; padding: 5px 9px; border-radius: 8px;
       white-space: nowrap; transform: translate(-50%, -120%); opacity: 0; transition: opacity .15s; }
.tip.show { opacity: 1; }
.seg-toggle { display: inline-flex; background: var(--bg); border-radius: 999px; padding: 3px; gap: 2px; }
.seg-toggle button { border: 0; background: none; border-radius: 999px; padding: 3px 12px; font-size: 13px; cursor: pointer; color: var(--muted); transition: all .2s; }
.seg-toggle button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.kpi { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 13px; white-space: nowrap; }
td.nw { white-space: nowrap; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 14px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list .head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.list .head b { font-size: 15px; }

#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: var(--bg);
         padding: 10px 18px; border-radius: 12px; font-size: 14px; z-index: 60; width: max-content; max-width: calc(100% - 32px); transition: transform .3s var(--ease), opacity .3s; pointer-events: none; }
#toast.show { transform: translate(-50%, 0); opacity: 1; }
