/* 助教 · 糖果教室主题（clay-lite）。三个工具共用；每个工具只改 :root 里的强调色三件套。 */
:root {
  --accent: #0D9488; --accent-2: #2DD4BF; --accent-deep: #0F766E; --accent-soft: #CCFBF1; --accent-ink: #134E4A;
  --plus: #16A34A; --plus-soft: #DCFCE7; --plus-ink: #166534;
  --minus: #DC2626; --minus-soft: #FEE2E2; --minus-ink: #991B1B;
  --done: #16A34A; --fix: #F59E0B; --undone: #DC2626;
  --bg: #FFF7ED; --card: #FFFFFF; --ink: #1F2937; --muted: #7C7369; --line: #FFE4CC; --soft: #FFF1E3;
  --radius: 22px; --radius-sm: 16px;
  --shadow-card: 0 10px 24px rgba(234, 88, 12, .10), 0 1px 0 rgba(255,255,255,.9) inset;
  --shadow-float: 0 14px 34px rgba(31, 41, 55, .14);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  padding-bottom: calc(92px + env(safe-area-inset-bottom));
  background: var(--bg);
  background-image:
    radial-gradient(520px 360px at -10% -8%, rgba(251,146,60,.22), transparent 60%),
    radial-gradient(460px 340px at 110% 8%, rgba(96,165,250,.16), transparent 60%),
    radial-gradient(420px 380px at 50% 110%, rgba(250,204,21,.16), transparent 60%);
  background-attachment: fixed;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:active { transform: translateY(1px); }
main { padding: 14px 14px 16px; padding-left: calc(14px + env(safe-area-inset-left)); padding-right: calc(14px + env(safe-area-inset-right)); }

/* 顶栏：标题大一号，右侧小按钮做成药丸 */
.topbar { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; min-height: 48px; }
.topbar .classname, .topbar .left { flex: 1; font-size: 22px; font-weight: 800; letter-spacing: .5px; text-align: left; }
.topbar .classname { padding: 6px 0; }
.topbar .date { flex: 1; text-align: center; font-size: 19px; font-weight: 800; }
.topbar .date small { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.iconbtn { height: 44px; min-width: 44px; padding: 0 14px; border-radius: 999px; background: var(--card); font-size: 15px; font-weight: 700; color: var(--accent-ink); box-shadow: var(--shadow-card); border: 2px solid var(--line); }
.iconbtn.text { padding: 0 16px; }
.iconbtn:disabled { opacity: .45; }
.actions { display: flex; gap: 10px; margin-bottom: 12px; }
.btn { flex: 1; height: 48px; border-radius: 999px; background: var(--card); font-weight: 700; font-size: 16px; color: var(--ink); border: 2px solid var(--line); box-shadow: var(--shadow-card); transition: transform .12s, box-shadow .12s; }
.btn.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: #fff; border-color: transparent; box-shadow: 0 6px 0 var(--accent-deep), 0 12px 24px rgba(234,88,12,.25); }
.btn.primary:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--accent-deep), 0 6px 14px rgba(234,88,12,.2); }
.btn.danger { background: var(--minus-soft); color: var(--minus-ink); border-color: #FECACA; }
.btn:disabled { opacity: .45; transform: none; }
.small { height: 44px; min-width: 44px; padding: 0 12px; border-radius: 999px; background: var(--soft); font-size: 14px; font-weight: 600; color: var(--accent-ink); }
.small:disabled { opacity: .4; }

/* 分段开关 */
.seg { display: inline-flex; background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 4px; margin-bottom: 12px; box-shadow: var(--shadow-card); }
.seg button { height: 40px; padding: 0 16px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); }

