/* ============================================================
   AptitudeOS — macOS-inspired liquid-glass design system
   Crisp type · restrained translucency · calm blue/graphite/silver
   ============================================================ */

:root {
  --accent: #2f6fed;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Code", Consolas, monospace;

  --bg: #eef1f6;
  --bg-wash-a: #dfe7f3;
  --bg-wash-b: #eae6f2;
  --ink: #1c1f26;
  --ink-2: #4a5160;
  --ink-3: #7a8194;
  --panel: rgba(255, 255, 255, 0.62);
  --panel-strong: rgba(255, 255, 255, 0.88);
  --panel-opaque: #ffffff;
  --line: rgba(20, 30, 60, 0.12);
  --line-soft: rgba(20, 30, 60, 0.07);
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .08);
  --shadow-lift: 0 2px 6px rgba(16, 24, 40, .08), 0 16px 40px rgba(16, 24, 40, .14);
  --ok: #1f9d55; --warn: #b7791f; --bad: #d64545;
  --radius: 16px; --radius-sm: 10px;
  --blur: saturate(180%) blur(18px);
}

html[data-theme="dark"], html[data-theme="auto"][data-osdark="1"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --bg: #14161b; --bg-wash-a: #1a2233; --bg-wash-b: #231d31;
    --ink: #eceef2; --ink-2: #b3b9c6; --ink-3: #7e8494;
    --panel: rgba(30, 34, 44, 0.58); --panel-strong: rgba(30, 34, 44, 0.86);
    --panel-opaque: #1e222c;
    --line: rgba(255, 255, 255, 0.13); --line-soft: rgba(255, 255, 255, 0.07);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.5);
    --shadow-lift: 0 2px 6px rgba(0,0,0,.5), 0 16px 40px rgba(0,0,0,.6);
  }
}
html[data-theme="dark"] {
  --bg: #14161b; --bg-wash-a: #1a2233; --bg-wash-b: #231d31;
  --ink: #eceef2; --ink-2: #b3b9c6; --ink-3: #7e8494;
  --panel: rgba(30, 34, 44, 0.58); --panel-strong: rgba(30, 34, 44, 0.86);
  --panel-opaque: #1e222c;
  --line: rgba(255, 255, 255, 0.13); --line-soft: rgba(255, 255, 255, 0.07);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.5);
  --shadow-lift: 0 2px 6px rgba(0,0,0,.5), 0 16px 40px rgba(0,0,0,.6);
}
html[data-theme="contrast"] {
  --bg: #ffffff; --bg-wash-a: #ffffff; --bg-wash-b: #ffffff;
  --ink: #000000; --ink-2: #1a1a1a; --ink-3: #333333;
  --panel: #ffffff; --panel-strong: #ffffff; --panel-opaque: #ffffff;
  --line: #000000; --line-soft: #555555;
  --shadow: none; --shadow-lift: none; --blur: none;
  --accent: #0000cc;
}
html[data-reduced-glass="1"] { --panel: var(--panel-opaque); --panel-strong: var(--panel-opaque); --blur: none; }
@media (prefers-reduced-transparency: reduce) {
  :root { --panel: var(--panel-opaque); --panel-strong: var(--panel-opaque); --blur: none; }
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg);
  font-size: 15.5px; line-height: 1.55; min-height: 100vh;
}
.bg-wash {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60vw 40vh at 12% -5%, var(--bg-wash-a), transparent 60%),
    radial-gradient(55vw 45vh at 95% 10%, var(--bg-wash-b), transparent 60%),
    var(--bg);
}
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -0.015em; margin: 0 0 .5em; }
h1 { font-size: 1.7rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--panel-opaque); padding: 10px 16px; z-index: 999; border-radius: 0 0 8px 0; }
.skip-link:focus { left: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Glass panels ---------- */
.glass {
  background: var(--panel);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow);
}
.card {
  background: var(--panel); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px;
}
.card-opaque { background: var(--panel-opaque); -webkit-backdrop-filter: none; backdrop-filter: none; }
.card h2:first-child { margin-top: 0; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 50; border-left: 0; border-right: 0; border-top: 0; }
.topbar-inner { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 18px; padding: 10px 20px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #7aa5f8); box-shadow: inset 0 0 0 1px rgba(255,255,255,.35), 0 2px 6px rgba(47,111,237,.4); }
.brand-sub { color: var(--ink-3); font-size: .85em; margin-left: 4px; }
.mainnav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: 8px; }
.mainnav a { padding: 7px 12px; border-radius: 9px; color: var(--ink-2); font-weight: 500; font-size: .93rem; }
.mainnav a:hover { background: var(--line-soft); text-decoration: none; color: var(--ink); }
.mainnav a[aria-current="page"] { background: var(--accent); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.userchip { color: var(--ink-2); font-weight: 550; }
.inline { display: inline; }

.container { max-width: 1180px; margin: 26px auto 60px; padding: 0 20px; }
.site-footer { max-width: 1180px; margin: 0 auto 30px; padding: 0 20px; color: var(--ink-3); font-size: .82rem; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: .95rem;
  padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel-strong); color: var(--ink); cursor: pointer;
  transition: transform .06s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { text-decoration: none; box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; box-shadow: 0 2px 8px rgba(47,111,237,.35); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-soft); }
