:root {
  --bg: #fafaf7; --fg: #1a1a1a; --muted: #6b6b66; --line: #e4e2dc; --card: #ffffff;
  --accent: #1f5f8b; --accent-fg: #ffffff; --warn-bg: #fff4e5; --warn: #8a4b00; --ok-bg: #edf7ee; --ok: #1e6b2f;
  --flag: #b42318; --flag-bg: #fdecea; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; font-family: var(--sans); background: var(--bg); color: var(--fg); line-height: 1.5; font-size: 16px; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; margin-top: 1.6em; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: var(--mono); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
.wrap.narrow { max-width: 680px; }
.wrap.wide { max-width: 1200px; }
.brand-small { font-weight: 600; letter-spacing: .01em; color: var(--muted); font-size: .9rem; }
.brand-small a { color: inherit; text-decoration: none; }
.btn { display: inline-block; padding: 9px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--fg); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.2; }
.btn:hover { border-color: #c9c6be; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.primary:hover { background: #184c70; }
.btn.small { padding: 6px 11px; font-size: .875rem; }
.btn.active { background: #e8eef3; border-color: var(--accent); }
input[type=text], input[type=email], input[type=number], input[type=datetime-local], input:not([type]), textarea.field, select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; color: var(--fg); }
label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: .95rem; }
.warn { background: var(--warn-bg); color: var(--warn); padding: 10px 14px; border-radius: 8px; }
.flag { color: var(--flag); }
.flagbox { background: var(--flag-bg); color: var(--flag); border-radius: 8px; padding: 12px 16px; margin: 0 0 20px; }

