/* Upsolve. Quiet list: one typeface, white space, grey details, one blue. */

:root {
  --paper: #FFFFFF;
  --ink: #000000;
  --muted: #6E6E76;
  --faint: #9A9AA2;
  --line: #E9E9EE;
  --wash: #F6F6F8;
  --blue: #2F49D1;
  --blue-ink: #2F49D1;
  --on-blue: #FFFFFF;
  --ok: #17803D;
  --bad: #C42B2B;
  --focus: #2F49D1;

  /* Codeforces rank colours: handles only */
  --t-newbie: #6B6B6B; --t-pupil: #17803D; --t-specialist: #03807A; --t-expert: #2340D8;
  --t-cm: #9A1A9A; --t-master: #B35F00; --t-gm: #C42B2B;
  --r-newbie: #8A8F98; --r-pupil: #1E8A2E; --r-specialist: #03A89E; --r-expert: #2546D8;
  --r-cm: #A0219E; --r-master: #F28C00; --r-gm: #E0241B;

  --heat-0: #EEEEF2; --heat-1: #CBD2F4; --heat-2: #97A5EA; --heat-3: #5D72DE; --heat-4: #2F49D1;

  --font: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: clamp(20px, 5vw, 48px);
  color-scheme: light;

  /* names kept for plugins written against earlier versions */
  --sheet: var(--paper); --graphite: var(--muted); --ink-soft: var(--ink); --rule: var(--line);
  --soft: var(--line); --highlighter: var(--blue); --highlighter-ink: var(--on-blue);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0E0E10; --ink: #F2F2F4; --muted: #A0A0A8; --faint: #76767E; --line: #2A2A2E; --wash: #1D1D20;
    --blue: #8C9CFF; --blue-ink: #A3B0FF; --on-blue: #0E0E10; --ok: #5CCB83; --bad: #FF8A80; --focus: #A3B0FF;
    --t-newbie: #C2C2CC; --t-pupil: #5CCB83; --t-specialist: #4FD9CF; --t-expert: #A3B0FF;
    --t-cm: #F08CF0; --t-master: #FFB45C; --t-gm: #FF8A80;
    --heat-0: #232327; --heat-1: #2E3770; --heat-2: #4253B0; --heat-3: #6E80F0; --heat-4: #B3BDFF;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0E0E10; --ink: #F2F2F4; --muted: #A0A0A8; --faint: #76767E; --line: #2A2A2E; --wash: #1D1D20;
  --blue: #8C9CFF; --blue-ink: #A3B0FF; --on-blue: #0E0E10; --ok: #5CCB83; --bad: #FF8A80; --focus: #A3B0FF;
  --t-newbie: #C2C2CC; --t-pupil: #5CCB83; --t-specialist: #4FD9CF; --t-expert: #A3B0FF;
  --t-cm: #F08CF0; --t-master: #FFB45C; --t-gm: #FF8A80;
  --heat-0: #232327; --heat-1: #2E3770; --heat-2: #4253B0; --heat-3: #6E80F0; --heat-4: #B3BDFF;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column; position: relative; isolation: isolate;
  background: var(--paper); color: var(--ink);
  font: 400 16px/1.6 var(--font); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-weight: 600; line-height: 1.25; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: 2rem; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.0625rem; }
h4 { font-size: 0.9375rem; }
p { margin: 0 0 1em; max-width: 60ch; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--blue-ink); }
p a, .hint a, .colophon a { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 10; background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 6px; }
.skip:focus { top: 12px; }

/* ---------------------------------------------------------------- shell */

.masthead { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px var(--gutter); max-width: 1120px; width: 100%; margin: 0 auto; }
.wordmark { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 1.25rem; letter-spacing: -0.02em; }
.logo { width: 20px; height: 20px; flex: none; color: var(--blue-ink); }
.theme-toggle { flex: none; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer; }
.theme-toggle:hover { background: var(--wash); }
.theme-toggle svg { width: 18px; height: 18px; }
:root[data-theme="light"] .theme-toggle .sun { display: none; }
:root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
.wordmark-mark { display: none; }
.handle-form { display: flex; gap: 8px; flex: 0 1 280px; margin-left: auto; }
.is-landing .handle-form { visibility: hidden; }
.handle-form input, .landing-form input {
  flex: 1; min-width: 0; font: inherit; font-size: 0.9375rem; color: var(--ink); background: var(--wash);
  border: 1px solid transparent; border-radius: 8px; padding: 8px 12px;
}
.handle-form input:focus, .landing-form input:focus { background: var(--paper); border-color: var(--line); }
.handle-form input::placeholder, .landing-form input::placeholder { color: var(--faint); }

