:root {
  --ink: #0B0D17;
  --ink-2: #161A28;
  --ink-3: #1C2133;
  --text: #3D4253;
  --muted: #5B6070;
  --line: #E6E8EF;
  --line-2: #EEF0F5;
  --bg: #F5F6FA;
  --soft: #F3F4F8;
  --white: #FFFFFF;
  --indigo: #4338CA;
  --indigo-dark: #312E81;
  --indigo-soft: #EEF2FF;
  --indigo-line: #C7D2FE;
  --lime: #D9F99D;
  --lime-soft: #ECFCCB;
  --lime-text: #365314;
  --green-bg: #DCFCE7;
  --green: #166534;
  --red-bg: #FEE2E2;
  --red: #991B1B;
  --amber-bg: #FEF3C7;
  --amber: #92400E;
  --orange-bg: #FFF7ED;
  --orange-line: #FED7AA;
  --orange: #9A3412;
  --radius: 24px;
  --font: 'Outfit', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--white); -webkit-font-smoothing: antialiased; }
a { color: var(--indigo); text-decoration: none; }
a:hover { color: var(--indigo-dark); }
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.6; }
img, svg { display: block; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid var(--indigo-line); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; border: none; border-radius: 999px; font-weight: 600; font-size: 16px; padding: 14px 24px; min-height: 48px; text-align: center; line-height: 1.2; transition: background 0.15s, transform 0.1s; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--indigo); color: #fff; }
.btn-primary:hover { background: #3730A3; color: #fff; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #23283a; color: #fff; }
.btn-lime { background: var(--lime); color: var(--ink); font-weight: 700; }
.btn-lime:hover { background: #cdf27f; color: var(--ink); }
.btn-soft { background: var(--soft); color: var(--ink); }
.btn-soft:hover { background: #e9eaf1; color: var(--ink); }
.btn-outline { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-outline:hover { background: var(--soft); color: var(--ink); }
.btn-sm { font-size: 14px; padding: 10px 16px; min-height: 40px; }
.btn-lg { font-size: 17px; padding: 17px 28px; min-height: 56px; }
.btn-block { width: 100%; }
.icon-btn { width: 46px; height: 46px; border-radius: 999px; border: 1px solid var(--line); background: #fff; display: inline-flex; align-items: center; justify-content: center; flex: none; color: var(--ink); }
.link-btn { background: none; border: none; color: var(--indigo); font-weight: 600; padding: 8px 0; min-height: 44px; display: inline-flex; align-items: center; gap: 8px; }

/* Logo */
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; font-size: 22px; letter-spacing: -0.02em; }
.logo:hover { color: var(--ink); }
.logo-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--ink); display: flex; align-items: center; justify-content: center; }
.logo.light { color: #fff; }
.logo.light .logo-mark { background: var(--lime); }

/* Generic */
.card { background: #fff; border-radius: var(--radius); padding: 26px; }
.muted { color: var(--muted); }
.pill { display: inline-flex; align-items: center; font-weight: 700; font-size: 14px; padding: 6px 12px; border-radius: 999px; }
.pill-green { background: var(--green-bg); color: var(--green); }
.pill-amber { background: var(--amber-bg); color: var(--amber); }
.pill-red { background: var(--red-bg); color: var(--red); }
.pill-grey { background: var(--soft); color: var(--text); }
.pill-lime { background: var(--lime-soft); color: var(--lime-text); }
.spinner { width: 22px; height: 22px; border-radius: 999px; border: 3px solid rgba(67, 56, 202, 0.2); border-top-color: var(--indigo); animation: spin 0.8s linear infinite; }
.spinner.light { border-color: rgba(255, 255, 255, 0.3); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.fade-in { animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Toast */
.toast-wrap { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 440px); pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 14px 18px; border-radius: 16px; font-size: 15px; box-shadow: 0 12px 30px rgba(11, 13, 23, 0.25); animation: fade 0.2s ease; }
.toast.error { background: #7F1D1D; }

/* ---------- Landing ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 32px; }
.l-nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 24px 0; }
.l-links { display: flex; gap: 32px; font-weight: 500; }
.l-links a { color: var(--text); }
.l-hero { display: flex; flex-wrap: wrap; gap: 56px; align-items: center; padding: 48px 0 96px; }
.l-hero-copy { flex: 1 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 28px; }
.l-hero h1 { font-size: clamp(42px, 6vw, 68px); line-height: 1.02; font-weight: 700; letter-spacing: -0.035em; }
.l-hero p.lead { font-size: 20px; line-height: 1.55; color: #4A5063; max-width: 520px; }
.l-ticks { display: flex; flex-wrap: wrap; gap: 24px; font-size: 15px; color: #4A5063; }
.l-ticks span { display: flex; align-items: center; gap: 8px; }
.l-visual { flex: 1 1 420px; min-width: 0; background: var(--soft); border-radius: 32px; padding: 32px; display: flex; flex-direction: column; gap: 16px; }
.l-dark { background: var(--ink); color: #fff; padding: 96px 0; }
.l-sec-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 48px; }
.l-sec-head h2, .l-h2 { font-size: clamp(32px, 4.5vw, 48px); line-height: 1.08; font-weight: 700; letter-spacing: -0.03em; max-width: 640px; }
.l-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 20px; }
.l-step { background: var(--ink-2); border-radius: 24px; padding: 32px; display: flex; flex-direction: column; gap: 14px; }
.l-step b { color: var(--lime); font-size: 15px; }
.l-step h3 { font-size: 24px; font-weight: 600; }
.l-step p { color: #B9BDCC; line-height: 1.6; }
.l-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 20px; }
.l-feature { background: var(--soft); border-radius: 28px; padding: 36px; display: flex; flex-direction: column; gap: 14px; }
.l-feature h3 { font-size: 26px; font-weight: 600; }
.l-feature p { font-size: 17px; line-height: 1.6; color: #4A5063; }
.icon-tile { width: 52px; height: 52px; border-radius: 16px; background: #fff; display: flex; align-items: center; justify-content: center; color: var(--indigo); flex: none; }
.l-grading { background: var(--lime-soft); border-radius: 36px; padding: 56px; display: flex; flex-wrap: wrap; gap: 48px; align-items: center; }
.l-cta { background: var(--ink); color: #fff; border-radius: 36px; padding: 72px 32px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 24px; }
.l-footer { border-top: 1px solid var(--line); padding: 40px 0; display: flex; flex-wrap: wrap; gap: 24px; justify-content: space-between; color: var(--muted); }

/* Mini question card (landing) */
.mini { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.mini-opt { border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; display: flex; gap: 12px; }
.mini-opt.on { border: 2px solid var(--indigo); background: var(--indigo-soft); font-weight: 600; padding: 11px 15px; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: flex; flex-wrap: wrap; }
.auth-side { flex: 1 1 460px; background: var(--ink); color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 48px; }
.auth-side h1 { font-size: clamp(36px, 4vw, 52px); line-height: 1.05; font-weight: 700; letter-spacing: -0.03em; }
.auth-main { flex: 1 1 460px; padding: 48px 24px; display: flex; align-items: center; justify-content: center; }
.auth-form { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 20px; }
.field { display: flex; flex-direction: column; gap: 8px; font-size: 15px; font-weight: 500; }
.input { border: 1px solid #D9DCE5; border-radius: 14px; padding: 15px 16px; font-size: 16px; background: #F8F9FB; width: 100%; }
.input:focus { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 4px #E0E7FF; background: #fff; }
.form-error { background: var(--red-bg); color: var(--red); border-radius: 12px; padding: 12px 14px; font-size: 14px; font-weight: 500; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; background: var(--bg); }
.sidebar { width: 264px; flex: none; background: #fff; border-right: 1px solid var(--line); padding: 28px 20px; display: flex; flex-direction: column; gap: 32px; position: sticky; top: 0; height: 100vh; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; color: var(--text); font-weight: 500; }
.side-nav a:hover { background: var(--soft); color: var(--ink); }
.side-nav a.active { background: var(--ink); color: #fff; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.main { flex: 1; min-width: 0; padding: 32px 40px 64px; display: flex; flex-direction: column; gap: 28px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; }
.page-head h1 { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; }
.avatar { width: 46px; height: 46px; border-radius: 999px; background: var(--indigo); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.tabbar { display: none; }

/* Dropzone */
.dropzone { background: #fff; border: 2px dashed #C7CBE0; border-radius: 28px; padding: 44px 24px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; transition: border-color 0.15s, background 0.15s; }
.dropzone.drag { border-color: var(--indigo); background: var(--indigo-soft); }
.dropzone h2 { font-size: 26px; font-weight: 600; }
.drop-icon { width: 68px; height: 68px; border-radius: 20px; background: var(--indigo-soft); color: var(--indigo); display: flex; align-items: center; justify-content: center; }
.upload-progress { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 10px; }
.bar { height: 8px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--indigo); border-radius: 999px; transition: width 0.3s; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat { background: #fff; border-radius: 22px; padding: 24px; display: flex; flex-direction: column; gap: 6px; }
.stat .k { font-size: 14px; color: var(--muted); font-weight: 500; }
.stat .v { font-size: 36px; font-weight: 700; letter-spacing: -0.02em; }
.stat .s { font-size: 14px; color: var(--muted); font-weight: 500; }
.stat .s.up { color: #15803D; }
.stat.dark { background: var(--ink); color: #fff; }
.stat.dark .k, .stat.dark .s { color: #B9BDCC; }
.stat.dark .v { color: var(--lime); }

/* Lists */
.two-col { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.two-col > * { flex: 1 1 380px; min-width: 0; }
.list-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.list-head h2 { font-size: 20px; font-weight: 600; }
.row { display: flex; align-items: center; gap: 14px; padding: 13px 0; border-top: 1px solid var(--line-2); color: var(--ink); }
a.row:hover { color: var(--ink); background: linear-gradient(90deg, transparent, var(--bg), transparent); }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .d { font-size: 14px; color: var(--muted); }
.file-badge { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11px; flex: none; text-transform: uppercase; }
.fb-pdf { background: var(--indigo-soft); color: var(--indigo); }
.fb-docx { background: #FFEDD5; color: var(--orange); }
.fb-pptx { background: #FCE7F3; color: #9D174D; }
.fb-txt { background: var(--soft); color: var(--text); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }

/* ---------- Setup ---------- */
.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1240px; margin: 0 auto; padding: 16px 32px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.back { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; min-height: 44px; }
.back:hover { color: var(--ink); }
.setup { max-width: 1240px; margin: 0 auto; padding: 40px 32px 64px; display: flex; flex-direction: column; gap: 28px; }
.setup h1 { font-size: 40px; font-weight: 700; letter-spacing: -0.025em; }
.setup-grid { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.setup-side { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.setup-main { flex: 999 1 560px; min-width: 0; background: #fff; border-radius: 28px; padding: 32px; display: flex; flex-direction: column; gap: 28px; }
.label { font-size: 17px; font-weight: 600; }
.presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.preset { text-align: left; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 18px; border-radius: 20px; border: 2px solid var(--line); background: #fff; }
.preset:hover { border-color: var(--indigo-line); }
.preset.on { border-color: var(--indigo); background: var(--indigo-soft); color: #1E1B4B; }
.preset .badge { min-width: 40px; height: 40px; padding: 0 10px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 700; background: var(--soft); }
.preset.on .badge { background: var(--indigo); color: #fff; }
.preset .pt { font-size: 18px; font-weight: 600; }
.preset .pd { font-size: 14px; line-height: 1.45; opacity: 0.8; }
.preset-top { display: flex; justify-content: space-between; align-items: center; width: 100%; gap: 8px; }
.tag { font-size: 12px; font-weight: 700; background: var(--lime-soft); color: var(--lime-text); padding: 4px 10px; border-radius: 999px; }
.recap { background: var(--bg); border-radius: 20px; padding: 20px 22px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.chip { background: #fff; border: 1px solid var(--line); font-size: 14px; font-weight: 600; padding: 7px 12px; border-radius: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; background: var(--soft); padding: 5px; border-radius: 16px; }
.seg button { border: none; background: transparent; color: #4A5063; font-size: 15px; font-weight: 600; padding: 11px 8px; min-height: 44px; border-radius: 12px; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 2px 6px rgba(11, 13, 23, 0.1); }
.custom { display: flex; flex-direction: column; gap: 24px; border-top: 1px solid var(--line-2); padding-top: 24px; }
.dd-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.dd { position: relative; display: flex; flex-direction: column; gap: 10px; }
.dd-trigger { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 16px 12px 12px; border-radius: 18px; background: #fff; border: 2px solid var(--line); text-align: left; }
.dd.open .dd-trigger { border-color: var(--indigo); box-shadow: 0 0 0 4px #E0E7FF; }
.dd-badge { width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--indigo-soft); color: var(--indigo); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.dd-val { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dd-val b { font-size: 17px; font-weight: 600; }
.dd-val small { font-size: 13px; color: var(--muted); }
.dd-chev { flex: none; transition: transform 0.2s; }
.dd.open .dd-chev { transform: rotate(180deg); }
.dd-menu { position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 20px 44px rgba(11, 13, 23, 0.14); padding: 6px; display: none; flex-direction: column; gap: 2px; max-height: 360px; overflow-y: auto; }
.dd.open .dd-menu { display: flex; }
.dd-menu-head { display: none; }
.dd-opt { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: none; border-radius: 14px; background: #fff; text-align: left; min-height: 52px; }
.dd-opt:hover { background: var(--bg); }
.dd-opt.on { background: var(--indigo-soft); }
.dd-opt .grow { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.dd-opt b { font-size: 16px; font-weight: 600; }
.dd-opt small { font-size: 13px; color: var(--muted); }
.dd-backdrop { display: none; }
.topic-chip { border: 1px solid var(--indigo-line); background: var(--indigo-soft); color: var(--indigo-dark); font-size: 14px; font-weight: 600; padding: 8px 14px; min-height: 40px; border-radius: 999px; }
.topic-chip.off { border-color: var(--line); background: #fff; color: #6B7080; font-weight: 500; text-decoration: line-through; }
.summary-bar { background: var(--bg); border-radius: 20px; padding: 20px 24px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.summary-bar b { font-size: 20px; font-weight: 600; }

/* Generating overlay */
.gen { position: fixed; inset: 0; z-index: 60; background: rgba(245, 246, 250, 0.96); display: flex; align-items: center; justify-content: center; padding: 24px; }
.gen-card { background: #fff; border-radius: 28px; padding: 40px 32px; max-width: 440px; width: 100%; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 18px; box-shadow: 0 30px 60px rgba(11, 13, 23, 0.1); }
.gen-card h2 { font-size: 24px; font-weight: 700; }

/* ---------- Exam ---------- */
.exam { min-height: 100vh; background: var(--bg); }
.exam-top { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 20; }
.exam-top-in { max-width: 1280px; margin: 0 auto; padding: 14px 32px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.exam-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.exam-title b { font-size: 18px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exam-title small { font-size: 14px; color: #B9BDCC; }
.timer { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 700; padding: 10px 20px; border-radius: 999px; background: var(--ink-3); font-variant-numeric: tabular-nums; flex: none; }
.timer.low { background: var(--red-bg); color: var(--red); }
.timebar { height: 4px; background: #232838; }
.timebar > i { display: block; height: 4px; background: var(--lime); transition: width 1s linear; }
.exam-body { max-width: 1280px; margin: 0 auto; padding: 32px; display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.q-card { flex: 999 1 560px; min-width: 0; background: #fff; border-radius: 28px; padding: 36px; display: flex; flex-direction: column; gap: 24px; }
.q-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.q-num { font-size: 16px; font-weight: 600; color: var(--indigo); }
.q-text { font-size: 26px; line-height: 1.4; font-weight: 600; letter-spacing: -0.01em; white-space: pre-wrap; }
.flag-btn { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; padding: 10px 16px; min-height: 44px; border-radius: 999px; background: #fff; color: var(--text); border: 1px solid var(--line); }
.flag-btn.on { background: #FFEDD5; color: var(--orange); border-color: var(--orange-line); }
.opts { display: flex; flex-direction: column; gap: 12px; }
.opt { display: flex; align-items: center; gap: 16px; text-align: left; font-size: 18px; padding: 16px 18px; border-radius: 18px; border: 2px solid var(--line); background: #fff; font-weight: 500; }
.opt:hover { border-color: var(--indigo-line); }
.opt.on { border-color: var(--indigo); background: var(--indigo-soft); color: #1E1B4B; font-weight: 600; }
.opt .letter { width: 36px; height: 36px; flex: none; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; background: var(--soft); color: var(--text); }
.opt.on .letter { background: var(--indigo); color: #fff; }
.answer-box { border: 1px solid #D9DCE5; border-radius: 18px; padding: 18px; font-size: 17px; line-height: 1.6; background: #F8F9FB; resize: vertical; min-height: 240px; width: 100%; }
.answer-box:focus { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 4px #E0E7FF; background: #fff; }
.q-nav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line-2); padding-top: 24px; }
.navi { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 100px; }
.navi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.cell { height: 40px; border-radius: 10px; font-size: 14px; font-weight: 600; background: var(--soft); color: var(--text); border: 1px solid var(--line); }
.cell.done { background: var(--indigo-line); color: #1E1B4B; border-color: var(--indigo-line); }
.cell.flag { background: var(--orange-line); color: #7C2D12; border-color: var(--orange-line); }
.cell.cur { background: var(--ink); color: #fff; border-color: var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: block; }
.save-note { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.strip { display: none; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-bg { position: absolute; inset: 0; border: none; background: rgba(11, 13, 23, 0.55); }
.modal-card { position: relative; width: 520px; max-width: 100%; max-height: 90vh; overflow-y: auto; background: #fff; border-radius: 28px; padding: 32px; display: flex; flex-direction: column; gap: 18px; animation: fade 0.2s ease; }
.modal-grab { display: none; }
.modal-icon { width: 48px; height: 48px; flex: none; border-radius: 14px; display: flex; align-items: center; justify-content: center; }
.mi-ok { background: var(--green-bg); color: #15803D; }
.mi-warn { background: #FFEDD5; color: #C2410C; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--bg); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.tile small { font-size: 12px; font-weight: 500; color: var(--muted); }
.tile b { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile.warn { background: var(--orange-bg); color: var(--orange); }
.tile.warn small { color: var(--orange); }
.num-chip { min-width: 40px; height: 40px; padding: 0 8px; border-radius: 10px; font-size: 14px; font-weight: 700; border: 1px solid var(--orange-line); background: var(--orange-bg); color: var(--orange); }
.num-chip.blue { border-color: var(--indigo-line); background: var(--indigo-soft); color: var(--indigo-dark); }

/* ---------- Results ---------- */
.res { max-width: 1240px; margin: 0 auto; padding: 40px 32px 72px; display: flex; flex-direction: column; gap: 24px; }
.res-top { display: flex; flex-wrap: wrap; gap: 20px; align-items: stretch; }
.score-card { flex: 1 1 420px; min-width: 0; background: var(--ink); color: #fff; border-radius: 32px; padding: 40px; display: flex; flex-wrap: wrap; gap: 32px; align-items: center; }
.ring { width: 180px; height: 180px; flex: none; border-radius: 999px; display: flex; align-items: center; justify-content: center; }
.ring-in { width: 144px; height: 144px; border-radius: 999px; background: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-in b { font-size: 46px; font-weight: 700; letter-spacing: -0.03em; }
.ring-in small { font-size: 14px; color: #B9BDCC; }
.score-copy { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.score-copy h1 { font-size: 32px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; }
.score-copy p { color: #B9BDCC; line-height: 1.55; }
.topics-card { flex: 1 1 340px; min-width: 0; background: #fff; border-radius: 32px; padding: 32px; display: flex; flex-direction: column; gap: 18px; }
.topic-row { display: flex; flex-direction: column; gap: 8px; }
.topic-row .top { display: flex; justify-content: space-between; font-size: 15px; gap: 12px; }
.topic-row .bar { height: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.review { background: #fff; border-radius: 32px; padding: 32px; display: flex; flex-direction: column; gap: 18px; }
.filter { display: flex; gap: 6px; background: var(--soft); padding: 5px; border-radius: 999px; overflow-x: auto; }
.filter button { border: none; background: transparent; color: var(--text); font-size: 15px; font-weight: 600; padding: 10px 16px; min-height: 44px; border-radius: 999px; white-space: nowrap; }
.filter button.on { background: var(--ink); color: #fff; }
.r-item { border: 1px solid var(--line); border-radius: 22px; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.r-item .qh { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.r-item .qt { font-size: 19px; font-weight: 600; line-height: 1.4; white-space: pre-wrap; }
.ans { font-weight: 600; font-size: 15px; padding: 8px 14px; border-radius: 12px; display: inline-block; }
.ans.good { background: var(--green-bg); color: var(--green); }
.ans.bad { background: var(--red-bg); color: var(--red); }
.ans.none { background: var(--soft); color: var(--text); }
.why { font-size: 15px; line-height: 1.6; color: var(--text); background: #F8F9FB; border-radius: 14px; padding: 14px 16px; white-space: pre-wrap; }
.your-text { font-size: 15px; line-height: 1.6; color: var(--ink); border-left: 3px solid var(--line); padding: 4px 0 4px 14px; white-space: pre-wrap; }
.point { display: flex; gap: 10px; font-size: 15px; line-height: 1.5; }
.page-ref { font-size: 14px; color: var(--indigo); font-weight: 600; }
details.model summary { cursor: pointer; font-weight: 600; color: var(--indigo); font-size: 15px; min-height: 32px; display: flex; align-items: center; }

/* History */
.table-wrap { overflow-x: auto; }
.hist-row { display: grid; grid-template-columns: minmax(0, 2.4fr) 1.4fr 1fr 1fr auto; gap: 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line-2); color: var(--ink); min-width: 640px; }
.hist-row.head { font-size: 13px; color: var(--muted); font-weight: 600; border-top: none; }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .wrap { padding: 0 20px; }
  .l-links { display: none; }
  .l-hero { padding: 24px 0 64px; gap: 36px; }
  .l-visual { padding: 20px; border-radius: 24px; }
  .l-dark { padding: 64px 0; }
  .l-grading { padding: 32px 24px; border-radius: 28px; }
  .l-cta { padding: 48px 24px; border-radius: 28px; }
  .auth-side { padding: 32px 24px; gap: 28px; flex-basis: 100%; }
  .auth-side .hide-sm { display: none; }

  .sidebar { display: none; }
  .main { padding: 20px 20px 110px; gap: 20px; }
  .page-head h1 { font-size: 26px; }
  .tabbar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: #fff; border-top: 1px solid var(--line); padding: 8px 8px calc(10px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 600; padding: 6px 0; min-height: 52px; justify-content: center; }
  .tabbar a.active { color: var(--indigo); }
  .dropzone { padding: 28px 20px; border-radius: 24px; }
  .dropzone h2 { font-size: 22px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stat { padding: 18px; border-radius: 20px; }
  .stat .v { font-size: 28px; }
  .card { padding: 18px; border-radius: 22px; }

  .topbar-in { padding: 12px 20px; }
  .setup { padding: 20px 20px 140px; gap: 18px; }
  .setup h1 { font-size: 28px; }
  .setup-main { padding: 20px; border-radius: 22px; gap: 22px; }
  .presets { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .preset { padding: 14px; border-radius: 18px; }
  .preset .pt { font-size: 16px; }
  .preset .pd { font-size: 12px; }
  .preset .tag { display: none; }
  .summary-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; border-radius: 0; background: #fff; border-top: 1px solid var(--line); padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); flex-direction: column; align-items: stretch; gap: 10px; text-align: center; }
  .summary-bar b { font-size: 14px; font-weight: 500; color: var(--muted); }
  .summary-bar .k { display: none; }
  .tip-card { display: none !important; }

  /* Dropdown becomes a bottom sheet on phones */
  .dd-menu { position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 80; border-radius: 28px 28px 0 0; padding: 12px 20px calc(24px + env(safe-area-inset-bottom)); max-height: 75vh; box-shadow: none; gap: 6px; }
  .dd-menu-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 4px 10px; }
  .dd-menu-head b { font-size: 20px; font-weight: 700; }
  .dd.open .dd-backdrop { display: block; position: fixed; inset: 0; z-index: 79; border: none; background: rgba(11, 13, 23, 0.5); }
  .dd-opt { min-height: 58px; border: 2px solid transparent; border-radius: 16px; }
  .dd-opt.on { border-color: var(--indigo); }

  .exam-top-in { padding: 12px 16px; gap: 10px; }
  .exam-title { display: none; }
  .timer { font-size: 19px; padding: 9px 16px; }
  .strip { display: flex; gap: 6px; overflow-x: auto; padding: 0 16px 12px; max-width: 1280px; margin: 0 auto; scrollbar-width: none; }
  .strip::-webkit-scrollbar { display: none; }
  .strip .cell { width: 38px; height: 38px; flex: none; border: none; background: var(--ink-3); color: #B9BDCC; }
  .strip .cell.done { background: #3730A3; color: #fff; }
  .strip .cell.flag { background: var(--orange-line); color: #7C2D12; }
  .strip .cell.cur { background: var(--lime); color: var(--ink); }
  .exam-body { padding: 18px 16px 110px; }
  .q-card { padding: 22px 18px; border-radius: 22px; gap: 18px; }
  .q-text { font-size: 21px; }
  .opt { font-size: 16px; padding: 13px 14px; border-radius: 16px; gap: 14px; }
  .opt .letter { width: 32px; height: 32px; font-size: 15px; }
  .navi { display: none; }
  .q-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line); padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); flex-wrap: nowrap; }
  .q-nav .btn { flex: 1; }
  .q-nav .prev-label { display: none; }
  .q-nav .btn-soft { flex: none; width: 52px; padding: 0; }
  .answer-box { min-height: 200px; font-size: 16px; }

  .modal { align-items: flex-end; padding: 0; }
  .modal-card { width: 100%; border-radius: 28px 28px 0 0; padding: 14px 20px calc(26px + env(safe-area-inset-bottom)); max-height: 88vh; }
  .modal-grab { display: block; align-self: center; width: 40px; height: 5px; border-radius: 999px; background: #D9DCE5; }
  .tile b { font-size: 19px; }

  .res { padding: 16px 20px 48px; gap: 14px; }
  .score-card { padding: 26px; border-radius: 28px; flex-direction: column; text-align: center; gap: 16px; }
  .score-copy { align-items: center; }
  .score-copy h1 { font-size: 24px; }
  .ring { width: 150px; height: 150px; }
  .ring-in { width: 118px; height: 118px; }
  .ring-in b { font-size: 38px; }
  .topics-card, .review { padding: 20px; border-radius: 22px; }
  .actions .btn { flex: 1 1 140px; }
  .r-item { padding: 16px; border-radius: 18px; }
  .r-item .qt { font-size: 16px; }
}

@media (max-width: 860px) { .hide-sm { display: none; } }
.show-sm { display: none; }
@media (max-width: 860px) {
  .show-sm { display: inline; }
  .l-nav { flex-wrap: nowrap; padding: 16px 0; }
  .l-nav .btn { padding: 10px 14px; min-height: 42px; font-size: 15px; }
}
