/* TutorMark design system ------------------------------------------------ */
:root {
  --brand: #3b3fd9;
  --brand-600: #2f33c4;
  --brand-700: #2629a3;
  --brand-50: #eef0ff;
  --brand-100: #dfe2ff;
  --accent: #ff6b4a;
  --ink: #141833;
  --ink-2: #2b3050;
  --muted: #5d6481;
  --faint: #8a90a8;
  --line: #e4e6f0;
  --line-2: #eef0f6;
  --bg: #f5f6fb;
  --surface: #ffffff;
  --side: #0f1226;
  --side-2: #181c38;
  --ok: #16a34a;
  --ok-50: #e9f8ef;
  --warn: #d97706;
  --warn-50: #fff5e6;
  --danger: #dc2626;
  --danger-50: #fdecec;
  --info: #2563eb;
  --info-50: #eaf1ff;
  --ai: #7c3aed;
  --ai-50: #f4eefe;
  --ai-100: #e9ddfd;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(20, 24, 51, 0.06);
  --shadow: 0 4px 16px rgba(20, 24, 51, 0.08);
  --shadow-lg: 0 18px 48px rgba(20, 24, 51, 0.18);
  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--ink); }
h1 { font-size: 24px; font-weight: 750; letter-spacing: -0.01em; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0 0 10px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brand-100); outline-offset: 1px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.top { align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.mt { margin-top: 16px; } .mt-s { margin-top: 8px; } .mb { margin-bottom: 16px; } .mb-s { margin-bottom: 8px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }

/* Buttons ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font-weight: 600; font-size: 13.5px;
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s, transform .05s;
  text-decoration: none !important;
}
.btn:hover { background: #f7f8fc; border-color: #d4d7e6; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(59,63,217,.35); }
.btn.primary:hover { background: var(--brand-600); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn.danger-ghost { color: var(--danger); border-color: transparent; background: transparent; }
.btn.danger-ghost:hover { background: var(--danger-50); }
.btn.success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.success:hover { background: #12843c; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(20,24,51,.05); }
.btn.ai { background: linear-gradient(135deg, #7c3aed, #4f46e5); border-color: transparent; color: #fff; box-shadow: 0 2px 8px rgba(124,58,237,.3); }
.btn.ai:hover { filter: brightness(1.07); }
.btn.ai-soft { background: var(--ai-50); border-color: var(--ai-100); color: var(--ai); }
.btn.ai-soft:hover { background: var(--ai-100); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 7px; gap: 4px; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 15px; border-radius: 11px; }
.btn.icon-only { width: 36px; padding: 0; }
.btn.sm.icon-only { width: 30px; }
.btn.block { width: 100%; }
.btn .spin { width: 15px; height: 15px; }

/* Forms ------------------------------------------------------------------ */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .label { font-weight: 600; font-size: 13px; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; border: 1px solid #d9dceb; background: #fff; border-radius: 9px;
  padding: 8px 11px; min-height: 38px; transition: border-color .12s, box-shadow .12s;
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.input.sm, .select.sm { min-height: 32px; padding: 5px 9px; font-size: 13px; }
.input-group { display: flex; align-items: center; gap: 0; }
.check { display: inline-flex; align-items: flex-start; gap: 8px; cursor: pointer; user-select: none; }
.check input { margin-top: 3px; accent-color: var(--brand); width: 16px; height: 16px; }
.toggle { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { appearance: none; width: 38px; height: 22px; border-radius: 22px; background: #cfd3e3; position: relative; transition: background .15s; cursor: pointer; flex: none; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle input:checked { background: var(--brand); }
.toggle input:checked::after { transform: translateX(16px); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.error-text { color: var(--danger); font-size: 13px; }

/* Cards & layout --------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.card-body { padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.main-side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--brand); }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 700; margin: 4px 0 10px; }

/* Stats ------------------------------------------------------------------ */
.stat { padding: 16px 18px; display: flex; gap: 14px; align-items: center; }
.stat .ico { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); flex: none; }
.stat .ico.ok { background: var(--ok-50); color: var(--ok); }
.stat .ico.warn { background: var(--warn-50); color: var(--warn); }
.stat .ico.info { background: var(--info-50); color: var(--info); }
.stat .ico.ai { background: var(--ai-50); color: var(--ai); }
.stat .num { font-size: 24px; font-weight: 800; line-height: 1.1; letter-spacing: -.01em; }
.stat .lbl { color: var(--muted); font-size: 12.5px; font-weight: 600; }

/* Chips / badges --------------------------------------------------------- */
.chip { display: inline-flex; align-items: center; gap: 5px; height: 23px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 650; background: #eef0f6; color: var(--ink-2); white-space: nowrap; }
.chip.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.chip.unmarked { background: #eef0f6; color: #4b5170; }
.chip.in_progress { background: var(--warn-50); color: #b45309; }
.chip.marked { background: var(--info-50); color: var(--info); }
.chip.released { background: var(--ok-50); color: #15803d; }
.chip.missing { background: #fff; color: var(--faint); border: 1px dashed #cfd3e3; }
.chip.ai { background: var(--ai-50); color: var(--ai); }
.chip.danger { background: var(--danger-50); color: var(--danger); }
.chip.ok { background: var(--ok-50); color: #15803d; }
.chip.warn { background: var(--warn-50); color: #b45309; }
.grade { display: inline-grid; place-items: center; min-width: 34px; height: 26px; padding: 0 8px; border-radius: 8px; font-weight: 800; font-size: 13px; background: var(--brand-50); color: var(--brand-700); }
.grade.lg { min-width: 54px; height: 40px; font-size: 18px; border-radius: 11px; }
.count-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; }

/* Tables ----------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfe; white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #fafbff; }
.table tr.clickable { cursor: pointer; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }

/* Tabs ------------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; box-shadow: inset 0 -1px 0 var(--line); margin-bottom: 18px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: none; background: none; padding: 10px 14px; font-weight: 650; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; display: inline-flex; gap: 7px; align-items: center; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.seg { display: inline-flex; background: #eceef6; border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; padding: 5px 12px; border-radius: 7px; font-weight: 600; color: var(--muted); cursor: pointer; font-size: 13px; }
.seg button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

/* Progress --------------------------------------------------------------- */
.progress { height: 8px; border-radius: 99px; background: #eceef6; overflow: hidden; display: flex; }
.progress > span { display: block; height: 100%; }
.progress .p-released { background: var(--ok); }
.progress .p-marked { background: var(--info); }
.progress .p-in_progress { background: #f59e0b; }

/* Empty / loading -------------------------------------------------------- */
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .ico { width: 54px; height: 54px; border-radius: 16px; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; margin: 0 auto 14px; }
.empty h3 { margin-bottom: 6px; }
.loading { display: grid; place-items: center; padding: 60px 0; color: var(--muted); }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; display: inline-block; opacity: .8; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, #eef0f6, #f7f8fc, #eef0f6); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Callouts --------------------------------------------------------------- */
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--info-50); color: #1e3a8a; font-size: 13px; align-items: flex-start; }
.callout.warn { background: var(--warn-50); color: #8a4b05; }
.callout.danger { background: var(--danger-50); color: #8f1d1d; }
.callout.ok { background: var(--ok-50); color: #14532d; }
.callout.ai { background: var(--ai-50); color: #4c1d95; }
.callout .icon { margin-top: 1px; }

/* App shell -------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: #c9cde4; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 16px 12px; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; color: #fff; font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.brand img { width: 30px; height: 30px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6f7594; font-weight: 700; padding: 14px 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; color: #c9cde4; font-weight: 600; font-size: 13.5px; text-decoration: none !important; }
.nav-item:hover { background: var(--side-2); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(59,63,217,.45); }
.nav-item .count-badge { margin-left: auto; }
.side-foot { margin-top: auto; padding: 12px; border-radius: 10px; background: var(--side-2); font-size: 12px; color: #9aa0bd; }
.side-foot b { color: #fff; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 62px; display: flex; align-items: center; gap: 14px; padding: 0 26px; background: rgba(255,255,255,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.content { padding: 26px; max-width: 1280px; width: 100%; margin: 0 auto; }
.menu-btn { display: none; }
.search { position: relative; flex: 1; max-width: 420px; }
.search .input { padding-left: 36px; background: #f5f6fb; border-color: transparent; }
.search .input:focus { background: #fff; }
.search > .icon { position: absolute; left: 11px; top: 10px; color: var(--faint); }
.dropdown { position: absolute; top: calc(100% + 6px); right: 0; min-width: 260px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 50; padding: 6px; max-height: 70vh; overflow: auto; }
.dropdown.left { left: 0; right: auto; }
.dd-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 8px; color: var(--ink); cursor: pointer; text-decoration: none !important; }
.dd-item:hover { background: #f5f6fb; }
.dd-head { font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px 4px; }
.dd-sep { height: 1px; background: var(--line-2); margin: 6px 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), #8b5cf6); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; }
.avatar.sm { width: 28px; height: 28px; font-size: 11.5px; }
.icon-btn { position: relative; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; border: none; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: #f0f1f7; color: var(--ink); }
.icon-btn .count-badge { position: absolute; top: 3px; right: 2px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 4px 8px 4px 4px; border-radius: 99px; border: none; background: transparent; cursor: pointer; }
.user-chip:hover { background: #f0f1f7; }
.notif { padding: 10px; border-radius: 9px; display: block; color: var(--ink); }
.notif:hover { background: #f5f6fb; text-decoration: none; }
.notif.unread { background: var(--brand-50); }
.notif .t { font-weight: 650; font-size: 13px; }

/* Modal & toast ---------------------------------------------------------- */
.overlay { position: fixed; inset: 0; background: rgba(15,18,38,.45); display: grid; place-items: center; z-index: 100; padding: 20px; animation: fade .12s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 520px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop .14s ease-out; }
.modal.wide { max-width: 760px; }
.modal.narrow { max-width: 420px; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal-head { padding: 18px 22px 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-body { padding: 16px 22px; overflow: auto; }
.modal-foot { padding: 14px 22px 18px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line-2); }
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; max-width: 380px; }
.toast { background: var(--ink); color: #fff; border-radius: 11px; padding: 12px 14px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; animation: pop .15s ease-out; }
.toast.ok .icon { color: #4ade80; }
.toast.error { background: #7f1d1d; }
.toast.ai { background: #3b1a78; }
.toast .btn { margin-left: auto; height: 26px; }

/* Upload dropzone -------------------------------------------------------- */
.dropzone { border: 2px dashed #c9cde3; border-radius: 14px; padding: 26px; text-align: center; background: #fafbff; cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-50); }
.dropzone .icon { width: 34px; height: 34px; color: var(--brand); }
.file-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; max-height: 180px; overflow: auto; }
.file-row { display: flex; gap: 8px; align-items: center; padding: 7px 10px; border-radius: 8px; background: #f5f6fb; font-size: 13px; }
.radio-card { display: flex; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; align-items: flex-start; }
.radio-card:has(input:checked) { border-color: var(--brand); background: var(--brand-50); }
.radio-card input { margin-top: 3px; accent-color: var(--brand); }
.upload-bar { height: 6px; border-radius: 9px; background: #eceef6; overflow: hidden; margin-top: 10px; }
.upload-bar > span { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s; }

/* Charts ----------------------------------------------------------------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; }
.bars .bar span.fill { width: 100%; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, #6366f1, var(--brand)); min-height: 2px; }
.bars .bar small { font-size: 10.5px; color: var(--faint); }
.bars .bar b { font-size: 11px; color: var(--ink-2); }
.hbar { display: grid; grid-template-columns: 70px 1fr 64px; gap: 10px; align-items: center; margin-bottom: 9px; font-size: 13px; }
.hbar .track { height: 10px; border-radius: 99px; background: #eceef6; overflow: hidden; }
.hbar .track span { display: block; height: 100%; border-radius: 99px; }
.linechart { width: 100%; height: 180px; }

/* Public pages ----------------------------------------------------------- */
.public { min-height: 100vh; background: #0b0d1f; color: #fff; }
.pub-nav { display: flex; align-items: center; justify-content: space-between; padding: 18px 40px; position: relative; z-index: 2; }
.pub-nav .brand { padding: 0; }
.pub-nav nav { display: flex; gap: 26px; align-items: center; }
.pub-nav nav a { color: #e6e8f5; font-weight: 600; font-size: 14px; }
.btn.login { background: #4f7a52; border-color: #4f7a52; color: #fff; border-radius: 9px; }
.btn.login:hover { background: #42683f; }
.hero { position: relative; min-height: 78vh; display: grid; place-items: center; text-align: center; overflow: hidden; padding: 40px 20px 80px; }
.hero::before { content: ""; position: absolute; inset: -20%; background:
  radial-gradient(40% 35% at 20% 30%, rgba(255,107,74,.55), transparent 70%),
  radial-gradient(35% 40% at 80% 25%, rgba(236,72,153,.45), transparent 70%),
  radial-gradient(45% 45% at 50% 80%, rgba(59,63,217,.85), transparent 70%),
  radial-gradient(30% 30% at 85% 80%, rgba(245,158,11,.4), transparent 70%),
  linear-gradient(160deg, #1b1f6b, #0b0d1f 70%);
  filter: blur(10px); animation: drift 18s ease-in-out infinite alternate; }
@keyframes drift { to { transform: translate3d(2%, -2%, 0) rotate(2deg) scale(1.04); } }
.hero .inner { position: relative; z-index: 1; max-width: 820px; }
.hero h1 { color: #fff; font-size: clamp(36px, 6vw, 64px); font-weight: 850; letter-spacing: -.03em; line-height: 1.05; }
.hero p { color: #d7daf0; font-size: 18px; margin: 18px auto 28px; max-width: 620px; }
.hero .cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn.hero-btn { height: 48px; padding: 0 26px; font-size: 15px; border-radius: 12px; background: #2d31c9; border-color: #2d31c9; color: #fff; }
.btn.hero-btn.alt { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); }
.pub-section { background: #fff; color: var(--ink); padding: 70px 40px; }
.pub-section.alt { background: var(--bg); }
.pub-section .wrap { max-width: 1100px; margin: 0 auto; }
.pub-section h2 { font-size: 30px; letter-spacing: -.02em; margin-bottom: 10px; }
.feature { padding: 22px; }
.feature .ico { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); margin-bottom: 14px; }
.feature h3 { margin-bottom: 6px; font-size: 16px; }
.pub-foot { background: #0b0d1f; color: #9aa0bd; padding: 26px 40px; font-size: 13px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 30px 16px; background:
  radial-gradient(50% 50% at 0% 0%, rgba(59,63,217,.12), transparent), radial-gradient(40% 40% at 100% 100%, rgba(255,107,74,.10), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 420px; padding: 30px; }
.auth-card .brand { color: var(--ink); justify-content: center; padding-bottom: 8px; }
.auth-card h1 { text-align: center; font-size: 22px; margin-bottom: 6px; }
.auth-card .sub { text-align: center; color: var(--muted); margin-bottom: 22px; }
.pw-meter { height: 5px; border-radius: 9px; background: #eceef6; overflow: hidden; margin-top: 6px; }
.pw-meter span { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }

/* Marking workspace ------------------------------------------------------ */
.marker { display: grid; grid-template-rows: 58px 1fr; height: 100vh; background: #e9ebf3; overflow: hidden; }
.mk-top { display: flex; align-items: center; gap: 10px; padding: 0 14px; background: #fff; border-bottom: 1px solid var(--line); min-width: 0; }
.mk-title { min-width: 0; }
.mk-title .t { font-weight: 750; font-size: 14.5px; }
.mk-title .s { font-size: 12px; color: var(--muted); }
.mk-body { display: grid; grid-template-columns: 58px 1fr 390px; min-height: 0; }
.mk-body.no-tools { grid-template-columns: 1fr 390px; }
.mk-tools { background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 3px; overflow-y: auto; }
.tool { width: 40px; height: 38px; border-radius: 9px; border: none; background: transparent; color: var(--ink-2); display: grid; place-items: center; cursor: pointer; position: relative; flex: none; }
.tool:hover { background: #f0f1f7; }
.tool.active { background: var(--brand); color: #fff; }
.tool:disabled { opacity: .35; cursor: not-allowed; }
.tool .key { position: absolute; bottom: 1px; right: 3px; font-size: 9px; opacity: .55; font-weight: 700; }
.tool-sep { width: 30px; height: 1px; background: var(--line); margin: 6px 0; flex: none; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #d0d3e2; cursor: pointer; flex: none; margin: 2px 0; }
.swatch.active { box-shadow: 0 0 0 2px var(--ink); }
.sizes { display: flex; flex-direction: column; gap: 3px; align-items: center; }
.size-btn { width: 32px; height: 24px; border-radius: 7px; border: none; background: transparent; display: grid; place-items: center; cursor: pointer; }
.size-btn.active { background: #e8eaf6; }
.size-btn span { display: block; border-radius: 9px; background: var(--ink-2); }
.mk-canvas { overflow: auto; position: relative; padding: 24px; scroll-behavior: auto; }
.mk-pages { display: flex; flex-direction: column; align-items: center; gap: 22px; margin: 0 auto; }
.page { position: relative; background: #fff; box-shadow: 0 2px 10px rgba(20,24,51,.15); border-radius: 3px; flex: none; }
.page img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; border-radius: 3px; }
.page svg.ink { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pan-x pan-y; }
.page svg.ink.drawing { cursor: crosshair; touch-action: none; }
.page svg.ink.drawing .ann { pointer-events: none; }
.page svg.ink.text-mode { cursor: text; touch-action: none; }
.page svg.ink.text-mode .ann:not(.ann-text) { pointer-events: none; }
.page svg.ink.erasing { cursor: cell; }
.page svg.ink.readonly .ann { pointer-events: none; }
.page .page-no { position: absolute; top: -18px; left: 0; font-size: 11px; color: var(--faint); font-weight: 700; }
.page .page-tools { position: absolute; top: 6px; right: -44px; display: flex; flex-direction: column; gap: 4px; }
.ann { cursor: pointer; }
.ann.selected { filter: drop-shadow(0 0 3px rgba(59,63,217,.9)); }
.ann-text-box { font-family: var(--font); font-weight: 700; line-height: 1.25; white-space: pre-wrap; word-wrap: break-word; padding: 1px 3px; border-radius: 3px; background: rgba(255,255,255,.72); width: fit-content; max-width: 100%; }
.ann.ai-ann .ann-text-box { outline: 1.5px dashed rgba(124,58,237,.55); }
.text-editor { position: absolute; z-index: 5; border: 2px solid var(--brand); border-radius: 6px; padding: 4px 6px; font-weight: 700; line-height: 1.25; resize: both; min-width: 140px; min-height: 40px; background: rgba(255,255,255,.95); box-shadow: var(--shadow); }
.mk-panel { background: #fff; border-left: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; min-height: 0; }
.mk-panel .blk { padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.score-card { display: flex; align-items: center; gap: 14px; }
.score-card .big { font-size: 30px; font-weight: 850; letter-spacing: -.02em; line-height: 1; }
.score-card .big small { font-size: 16px; color: var(--faint); font-weight: 700; }
.q-card { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; overflow: hidden; transition: border-color .12s, box-shadow .12s; }
.q-card.focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.q-card.done { border-left: 3px solid var(--ok); }
.q-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; cursor: pointer; background: #fbfbfe; }
.q-head .lbl { font-weight: 800; }
.q-head .mx { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 600; }
.q-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 9px; }
.q-text { font-size: 12.5px; color: var(--muted); white-space: pre-wrap; }
.score-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.score-input { width: 68px; text-align: center; font-weight: 800; font-size: 15px; }
.quick { height: 28px; min-width: 30px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 700; font-size: 12.5px; color: var(--ink-2); }
.quick:hover { border-color: var(--brand); color: var(--brand); }
.quick.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.rubric-item { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; padding: 5px 6px; border-radius: 7px; cursor: pointer; }
.rubric-item:hover { background: #f5f6fb; }
.rubric-item input { margin-top: 2px; accent-color: var(--brand); }
.rubric-item .m { margin-left: auto; font-weight: 700; color: var(--muted); white-space: nowrap; }
.ai-suggest { border-radius: 10px; background: var(--ai-50); border: 1px solid var(--ai-100); padding: 9px 10px; font-size: 12.5px; color: #3b1a78; }
.ai-suggest .head { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.ai-suggest .head .btn { margin-left: auto; }
.conf { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 800; padding: 1px 6px; border-radius: 99px; background: #fff; }
.conf.high { color: var(--ok); } .conf.medium { color: var(--warn); } .conf.low { color: var(--danger); }
.ai-panel { background: linear-gradient(160deg, #f6f0ff, #eef0ff); }
.thread { display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 8px 11px; border-radius: 11px; background: #f2f3f8; font-size: 13px; max-width: 92%; }
.msg.mine { align-self: flex-end; background: var(--brand-50); }
.msg .who { font-size: 11.5px; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.readonly-banner { background: var(--ok-50); color: #14532d; font-size: 13px; padding: 9px 16px; display: flex; gap: 10px; align-items: center; }
.save-state { font-size: 12px; color: var(--muted); display: inline-flex; gap: 5px; align-items: center; }
.save-state.err { color: var(--danger); }
.kbd { font-family: var(--mono); font-size: 11px; background: #f0f1f7; border: 1px solid #dfe2ee; border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; }
.panel-toggle { display: none; }
.page svg.ink foreignObject { pointer-events: none; overflow: visible; }
.page svg.ink .ann-text-box { pointer-events: auto; cursor: pointer; }
.page svg.ink.text-mode .ann-text .ann-text-box { cursor: text; }
.page svg.ink.drawing .ann-text-box, .page svg.ink.readonly .ann-text-box { pointer-events: none; }
.cbank { position: absolute; z-index: 6; display: flex; flex-wrap: wrap; gap: 4px; max-width: 360px; padding: 6px; background: #fff; border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow); }
.cbank .quick { height: 24px; font-size: 11.5px; font-weight: 600; }
.input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-50); }
.model-answer { background: #f7f8fc; border-radius: 8px; padding: 7px 9px; color: var(--ink-2); }


/* Student view ----------------------------------------------------------- */
.work-card { padding: 16px 18px; display: flex; gap: 14px; align-items: center; cursor: pointer; transition: box-shadow .12s, transform .12s; }
.work-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.work-card .grade { margin-left: auto; }
.pct-ring { --p: 0; width: 54px; height: 54px; border-radius: 50%; background: conic-gradient(var(--brand) calc(var(--p) * 1%), #eceef6 0); display: grid; place-items: center; flex: none; }
.pct-ring b { width: 42px; height: 42px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 12.5px; }

/* Question editor -------------------------------------------------------- */
.qe { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: #fff; }
.qe-head { display: grid; grid-template-columns: 110px 110px 150px 1fr auto; gap: 10px; align-items: end; margin-bottom: 10px; }
.qe.proposed { border-color: var(--ai-100); box-shadow: 0 0 0 3px var(--ai-50); }
.rubric-row { display: grid; grid-template-columns: 1fr 86px 32px; gap: 8px; margin-bottom: 6px; }

/* Responsive ------------------------------------------------------------- */
/* Setup page: restore a backup */
.restore { border-top: 1px solid var(--line-2); padding-top: 14px; }
.restore summary { cursor: pointer; font-weight: 650; font-size: 14px; color: var(--brand); }
.restore-form { margin-top: 10px; }
.restore-form .progress { margin: 8px 0; }
.restore-form .progress > span { background: var(--brand); transition: width .2s; }

/* Class statistics */
.stats-page { display: grid; gap: 16px; }
.stats-filters { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.stats-filters .select { width: auto; min-width: 200px; }
.stat .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat .num.name { font-size: 17px; line-height: 1.4; }
.chart-box { position: relative; }
.chart-scroll { overflow-x: auto; }
.boxplot { display: block; }
.boxplot .ax { font-size: 11px; fill: var(--muted); }
.boxplot .bp-band { fill: transparent; }
.boxplot .bp-col.on .bp-band { fill: var(--line-2); }
.boxplot .bp-hit { outline: none; }
.boxplot .bp-hit:focus-visible { stroke: var(--brand); stroke-width: 2; }
.chart-tip { position: absolute; top: 4px; z-index: 5; min-width: 170px; max-width: 260px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(20, 24, 51, .12); font-size: 12.5px; line-height: 1.55; color: var(--ink-2); pointer-events: none; }
.chart-tip b { color: var(--ink); font-variant-numeric: tabular-nums; }
.chart-tip .tip-title { font-weight: 700; color: var(--ink); }
.chart-tip .tip-sub { color: var(--muted); font-size: 11.5px; margin-bottom: 6px; }
.chart-tip .tip-student { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line-2); display: flex; align-items: center; gap: 6px; }
.chart-legend, .heat-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); }
.chart-legend { margin-bottom: 10px; }
.chart-legend:empty { display: none; }
.heat-legend { padding-top: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.key-box { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.key-line { width: 16px; height: 2px; border-radius: 1px; flex: none; }
.students-compared td.heat { font-weight: 650; min-width: 52px; border: 2px solid var(--surface); }
.students-compared td.heat:not(.empty):hover { outline: 2px solid var(--ink); outline-offset: -3px; }
.students-compared td.heat.empty { color: var(--faint); }
.students-compared tr.hl td:not(.heat) { background: var(--brand-50); }
.students-compared tr.hl td.sticky-col { box-shadow: inset 4px 0 0 #f47230; }
.stats-table .sticky-col { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.stats-table th.sticky-col { background: #fafbfe; }
.stats-table .col-title { display: inline-block; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.stats-table td.strong { font-weight: 700; }
.trend { white-space: nowrap; }
.trend.up { color: #006c10; }
.trend.down { color: #b42318; }

/* Worksheet & answer sheet */
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.doc-slot { border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px; background: #fbfbfe; }
.doc-slot.has { border-style: solid; background: #fff; }
.doc-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); flex: none; }
.scheme-box { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-2); display: grid; gap: 6px; }
.scheme-warnings { margin: 8px 0 0; padding-left: 18px; }
.scheme-warnings li { margin: 2px 0; }
.modal.doc-viewer { max-width: 980px; }
.doc-toolbar { position: sticky; top: -16px; z-index: 2; background: #fff; padding: 4px 0; }
.doc-toolbar .select { width: auto; }
.doc-pages { display: grid; gap: 14px; }
.doc-page { margin: 0; }
.doc-page img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.doc-page figcaption { text-align: center; margin-top: 4px; }

.doc-float { position: fixed; top: 76px; right: 24px; width: min(460px, 92vw); height: min(620px, 75vh); min-width: 260px; min-height: 200px; z-index: 70; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); resize: both; overflow: hidden; }
.doc-float-head { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-bottom: 1px solid var(--line-2); cursor: move; user-select: none; touch-action: none; font-size: 13px; }
.doc-float-head .select { width: auto; }
.doc-float-body { flex: 1; overflow: auto; padding: 10px; background: #f5f6fb; }
.marking-notes { border-radius: 10px; background: var(--info-50); color: #1e3a8a; padding: 8px 12px; }
.marking-notes summary { cursor: pointer; font-weight: 650; font-size: 13px; }
.marking-notes > div { white-space: pre-wrap; margin-top: 6px; }

@media (max-width: 1100px) {
  .mk-body { grid-template-columns: 54px 1fr; }
  .mk-body.no-tools { grid-template-columns: 1fr; }
  .mk-panel { position: fixed; right: 0; top: 58px; bottom: 0; width: min(390px, 92vw); z-index: 30; box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform .2s; }
  .mk-panel.open { transform: none; }
  .panel-toggle { display: inline-flex; }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.main-side { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: grid; }
  .content { padding: 18px 14px; }
  .topbar { padding: 0 12px; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .pub-nav { padding: 16px 18px; }
  .pub-nav nav a.hide-sm { display: none; }
  .pub-section { padding: 48px 18px; }
  .qe-head { grid-template-columns: 1fr 1fr; }
  .doc-slots { grid-template-columns: 1fr; }
  .mk-top .hide-sm { display: none; }
  .page .page-tools { right: 4px; top: 4px; }
}
@media (max-width: 560px) {
  .grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .user-chip .name { display: none; }
}
@media print {
  .sidebar, .topbar { display: none; }
}

/* Student hand-in ---------------------------------------------------------- */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-top: 14px; }
.thumb { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #f5f6fb; aspect-ratio: 3 / 4; display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .n { position: absolute; left: 6px; top: 6px; background: rgba(15,18,38,.75); color: #fff; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 6px; }
.thumb .x { position: absolute; right: 4px; top: 4px; }
.thumb .pdf { font-size: 12px; color: var(--muted); padding: 8px; text-align: center; word-break: break-all; }

/* Installed app (PWA) ------------------------------------------------------ */
/* Keep content clear of the iPhone home indicator and notches. */
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.content { padding-bottom: calc(26px + env(safe-area-inset-bottom)); }
.sidebar { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.toasts { bottom: calc(20px + env(safe-area-inset-bottom)); }
.mk-panel { padding-bottom: env(safe-area-inset-bottom); }
@media (display-mode: standalone) {
  /* Feels like an app: no text-selection callouts on buttons, no rubber-band page bounce. */
  html, body { overscroll-behavior-y: none; }
  .btn, .icon-btn, .nav-item, .tab { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
}
.offline-bar { position: fixed; left: 50%; top: calc(10px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 300; display: flex; gap: 8px; align-items: center; max-width: calc(100vw - 24px); padding: 9px 14px; border-radius: 99px; background: #7c2d12; color: #fff; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg); }
.offline-bar[hidden] { display: none; }
.install-banner { display: flex; align-items: center; gap: 12px; margin: 12px 14px 0; padding: 10px 12px; border-radius: 12px; background: var(--brand-50, #eef0ff); border: 1px solid var(--line); font-size: 13px; }
.install-banner img { width: 38px; height: 38px; border-radius: 9px; flex: none; }
.install-banner .tiny { color: var(--muted); }
.install-banner .icon-btn { flex: none; }
.steps { margin: 0; padding-left: 20px; font-size: 13.5px; }
.steps li { margin-bottom: 8px; }
.qr { border-radius: 10px; border: 1px solid var(--line); background: #fff; padding: 6px; flex: none; }
.url-box { padding: 6px 10px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); word-break: break-all; font-size: 12.5px; }
/* Phones: size full-screen views to the visible area, not behind the browser's toolbars. */
@supports (height: 100dvh) {
  .marker { height: 100dvh; }
  .sidebar { height: 100dvh; }
}