main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 var(--gutter) 96px; }
main:focus { outline: none; }
.colophon { max-width: 1120px; width: 100%; margin: 0 auto; padding: 24px var(--gutter) 32px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 0.8125rem; color: var(--faint); }
.colophon p { margin: 0; }
.colophon-links { display: flex; gap: 20px; list-style: none; margin: 0; padding: 0; }
.noscript { padding: var(--gutter); }

/* ---------------------------------------------------------------- buttons */

.btn {
  font: 500 0.875rem/1 var(--font); padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--wash); color: var(--ink); }
.btn-ink, .btn-blue { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn-ink:hover, .btn-blue:hover { background: var(--ink); color: var(--paper); opacity: 0.85; }
.btn-small { padding: 6px 10px; font-size: 0.8125rem; }
.btn-mark { color: var(--blue-ink); }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; }
.linkish:hover { color: var(--ink); }

/* ---------------------------------------------------------------- status */

.status:empty { display: none; }
.status { max-width: 1120px; width: calc(100% - 2 * var(--gutter)); margin: 0 auto 8px; padding: 10px 14px; border-radius: 8px; background: var(--wash); font-size: 0.875rem; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.status[data-tone="error"] { color: var(--bad); }
.status[data-tone="busy"]::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--ink); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- landing */

.landing { max-width: 640px; padding-top: clamp(48px, 10vh, 120px); }
.landing h1 { font-size: clamp(1.75rem, 4vw, 2.25rem); margin-bottom: 0.4em; }
.landing .lede { color: var(--muted); font-size: 1.0625rem; }
.landing-form { display: flex; gap: 8px; margin: 28px 0 10px; max-width: 420px; }
.landing-form input { font-size: 1rem; padding: 11px 14px; }
.landing-form .btn { padding: 0 16px; }
.hint { color: var(--faint); font-size: 0.875rem; }
.sample { margin-top: 64px; }
.sample h2, .recent h2, .facts-row h3 { font-size: 0.8125rem; font-weight: 500; color: var(--faint); letter-spacing: 0; }
.recent { margin-top: 48px; }
.recent ul { list-style: none; padding: 0; margin: 0; display: flex; gap: 6px 18px; flex-wrap: wrap; font-weight: 500; }
.facts-row { margin-top: 56px; display: grid; gap: 20px; }
.facts-row h3 { margin: 0 0 2px; color: var(--ink); font-size: 0.9375rem; font-weight: 600; }
.facts-row p { color: var(--muted); font-size: 0.9375rem; margin: 0; }

/* ---------------------------------------------------------------- profile + tabs */

.who { padding: 32px 0 24px; }
.who h1 { margin: 0 0 6px; overflow-wrap: anywhere; }
.who-line { display: flex; gap: 6px 22px; flex-wrap: wrap; color: var(--muted); font-size: 0.9375rem; margin: 0; }
.who-line b { color: var(--ink); font-weight: 600; }

.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { font: 500 0.9375rem var(--font); background: none; border: 0; color: var(--muted); padding: 10px 0 12px; cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }

.view { padding-top: 32px; }
.view-narrow { max-width: 720px; }
.view-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 32px; flex-wrap: wrap; margin-bottom: 20px; }
.view-head h2 { margin: 0; }
.view-head .lead { margin: 0; color: var(--muted); font-size: 0.9375rem; }
.view-head p { margin: 4px 0 0; color: var(--muted); font-size: 0.9375rem; }
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 0.875rem; color: var(--muted); }
select, input[type="number"] { font: inherit; font-size: 0.875rem; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }

/* ---------------------------------------------------------------- the list */

.list { list-style: none; margin: 0; padding: 0; }
.item { border-top: 1px solid var(--line); padding: 18px 0; }
.item:last-child { border-bottom: 1px solid var(--line); }
.item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.item-title { font-size: 1.0625rem; font-weight: 600; }
.item-chance { font-size: 1.0625rem; font-weight: 600; }
.item-meta { display: flex; gap: 4px 16px; flex-wrap: wrap; color: var(--muted); font-size: 0.875rem; margin-top: 2px; }
.item-meta .is-focus, .taglist li.is-focus { color: var(--blue-ink); }
.item-toggle { background: none; border: 0; padding: 0; margin-top: 8px; font: inherit; font-size: 0.8125rem; color: var(--faint); cursor: pointer; }
.item-toggle:hover, .item-toggle[aria-expanded="true"] { color: var(--ink); }
.item-body { padding-top: 12px; }
.item-body[hidden] { display: none; }
.zone-note { color: var(--muted); font-size: 0.875rem; margin: 16px 0 0; }

