:root {
  --bg: #f4f2ee; --card: #fff; --ink: #1d1d1f; --muted: #6b6b70; --line: #e3e0da;
  --accent: #2f6fd6; --accent-soft: #e6effc; --ok: #1f9d55; --ok-soft: #e3f5ea;
  --warn: #c77700; --warn-soft: #fdf1dc; --bad: #c8372d; --bad-soft: #fbe6e4;
  --radius: 16px; --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
.app { max-width: 820px; margin: 0 auto; padding: 0 16px calc(110px + var(--safe-b)); }
header.bar {
  position: sticky; top: 0; z-index: 5; background: rgba(244,242,238,.92); backdrop-filter: blur(12px);
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin: 0 -16px 8px;
  border-bottom: 1px solid var(--line);
}
header.bar .back { font-size: 17px; }
header.bar h1 { font-size: 17px; font-weight: 600; margin: 0; flex: 1; text-align: center; }
header.bar .spacer { width: 60px; }
.large-title { font-size: 32px; font-weight: 700; margin: 18px 0 4px; letter-spacing: -.5px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 24px 4px 8px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card + .card { margin-top: 12px; }
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--ink); min-height: 56px; }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .meta { color: var(--muted); font-size: 15px; }
.row .chev { color: #b8b5ae; font-size: 22px; }
.icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; }
.i-m { background: #2f6fd6; } .i-d { background: #d2553f; } .i-e { background: #7a4fd0; } .i-g { background: #1f9d8a; } .i-b { background: #4c9a2a; }
.badge { font-size: 13px; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.b-ok { background: var(--ok-soft); color: var(--ok); } .b-warn { background: var(--warn-soft); color: var(--warn); }
.b-new { background: var(--accent-soft); color: var(--accent); } .b-bad { background: var(--bad-soft); color: var(--bad); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px;
  font: inherit; font-weight: 600; padding: 15px 20px; min-height: 52px; cursor: pointer; background: var(--accent-soft); color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.block { width: 100%; }
.btn.small { min-height: 40px; padding: 8px 14px; font-size: 15px; border-radius: 10px; }
.actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 12px 16px calc(16px + var(--safe-b));
  background: linear-gradient(transparent, var(--bg) 30%); }
.actions .inner { max-width: 820px; margin: 0 auto; display: flex; gap: 10px; }
.actions .inner > * { flex: 1; }
.seg { display: flex; background: #e6e3dd; border-radius: 12px; padding: 3px; }
.seg span { flex: 1; text-align: center; padding: 9px 4px; border-radius: 9px; font-size: 15px; font-weight: 600; color: var(--muted); }
.seg span.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 10px 14px; border-radius: 12px; background: var(--card); border: 1.5px solid var(--line); font-size: 15px; font-weight: 500; cursor: pointer; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip.on::before { content: "✓ "; }
.subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.subject { background: var(--card); border-radius: var(--radius); padding: 14px; border: 2px solid transparent; display: flex; flex-direction: column; gap: 10px; font-weight: 600; cursor: pointer; }
.subject.on { border-color: var(--accent); }
.field { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); gap: 12px; }
.field:last-child { border-bottom: 0; }
.field .val { color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 14px; font-weight: 600; }
.stepper b { width: 36px; height: 36px; border-radius: 10px; background: #eeebe5; display: grid; place-items: center; font-size: 20px; }
textarea, input[type=text] { width: 100%; font: inherit; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; resize: vertical; }
.upload { border: 2px dashed #cdc8bf; border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); background: #fbfaf8; }
.thumbs { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.thumb { width: 74px; height: 98px; border-radius: 8px; background: repeating-linear-gradient(#fff 0 9px, #ddd 9px 10px); border: 1px solid var(--line); position: relative; }
.thumb::after { content: "×"; position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%; background: #555; color: #fff; font-size: 14px; display: grid; place-items: center; }
.task { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.task h3 { margin: 0 0 6px; font-size: 17px; display: flex; justify-content: space-between; gap: 10px; }
.task h3 small { font-weight: 500; color: var(--muted); font-size: 14px; }
.task ul { list-style: none; padding: 0; margin: 6px 0 0; }
.sol { background: #f2f6fc; border-left: 4px solid var(--accent); border-radius: 0 10px 10px 0; padding: 10px 12px; margin-top: 10px; font-size: 15px; }
.sol ol { margin: 6px 0; padding-left: 20px; }
.canvas-wrap { margin-top: 10px; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; position: relative;
  background: repeating-linear-gradient(#fff 0 35px, #dfe6f0 35px 36px); }
.canvas-wrap canvas { display: block; width: 100%; height: 240px; touch-action: none; }
.tools { display: flex; gap: 8px; margin-top: 8px; }
.tools .t { min-height: 40px; min-width: 44px; padding: 0 12px; border-radius: 10px; background: #eeebe5; display: grid; place-items: center; font-size: 15px; font-weight: 600; cursor: pointer; }
.tools .t.on { background: var(--ink); color: #fff; }
.progress { height: 6px; background: #e3e0da; border-radius: 9px; overflow: hidden; margin: 6px 0 14px; }
.progress div { height: 100%; background: var(--accent); }
.hand { font-family: "Bradley Hand", "Segoe Print", "Comic Sans MS", cursive; font-size: 20px; color: #24408e; background: repeating-linear-gradient(#fff 0 31px, #dfe6f0 31px 32px); border-radius: 10px; padding: 2px 12px; line-height: 32px; border: 1px solid var(--line); }
.verdict { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.pts { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.pts b { width: 34px; height: 34px; border-radius: 9px; background: #eeebe5; display: grid; place-items: center; }
.ai { background: var(--warn-soft); color: #7a4a00; border-radius: 10px; padding: 10px 12px; font-size: 15px; margin-top: 10px; }
.ai.ok { background: var(--ok-soft); color: #145c33; }
.score { display: flex; align-items: baseline; gap: 6px; }
.score .big { font-size: 44px; font-weight: 800; letter-spacing: -1px; }
.grade { font-size: 15px; color: var(--muted); }
.note { background: #fffbe6; border: 1px solid #f0e2a8; color: #6b5a12; border-radius: 12px; padding: 10px 14px; font-size: 14px; margin: 12px 0; }
.mock-tag { position: fixed; top: 8px; right: 8px; z-index: 50; background: #1d1d1f; color: #fff; font-size: 11px; padding: 3px 8px; border-radius: 6px; opacity: .65; }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 5px solid var(--accent-soft); border-top-color: var(--accent); margin: 40px auto 18px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.check-list { list-style: none; padding: 0; margin: 0 auto; max-width: 360px; }
.check-list li { padding: 8px 0; color: var(--muted); }
.check-list li.done { color: var(--ink); } .check-list li.done::before { content: "✓  "; color: var(--ok); font-weight: 700; }
.check-list li.now::before { content: "•  "; color: var(--accent); font-weight: 700; }
.photo-ans { height: 180px; border-radius: 12px; background: linear-gradient(135deg, #f7f5ef, #ebe6db); border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); font-size: 14px; position: relative; overflow: hidden; }
.photo-ans .box { position: absolute; border: 2.5px solid var(--accent); border-radius: 6px; background: rgba(47,111,214,.08); }
@media (min-width: 700px) { .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } .two .card + .card { margin-top: 0; } }
