:root {
  --bg: #f3f1ec;
  --surface: #ffffff;
  --ink: #1f2328;
  --muted: #6e7480;
  --line: #e1ddd3;
  --red: #d0342c;
  --red-bg: #fdf1ef;
  --amber: #c27400;
  --amber-bg: #fdf5e6;
  --green: #2e7d4f;
  --green-bg: #eef7f1;
  --blue: #2f6fb6;
  --blue-bg: #eef4fb;
  --purple: #6b5aa8;
  --accent: #26324a;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
/* 桌面全屏模式下，状态栏的底色来自页面：html 和每个 .view 都给不透明的浅底色，并声明只用浅色外观。
   真机上加了这几条之后状态栏才从黑色变成浅色（模拟器里复现不出黑色，具体是哪一条起作用没有确认）。 */
html { background: var(--bg); color-scheme: light; }
body {
  height: var(--app-h, 100dvh);
  font: 16px/1.7 -apple-system, "PingFang SC", "Hiragino Sans GB", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  /* 像 App 一样：按钮、标题、照片长按都不选中文字；只有答案卡片里的内容和输入框可以选（见下） */
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  touch-action: pan-x pan-y; /* 页面不缩放，只有照片能放大（见 app.js 的 enableZoom） */
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.view { position: fixed; left: 0; right: 0; top: 0; height: var(--app-h, 100dvh); display: flex; background: var(--bg); flex-direction: column; }

/* 电脑上（有鼠标）窗口比较宽时，整个应用收成居中的一栏，像一台竖放的平板，两边留深一点的底色。
   body 加了 transform 之后，里面所有 position: fixed 的元素（各个界面、浮层、提示条）都改成相对 body 定位，
   所以不用逐个改；翻页等脚本量的都是容器自己的宽度，也不受影响。手机和平板不满足这个条件，照旧铺满。 */
@media (hover: hover) and (pointer: fine) and (min-width: 821px) {
  html { background: #dedad0; }
  body { width: 820px; margin: 0 auto; transform: translateX(0); box-shadow: 0 0 0 1px var(--line), 0 0 40px rgba(0, 0, 0, .08); }
}

.spinner {
  width: 15px; height: 15px; flex: none; border-radius: 50%;
  border: 2px solid rgba(38, 50, 74, .2); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.spinner.light { border-color: rgba(255, 255, 255, .3); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────── 首页 ───────── */
#home { align-items: center; padding: calc(var(--safe-t) + 56px) 24px calc(var(--safe-b) + 20px); }
/* 名称在上半屏，拍照按钮在下半屏拇指够得着的地方；三段空白按 3 : 2 : 3 分 */
.home-inner { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; width: 100%; max-width: 340px; }
.home-inner::before { content: ""; flex: 3; }
.home-inner::after { content: ""; flex: 3; }
#home h1 { margin: 0; font-size: 48px; line-height: 1.15; font-weight: 800; letter-spacing: .06em; text-indent: .06em; color: var(--red); }
#home .slogan { margin: 8px 0 0; font-size: 17px; letter-spacing: .12em; text-indent: .12em; color: var(--ink); }

/* 拍照按钮就是那"一点"：一个红色的圆，外面是红笔画的圈。进首页时圈画一遍，笔跟着落下 */
.shoot-wrap { position: relative; flex: 2 0 auto; display: flex; align-items: center; justify-content: center; width: 132px; min-height: 250px; }
.shoot-ring { position: absolute; left: 50%; top: 50%; width: 246px; height: 246px; margin: -123px 0 0 -123px; overflow: visible; pointer-events: none; }
.shoot-ring .loop { fill: none; stroke: var(--red); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; animation: ring-draw .8s .3s cubic-bezier(.5, 0, .3, 1) backwards; }
.shoot-ring .pen { animation: pen-in .4s .95s ease-out backwards; }
@keyframes ring-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes pen-in { from { opacity: 0; transform: translate(11px, -11px); } }
@media (prefers-reduced-motion: reduce) { .shoot-ring .loop, .shoot-ring .pen { animation: none; } }
.shoot {
  width: 132px; height: 132px; flex: none; border-radius: 50%;
  background: #3a3e44; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 17px; font-weight: 600; letter-spacing: .1em;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .24);
  transition: transform .12s;
}
/* 域名：截图、转发出去之后别人能照着找回来 */
#home .home-domain { position: absolute; left: 0; right: 0; bottom: calc(var(--safe-b) + 14px); margin: 0; text-align: center; font-size: 13px; letter-spacing: .08em; color: var(--muted); }
.shoot span { text-indent: .1em; }
.shoot:active { transform: scale(.95); }
.shoot svg { width: 42px; height: 42px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
/* 圈的下沿比按钮低，这里不用再留间距 */
.link-btn { margin-top: 0; padding: 10px 18px; color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }
.shoot:focus-visible, .link-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

#btn-history {
  position: absolute; right: 12px; top: calc(var(--safe-t) + 10px);
  display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%;
  color: var(--accent); background: rgba(38, 50, 74, .07);
}
#btn-history:active, #btn-member:active { background: rgba(38, 50, 74, .14); }
#btn-member {
  position: absolute; left: 12px; top: calc(var(--safe-t) + 10px);
  display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%;
  color: var(--accent); background: rgba(38, 50, 74, .07);
}
#btn-member.on { color: var(--amber); background: var(--amber-bg); }
#btn-history svg, #btn-member svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ───────── 历史记录 ───────── */
#his-top, #member-top {
  flex: none; display: flex; align-items: center; gap: 4px;
  padding: calc(var(--safe-t) + 6px) 8px 6px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.his-title { flex: 1; padding: 8px 0; font-size: 17px; font-weight: 600; }
#his-list {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 12px 12px calc(var(--safe-b) + 16px); width: 100%; max-width: 760px; margin: 0 auto;
}
.his-row {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; text-align: left;
}
.his-row:active { background: #faf9f6; }
.his-thumb { flex: none; width: 68px; height: 68px; border-radius: 9px; overflow: hidden; background: var(--line); }
.his-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.his-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.his-when { font-size: 13px; color: var(--muted); line-height: 1.4; }
.his-name {
  font-size: 16px; font-weight: 600; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.his-tally { font-size: 14px; line-height: 1.5; color: var(--muted); }
.his-tally b { font-weight: 700; color: var(--ink); }
.his-tally b.t-wrong { color: var(--red); } .his-tally b.t-improve { color: var(--amber); } .his-tally b.t-correct { color: var(--green); }
.his-go { flex: none; font-size: 22px; color: var(--muted); padding: 0 2px; }
.his-note { margin: 18px 0; text-align: center; font-size: 14px; color: var(--muted); white-space: pre-line; }

/* ───────── 拍照页 ───────── */
#camera { background: #000; color: #fff; }
#cam-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #111; }
#cam-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-grid {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to right, transparent calc(33.33% - .5px), rgba(255, 255, 255, .45) calc(33.33% - .5px), rgba(255, 255, 255, .45) calc(33.33% + .5px), transparent calc(33.33% + .5px), transparent calc(66.66% - .5px), rgba(255, 255, 255, .45) calc(66.66% - .5px), rgba(255, 255, 255, .45) calc(66.66% + .5px), transparent calc(66.66% + .5px)),
    linear-gradient(to bottom, transparent calc(33.33% - .5px), rgba(255, 255, 255, .45) calc(33.33% - .5px), rgba(255, 255, 255, .45) calc(33.33% + .5px), transparent calc(33.33% + .5px), transparent calc(66.66% - .5px), rgba(255, 255, 255, .45) calc(66.66% - .5px), rgba(255, 255, 255, .45) calc(66.66% + .5px), transparent calc(66.66% + .5px));
}
#cam-hint {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  text-align: center; font-size: 19px; line-height: 1.9; letter-spacing: .08em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .55); pointer-events: none; transition: opacity .4s;
}
#cam-hint.gone { opacity: 0; }
#cam-fallback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 40px; text-align: center; background: #16181c; color: #c9ccd2; font-size: 15px;
}
#cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
#cam-flash.on { animation: flash .42s ease-out; }
@keyframes flash { 0%, 25% { opacity: 1; } 100% { opacity: 0; } }
#cam-thumb.pop { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }
#cam-back {
  position: absolute; left: 16px; top: calc(var(--safe-t) + 12px);
  width: 40px; height: 40px; border-radius: 50%; background: rgba(0, 0, 0, .4);
  font-size: 28px; line-height: 36px; padding-right: 2px;
}
#cam-bar {
  flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 22px 26px calc(var(--safe-b) + 26px); background: #000;
}
#cam-thumb { position: relative; justify-self: start; width: 54px; height: 54px; border-radius: 6px; border: 1.5px solid #fff; }
#cam-thumb:disabled { visibility: hidden; }
#cam-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; display: block; }
#cam-thumb .badge {
  position: absolute; right: -10px; top: -10px; min-width: 24px; height: 24px; padding: 0 6px;
  border-radius: 12px; background: #fff; color: #000; font-size: 14px; line-height: 24px; font-weight: 600;
}
#cam-shutter { width: 76px; height: 76px; border-radius: 50%; border: 4px solid #fff; padding: 4px; }
#cam-shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .1s; }
#cam-shutter:active span { transform: scale(.88); }
#cam-done { justify-self: end; padding: 6px 16px; border: 1.5px solid #fff; border-radius: 6px; font-size: 17px; font-weight: 600; }
#cam-done:disabled { opacity: .35; }
#cam-review { position: absolute; inset: 0; background: #0d0e10; display: flex; flex-direction: column; }
#cam-review header {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(var(--safe-t) + 12px) 18px 12px; font-size: 17px;
}
#review-close { padding: 4px 14px; border: 1.5px solid #fff; border-radius: 6px; font-weight: 600; }
#review-grid {
  flex: 1; overflow-y: auto; padding: 8px 14px calc(var(--safe-b) + 20px);
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; align-content: start;
}
.review-item { position: relative; }
.review-item img { width: 100%; display: block; border-radius: 8px; }
.review-item .idx { position: absolute; left: 8px; top: 8px; padding: 0 9px; border-radius: 11px; background: rgba(0, 0, 0, .6); font-size: 13px; }
.review-item button { position: absolute; right: 6px; top: 6px; width: 30px; height: 30px; border-radius: 50%; background: rgba(0, 0, 0, .65); font-size: 14px; }