.reasons { margin: 0 0 14px; padding: 0 0 0 16px; color: var(--muted); font-size: 0.9375rem; display: grid; gap: 2px; }
.reasons li::marker { color: var(--faint); }
.reasons li[data-kind="focus"], .reasons li[data-kind="upsolve"] { color: var(--ink); }
.route-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* .route rows stay available to plugins */
.routes { list-style: none; margin: 0; padding: 0; }
.route { border-top: 1px solid var(--line); padding: 14px 0; display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: baseline; }
.route-grade { color: var(--muted); font-size: 0.9375rem; }
.route-grade span { display: none; }
.route-title { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.route-title h3 { margin: 0; font-size: 1rem; }
.route-id { color: var(--muted); margin-right: 8px; font-weight: 400; }
.chance strong { font-weight: 600; }
.taglist { display: flex; flex-wrap: wrap; gap: 2px 12px; margin: 2px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 0.875rem; }

/* ---------------------------------------------------------------- insights */

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 56px 64px; }
.panel { min-width: 0; }
.panel > h2 { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; font-size: 1rem; }
.panel-note { color: var(--muted); font-size: 0.9375rem; }
.span-all { grid-column: 1 / -1; }

figure { margin: 0; }
figure.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
figure.chart figcaption { color: var(--faint); font-size: 0.8125rem; margin-top: 8px; }
.chart text { font-family: var(--font); fill: var(--faint); font-size: 12px; }
.chart .axis line, .chart .axis path { stroke: var(--line); }

.topic-bars { list-style: none; padding: 0; margin: 0; }
.topic-row {
  display: grid; grid-template-columns: minmax(110px, 170px) minmax(0, 1fr) 52px; gap: 14px; align-items: center;
  width: 100%; padding: 7px 8px; margin: 0 -8px; background: none; border: 0; border-radius: 6px;
  font: inherit; font-size: 0.9375rem; color: inherit; text-align: left; cursor: pointer;
}
.topic-row:hover { background: var(--wash); }
.topic-row[aria-pressed="true"] { background: var(--wash); }
.topic-row[aria-pressed="true"] .topic-name { font-weight: 600; }
.topic-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-name mark { background: none; color: var(--blue-ink); }
.topic-track { position: relative; height: 4px; background: var(--line); border-radius: 2px; }
.topic-bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ink); border-radius: 2px; }
.topic-bar[data-focus] { background: var(--blue); }
.topic-bar[data-confidence="low"] { background: var(--faint); }
.topic-overall { position: absolute; top: -5px; bottom: -5px; width: 1px; background: var(--muted); }
.topic-num { text-align: right; line-height: 1.2; }
.topic-num b { font-weight: 500; }
.topic-num span { display: none; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.8125rem; color: var(--faint); margin: 12px 0 0; padding: 0; list-style: none; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 4px; display: inline-block; background: var(--ink); border-radius: 2px; }
.swatch-hatch { background: var(--faint); }
.swatch-dash { width: 1px; height: 12px; background: var(--muted); border-radius: 0; }

