/* 作业助手 · 家长页面样式（孩子端用 kid.css）
   和孩子端同一套设计语言（docs/05-界面规范.md v4）：纸底 + 墨色文字、马卡龙色只表示状态、留白克制
   规则：颜色、字号、圆角只用下面的变量；每屏一个墨色实心主按钮；字号不小于 12px；文字对比度 ≥ 4.5；手机 390 宽不横向滚动 */

/* ============ 1. 变量 ============ */
:root {
  --bg: #F7F5F1; --paper: #FFFEFC; --line: #ECE9E3; --line2: #DCD8D0;
  --ink: #2E2E2E; --quiet: #5F5D58; --t3: #6F6C66; --t4: #BDB9B1;
  --mint: #D3EDE1; --lav: #E3DDF6; --sky: #D6E8F6; --lemon: #FAF0BC; --peach: #FBDFD0; --pink: #F7D6DF;
  /* 有颜色的文字用深一档，保证对比度 */
  --ok: #3F6B55; --warn: #7F5518; --bad: #9E3B4D;
  --lift: 0 1px 2px rgba(60, 50, 40, .04), 0 6px 18px rgba(60, 50, 40, .05);

  --f1: 1.375rem;  /* 22 大标题 */
  --f2: 1.0625rem; /* 17 小标题 */
  --f3: 0.9375rem; /* 15 正文、按钮 */
  --f4: 0.8125rem; /* 13 辅助说明 */
  --f5: 0.75rem;   /* 12 标签、提示（最小） */

  --sp: 16px; --sp-s: 10px;
  --r-card: 16px; --r-btn: 12px; --r-sheet: 20px;
  --tap: 44px;
}

/* ============ 2. 基础 ============ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; overflow-x: clip; }
body { background: var(--bg); color: var(--ink); font-size: var(--f3); line-height: 1.5;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
b, strong { font-weight: 700; }
img { max-width: 100%; }
.hidden { display: none !important; }
.note { font-size: var(--f4); color: var(--quiet); line-height: 1.5; }
.small { font-size: var(--f5); color: var(--t3); }
.err { color: var(--bad); }
.num { font-variant-numeric: tabular-nums; }
svg { display: block; flex: 0 0 auto; }

/* ============ 3. 骨架：标题、一级标签、「更多」 ============ */
.parent { max-width: 760px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) var(--sp) 96px; }
.phead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 4px 12px; }
.phead h1 { font-size: var(--f1); margin: 0; font-weight: 700; }
.kidsel { appearance: none; -webkit-appearance: none; border: 0; background: var(--paper); box-shadow: var(--lift); border-radius: 999px;
  font: inherit; font-size: var(--f4); color: var(--ink); min-height: 36px; padding: 0 14px; max-width: min(60%, 240px); }

.tabs { position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; padding: 4px;
  background: var(--line); border-radius: 14px; margin: 0 0 var(--sp); }
