/* Max Grade — arcade skin.
   Layout: one phone-width column (max 600px), sticky scoreboard header, bottom tab bar.
   Look: black cabinet ground, bubble display type with red outline and stacked rainbow drop, one neon accent per job.
   Single dark theme by design. */
:root {
  --bg: #07080a;
  --surface: #13161b;
  --surface-2: #1d2128;
  --fg: #f6f7f4;
  --muted: #a3aab6;
  --line: #2a2f38;
  --accent: #ff2e2e;
  --accent-ink: #ffffff;
  --r-red: #ff2e2e; --r-orange: #ff8a00; --r-yellow: #ffd400; --r-green: #2ad15a; --r-blue: #2a6cff;
  --pe: #2ad15a;
  --psych: #4f8cff;
  --rs: #ffd400;
  --warn: #ff5c5c;
  --m0: #1b1f26; --m1: #163424; --m2: #175d35; --m3: #1c8a49; --m4: #22b45a; --m5: #2ad15a;
  --display: "Fredoka", "Arial Rounded MT Bold", "Nunito", sans-serif;
  --body: "Nunito", "Segoe UI", Helvetica, Arial, sans-serif;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.45);
  --radius: 18px;
  --stack: 2px 2px 0 var(--r-red), 4px 4px 0 var(--r-orange), 6px 6px 0 var(--r-yellow), 8px 8px 0 var(--r-green), 10px 10px 0 var(--r-blue);
  --stack-sm: 1px 1px 0 var(--r-red), 2px 2px 0 var(--r-orange), 3px 3px 0 var(--r-yellow), 4px 4px 0 var(--r-green), 5px 5px 0 var(--r-blue);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--fg); font-family: var(--body); font-size: 16px; line-height: 1.45; font-weight: 500;
  background: var(--bg) radial-gradient(circle at 1px 1px, rgba(42, 209, 90, .10) 1px, transparent 1.5px) 0 0 / 22px 22px;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; text-wrap: balance; line-height: 1.05; letter-spacing: .005em; }
h1 { font-size: 2.1rem; } h2 { font-size: 1.5rem; } h3 { font-size: 1.15rem; }
p { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible, a:focus-visible { outline: 3px solid var(--r-yellow); outline-offset: 2px; border-radius: 6px; }
a { color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.eyebrow { font-family: var(--display); font-weight: 600; text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; color: var(--r-yellow); }
[hidden] { display: none !important; }

/* Bubble lettering: white face, red outline, rainbow stack */
.bubble { font-family: var(--display); font-weight: 700; color: #fff; -webkit-text-stroke: 1.5px var(--r-red); paint-order: stroke fill; text-shadow: var(--stack-sm); }
.bubble.lg { -webkit-text-stroke: 2px var(--r-red); text-shadow: var(--stack); }

/* Shell */
.app { min-height: 100%; display: flex; flex-direction: column; max-width: 600px; margin: 0 auto; }
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9; background: var(--bg);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 12px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line);
}
.wordmark { white-space: nowrap; font-family: var(--display); font-weight: 700; font-size: 1.25rem; letter-spacing: .01em; text-transform: uppercase; display: flex; align-items: center; gap: 10px; color: #fff; -webkit-text-stroke: 1.2px var(--r-red); paint-order: stroke fill; text-shadow: 1px 1px 0 var(--r-red), 2px 2px 0 var(--r-orange), 3px 3px 0 var(--r-yellow), 4px 4px 0 var(--r-green), 5px 5px 0 var(--r-blue); }
.wordmark i { display: inline-block; width: 22px; height: 20px; background: linear-gradient(var(--r-red), var(--r-red)) 0 100% / 5px 40% no-repeat, linear-gradient(var(--r-yellow), var(--r-yellow)) 50% 100% / 5px 70% no-repeat, linear-gradient(var(--r-green), var(--r-green)) 100% 100% / 5px 100% no-repeat; filter: drop-shadow(2px 2px 0 var(--r-blue)); }
.countdown { text-align: right; line-height: 1.1; }
.countdown { white-space: nowrap; }
.countdown b { font-family: var(--display); font-size: 1.4rem; font-weight: 700; color: var(--r-yellow); }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); flex: 0 0 auto; }
main {
  flex: 1; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 16px calc(88px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 18px;
}
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 9; background: #0b0d10; border-top: 2px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.tabs > div { max-width: 600px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 4px 8px; color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-family: var(--display); }
.tab svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-selected="true"] { color: #fff; }
.tab[aria-selected="true"] svg { stroke: var(--r-yellow); filter: drop-shadow(2px 2px 0 var(--r-red)); }

/* Blocks */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.flat { box-shadow: none; background: transparent; border: 1px dashed var(--line); }
.row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 999px; font-weight: 700; font-family: var(--display); letter-spacing: .02em; background: var(--surface-2); color: var(--fg); border: 2px solid var(--line); min-height: 46px; }
.btn.primary { background: #fff; color: #111; border-color: var(--r-red); box-shadow: 3px 3px 0 var(--r-orange), 6px 6px 0 var(--r-yellow); }
.btn.primary:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--r-orange), 3px 3px 0 var(--r-yellow); }
.btn.ghost { background: transparent; }
.btn.small { padding: 8px 12px; min-height: 36px; font-size: .9rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; box-shadow: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); color: var(--fg); white-space: nowrap; }
.chip .dot, .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.dot.pe { background: var(--pe); } .dot.psych { background: var(--psych); } .dot.rs { background: var(--rs); }
.chip.due { border-color: var(--r-yellow); color: var(--r-yellow); }
.chip.over { border-color: var(--r-red); color: var(--warn); }
.chip.ok { border-color: var(--r-green); color: var(--r-green); }
.box-lvl { display: inline-grid; grid-template-columns: repeat(5, 6px); gap: 2px; }
.box-lvl i { height: 12px; border-radius: 1px; background: var(--m0); }
.box-lvl i.on { background: var(--r-green); box-shadow: 0 0 6px rgba(42,209,90,.6); }

