/* SplitHomework — styles */
:root {
  --bg: #0e1322;
  --bg-2: #151b30;
  --panel: #1a2138;
  --panel-2: #222b48;
  --line: #2c3656;
  --ink: #eef2ff;
  --ink-dim: #aeb8da;
  --ink-faint: #76819f;
  --accent: #6f8cff;       /* homework / primary */
  --accent-2: #9b8cff;
  --ok: #34d399;           /* correct / unlocked */
  --ok-ink: #062017;
  --bad: #f87171;          /* wrong */
  --warn: #f5b04a;         /* locked / break */
  --radius: 16px;
  --shadow: 0 16px 44px rgba(0,0,0,.4);
  font-synthesis: none;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1100px 600px at 12% -8%, #1c2444 0%, transparent 60%),
    radial-gradient(900px 540px at 95% 0%, #241f44 0%, transparent 55%),
    var(--bg);
  color: var(--ink); min-height: 100%; -webkit-font-smoothing: antialiased; line-height: 1.45;
  display: flex; flex-direction: column;
}
a { color: var(--accent-2); }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }
.mono { font-variant-numeric: tabular-nums; }
code { background: rgba(255,255,255,.06); padding: 1px 5px; border-radius: 5px; font-size: .9em; color: var(--ink-dim); }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 13px 22px;
  border-bottom: 1px solid var(--line); background: rgba(14,19,34,.78); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 30; flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .2px; font-size: 18.5px; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0; color: #11132e;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center;
}
.brand .logo svg { display: block; }
.brand .wordmark { white-space: nowrap; }
.brand b { color: var(--accent-2); }
.topbar .spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.earned-pill {
  font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--panel-2);
}
.earned-pill.unlocked { color: var(--ok); border-color: rgba(52,211,153,.45); background: rgba(52,211,153,.1); }
.earned-pill.locked { color: var(--warn); }
.btn-ghost {
  background: transparent; color: var(--ink-dim); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 10px; font-size: 13px; white-space: nowrap;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--accent); }
.hamburger { display: none; background: transparent; border: 1px solid var(--line); color: var(--ink-dim); border-radius: 10px; padding: 6px 8px; line-height: 0; }
.hamburger:hover { color: var(--ink); border-color: var(--accent); }
.hamburger svg { display: block; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0c1130; border: none;
  border-radius: 12px; padding: 12px 20px; font-weight: 800; font-size: 15px; display: inline-block; text-align: center;
}
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:disabled { opacity: .5; cursor: default; filter: none; }

/* ---------- split layout ---------- */
.split {
  flex: 1; display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px;
  max-width: 1360px; width: 100%; margin: 0 auto; padding: 18px 22px 8px;
}
@media (max-width: 880px) { .split { grid-template-columns: 1fr; } }
.pane {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 130%);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0;
}
.yt-pane { border-color: rgba(155,140,255,.28); }
.pane-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pane-head h2 { font-size: 16px; font-weight: 800; letter-spacing: .2px; display: flex; align-items: center; gap: 7px; }
.pane-head h2 .ph-emoji { font-size: 17px; }
.pane-head h2 .muted { color: var(--ink-faint); font-weight: 600; }

/* ---------- chips (level / category pickers) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chips-scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.chips-scroll::-webkit-scrollbar { height: 6px; }
.chips-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
.chip {
  background: var(--panel-2); border: 1.5px solid var(--line); color: var(--ink-dim);
  padding: 6px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; transition: .12s;
}
.chip:hover { color: var(--ink); border-color: var(--accent); }
.chip.sel { color: var(--ink); border-color: var(--accent-2); background: rgba(155,140,255,.14); }
.chip.chip-more { display: inline-flex; align-items: center; gap: 6px; }
.chip.chip-more svg { display: block; opacity: .85; }

/* ---------- category dropdown ("More ▾") ---------- */
.cat-bar { position: relative; }
.cat-menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 25;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 13px;
  box-shadow: var(--shadow); padding: 7px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px;
  width: max-content; max-width: min(440px, 88vw); max-height: min(58vh, 420px); overflow-y: auto;
}
@media (max-width: 520px) { .cat-menu { grid-template-columns: 1fr; } }
.cat-menu::-webkit-scrollbar { width: 7px; }
.cat-menu::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
.cat-menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  background: transparent; border: 1.5px solid transparent; color: var(--ink-dim);
  padding: 8px 11px; border-radius: 9px; font-size: 13px; font-weight: 600; white-space: nowrap; transition: .1s;
}
.cat-menu-item:hover { background: var(--panel-2); color: var(--ink); }
.cat-menu-item.sel { color: var(--ink); background: rgba(155,140,255,.14); border-color: var(--accent-2); }
.cat-menu-item .cm-emoji { font-size: 15px; line-height: 1; flex-shrink: 0; }