/* 学生卡片 */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 400px) { .cards { grid-template-columns: repeat(3, 1fr); } }
.card { position: relative; background: var(--card); border-radius: var(--radius); border: 2px solid var(--line); min-height: 96px; padding: 14px 14px 12px; text-align: left; box-shadow: var(--shadow-card); display: flex; flex-direction: column; gap: 4px; transition: transform .12s; }
.card:active { transform: scale(.97); }
.card .nm { font-size: 17px; font-weight: 800; }
.card .total { font-size: 36px; font-weight: 900; line-height: 1.05; color: var(--accent); letter-spacing: -1px; }
.card .today { display: inline-block; width: max-content; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.card .today.plus { background: var(--plus-soft); color: var(--plus-ink); }
.card .today.minus { background: var(--minus-soft); color: var(--minus-ink); }
.plus { color: var(--plus-ink); } .minus { color: var(--minus-ink); }

/* 理由按钮 */
.reasons { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 10px 0; }
.reason { height: 52px; border-radius: var(--radius-sm); color: #fff; font-weight: 800; font-size: 16px; transition: transform .1s; }
.reason.plus { background: linear-gradient(180deg, #22C55E, var(--plus)); box-shadow: 0 5px 0 #15803D; }
.reason.minus { background: linear-gradient(180deg, #EF4444, var(--minus)); box-shadow: 0 5px 0 #B91C1C; }
.reason.custom { background: var(--soft); color: var(--ink); border: 2px solid var(--line); }
.reason:active { transform: translateY(3px); box-shadow: none; }

/* 记录行 */
.log { background: var(--card); border-radius: var(--radius); border: 2px solid var(--line); box-shadow: var(--shadow-card); }
.log .row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); min-height: 52px; }
.log .row:last-child { border-bottom: 0; }
.log .when { font-size: 12px; color: var(--muted); width: 64px; flex: none; }
.log .who { font-weight: 800; flex: none; }
.log .why { flex: 1; color: var(--muted); font-size: 14px; }
.log .delta { font-weight: 900; flex: none; }
.log .undo { height: 44px; min-width: 44px; padding: 0 12px; border-radius: 999px; background: var(--soft); font-size: 13px; font-weight: 600; }

/* 登记表（作业） */
.grid { background: var(--card); border-radius: var(--radius); border: 2px solid var(--line); overflow-x: auto; box-shadow: var(--shadow-card); }
.grid table { width: 100%; border-collapse: collapse; }
.grid th, .grid td { padding: 7px 5px; text-align: center; border-bottom: 1px solid var(--line); }
.grid td { vertical-align: middle; }
.grid th { font-size: 13px; color: var(--muted); font-weight: 700; padding-top: 10px; }
.grid th:first-child, .grid td:first-child { text-align: left; padding-left: 12px; width: 1%; white-space: nowrap; }
.grid tr:last-child td { border-bottom: 0; }
.name { font-size: 16px; font-weight: 800; padding: 8px 6px 8px 0; min-height: 44px; display: inline-flex; align-items: center; }
.cell { display: block; width: 100%; min-width: 46px; height: 46px; border-radius: 14px; font-size: 20px; font-weight: 800; background: var(--soft); color: var(--muted); border: 2px solid transparent; transition: transform .1s, background .12s; }
.cell:active { transform: scale(.94); }
.cell[data-status="done"] { background: var(--done); color: #fff; box-shadow: 0 3px 0 #15803D; }
.cell[data-status="fix"] { background: var(--fix); color: #fff; box-shadow: 0 3px 0 #B45309; }
.cell[data-status="undone"] { background: var(--undone); color: #fff; box-shadow: 0 3px 0 #991B1B; }

/* 点名：大字舞台与大按钮 */
.stage { position: relative; min-height: 45vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; background: var(--card); border-radius: 28px; border: 2px solid var(--line); box-shadow: var(--shadow-card); overflow: hidden; }
.stage::before { content: ""; position: absolute; inset: auto -20% -40% -20%; height: 60%; background: radial-gradient(closest-side, var(--accent-soft), transparent); opacity: .9; pointer-events: none; }
.stage > * { position: relative; }
.stage .name { font-size: clamp(56px, 16vw, 160px); font-weight: 900; color: var(--accent); line-height: 1.1; word-break: break-all; letter-spacing: -1px; }
.stage .name.rolling { color: var(--muted); }
.stage .name.landed { animation: pop .3s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(.86); } to { transform: scale(1); } }
.stage .hint { color: var(--muted); font-size: 18px; font-weight: 600; }
.stage .who { font-size: clamp(28px, 8vw, 64px); font-weight: 800; color: var(--accent); margin-bottom: 12px; }
.stage .q { font-size: clamp(28px, 6vw, 56px); font-weight: 700; line-height: 1.35; max-height: 8.2em; overflow-y: auto; word-break: break-word; }
.answer { margin-top: 14px; background: var(--soft); border-radius: 16px; padding: 12px 16px; font-size: 20px; line-height: 1.5; text-align: left; border: 2px solid var(--line); }
.bigbtn { width: 100%; height: 68px; border-radius: 999px; background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: #fff; font-size: 24px; font-weight: 900; margin-top: 14px; letter-spacing: 1px; box-shadow: 0 7px 0 var(--accent-deep), 0 16px 30px rgba(0,0,0,.14); transition: transform .12s, box-shadow .12s; }
.bigbtn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--accent-deep), 0 6px 14px rgba(0,0,0,.12); }
.bigbtn:disabled { opacity: .55; transform: none; }
.small-row { display: flex; gap: 10px; margin-top: 12px; }
.small-row .btn { height: 46px; }
.switch-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.toggle { display: inline-flex; align-items: center; gap: 10px; height: 44px; padding: 0 6px 0 12px; border-radius: 999px; background: #fff; border: 2px solid var(--line); font-weight: 700; font-size: 15px; box-shadow: var(--shadow-card); }
.toggle .knob { width: 40px; height: 24px; border-radius: 999px; background: #E5E7EB; position: relative; transition: background .15s; }
.toggle .knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .15s; }
.toggle[aria-pressed="true"] .knob { background: var(--accent); }
.toggle[aria-pressed="true"] .knob::after { left: 19px; }
.toggle:disabled { opacity: .45; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 600; }
.chip.absent { color: var(--muted); text-decoration: line-through; }
.drawn summary { list-style: none; cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--muted); font-weight: 600; }
.drawn summary::-webkit-details-marker { display: none; }
.drawn summary::before { content: "▸"; margin-right: 6px; } .drawn[open] summary::before { content: "▾"; }
body.fullscreen main { padding: 12px; } body.fullscreen .tabs, body.fullscreen .fs-hide { display: none; }
body.fullscreen .stage { min-height: calc(100vh - 140px); }
body.fullscreen .stage .name { font-size: clamp(80px, 22vw, 240px); }
body.fullscreen .stage .q { font-size: clamp(36px, 7vw, 80px); max-height: calc(100vh - 260px); overflow-y: auto; }
.fs-exit { position: fixed; top: calc(10px + env(safe-area-inset-top)); right: 12px; height: 44px; padding: 0 16px; border-radius: 999px; background: var(--card); border: 2px solid var(--line); font-weight: 700; box-shadow: var(--shadow-float); z-index: 20; }
select.field { height: 48px; font-size: 16px; font-weight: 600; border-radius: 999px; border: 2px solid var(--line); background: var(--card); padding: 0 16px; box-shadow: var(--shadow-card); }

/* 设置页区块 */
.section { background: var(--card); border-radius: var(--radius); border: 2px solid var(--line); padding: 14px 14px 12px; margin-bottom: 14px; box-shadow: var(--shadow-card); }
.section .label, .label { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 10px; letter-spacing: .5px; }
.item { display: flex; align-items: center; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.item:last-of-type { border-bottom: 0; }
.item .txt { flex: 1; font-weight: 700; font-size: 16px; }
.addrow { display: flex; gap: 8px; margin-top: 10px; }
.addrow input, .addrow textarea, .field, textarea.field, input.field { flex: 1; min-height: 46px; font-size: 16px; padding: 10px 14px; border-radius: 16px; border: 2px solid var(--line); background: #fff; outline: none; }
.addrow input:focus, .addrow textarea:focus, .field:focus { border-color: var(--accent-2); box-shadow: 0 0 0 4px var(--accent-soft); }
.hint { font-size: 13px; color: var(--muted); margin-top: 8px; line-height: 1.5; }
.foot { text-align: center; font-size: 12px; color: var(--muted); line-height: 1.7; padding: 8px 0 4px; }

/* 空状态 */
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty img { width: 220px; height: auto; margin-bottom: 8px; }
.empty p { margin-bottom: 16px; font-weight: 600; }
.empty .btn { flex: none; width: 72%; margin: 0 auto; }

/* 底部悬浮标签栏 */
.tabs { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; gap: 4px; padding: 6px; background: rgba(255,255,255,.96); border: 2px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-float); backdrop-filter: blur(10px); z-index: 10; }
.tab { flex: 1; height: 50px; border-radius: 999px; font-size: 15px; font-weight: 700; color: var(--muted); }
.tab.active, .tab[aria-current] { background: var(--accent-soft); color: var(--accent-ink); }

/* 吉祥物：顶栏右侧一个小贴纸 */
.topbar::after { content: ""; width: 44px; height: 44px; background: url("assets/mascot.png") center/contain no-repeat; order: 99; flex: none; margin-left: 2px; }

/* 提示条与弹层 */
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: 92vw; background: #1F2937; color: #fff; padding: 12px 18px; border-radius: 999px; font-size: 15px; font-weight: 600; z-index: 50; box-shadow: var(--shadow-float); }
.toast[hidden] { display: none; }
.toast button { margin-left: 12px; color: #FDE68A; font-weight: 800; text-decoration: underline; min-height: 44px; min-width: 44px; margin-top: -10px; margin-bottom: -10px; }
.has-sheet .toast { bottom: auto; top: calc(12px + env(safe-area-inset-top)); }
.sheet-mask { position: fixed; inset: 0; background: rgba(31,41,55,.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 85vh; overflow-y: auto; background: var(--card); border-radius: 28px 28px 0 0; padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0,0,0,.18); animation: up .22s cubic-bezier(.2,1,.3,1); }
.sheet::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet h2 { font-size: 20px; font-weight: 800; margin-bottom: 10px; }
.sheet h2 small { font-size: 14px; color: var(--muted); font-weight: 600; margin-left: 6px; }
.sheet textarea, .sheet input { width: 100%; font-size: 16px; padding: 12px 14px; border-radius: 16px; border: 2px solid var(--line); background: #fff; outline: none; }
.sheet textarea { min-height: 160px; line-height: 1.5; resize: vertical; }
.sheet textarea:focus, .sheet input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 4px var(--accent-soft); }
.sheet .actions { margin: 12px 0 0; }
.sheet .msg { font-size: 16px; line-height: 1.5; margin: 6px 0 14px; }
.sheet .err { color: var(--minus-ink); font-size: 14px; margin-top: 6px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* 弹层底部按钮行、区块标题、输入框宽度、焦点环 */
.sheet .row, .section .row { display: flex; gap: 10px; margin-top: 12px; }
.sheet .row .btn, .section .row .btn { flex: 1; }
.section h2 { font-size: 17px; font-weight: 800; margin-bottom: 10px; }
.section .row { align-items: center; }
.field, textarea.field, .roster { width: 100%; display: block; }
textarea.roster { min-height: 150px; line-height: 1.6; resize: vertical; }
button:focus { outline: none; }
button:focus-visible, .cell:focus-visible, .card:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.sheet .reasons + .row, .sheet .row { margin-top: 10px; }

/* 抽题页顶栏：下拉占一整行；舞台里的按钮不要被 flex 拉伸 */
.topbar .left { white-space: nowrap; }
.quizbar { flex-wrap: wrap; row-gap: 10px; }
.quizbar select.field { flex: 1 1 100%; min-width: 0; width: 100%; order: -1; }
.quizbar::after { order: 98; }
.stage .btn, .stage .ansbtn { flex: none; width: auto; min-width: 120px; height: 44px; padding: 0 20px; margin-top: 14px; background: var(--soft); }