.tabs button { border: 0; background: none; border-radius: 10px; min-height: 40px; padding: 0 2px; font-size: var(--f4); color: var(--quiet);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs button.on { background: var(--paper); color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.tabs .more::after { content: ' ▾'; font-size: var(--f5); }

.moresheet { position: sticky; top: 52px; z-index: 9; background: var(--paper); border-radius: var(--r-sheet); box-shadow: 0 10px 30px rgba(60, 50, 40, .14);
  padding: 8px; margin: -8px 0 var(--sp); display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.moresheet button { border: 0; background: none; border-radius: var(--r-btn); padding: 10px 6px; text-align: left; min-height: var(--tap); display: flex; flex-direction: column; gap: 2px; }
.moresheet button b { font-size: var(--f3); }
.moresheet button span { font-size: var(--f5); color: var(--t3); line-height: 1.35; }
.moresheet button.on { background: var(--bg); }
@media (max-width: 420px) { .moresheet { grid-template-columns: repeat(2, 1fr); } }

/* ============ 4. 卡片、小标题 ============ */
.card { background: var(--paper); border-radius: var(--r-card); box-shadow: var(--lift); padding: var(--sp); margin-bottom: 12px; min-width: 0; }
.card.flat { box-shadow: none; background: transparent; padding: 4px; }
.card .meta, .meta { font-size: var(--f4); color: var(--quiet); margin-bottom: 6px; }
.sect { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 22px 4px 8px; }
.sect h2 { font-size: var(--f2); margin: 0; font-weight: 700; }
.sect .small { white-space: nowrap; }
.empty { text-align: center; padding: 28px var(--sp); color: var(--quiet); }
.lead { font-size: var(--f2); font-weight: 700; margin: 0 0 4px; }

/* ============ 5. 表单 ============ */
.parent textarea, .parent input[type=text], .parent input[type=number], .parent select {
  width: 100%; font: inherit; font-size: var(--f3); color: var(--ink); padding: 10px 12px; min-height: var(--tap);
  border: 1px solid var(--line2); border-radius: var(--r-btn); background: var(--paper); }
.parent textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.parent textarea:focus, .parent input:focus, .parent select:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.parent input[type=number] { width: 72px; display: inline-block; padding: 6px 8px; min-height: 36px; text-align: center; }
.field { margin-top: 10px; }
.field > label { display: block; font-size: var(--f4); color: var(--quiet); margin-bottom: 4px; }
.frow { display: flex; gap: 8px; margin-top: 10px; }
.frow > * { min-width: 0; }
/* 选文件：原生控件藏起来，整块虚线框可点 */
.filepick { display: flex; align-items: center; gap: 10px; margin-top: 10px; min-height: 56px; padding: 10px 14px; border: 1.5px dashed var(--line2);
  border-radius: var(--r-btn); color: var(--quiet); font-size: var(--f4); cursor: pointer; position: relative; }
.filepick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.filepick b { color: var(--ink); font-size: var(--f3); }
.filepick.has { border-style: solid; border-color: var(--ink); color: var(--ink); }

/* ============ 6. 按钮三级 ============ */
.pri, .sec, .soft { border: 0; border-radius: var(--r-btn); min-height: var(--tap); font-size: var(--f3); padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.pri { background: var(--ink); color: #fff; font-weight: 700; min-height: 48px; }
.sec { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); font-weight: 700; }
.soft { background: var(--bg); color: var(--ink); }
.pri:active, .sec:active, .soft:active, .ibtn:active, .chip:active { transform: scale(.97); }
.pri:disabled, .sec:disabled { opacity: .45; cursor: default; }
.block { width: 100%; margin-top: 12px; }
.link { border: 0; background: none; padding: 6px 2px; color: var(--quiet); font-size: var(--f4); text-decoration: underline; text-underline-offset: 3px; min-height: 40px; }
.link.danger { color: var(--bad); }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
/* 图标按钮（行右边的操作） */
.ibtn { width: var(--tap); height: var(--tap); border: 0; border-radius: 50%; background: none; color: var(--quiet); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.ibtn svg { width: 20px; height: 20px; }
.ibtn.tick { color: var(--t4); }
.ibtn.tick svg { width: 28px; height: 28px; }
.ibtn.tick.on { color: var(--ok); }

/* ============ 7. 列表行（一项一行，操作在右边） ============ */
.list { background: var(--paper); border-radius: var(--r-card); box-shadow: var(--lift); overflow: hidden; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 6px 10px var(--sp); border-top: 1px solid var(--line); min-height: 56px; }
.row:first-child { border-top: 0; }
.row .main { flex: 1; min-width: 0; }
.row .ttl { overflow-wrap: anywhere; line-height: 1.45; }
.row .sub { font-size: var(--f5); color: var(--t3); margin-top: 2px; overflow-wrap: anywhere; }
.row .acts { display: flex; align-items: center; flex: 0 0 auto; }
.row.done .ttl { color: var(--t3); text-decoration: line-through; text-decoration-color: var(--t4); }
.tag { display: inline-block; font-size: var(--f5); line-height: 1.6; padding: 0 8px; border-radius: 999px; background: var(--bg); color: var(--ink); margin-right: 6px; white-space: nowrap; vertical-align: 1px; }
.tag.mint { background: var(--mint); } .tag.lav { background: var(--lav); } .tag.sky { background: var(--sky); }
.tag.lemon { background: var(--lemon); } .tag.peach { background: var(--peach); } .tag.pink { background: var(--pink); }

/* ============ 8. 筛选（判题） ============ */
.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 0; border-radius: 999px; min-height: 36px; padding: 0 14px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line2); font-size: var(--f4); color: var(--ink); }
.chip.on { background: var(--ink); color: #fff; box-shadow: none; font-weight: 700; }
.chip .n { font-size: var(--f5); opacity: .75; margin-left: 4px; }
.filters select { max-width: 240px; }

/* 判题：一题一块 */
.qitem { border-top: 1px solid var(--line); padding: 10px 0; }
.qitem:first-of-type { border-top: 0; }
.qhead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qhead .q { flex: 1; min-width: 0; color: var(--quiet); font-size: var(--f4); overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: 5.5em 1fr; gap: 2px 8px; margin-top: 6px; font-size: var(--f4); }
.kv dt { color: var(--t3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv dd.secret { background: var(--bg); border-radius: 6px; padding: 0 6px; }
.v { display: inline-block; font-size: var(--f5); font-weight: 700; line-height: 1.7; padding: 0 10px; border-radius: 999px; }
.v-对 { background: var(--mint); } .v-错 { background: var(--pink); } .v-存疑 { background: var(--lemon); }

/* ============ 9. 图片 ============ */
.thumb { display: block; max-width: 100%; max-height: 220px; border-radius: 10px; border: 1px solid var(--line); margin: 8px 0; object-fit: contain; background: var(--bg); }
.media { display: flex; gap: 12px; align-items: flex-start; }
.media .pic { width: 96px; flex: 0 0 96px; position: relative; }
.media .pic img { width: 96px; height: 128px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.media .body { flex: 1; min-width: 0; }
canvas.crop { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); margin-top: 8px; }

/* 扫描件：右上角的圆形勾选 */
.pick { position: absolute; top: 6px; left: 6px; width: 28px; height: 28px; margin: 0; appearance: none; -webkit-appearance: none; border-radius: 50%;
  background: rgba(255, 254, 252, .9); box-shadow: inset 0 0 0 2px var(--ink); cursor: pointer; }
.pick:checked { background: var(--ink); }
.pick:checked::after { content: ''; position: absolute; left: 10px; top: 5px; width: 6px; height: 12px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.pick:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.scan-tasks { margin-top: 12px; border-radius: 10px; background: var(--bg); padding: 6px 10px; }
.scan-tasks .row { padding: 6px 0; min-height: 0; border-top-color: var(--line2); }
.scan-tasks .ttl { font-size: var(--f4); }
.selbar { position: sticky; bottom: 12px; z-index: 8; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.selbar .note { flex: 1 1 100%; }

/* ============ 10. 设置：一行一个开关 ============ */
.set { display: flex; align-items: center; gap: 12px; }
.set .main { flex: 1; min-width: 0; }
.set .ttl { font-weight: 700; }
.sw { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 15px; background: var(--t4); position: relative; flex: 0 0 auto; margin: 0; cursor: pointer; transition: background .15s; }
.sw::after { content: ''; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .15); transition: left .15s; }
.sw:checked { background: var(--ink); }
.sw:checked::after { left: 23px; }
.sw:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
/* 保存反馈：控件旁边变成「已保存 ✓」再淡出 */
.saved { font-size: var(--f5); font-weight: 700; color: var(--ok); white-space: nowrap; opacity: 0; transition: opacity .6s; pointer-events: none; }
.saved.show { opacity: 1; transition: none; }
.saved.bad { color: var(--bad); }
.inl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.inl input[type=text] { width: 9em; }
.inl select { width: auto; }
audio { width: 100%; height: 40px; margin-top: 8px; }

/* ============ 11. 对话、背诵 ============ */
.bubble { max-width: 86%; padding: 8px 12px; border-radius: 14px; margin: 6px 0; overflow-wrap: anywhere; }
.bubble.kid { background: var(--sky); margin-left: auto; border-bottom-right-radius: 4px; }
.bubble.ai { background: var(--paper); box-shadow: var(--lift); border-bottom-left-radius: 4px; }
.bubble .small { display: block; margin-top: 2px; }
.weak { background: var(--pink); border-radius: 4px; padding: 0 3px; }
.sent { padding: 6px 0; border-top: 1px solid var(--line); display: flex; align-items: flex-start; gap: 10px; }
.sent:first-child { border-top: 0; }
.sent .no { color: var(--t3); font-size: var(--f5); min-width: 1.6em; white-space: nowrap; flex: 0 0 auto; padding-top: 2px; }
.sent .txt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sent.miss .txt { background: var(--lemon); border-radius: 4px; padding: 0 4px; }
details summary { cursor: pointer; font-size: var(--f4); color: var(--quiet); min-height: 32px; display: flex; align-items: center; }
details[open] summary { margin-bottom: 6px; }
.big { font-size: var(--f1); font-weight: 700; line-height: 1.2; }

/* ============ 12. 提示条（底部，几秒后自己消失） ============ */
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); z-index: 30; max-width: min(92vw, 560px);
  background: var(--ink); color: #fff; border-radius: 14px; padding: 12px 16px; font-size: var(--f4); box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.err { background: var(--bad); }

/* 印出来的练习纸预览 */
iframe.ws { display: block; width: 100%; height: 520px; border: 1px solid var(--line); border-radius: 10px; margin-top: 10px; background: #fff; }