/* Today */
.hero { display: flex; flex-direction: column; gap: 6px; }
.hero h1 { font-size: 2.4rem; color: #fff; -webkit-text-stroke: 1.5px var(--r-red); paint-order: stroke fill; text-shadow: var(--stack-sm); }
.session-picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pick { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; text-align: left; min-width: 0; }
.pick b { font-family: var(--display); font-size: 2rem; line-height: 1; font-weight: 700; color: #fff; -webkit-text-stroke: 1px var(--r-red); paint-order: stroke fill; text-shadow: 2px 2px 0 var(--r-orange), 4px 4px 0 var(--r-yellow); }
.pick span { font-size: .8rem; color: var(--muted); }
.pick:hover, .pick:focus-visible, .pick[aria-pressed="true"] { border-color: var(--r-yellow); }
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); min-width: 0; text-align: left; width: 100%; }
.item:first-child { border-top: 0; }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; font-weight: 700; overflow-wrap: anywhere; }
.item .t span { font-size: .82rem; color: var(--muted); }
.tip { border-left: 4px solid var(--r-yellow); }
.tip p { font-weight: 600; }

/* Next-up and week */
.next h2.big { font-size: 2.6rem; color: #fff; -webkit-text-stroke: 1.5px var(--r-red); paint-order: stroke fill; text-shadow: var(--stack-sm); }
.next.live { border-color: var(--r-yellow); box-shadow: 0 0 0 3px rgba(255,212,0,.25), var(--shadow); }
.weekcard { flex-direction: row; align-items: center; gap: 14px; }
.ring { width: 84px; height: 84px; flex: 0 0 auto; }
.ring .track { fill: none; stroke: var(--m0); stroke-width: 9; }
.ring .fill { fill: none; stroke: var(--r-yellow); stroke-width: 9; stroke-linecap: butt; transition: stroke-dashoffset .4s ease; }
.ring .fill.full { stroke: var(--r-green); }
.ring text { font-family: var(--display); font-weight: 700; font-size: 20px; fill: #fff; }
.streak { text-align: center; min-width: 64px; }
.streak b { font-family: var(--display); font-size: 2.2rem; line-height: 1; display: block; color: #fff; -webkit-text-stroke: 1px var(--r-red); paint-order: stroke fill; text-shadow: 2px 2px 0 var(--r-orange), 4px 4px 0 var(--r-yellow); }
.streak span { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.summary-big { font-family: var(--display); font-size: 1.5rem; font-weight: 700; }
.install { display: flex; flex-direction: column; gap: 2px; text-align: left; background: var(--surface); border: 2px dashed var(--r-yellow); border-radius: var(--radius); padding: 12px 14px; }
.install b { font-weight: 700; color: var(--r-yellow); } .install span { font-size: .85rem; color: var(--muted); }

/* Spec */
.pills { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill { padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 2px solid var(--line); font-weight: 700; font-family: var(--display); white-space: nowrap; }
.pill[aria-pressed="true"] { background: #fff; color: #111; border-color: var(--r-red); box-shadow: 2px 2px 0 var(--r-yellow); }
.heat { display: grid; grid-template-columns: repeat(auto-fill, minmax(22px, 1fr)); gap: 4px; }
.heat i { aspect-ratio: 1; border-radius: 3px; background: var(--m0); display: block; box-shadow: inset 0 0 0 1px rgba(255,255,255,.04); }
.heat i.l1 { background: var(--m1); } .heat i.l2 { background: var(--m2); } .heat i.l3 { background: var(--m3); } .heat i.l4 { background: var(--m4); } .heat i.l5 { background: var(--m5); box-shadow: 0 0 8px rgba(42,209,90,.55); }
.legend { display: flex; align-items: center; gap: 4px; font-size: .75rem; color: var(--muted); }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.paper-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.detail { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 14px; }
.detail ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.grade { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.grade button { padding: 10px 4px; border-radius: 12px; font-weight: 700; font-family: var(--display); font-size: 1.05rem; background: var(--surface-2); border: 2px solid var(--line); }
.grade button:nth-child(1):hover { border-color: var(--r-red); } .grade button:nth-child(2):hover { border-color: var(--r-orange); } .grade button:nth-child(3):hover { border-color: var(--r-yellow); } .grade button:nth-child(4):hover { border-color: var(--r-green); }
.grade button.sel { background: #fff; color: #111; border-color: var(--r-red); box-shadow: 2px 2px 0 var(--r-yellow); }
.stepper { display: inline-flex; align-items: center; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; }
.stepper button { width: 40px; height: 36px; font-size: 1.2rem; font-weight: 700; }
.stepper b { min-width: 36px; text-align: center; font-family: var(--display); font-size: 1.2rem; }

/* Session and overlays */
.session { position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto; display: flex; flex-direction: column; }
.session::after { content: ""; position: fixed; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0,0,0,.14) 0 1px, transparent 1px 3px); opacity: .5; }
.session .inner { max-width: 600px; width: 100%; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: calc(16px + env(safe-area-inset-top, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 16px; flex: 1; position: relative; z-index: 1; }
.clock { text-align: center; padding: 10px 0 0; }
.clock b { font-family: var(--display); font-size: clamp(4.5rem, 24vw, 7rem); font-weight: 700; line-height: .95; display: block; color: #fff; -webkit-text-stroke: 2px var(--r-red); paint-order: stroke fill; text-shadow: var(--stack); }
.clock .phase { font-family: var(--display); text-transform: uppercase; letter-spacing: .14em; font-weight: 700; color: var(--r-yellow); font-size: 1rem; }
.phases { display: flex; gap: 4px; }
.phases i { flex: 1; height: 8px; border-radius: 2px; background: var(--m0); }
.phases i.done { background: var(--r-green); } .phases i.now { background: var(--r-yellow); box-shadow: 0 0 8px rgba(255,212,0,.6); }
.instr { font-size: 1.05rem; font-weight: 600; }
.checklist { display: flex; flex-direction: column; gap: 8px; }
.check { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); text-align: left; width: 100%; }
.check i { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); flex: 0 0 auto; display: grid; place-items: center; font-style: normal; }
.check[aria-pressed="true"] i { background: var(--r-green); border-color: var(--r-green); color: #06130a; }
.check[aria-pressed="true"] { color: var(--muted); text-decoration: line-through; }
details { border-top: 1px solid var(--line); }
details summary { list-style: none; cursor: pointer; padding: 10px 0; display: flex; align-items: center; gap: 10px; font-weight: 700; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "+"; margin-left: auto; font-family: var(--display); font-size: 1.3rem; color: var(--r-yellow); }
details[open] summary::after { content: "–"; }
details .body { padding: 0 0 12px; display: flex; flex-direction: column; gap: 10px; }
.q { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; display: flex; gap: 10px; align-items: flex-start; }
.q b { font-family: var(--display); font-size: 1.1rem; min-width: 34px; color: var(--r-yellow); }
.intro { justify-content: flex-start; }
.intro h1 { font-size: 2.6rem; color: #fff; -webkit-text-stroke: 1.5px var(--r-red); paint-order: stroke fill; text-shadow: var(--stack-sm); }
.intro-art { display: flex; align-items: flex-end; gap: 10px; height: 120px; padding: 16px 0 8px; }
.intro-art i { width: 34px; border-radius: 6px; display: block; filter: drop-shadow(3px 3px 0 var(--r-blue)); }
.intro-art .b1 { height: 40%; background: var(--r-red); } .intro-art .b2 { height: 65%; background: var(--r-yellow); } .intro-art .b3 { height: 100%; background: var(--r-green); }
.intro-art .b3.on { background: #fff; }
.dots { display: flex; gap: 6px; justify-content: center; padding-bottom: 4px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); display: block; }
.dots i.on { background: var(--r-yellow); }
a.btn { text-decoration: none; }
.steps { padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 1.05rem; }

/* Wizard */
.daygrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.daybtn { aspect-ratio: 1; border-radius: 12px; background: var(--surface); border: 2px solid var(--line); font-family: var(--display); font-weight: 700; font-size: 1rem; }
.daybtn[aria-pressed="true"] { background: #fff; color: #111; border-color: var(--r-red); box-shadow: 2px 2px 0 var(--r-yellow); }
.slotrow { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.slotrow select, .slotrow input { min-height: 40px; padding: 6px 8px; }
.slotrow .row > select:first-child { flex: 1.4; } .slotrow .row > select { flex: 1; min-width: 0; }
.maths .row { padding: 6px 0; border-bottom: 1px solid var(--line); } .maths .row:last-of-type { border-bottom: 0; }
.contract { border: 2px solid #fff; box-shadow: 4px 4px 0 var(--r-red), 8px 8px 0 var(--r-yellow); }
.contract p { font-size: 1.1rem; line-height: 1.5; } .contract ul { margin: 0; padding-left: 18px; }
.weekrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); gap: 6px; }
.wk { border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); padding: 6px 4px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.wk b { font-family: var(--display); font-size: 1.1rem; line-height: 1; } .wk span { font-size: .62rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.wk.kept { border-color: var(--r-green); color: var(--r-green); } .wk.missed { border-color: var(--r-red); } .wk.cur { border-color: var(--r-yellow); } .wk.shield { border-color: var(--r-blue); }
.code b { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1rem; letter-spacing: .04em; overflow-wrap: anywhere; color: var(--r-yellow); }
.clockinline { font-family: var(--display); font-size: 1.8rem; color: var(--r-yellow); }
#syncDot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); display: inline-block; margin-left: 6px; vertical-align: middle; }
#syncDot[data-s="synced"] { background: var(--r-green); } #syncDot[data-s^="synced-dirty"], #syncDot[data-s^="offline"] { background: var(--r-orange); }

/* Plan and progress */
.exams .item .t b { font-weight: 700; }
.days { font-family: var(--display); font-size: 1.5rem; font-weight: 700; min-width: 56px; text-align: right; color: var(--r-yellow); }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.tile b { font-family: var(--display); font-size: 2.2rem; line-height: 1; font-weight: 700; display: block; color: #fff; -webkit-text-stroke: 1px var(--r-red); paint-order: stroke fill; text-shadow: 2px 2px 0 var(--r-orange), 4px 4px 0 var(--r-yellow); }
.tile span { font-size: .8rem; color: var(--muted); display: block; margin-top: 6px; }
.bar { height: 10px; background: var(--m0); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--r-green); border-radius: 3px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-family: var(--body); font-size: 11px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .grid.target { stroke: var(--r-yellow); stroke-dasharray: 3 3; }
.chart rect { fill: var(--psych); }
.chart rect.kept { fill: var(--r-green); }
.chart rect.now { fill: var(--r-yellow); }

/* Forms */
label.field { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); font-weight: 700; }
select, input[type="date"], input[type="text"], textarea { font: inherit; color: var(--fg); background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-height: 44px; width: 100%; }
textarea { min-height: 120px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; }
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: #fff; color: #111; border: 2px solid var(--r-red); box-shadow: 3px 3px 0 var(--r-yellow); padding: 10px 16px; border-radius: 999px; font-weight: 700; font-family: var(--display); z-index: 30; max-width: 90vw; }
@media (prefers-reduced-motion: no-preference) {
  .pick, .btn, .check { transition: transform .12s ease, border-color .12s ease, background .12s ease, box-shadow .12s ease; }
  .btn:active, .pick:active { transform: scale(.98); }
}
@media (prefers-reduced-motion: reduce) { .session::after { display: none; } }
@media (max-width: 380px) { .session-picks { grid-template-columns: 1fr 1fr; } }
