/* 布局和配色。控件本身是 Google 官方 Material Web（<md-…>）；这里只管排版、对错底色，和官方没有的几样：
   顶栏、表格、助教面板和对话气泡、提示条。颜色变量在 index.html 的 :root（Gmail 那套）。 */
* { box-sizing: border-box; }
:root { --ok: #146C2E; --ok-soft: #C4EED0; --bad: #B3261E; --bad-soft: #F9DEDC; --warn: #8C5000; --warn-soft: #FFEFC9; --info-soft: #F0F4F9; --muted: #444746; }
body { line-height: 1.6; }
a { color: var(--md-sys-color-primary); }
.muted { color: var(--muted); }
.pre { white-space: pre-wrap; }

/* 顶栏（手写） */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: flex-end; gap: 24px; padding: 0 24px; background: #fff; border-bottom: 1px solid #E1E3E1; }
.brand { color: #1F1F1F; text-decoration: none; padding: 14px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.topbar md-tabs { flex: 1; max-width: 640px; margin-left: auto; --md-primary-tab-container-color: transparent; }
@media (max-width: 760px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 0; padding: 0 8px; }
  .brand { max-width: 100%; padding: 10px 8px 0; }
  .topbar md-tabs { max-width: none; }
}

main { max-width: 880px; margin: 0 auto; padding: 20px 20px 96px; }
h1 { margin: 12px 0 4px; }
h2 { margin: 28px 0 10px; }
.crumbs { color: var(--muted); }
.crumbs a { text-decoration: none; }
.note { margin: 12px 0 4px; }

/* 卡片 */
.card { margin: 14px 0; }
.card-in { padding: 18px 20px; }
md-outlined-card.warm { --md-outlined-card-outline-color: var(--md-sys-color-primary); }
.cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 18px; align-items: start; }
.cols .card { margin: 0; }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } }
md-list { --md-list-container-color: transparent; padding: 0; }
md-list-item { --md-list-item-leading-space: 4px; --md-list-item-trailing-space: 4px; }
/* 列表项里的长文字要换行（Material Web 默认截成一行） */
.wrap { white-space: normal; overflow: visible; text-overflow: clip; display: block; }

/* 反馈框：带底色的实心卡片 */
md-filled-card.fb { margin-top: 12px; }
.fb-in { padding: 12px 16px; }
.fb-in p { margin: 6px 0; }
md-filled-card.fb-ok { --md-filled-card-container-color: var(--ok-soft); }
md-filled-card.fb-bad { --md-filled-card-container-color: var(--bad-soft); }
md-filled-card.fb-warn { --md-filled-card-container-color: var(--warn-soft); }
md-filled-card.fb-info { --md-filled-card-container-color: var(--info-soft); }