.inspect h3 { font-size: 1.25rem; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.facts, .stat-line { display: flex; gap: 12px 28px; flex-wrap: wrap; margin: 4px 0 20px; }
.facts div, .stat-line div { display: flex; flex-direction: column-reverse; }
.facts dt, .stat-line dt { font-size: 0.8125rem; color: var(--faint); }
.facts dd, .stat-line dd { margin: 0; font-size: 1.0625rem; font-weight: 600; }
.attempt-list { list-style: none; padding: 0; margin: 8px 0 0; font-size: 0.9375rem; }
.attempt-list li { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.attempt-list li > span:last-child { color: var(--muted); }
.mark-ok { color: var(--ok); }
.mark-no { color: var(--bad); }

details.table-toggle { margin-top: 8px; font-size: 0.8125rem; }
details.table-toggle summary { cursor: pointer; color: var(--faint); width: fit-content; }
details.table-toggle summary:hover { color: var(--ink); }
.table-wrap { max-height: 320px; overflow: auto; margin-top: 8px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table caption { text-align: left; color: var(--faint); padding: 4px 0; }
.data-table th, .data-table td { text-align: left; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); }
.data-table th { font-weight: 500; color: var(--muted); }

/* ---------------------------------------------------------------- plan */

.plan-top { display: grid; gap: 48px; max-width: 720px; }
.progress { margin: 4px 0 28px; }
.progress-bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin: 10px 0 6px; max-width: 320px; }
.progress-bar span { display: block; height: 100%; background: var(--ink); }
.progress p { margin: 0; color: var(--muted); font-size: 0.875rem; }
.progress p b { color: var(--ink); font-weight: 600; }

.week { list-style: none; padding: 0; margin: 0; }
.day { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.day:last-child { border-bottom: 1px solid var(--line); }
.day h3 { margin: 0; font-size: 0.9375rem; font-weight: 500; color: var(--muted); }
.day.is-today h3 { color: var(--ink); font-weight: 600; }
.day-items { display: grid; gap: 6px; min-width: 0; }
.day-empty { color: var(--faint); font-size: 0.9375rem; }
.slot { display: flex; justify-content: space-between; gap: 12px; font-size: 0.9375rem; }
.slot b { font-weight: 500; }
.slot span { color: var(--muted); white-space: nowrap; }
.slot.is-done b { text-decoration: line-through; color: var(--muted); }
.slot-solved b::before { content: "✓ "; color: var(--ok); }

.settings h2 { font-size: 1rem; }
.settings-grid { display: grid; gap: 24px; }
.settings fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.settings legend { font-weight: 600; font-size: 0.9375rem; margin-bottom: 8px; }
.settings .help { color: var(--faint); font-size: 0.8125rem; margin: 8px 0 0; }
.topic-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 16px; }
.topic-pick label { display: flex; gap: 8px; align-items: center; padding: 4px 0; cursor: pointer; font-size: 0.9375rem; }
.topic-pick input { width: 15px; height: 15px; accent-color: var(--ink); }
.topic-pick label span small { color: var(--faint); margin-left: 4px; }
.topic-pick input:disabled + span { color: var(--faint); }
.settings-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.settings-actions input { width: 72px; }

/* ---------------------------------------------------------------- plugins */

.plugin-list { list-style: none; padding: 0; margin: 0; max-width: 720px; }
.plugin-item { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; padding: 16px 0; border-top: 1px solid var(--line); }
.plugin-item h3 { margin: 0 0 2px; }
.plugin-item h3 small { color: var(--faint); font-weight: 400; }
.plugin-item p { margin: 0; color: var(--muted); font-size: 0.9375rem; }
.plugin-item .errors { color: var(--bad); }
.plugin-slot { margin-top: 56px; display: grid; gap: 40px; }
.plugin-frame > header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.plugin-frame > header h2 { margin: 0; font-size: 1rem; }
.plugin-frame > header small { color: var(--faint); font-size: 0.8125rem; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.875rem; color: var(--muted); }
.switch input { width: 16px; height: 16px; accent-color: var(--ink); }

/* ---------------------------------------------------------------- states */

.empty { padding: 32px 0; color: var(--muted); max-width: 60ch; }
.empty h2 { color: var(--ink); font-size: 1.0625rem; }
.skeleton { color: var(--faint); padding: 32px 0; font-size: 0.9375rem; }

.rk-newbie { color: var(--t-newbie); } .rk-pupil { color: var(--t-pupil); } .rk-specialist { color: var(--t-specialist); }
.rk-expert { color: var(--t-expert); } .rk-cm { color: var(--t-cm); } .rk-master { color: var(--t-master); } .rk-gm { color: var(--t-gm); }

@media (max-width: 600px) {
  .masthead { flex-wrap: wrap; }
  .handle-form { flex-basis: 100%; }
  .topic-row { grid-template-columns: 100px minmax(0, 1fr) 44px; gap: 10px; }
  .day { grid-template-columns: 48px minmax(0, 1fr); }
  .slot { flex-direction: column; gap: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Slow cross-fade when switching theme (only while switching, so normal use has no lag). */
.theme-fading, .theme-fading *, .theme-fading *::before, .theme-fading *::after {
  transition: background-color 600ms ease, color 600ms ease, border-color 600ms ease, fill 600ms ease, stroke 600ms ease !important;
}