.btn-danger { background: var(--bad); border-color: transparent; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .87rem; border-radius: 9px; }
.btn-lg { padding: 13px 26px; font-size: 1.05rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

label { display: block; font-weight: 600; font-size: .9rem; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  font: inherit; width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-opaque); color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > div { flex: 1; min-width: 180px; }
.help { color: var(--ink-3); font-size: .84rem; margin-top: 4px; }
.checkline { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 8px 0; }
.checkline input { width: auto; }

.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; border: 1px solid; font-weight: 500; }
.alert-error { background: rgba(214,69,69,.08); border-color: rgba(214,69,69,.4); color: var(--bad); }
.alert-ok { background: rgba(31,157,85,.08); border-color: rgba(31,157,85,.4); color: var(--ok); }
.alert-info { background: rgba(47,111,237,.07); border-color: rgba(47,111,237,.35); color: var(--accent); }

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; font-weight: 650; color: var(--ink-2); padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.data tr:hover td { background: var(--line-soft); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 650; border: 1px solid var(--line); color: var(--ink-2); }
.badge-ok { color: var(--ok); border-color: rgba(31,157,85,.5); background: rgba(31,157,85,.07); }
.badge-warn { color: var(--warn); border-color: rgba(183,121,31,.5); background: rgba(183,121,31,.07); }
.badge-bad { color: var(--bad); border-color: rgba(214,69,69,.5); background: rgba(214,69,69,.07); }
.badge-accent { color: var(--accent); border-color: rgba(47,111,237,.4); background: rgba(47,111,237,.07); }

/* ---------- Dashboard ---------- */
.grid { display: grid; gap: 18px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stat { padding: 16px 18px; }
.stat .stat-label { color: var(--ink-3); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .stat-value { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.stat .stat-sub { color: var(--ink-2); font-size: .85rem; }
.progressbar { height: 8px; border-radius: 99px; background: var(--line-soft); overflow: hidden; }
.progressbar > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), #7aa5f8); }
.tasklist { list-style: none; margin: 0; padding: 0; }
.tasklist li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.tasklist li:last-child { border-bottom: 0; }
.chart-svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--ink-3); font-size: .8rem; }