/* 状态小块（官方 md-assist-chip，加底色） */
md-chip-set { margin: 6px 0; }
md-assist-chip { --md-assist-chip-elevated-container-elevation: 0; --md-assist-chip-elevated-container-color: #E9EEF6; --md-assist-chip-label-text-color: #444746; }
md-assist-chip.tone-on { --md-assist-chip-elevated-container-color: var(--md-sys-color-primary); --md-assist-chip-label-text-color: #fff; }
md-assist-chip.tone-ok { --md-assist-chip-elevated-container-color: var(--ok-soft); --md-assist-chip-label-text-color: var(--ok); }
md-assist-chip.tone-bad { --md-assist-chip-elevated-container-color: var(--bad-soft); --md-assist-chip-label-text-color: var(--bad); }
md-assist-chip.tone-warn, md-assist-chip.tone-key { --md-assist-chip-elevated-container-color: var(--warn-soft); --md-assist-chip-label-text-color: var(--warn); }

/* 题目 */
.prompt { white-space: pre-wrap; margin: 10px 0; }
.conf-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.ans { margin-top: 12px; }
.ans md-outlined-text-field, .fb-in md-outlined-text-field, .card-in md-outlined-text-field { width: 100%; margin-top: 8px; }
md-list.opts md-list-item.opt { border: 1px solid #C4C7C5; border-radius: 12px; margin: 6px 0; }
md-list-item.opt.picked { background: var(--md-sys-color-primary-container); border-color: var(--md-sys-color-primary); }
md-list-item.opt.right { background: var(--ok-soft); border-color: var(--ok); }
md-list-item.opt.wrong { background: var(--bad-soft); border-color: var(--bad); }
md-list.rubric md-list-item { --md-list-item-one-line-container-height: 40px; --md-list-item-top-space: 4px; --md-list-item-bottom-space: 4px; }
md-icon.key { color: var(--warn); }
md-icon.mk-hit { color: var(--ok); }
md-icon.mk-miss { color: var(--muted); }
md-icon.mk-wrong { color: var(--bad); }
.mark-row { margin: 12px 0; }
.radios { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 4px; }
.radios label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.steps { margin: 12px 0 6px; }
.screen-title { margin: 4px 0 10px; }
.fold { margin-top: 8px; }
.fold-body { padding: 4px 8px 4px 12px; }
blockquote { margin: 4px 0; padding-left: 12px; border-left: 3px solid #C4C7C5; color: var(--muted); }
.figure { margin: 16px 0; overflow-x: auto; }
.figure svg { max-width: 100%; height: auto; }

/* 表格（手写：Material Web 没有数据表） */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { white-space: nowrap; background: #F8FAFD; color: #444746; font-weight: 500; text-align: left; padding: 8px 10px; border-bottom: 1px solid #E1E3E1; }
.tbl:not(.wrapcells) td:not(:first-child) { white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid #F1F3F4; vertical-align: top; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl md-assist-chip { margin: 2px 0 2px 4px; }

/* 演示 */
canvas { display: block; max-width: 100%; border: 1px solid #E1E3E1; border-radius: 12px; background: #fff; touch-action: none; }
.demo-ctl { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.demo-ctl label { display: inline-flex; align-items: center; gap: 4px; }
.demo-note { margin-top: 8px; }

/* 提示条（手写：Material Web 没有 snackbar），照 MD3 snackbar 的样子 */
.snackbar { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 50; background: #313033; color: #F4EFF4; padding: 14px 16px; border-radius: 4px; box-shadow: 0 3px 8px rgba(0,0,0,.25); max-width: calc(100vw - 32px); }

/* 问助教：入口是官方 md-fab；面板和气泡是手写的 */
.askbtn { position: fixed; right: 24px; bottom: 24px; z-index: 20; }
.askbtn[hidden] { display: none; }
.askpane { position: fixed; right: 16px; bottom: 16px; z-index: 21; width: min(440px, calc(100vw - 24px)); height: min(600px, calc(100vh - 32px));
  background: #fff; border-radius: 28px; box-shadow: 0 4px 24px rgba(0,0,0,.2); display: flex; flex-direction: column; overflow: hidden; }
.askpane[hidden] { display: none; }
.askhead { display: flex; align-items: center; gap: 10px; padding: 12px 12px 8px 20px; }
.askttl { flex: 1; min-width: 0; }
.askttl .where { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asklog { flex: 1; overflow-y: auto; padding: 4px 20px 10px; }
.asklog .q { margin: 14px 0 6px auto; max-width: 85%; width: fit-content; background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); border-radius: 18px 18px 4px 18px; padding: 8px 14px; }
.asklog .a { background: #F0F4F9; border-radius: 18px 18px 18px 4px; padding: 6px 14px; margin-bottom: 6px; max-width: 95%; }
.asklog .a p { margin: 6px 0; }
.asklog .a ul { margin: 6px 0; padding-left: 20px; }
.askwait { width: 100%; }
.askwait[hidden] { display: none; }
.askgate { padding: 4px 20px; color: var(--warn); }
.askgate:empty { display: none; }
.askin { display: flex; gap: 8px; align-items: center; padding: 8px 16px 16px; }
.askin md-outlined-text-field { flex: 1; }