/* ---------- homework card ---------- */
.hw-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.hw-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 12px; color: var(--ink-faint); flex-wrap: wrap; }
.hw-meta .reward-hint { color: var(--ink-faint); }
.hw-meta .reward-hint b { color: var(--ok); font-weight: 800; }
.hw-prompt { font-size: 22px; font-weight: 700; line-height: 1.35; min-height: 60px; word-break: break-word; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
@media (max-width: 560px) { .choices { grid-template-columns: 1fr; } }
.choice {
  text-align: left; background: var(--panel); border: 1.5px solid var(--line); border-radius: 12px;
  padding: 13px 15px; font-size: 16px; color: var(--ink); display: flex; align-items: center; gap: 10px; transition: .1s;
}
.choice .key { width: 22px; height: 22px; border-radius: 6px; background: var(--line); display: grid; place-items: center; font-size: 12px; font-weight: 800; color: var(--ink-dim); flex-shrink: 0; }
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice:disabled { cursor: default; }
.choice.correct { border-color: var(--ok); background: rgba(52,211,153,.16); }
.choice.correct .key { background: var(--ok); color: var(--ok-ink); }
.choice.wrong { border-color: var(--bad); background: rgba(248,113,113,.15); }
.choice.wrong .key { background: var(--bad); color: #2a0a0e; }
.hw-feedback { min-height: 22px; font-size: 14px; font-weight: 700; }
.hw-feedback.ok { color: var(--ok); }
.hw-feedback.bad { color: var(--bad); }
.hw-solution { padding: 12px 15px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; background: rgba(111,140,255,.08); font-size: 14px; color: var(--ink-dim); line-height: 1.55; }
.hw-solution .sol-h { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); font-weight: 800; margin-bottom: 4px; }
.hw-solution b { color: var(--ink); }
.hw-nextrow { text-align: right; }
.hw-stats { font-size: 13px; color: var(--ink-faint); }
.hw-stats b { color: var(--ink-dim); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
@media (max-width: 480px) { .stat-grid { grid-template-columns: 1fr; } }
.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat .v { font-size: 21px; font-weight: 900; line-height: 1.1; color: var(--ink); }
.stat .v.hi { color: var(--ok); }
.stat .k { font-size: 11px; color: var(--ink-faint); margin-top: 4px; letter-spacing: .3px; text-transform: uppercase; }
.stat .sub { font-size: 11.5px; color: var(--ink-dim); margin-top: 3px; line-height: 1.4; }

/* ---------- YouTube panel ---------- */
.yt-time { font-size: 13px; font-weight: 800; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.yt-time.locked { color: var(--warn); }
.yt-time.unlocked { color: var(--ok); border-color: rgba(52,211,153,.45); background: rgba(52,211,153,.1); }
.yt-stage { position: relative; flex: 1; min-height: 360px; }
.yt-frame-wrap { position: absolute; inset: 0; border-radius: 12px; overflow: hidden; background: #000; border: 1px solid var(--line); }
.yt-frame-wrap iframe, .yt-frame-wrap #ytFrame { width: 100%; height: 100%; border: 0; display: block; }
.yt-loading { position: absolute; inset: 0; display: grid; place-items: center; padding: 22px; text-align: center; color: var(--ink-faint); font-size: 13px; line-height: 1.55; background: #000; z-index: 2; }
.yt-loading.err { color: var(--warn); }
.yt-overlay {
  position: absolute; inset: 0; border-radius: 12px; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 26px; gap: 8px;
  background: linear-gradient(180deg, rgba(14,19,34,.92), rgba(14,19,34,.97));
  border: 1px solid var(--line); backdrop-filter: blur(2px);
}
.yt-overlay.yt-lock { border-color: rgba(245,176,74,.4); }
.yt-overlay .ov-icon { font-size: 34px; }
.yt-overlay .ov-h { font-size: 18px; font-weight: 800; }
.yt-overlay.yt-lock .ov-h { color: var(--warn); }
.yt-overlay .ov-d { font-size: 13.5px; color: var(--ink-dim); max-width: 360px; line-height: 1.5; }
.yt-overlay .ov-d b { color: var(--ink); }
.yt-np .np-row { display: flex; gap: 8px; width: 100%; max-width: 380px; margin-top: 6px; }
.yt-np .np-row input {
  flex: 1; min-width: 0; background: var(--panel); border: 1.5px solid var(--line); color: var(--ink);
  border-radius: 10px; padding: 9px 11px; font-size: 13px; font-family: inherit;
}
.yt-np .np-row input:focus { outline: none; border-color: var(--accent); }
.yt-np .np-row input.err { border-color: var(--bad); }
.yt-np .np-row .btn-primary { padding: 9px 14px; font-size: 14px; }
.yt-np .np-search { font-size: 12.5px; color: var(--accent-2); margin-top: 4px; }
.yt-np .np-note { font-size: 11px; color: var(--ink-faint); margin-top: 2px; }
.yt-controls { display: flex; align-items: center; gap: 8px; }
.yt-controls .spacer { flex: 1; }
.yt-controls .btn-ghost { font-size: 12.5px; padding: 6px 11px; }

/* ---------- footer ---------- */
.foot { text-align: center; color: var(--ink-faint); font-size: 12px; padding: 16px 22px 18px; }
.foot code { color: var(--ink-dim); }

/* ---------- mobile topbar (hamburger) ---------- */
@media (max-width: 620px) {
  .topbar { padding: 11px 14px; gap: 8px; }
  .split { padding: 14px; }
  .hamburger { display: grid; place-items: center; }
  .topbar-actions {
    display: none; position: absolute; top: calc(100% + 6px); right: 12px;
    flex-direction: column; align-items: stretch; gap: 8px;
    background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-width: 210px;
    box-shadow: var(--shadow); z-index: 40;
  }
  .topbar.menu-open .topbar-actions { display: flex; }
  .topbar-actions .earned-pill { text-align: center; }
  .topbar-actions .btn-ghost { text-align: center; }
}