/* ───────── 结果页 ───────── */
#res-top {
  flex: none; display: flex; align-items: center; gap: 4px;
  padding: calc(var(--safe-t) + 6px) 8px 6px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.top-btn { width: 40px; height: 40px; flex: none; font-size: 26px; line-height: 38px; border-radius: 10px; }
.top-btn.text { width: auto; padding: 0 10px; font-size: 15px; color: var(--red); }
.top-btn.text.retry { color: var(--blue); font-weight: 600; }
.top-btn:active, #res-summary:active { background: rgba(0, 0, 0, .06); }
#res-summary {
  flex: 1; min-width: 0; height: 40px; padding: 0 8px; border-radius: 10px;
  display: flex; align-items: center; gap: 8px; text-align: left; font-size: 15px;
}
#res-status { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#res-status b { font-weight: 700; }
.t-wrong { color: var(--red); } .t-improve { color: var(--amber); } .t-correct { color: var(--green); }
#res-page { flex: none; font-size: 14px; color: var(--muted); padding: 0 4px; font-variant-numeric: tabular-nums; }

#res-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#pager {
  flex: 1; min-height: 0; display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain;
}
#pager::-webkit-scrollbar { display: none; }
.page { flex: none; width: 100%; height: 100%; scroll-snap-align: start; scroll-snap-stop: always; }
.page-scroll { position: relative; height: 100%; overflow: auto; display: flex; flex-direction: column; -webkit-overflow-scrolling: touch; }
.page-scroll.zoomed { overscroll-behavior-x: contain; } /* 放大后左右拖是看照片，不翻页 */
.paper { position: relative; flex: none; width: 100%; max-width: 900px; margin: auto; background: #fff; }
.paper img { display: block; width: 100%; height: auto; min-height: 120px; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.overlay { position: absolute; inset: 0; }

.zone { position: absolute; border-radius: 6px; border: 1.5px dashed rgba(46, 125, 79, .4); }
.zone.wrong, .zone.improve, .zone.plain { border-color: transparent; }
/* 未作答：红色虚线，比错题的红色实线圈弱一档 */
.zone.unanswered { border: 2.5px dashed var(--red); border-radius: 10px; }
/* 圈的点击区域：看不见，比圈每边大 7px */
.zone-hit { position: absolute; }
.zone-hit::after { content: ''; position: absolute; inset: -7px; }
.zone.passage { border: 2px dashed rgba(107, 90, 168, .5); }
.zone.selected { background: rgba(38, 50, 74, .08); border: 2px solid rgba(38, 50, 74, .55); }
.zone.unanswered.selected { border: 2.5px dashed var(--red); background: rgba(208, 52, 44, .07); }
/* 圈画在 ::before 上，圆角不超过圈短边的四分之一：一行字高的小圈不会被 10px 的圆角挤成椭圆 */
.mark { position: absolute; container-type: size; }
.mark::before { content: ''; position: absolute; inset: 0; box-sizing: border-box; border: 2.5px solid var(--red); border-radius: min(10px, 25cqmin); }
.mark.improve::before { border-color: var(--amber); }
.mark.selected::before { box-shadow: 0 0 0 5px rgba(208, 52, 44, .28); }
.mark.improve.selected::before { box-shadow: 0 0 0 5px rgba(194, 116, 0, .3); }
/* 逐处订正：每处一个细圈，贴着那几个词；整道题不圈，右上角一个"总评"按钮 */
.spot { position: absolute; margin: -3px -4px; padding: 3px 4px; box-sizing: content-box; container-type: size; }
.spot::before { content: ''; position: absolute; inset: -2px; box-sizing: border-box; border: 2px solid var(--red); border-radius: min(8px, 25cqmin); }
.spot.improve::before { border-color: var(--amber); }
.spot.dim { opacity: .3; }
.spot.selected::before { background: rgba(208, 52, 44, .1); box-shadow: 0 0 0 4px rgba(208, 52, 44, .28); }
.spot.improve.selected::before { background: rgba(194, 116, 0, .1); box-shadow: 0 0 0 4px rgba(194, 116, 0, .3); }
.overall {
  position: absolute; transform: translate(-100%, -50%); display: flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 12px 0 4px; border-radius: 15px; white-space: nowrap;
  background: var(--red); color: #fff; font-size: 14px; font-weight: 700;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .9), 0 2px 8px rgba(0, 0, 0, .28);
}
.overall::after { content: ''; position: absolute; inset: -8px; }
.overall i { width: 22px; height: 22px; border-radius: 50%; background: #fff; color: var(--red); font-style: normal; font-size: 15px; line-height: 22px; text-align: center; }
.overall.improve { background: var(--amber); }
.overall.improve i { color: var(--amber); }
.overall.selected { box-shadow: 0 0 0 2px #fff, 0 0 0 6px rgba(208, 52, 44, .3); }
.overall.improve.selected { box-shadow: 0 0 0 2px #fff, 0 0 0 6px rgba(194, 116, 0, .32); }
/* 判为正确的题：框里靠右打一个手写样子的勾。大小统一，框放不下时才跟着框的短边缩小，最小 16px */
.tick { position: absolute; pointer-events: none; container-type: size; }
.tick svg {
  --s: clamp(16px, 100cqmin, 32px);
  position: absolute; right: min(6px, 6cqw); top: 50%; width: var(--s); height: var(--s); transform: translateY(-50%); overflow: visible; fill: var(--green);
}
.page-skipped {
  position: absolute; left: 50%; top: 4%; transform: translateX(-50%); pointer-events: none; white-space: nowrap;
  padding: 6px 14px; border-radius: 16px; background: rgba(0, 0, 0, .62); color: #fff; font-size: 14px;
}

#res-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; text-align: center; gap: 18px; }
.pill { padding: 10px 26px; border-radius: 24px; background: var(--accent); color: #fff; font-weight: 600; }

/* 从下往上弹出的卡片：和照片上下分屏，各自滚动 */
#sheet { flex: none; height: 0; overflow: hidden; }
/* 卡片顶上压住照片一条（和圆角一样高），圆角切掉的地方露出来的就是照片，不是底色。
   照片滚到底时最下面这一条也压在卡片底下：要是在照片下面补一条让它滚出来，圆角后面又成了底色 */
#sheet.open { position: relative; z-index: 1; margin-top: -16px; }
#sheet-inner {
  height: 100%; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 16px 16px 0 0;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, .16);
}
#sheet.rise #sheet-inner { animation: rise .24s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { transform: translateY(100%); } to { transform: none; } }
#sheet-grab { flex: none; position: relative; height: 44px; touch-action: none; cursor: pointer; }
#sheet-grab i { position: absolute; left: 50%; top: 10px; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: #d2cec4; }
/* 前后翻卡片：放在顶边右侧，拇指够得着，卡片滚到哪里都在；颜色淡，不抢内容。收起卡片点顶边其余地方或往下拖 */
#sheet-nav { position: absolute; right: 6px; top: 0; height: 100%; display: flex; align-items: center; color: var(--muted); }
#sheet-nav button { width: 52px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
#sheet-nav button:active { background: rgba(0, 0, 0, .06); }
#sheet-nav button:disabled { opacity: .28; }
#sheet-nav svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#sheet-nav #nav-overall { width: auto; padding: 0 12px; font-size: 15px; }
#sheet-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
#sheet-body, #ask-input { -webkit-user-select: text; user-select: text; }
#sheet-body { font-size: 18px; padding: 2px 16px 14px; max-width: 760px; margin: 0 auto; }
#ask {
  flex: none; display: flex; gap: 8px; padding: 8px 12px calc(var(--safe-b) + 8px);
  border-top: 1px solid var(--line); background: var(--surface);
}
#ask-input {
  flex: 1; min-width: 0; height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 20px;
  font: inherit; font-size: 16px; background: #faf9f6; color: var(--ink); outline: none; -webkit-appearance: none;
}
#ask-input:focus { border-color: var(--accent); }
#ask-send { flex: none; padding: 0 16px; height: 40px; border-radius: 20px; background: var(--accent); color: #fff; font-weight: 600; }
#ask-send:disabled { opacity: .4; }
/* 对话没有保存下来的历史记录：只读，不能追问、不能加照片 */
#result.readonly #ask, #result.readonly #res-add { display: none; }
#result.readonly #sheet-body { padding-bottom: calc(var(--safe-b) + 14px); }

.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head .q-label { font-weight: 700; font-size: 19px; }
.card-head .verdict { font-size: 13px; padding: 0 9px; border-radius: 10px; background: var(--red-bg); color: var(--red); }
.card.improve .verdict { background: var(--amber-bg); color: var(--amber); }
.card.correct .verdict { background: var(--green-bg); color: var(--green); }
.card.unanswered .verdict { background: var(--blue-bg); color: var(--blue); }
.card.passage .verdict { background: #f1eefa; color: var(--purple); }
.card-head .issue { flex: 1 1 100%; }
.answers { display: grid; gap: 8px; grid-template-columns: 1fr; }
.answers.side { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.ans { border-radius: 10px; padding: 8px 12px; min-width: 0; }
.ans-h { font-size: 13px; color: var(--muted); letter-spacing: .04em; }
.ans.student { background: #f6f5f1; }
.card.wrong .ans.student .rich { color: var(--red); }
.ans.correct { background: var(--green-bg); }
.ans.correct .rich { font-weight: 500; font-size: 20px; }
.explain { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); color: #3a3f47; }
.explain table { width: 100%; }
.overall-text { color: #3a3f47; }
.spots-h { margin: 14px 0 6px; }
.spot-list { display: flex; flex-direction: column; gap: 6px; }
.spot-row { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 10px; background: #f6f5f1; text-align: left; font: inherit; color: inherit; }
.spot-row .idx { flex: none; min-width: 22px; height: 22px; margin-top: 2px; border-radius: 11px; background: var(--red); color: #fff; font-size: 13px; line-height: 22px; font-weight: 700; text-align: center; }
.spot-row.improve .idx { background: var(--amber); }
.spot-line { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.spot-line .old { color: var(--red); text-decoration: line-through; text-decoration-color: rgba(208, 52, 44, .5); }
.spot-row.improve .old { color: var(--amber); text-decoration: none; }
.spot-line .arrow { margin: 0 6px; color: var(--muted); }
.spot-line .new { font-weight: 600; color: var(--green); }
.ans.model { margin-top: 14px; }
.ans.model .rich { font-weight: 400; font-size: inherit; }
.spot-card .of { font-size: 14px; color: var(--muted); }
.spot-card.improve .ans.student .rich { color: var(--amber); }
.figure { margin-top: 10px; padding: 8px; background: #fbfaf7; border: 1px solid var(--line); border-radius: 8px; text-align: center; }
.figure + .answers { margin-top: 10px; }
.answers > .figure { margin-top: 0; }
.figure svg { width: 100%; max-width: 440px; height: auto; max-height: 340px; font-family: inherit; }

.rich { overflow-wrap: anywhere; }
.rich > :first-child { margin-top: 0; }
.rich > :last-child { margin-bottom: 0; }
.rich p { margin: 0 0 .6em; }
.rich ul, .rich ol { margin: 0 0 .6em; padding-left: 1.4em; }
.rich table { border-collapse: collapse; margin: .4em 0; font-size: .9em; }
.rich th, .rich td { border: 1px solid var(--line); padding: 3px 8px; }
.rich th { background: #f6f5f1; font-weight: 600; text-align: left; }
.rich code { background: rgba(0, 0, 0, .05); padding: 1px 5px; border-radius: 4px; font-size: .92em; }
.rich a { color: var(--blue); }
.rich strong { font-weight: 700; }
.rich u { color: var(--blue); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.rich .katex { font-size: 1.05em; }
.rich .katex-display { margin: .25em 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

.thread { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 100%; }
.msg.user { align-self: flex-end; max-width: 86%; padding: 6px 14px; border-radius: 16px 16px 4px 16px; background: var(--accent); color: #fff; }
.msg.error { color: var(--red); font-size: 14px; }
.msg.notice { align-self: flex-start; padding: 4px 12px; border-radius: 10px; background: var(--green-bg); color: var(--green); font-size: 14px; }
.msg.notice::before { content: '↑ '; }
.sheet-title { font-weight: 700; font-size: 19px; margin-bottom: 8px; }
.working { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; margin-top: 12px; }

/* ───────── 浮层 ───────── */
.modal {
  position: fixed; left: 0; right: 0; top: 0; height: var(--app-h, 100dvh); z-index: 15; background: rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  position: relative; width: 100%; max-width: 360px; max-height: 100%; overflow-y: auto;
  padding: 22px 20px 18px; border-radius: 18px; background: var(--surface); box-shadow: 0 16px 48px rgba(0, 0, 0, .25);
}
.modal-card h2 { margin: 0 0 6px; font-size: 19px; }
.modal-card p { margin: 0 0 14px; font-size: 15px; white-space: pre-line; }
.modal-card .modal-note { margin: 14px 0 0; font-size: 13px; line-height: 1.6; color: var(--muted); }
.modal-actions { display: flex; flex-direction: column; gap: 10px; }
.pill.ghost { background: rgba(38, 50, 74, .07); color: var(--accent); }
.install-icon { display: block; width: 56px; height: 56px; margin: 0 0 12px; border-radius: 13px; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }
#install-steps { margin: 0 0 14px; padding: 10px 12px 10px 32px; border-radius: 12px; background: rgba(38, 50, 74, .06); font-size: 15px; line-height: 1.9; }
#install-steps .share-icon {
  width: 22px; height: 22px; margin-left: 6px; vertical-align: -5px;
  fill: none; stroke: #0a84ff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
#install-steps .more-icon { width: 24px; height: 24px; margin-left: 6px; vertical-align: -6px; fill: #1c1c1e; }
#member-body { flex: 1; min-height: 0; overflow-y: auto; width: 100%; max-width: 460px; margin: 0 auto; padding: 22px 20px calc(var(--safe-b) + 20px); }
#member-status { margin: 0 0 14px; font-size: 15px; color: var(--muted); }
.member-note { margin: 16px 0 0; font-size: 13px; line-height: 1.6; color: var(--muted); }
#member-status.on { color: var(--amber); font-weight: 600; }
#redeem { display: flex; gap: 8px; }
#redeem-input {
  flex: 1; min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; outline: none;
  font: 16px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .04em; color: var(--ink); background: var(--surface);
  -webkit-user-select: text; user-select: text;
}
#redeem-input:focus { border-color: var(--accent); }
#redeem-input::placeholder { font-family: -apple-system, "PingFang SC", sans-serif; letter-spacing: 0; }
#redeem-send { flex: none; padding: 0 18px; height: 44px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; }
#redeem-send:disabled { opacity: .4; }
#redeem-msg { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; font-size: 14px; line-height: 1.6; white-space: pre-line; background: var(--red-bg); color: var(--red); }
#redeem-msg.ok { background: var(--green-bg); color: var(--green); }
#uploading {
  position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .72); color: #fff;
  display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 17px;
}
#toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 90px); transform: translateX(-50%); z-index: 30;
  max-width: 84%; padding: 9px 18px; border-radius: 12px; background: rgba(20, 22, 26, .92); color: #fff; font-size: 15px; text-align: center;
}
/* 横屏提示：只支持竖屏，浏览器里锁不住方向，横过来时整屏盖住（由 app.js 的 checkOrientation 控制显示） */
#rotate {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center;
}
#rotate svg { width: 84px; height: 84px; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
/* 图标是动的：设备先横着停一下，转成竖的，再停一下，循环 */
#rotate svg g { transform-box: view-box; transform-origin: 32px 32px; animation: rotate-device 2.4s cubic-bezier(.6, 0, .3, 1) infinite; }
@keyframes rotate-device {
  0%, 18% { transform: rotate(var(--from, -90deg)); opacity: .45; } /* --from 由 app.js 按设备倒向哪边来定 */
  58%, 92% { transform: rotate(0deg); opacity: 1; }
  100% { transform: rotate(0deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { #rotate svg g { animation: none; } }
#rotate p { margin: 0; font-size: 18px; font-weight: 600; }