/* ---------- landing ---------- */
.site-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 0; }
.site-head .logo { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--fg); }
.site-head nav a { margin-left: 18px; text-decoration: none; color: var(--fg); font-weight: 500; }
.hero { padding: 40px 0 30px; max-width: 760px; }
.hero h1 { font-size: 2.8rem; margin-bottom: .3em; }
.hero .sub { font-size: 1.25rem; color: #3b3b38; max-width: 640px; }
.hero .cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.hero .cta .btn { padding: 12px 20px; font-size: 1.05rem; }
.shot { border: 1px solid var(--line); border-radius: 12px; background: var(--card); padding: 18px 20px; margin: 30px 0; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.shot .fake-bar { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 12px; }
.shot .fake-text { font-family: Georgia, "Times New Roman", serif; font-size: 1.05rem; }
.shot .caret { display: inline-block; width: 2px; height: 1.1em; background: var(--fg); vertical-align: text-bottom; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.steps3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 20px 0 40px; }
.steps3 .step { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.steps3 .n { display: inline-block; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; text-align: center; line-height: 28px; font-weight: 700; margin-bottom: 10px; }
.stats-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 20px; padding: 0; list-style: none; margin: 10px 0 30px; }
.stats-list li { padding-left: 18px; position: relative; }
.stats-list li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); }
.faq details { border-top: 1px solid var(--line); padding: 12px 0; }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { font-weight: 600; cursor: pointer; }
.faq details p { margin: 10px 0 0; color: #3b3b38; }
.pricing { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 22px; margin: 30px 0; }
.pricing form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.pricing input, .pricing select { width: auto; flex: 1 1 200px; }
.byrequest { border-left: 3px solid var(--accent); padding: 4px 16px; color: #3b3b38; margin: 30px 0; }
footer { border-top: 1px solid var(--line); margin-top: 50px; padding: 20px 0; color: var(--muted); font-size: .9rem; display: flex; gap: 18px; flex-wrap: wrap; }
footer a { color: var(--muted); }

/* ---------- /new ---------- */
.form-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-weight: 500; }
.check input { width: auto; }
.result { display: none; }
.result.show { display: block; }
.link-box { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 12px 0; }
.link-box label { margin: 0 0 6px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-family: var(--mono); font-size: .9rem; }

/* ---------- student ---------- */
body.student { background: #fff; }
.gate[hidden] { display: none; }
.gate { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg); }
.gate-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px; max-width: 560px; width: 100%; }
.gate-card h1 { font-size: 1.5rem; }
.prompt { white-space: pre-wrap; background: var(--bg); border-radius: 8px; padding: 12px 14px; margin: 10px 0; }
.rules { padding-left: 20px; color: #3b3b38; font-size: .95rem; }
.rules li { margin-bottom: 6px; }
.gate-card .btn { width: 100%; margin-top: 14px; padding: 12px; font-size: 1.05rem; }
.editor { display: flex; flex-direction: column; height: 100dvh; }
.editor[hidden] { display: none; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--bg); font-size: .9rem; flex-wrap: wrap; }
.bar-left, .bar-right { display: flex; align-items: center; gap: 12px; }
.sep { color: var(--line); }
.who { font-weight: 600; }
.stat { font-variant-numeric: tabular-nums; }
.save { color: var(--muted); }
.save.pending { color: var(--warn); }
.save.offline { color: var(--flag); font-weight: 600; }
.prompt-bar { border-bottom: 1px solid var(--line); background: #fffdf5; padding: 6px 14px; font-size: .9rem; }
.prompt-bar summary { cursor: pointer; font-weight: 600; }
.prompt-bar div { white-space: pre-wrap; padding: 6px 0; }
#ta { flex: 1; width: 100%; border: 0; outline: 0; resize: none; padding: 28px max(20px, calc(50% - 360px)); font-family: Georgia, "Times New Roman", serif; font-size: 1.2rem; line-height: 1.7; background: #fff; color: var(--fg); }
#ta[readonly] { background: #fafaf7; color: #444; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #1a1a1a; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: .95rem; max-width: 90vw; z-index: 10; }
.toast[hidden] { display: none; }
.done { border-top: 1px solid var(--line); background: var(--ok-bg); padding: 14px 20px; }
.done[hidden] { display: none; }
.done-card h2 { margin: 0 0 4px; color: var(--ok); }
.done-card p { margin: 0; }

/* ---------- teacher ---------- */
.crumbs { color: var(--muted); font-size: .9rem; margin-bottom: 8px; }
.dash-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.dash-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.links { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px 0 14px; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
table.sessions { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.sessions th, table.sessions td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.sessions th { background: var(--bg); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.sessions .num { text-align: right; font-variant-numeric: tabular-nums; }
table.sessions tr.flagged td:first-child { border-left: 3px solid var(--flag); }
table.sessions td.flags { white-space: normal; max-width: 320px; font-size: .85rem; color: var(--flag); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.pill.active { background: #e8f0f7; color: var(--accent); }
.pill.submitted { background: var(--ok-bg); color: var(--ok); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 6px 0 20px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.tile-v { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-l { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.tile-s { font-size: .78rem; color: var(--muted); }
.replay-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.speeds { display: inline-flex; gap: 4px; }
.timeline-wrap { position: relative; padding-top: 14px; }
.markers { position: absolute; left: 8px; right: 8px; top: 0; height: 12px; }
.markers i { position: absolute; top: 0; width: 3px; height: 12px; border-radius: 2px; }
.mk, .markers i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; margin: 0 4px 0 10px; }
.mk.paste, .markers i.paste { background: var(--flag); }
.mk.blur, .markers i.blur { background: #d97706; }
.mk.big, .markers i.big { background: #7c3aed; }
.mk.idle, .markers i.idle { background: #b8b5ad; }
#scrub { width: 100%; margin: 0; }
.replay-text { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; min-height: 240px; max-height: 60vh; overflow: auto; white-space: pre-wrap; word-wrap: break-word; font-family: Georgia, "Times New Roman", serif; font-size: 1.05rem; line-height: 1.65; }
.replay-text .cur { display: inline-block; width: 2px; height: 1.1em; background: var(--accent); vertical-align: text-bottom; }
.final-text { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; white-space: pre-wrap; word-wrap: break-word; font-family: Georgia, "Times New Roman", serif; font-size: 1.05rem; line-height: 1.65; }

/* ---------- report ---------- */
body.report { background: #fff; }
.report-page { max-width: 760px; margin: 0 auto; padding: 24px 20px 60px; font-size: 14px; }
.report-page h1 { font-size: 1.6rem; }
.report-page h2 { font-size: 1rem; margin-top: 1.4em; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.report-head { border-bottom: 2px solid var(--fg); padding-bottom: 10px; margin-bottom: 14px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.verdict { border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; }
.verdict.clean { background: var(--ok-bg); color: var(--ok); }
.verdict.flagged { background: var(--flag-bg); color: var(--flag); }
.verdict .small { color: #444; margin-top: 4px; }
.report-table { width: 100%; border-collapse: collapse; }
.report-table th, .report-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.report-table th { width: 220px; font-weight: 600; color: #333; }
.report-text { font-size: .95rem; max-height: none; }
@media print {
  .noprint { display: none !important; }
  body { background: #fff; }
  .report-page { padding: 0; font-size: 12px; }
  .report-text { border: 0; padding: 0; page-break-before: always; }
  a { color: inherit; text-decoration: none; }
}

@media (max-width: 720px) {
  .hero h1 { font-size: 2rem; }
  .steps3, .links, .row2 { grid-template-columns: 1fr; }
  .site-head nav a { margin-left: 12px; }
  #ta { padding: 18px 16px; font-size: 1.1rem; }
  .bar { padding: 6px 10px; font-size: .85rem; }
}

/* public demo banner (student page) */
.demo-banner { background: #fff4e5; color: #8a4b00; font-size: .9rem; padding: 8px 14px; text-align: center; border-bottom: 1px solid #f3dcb8; }
.demo-banner a { color: inherit; }
body.student:has(.demo-banner) .gate { min-height: calc(100dvh - 38px); }
body.student:has(.demo-banner) .editor { height: calc(100dvh - 38px); }