/* ---------- Exam interface (clarity-first, opaque surfaces) ---------- */
.exam-body { background: var(--bg); }
.exam-main { max-width: 1240px; margin: 0 auto; padding: 14px 18px 30px; }
.exam-top {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 16px;
  background: var(--panel-opaque); border: 1px solid var(--line-soft); border-radius: 12px;
  padding: 9px 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.exam-title { font-weight: 700; }
.exam-progress { color: var(--ink-2); font-size: .92rem; }
.exam-timer {
  margin-left: auto; font-family: var(--mono); font-size: 1.15rem; font-weight: 700;
  padding: 5px 14px; border-radius: 9px; background: var(--line-soft); min-width: 92px; text-align: center;
}
.exam-timer.warn { background: #ffd21f; color: #4a3b00; }
.exam-timer.untimed { font-size: .85rem; font-weight: 600; }
.exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.exam-layout.single { grid-template-columns: minmax(0, 1fr); max-width: 860px; margin: 0 auto; }
.stimulus-panel, .question-panel {
  background: var(--panel-opaque); border: 1px solid var(--line-soft); border-radius: 12px;
  padding: 20px 24px; box-shadow: var(--shadow);
}
.stimulus-panel { max-height: 74vh; overflow: auto; font-size: 1rem; line-height: 1.65; }
.stimulus-panel h3 { color: var(--ink-2); }
.stimulus-panel table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: .95rem; }
.stimulus-panel table th, .stimulus-panel table td { border: 1px solid var(--line); padding: 6px 10px; text-align: right; }
.stimulus-panel table th:first-child, .stimulus-panel table td:first-child { text-align: left; }
.stimulus-panel table caption { caption-side: top; text-align: left; font-weight: 650; padding-bottom: 6px; }
.question-stem { font-size: 1.04rem; font-weight: 550; margin-bottom: 16px; }
.options { list-style: none; margin: 0; padding: 0; }
.options li { margin-bottom: 10px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left;
  font: inherit; padding: 12px 14px; border-radius: 10px; border: 1.5px solid var(--line);
  background: var(--panel-opaque); color: var(--ink); cursor: pointer;
}
.opt:hover { border-color: var(--accent); }
.opt[aria-pressed="true"] { border-color: var(--accent); background: rgba(47,111,237,.09); box-shadow: inset 0 0 0 1px var(--accent); }
.opt .opt-letter { font-weight: 700; color: var(--ink-3); min-width: 1.2em; }
.opt[aria-pressed="true"] .opt-letter { color: var(--accent); }
.ynrow { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.ynrow .yn { padding: 7px 18px; border-radius: 9px; border: 1.5px solid var(--line); background: var(--panel-opaque); font: inherit; font-weight: 600; cursor: pointer; }
.ynrow .yn[aria-pressed="true"] { border-color: var(--accent); background: rgba(47,111,237,.1); color: var(--accent); }
.rate-scale { display: grid; gap: 8px; }
.exam-bottom { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.navigator { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.navq {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1.5px solid var(--line); font: inherit; font-size: .82rem; font-weight: 650;
  background: var(--panel-opaque); cursor: pointer; position: relative;
}
.navq.answered { background: rgba(31,157,85,.14); border-color: rgba(31,157,85,.6); }
.navq.flagged::after { content: ""; position: absolute; top: -4px; right: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--warn); border: 1.5px solid var(--panel-opaque); }
.navq.current { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47,111,237,.35); }
.flagbtn { border: 1.5px solid var(--line); background: var(--panel-opaque); font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 9px; cursor: pointer; }
.flagbtn[aria-pressed="true"] { background: rgba(183,121,31,.12); border-color: var(--warn); color: var(--warn); }

/* calculator */
.calc { position: fixed; right: 26px; top: 90px; width: 230px; z-index: 60; background: var(--panel-opaque); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lift); padding: 12px; }
.calc-display { font-family: var(--mono); font-size: 1.3rem; text-align: right; padding: 8px 10px; background: var(--line-soft); border-radius: 8px; margin-bottom: 8px; min-height: 1.5em; word-break: break-all; }
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.calc-grid button { font: inherit; font-size: 1.05rem; font-weight: 600; padding: 9px 0; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-opaque); cursor: pointer; }
.calc-grid button:hover { background: var(--line-soft); }
.calc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; cursor: move; font-weight: 650; font-size: .85rem; color: var(--ink-2); }

/* results / tutor */
.result-q { border: 1px solid var(--line-soft); border-radius: 12px; padding: 16px 18px; margin-bottom: 14px; background: var(--panel-opaque); }
.result-q.correct { border-left: 4px solid var(--ok); }
.result-q.partial { border-left: 4px solid var(--warn); }
.result-q.wrong { border-left: 4px solid var(--bad); }
.tutor { background: rgba(47,111,237,.06); border: 1px solid rgba(47,111,237,.25); border-radius: 10px; padding: 12px 16px; margin-top: 10px; }
.tutor h4 { margin: 0 0 6px; color: var(--accent); font-size: .9rem; }
details.explain summary { cursor: pointer; font-weight: 650; color: var(--accent); margin-top: 8px; }

@media (max-width: 900px) {
  .exam-layout { grid-template-columns: 1fr; }
  .topbar-inner { flex-wrap: wrap; }
  .calc { position: fixed; right: 10px; top: auto; bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mt0{margin-top:0}.mb0{margin-bottom:0}.muted{color:var(--ink-3)}.small{font-size:.85rem}
.landing-hero { text-align: center; padding: 60px 20px 30px; }
.landing-hero h1 { font-size: 2.4rem; }
.landing-hero p { max-width: 620px; margin: 0 auto 24px; color: var(--ink-2); font-size: 1.08rem; }
