:root {
  /* surfaces + text */
  --bg: #f7f7f5;
  --panel2: #efefeb;
  --border: #deded8;
  --text: #232522;
  --dim: #656961;              /* 5.1:1 on --panel2 (was #737373 = 4.12:1) */
  --acc: #242823;
  --link: #345744;
  --on-acc: #fff;
  --field: #fff;
  --card: #ffffff;
  --topbar: #f7f7f5;
  --sel: #dce7dd;
  --note-bg: #242927; --note-fg: #f0f0e8; --note-dim: #bec3ba;
  --note-line: #4a514b; --note-accent: #e4e7dc; --note-ink: #242927;
  --hover: #f0f2ec;

  /* status: text colour, solid chip background, soft surface */
  --green: #15803d;
  --yellow: #a16207;
  --red: #dc2626;
  --green-solid: #15803d;
  --yellow-solid: #a16207;
  --magenta-solid: #7e22ce;
  --red-solid: #b91c1c;
  --neutral-solid: #52525b;
  --badge-fg: #fff;
  --ok-bg: #f2fbf5;    --ok-line: #bbe5c9;
  --warn-bg: #fffdf3;  --warn-line: #f0dfae;
  --err-bg: #fff5f4;   --err-line: #f5c6c2;

  /* statement notice banner */
  --notice-bg: #fff8e6; --notice-fg: #7a5b00; --notice-line: #f0dfae;

  /* ranking medals for problem solvers and contests */
  --rank1-bg: #f6c945; --rank1-fg: #5c430a; --rank1-line: #d9a821;
  --rank2-bg: #e2e8f0; --rank2-fg: #3d4b5e; --rank2-line: #b6c2d2;
  --rank3-bg: #f0c8a0; --rank3-fg: #6b3d16; --rank3-line: #d69a63;

  /* Google button keeps Google's own colours, per theme */
  --google-bg: #fff; --google-fg: #1f1f1f; --google-line: #dadce0;
  --google-hover: #f8faff; --google-hover-line: #c6d7f5;

  /* code highlighting */
  --tk-k: #7c3aed; --tk-s: #15803d; --tk-c: #6c736b;
  --tk-n: #b45309; --tk-f: #1d4ed8; --tk-p: #dc2626;

  /* type scale — one token per size, no more one-off px */
  --fs-2xs: 11px; --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px;
  --fs-base: 15px; --fs-lg: 16px; --fs-xl: 18px; --fs-2xl: 22px;
  --fs-3xl: 24px; --fs-stat: 30px; --fs-display: 82px;
  --lh-body: 1.7;              /* Thai needs room for ascenders/descenders */
  --lh-tight: 1.35;

  /* spacing + radii */
  --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --r-sm: 5px; --r-md: 8px; --r-lg: 10px; --r-pill: 999px;

  /* interaction */
  --t-fast: .15s ease;
  --focus: 2px solid var(--link);

  --brand-ring: #fff;      /* white backing for transparent brand PNGs, both themes */
  --mono: "JetBrains Mono", "Anuphan", ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: "Anuphan", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
}

/* Dark mode only redefines what actually has to change: every token that is a
 * colour gets a counterpart, so nothing falls back to a light-theme literal. */
[data-theme="dark"] {
  --bg: #111214;
  --panel: #111214;
  --panel2: #202225;
  --border: #33363a;
  --text: #ededE8;
  --dim: #a5aaa6;
  --acc: #edede7;
  --on-acc: #171a18;
  --link: #c7dec9;
  --field: #191b1d;
  --card: #191b1d;
  --topbar: #111214;
  --sel: #35473b;
  --note-bg: #1c201e; --note-fg: #f0f0e8; --note-dim: #bec3ba;
  --note-line: #454d46; --note-accent: #e4e7dc; --note-ink: #242927;
  --hover: #242a25;

  /* the status colours were never redefined: 3.79-4.10:1 on dark */
  --green: #4ade80;
  --yellow: #fbbf24;
  --red: #f87171;
  --ok-bg: #0e1a12;    --ok-line: #1e4a2c;
  --warn-bg: #1c1808;  --warn-line: #4a3c12;
  --err-bg: #1d1111;   --err-line: #4a2020;

  --notice-bg: #231a05; --notice-fg: #f0d48a; --notice-line: #6b5518;

  --google-bg: #131314; --google-fg: #e3e3e3; --google-line: #8e918f;
  --google-hover: #1f2020; --google-hover-line: #bdc1c6;

  --tk-k: #c4b5fd; --tk-s: #86efac; --tk-c: #9aa398;
  --tk-n: #fbbf24; --tk-f: #93c5fd; --tk-p: #f87171;

  --brand-ring: #fff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* buttons should use the page font, never the platform default */
button { font: inherit; }
::selection { background: var(--sel); }
button, a, input, select, textarea { transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast), opacity var(--t-fast); }
:focus-visible { outline: var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
.ic {
  width: 16px; height: 16px; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -3px; flex: none;
}
.ic-lg { width: 28px; height: 28px; }
.nav-link, .btn-primary, .btn-ghost, .submit-btn, .backlink, .ghost-btn {
  display: inline-flex; align-items: center; gap: 7px;
}
.icon-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 7px;
  padding: 5px 7px; cursor: pointer; color: var(--dim); line-height: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--text); }
/* score colors */
.s100 { color: var(--green); font-weight: 700; }
.smid { color: var(--yellow); font-weight: 700; }
.s0 { color: var(--dim); }
/* rank medals */
.rank {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  font-size: var(--fs-xs); font-weight: 700; font-family: var(--mono);
  background: var(--panel2); border: 1px solid var(--border); color: var(--dim);
}
.rank-1 { background: var(--rank1-bg); border-color: var(--rank1-line); color: var(--rank1-fg); }
.rank-2 { background: var(--rank2-bg); border-color: var(--rank2-line); color: var(--rank2-fg); }
.rank-3 { background: var(--rank3-bg); border-color: var(--rank3-line); color: var(--rank3-fg); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans);
  font-size: var(--fs-base); line-height: var(--lh-body);
  min-height: 100vh; display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* top nav */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 16px max(24px, calc((100vw - 1360px) / 2)); background: var(--topbar);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 600; letter-spacing: -.8px; font-size: var(--fs-xl); color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 9px; }
.brand-logo { width: 28px; height: 28px; border-radius: 7px; background: var(--card); flex: none; }
.logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark { display: inline-block; }
[data-theme="dark"] .brand-logo { background: transparent; }
.brand-acc { color: var(--dim); font-weight: 400; }
.brand-name { white-space: nowrap; }
.nav { display: flex; gap: 2px; }
.nav-link {
  color: var(--dim); text-decoration: none; font-size: var(--fs-md);
  padding: 7px 9px; border-radius: 3px;
}
.nav-link:hover { color: var(--text); background: var(--panel2); }
.nav-link.active { color: var(--text); font-weight: 600; background: var(--panel2); }
.nav-link .ic { display: none; }
.health { margin-left: 0; font-size: var(--fs-2xs); color: var(--dim); font-family: var(--mono); letter-spacing: .5px; }
.health.ok { color: var(--green); }
.auth { display: flex; gap: 8px; align-items: center; }
.signup-btn {
  background: var(--acc); color: var(--on-acc); border: 1px solid var(--acc);
  border-radius: var(--r-sm); padding: 7px 16px; font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.signup-btn:hover { opacity: .85; }
.google-btn {
  width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--google-bg); color: var(--google-fg); border: 1px solid var(--google-line);
  border-radius: var(--r-sm);
  padding: 10px 16px; font-size: var(--fs-md); font-weight: 500; cursor: pointer;
}
.google-btn:hover { background: var(--google-hover); border-color: var(--google-hover-line); box-shadow: var(--shadow); }
.google-logo { width: 20px; height: 20px; flex: 0 0 20px; object-fit: contain; }
.or-divider { display: flex; align-items: center; gap: 12px; color: var(--dim); font-size: var(--fs-xs); margin: 4px 0 12px; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
#user-chip { font-size: var(--fs-sm); font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.report-row select {
  border: 1px solid var(--border); border-radius: var(--r-sm); padding: 11px 10px;
  font-size: var(--fs-sm); background: var(--field); color: var(--text);
}
.report-row input[type="text"] {
  flex: 1; min-width: 180px; border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 8px 12px; font-size: var(--fs-sm); background: var(--field); color: var(--text);
}
.report-row input[type="text"]:focus { outline: none; border-color: var(--text); }
.report-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.report-item:last-child { border-bottom: none; }
/* clickable chips are real <button>s: without an explicit face they inherit the
 * user-agent button colour, which is light in one theme and dark in the other */
.tag-click {
  cursor: pointer; font: inherit;
  background: var(--panel2); border: 1px solid var(--border); color: var(--dim);
}
.tag-click:hover { border-color: var(--text); color: var(--text); }
/* tasks sidebar + cards */
.tasks-layout { display: grid; grid-template-columns: 190px 1fr; gap: 20px; align-items: start; }
.side-group { display: flex; flex-direction: column; gap: 2px; }
.side-btn {
  background: none; border: none; text-align: left; cursor: pointer;
  padding: 9px 12px; border-radius: var(--r-sm); font-size: var(--fs-md); color: var(--dim);
}
.side-btn:hover { color: var(--text); background: var(--panel2); }
.side-btn.active { background: var(--text); color: var(--bg); font-weight: 500; }
.side-head { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 0 6px; }
.side-head h3 { margin: 0; font-size: var(--fs-sm); }
.link-btn { background: none; border: none; cursor: pointer; font-size: var(--fs-xs); color: var(--dim); padding: 0; }
.link-btn:hover { color: var(--text); }
#tag-list { display: flex; flex-direction: column; gap: 1px; }
.tag-row {
  background: none; border: none; text-align: left; cursor: pointer;
  padding: 6px 12px; border-radius: 6px; font-size: var(--fs-md); color: var(--dim);
}
.tag-row:hover { color: var(--text); background: var(--panel2); }
.tag-row.on { color: var(--text); font-weight: 700; background: var(--panel2); }
.tag-more { color: var(--link); }
.task-list-head, .task-card { display: grid; grid-template-columns: 54px minmax(0, 1fr) 90px 145px; gap: 20px; align-items: center; }
.task-list-head { border-bottom: 1px solid var(--border); color: var(--dim); font-size: var(--fs-2xs); padding: 12px 16px; }
.task-list-head > :last-child { text-align: right; }
.task-card { padding: 24px 16px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; background: transparent; }
.task-card:hover { background: var(--hover); }
.tc-number { align-self: start; padding-top: 2px; font: 400 var(--fs-md) var(--mono); color: var(--dim); }
.tc-main { min-width: 0; }
.tc-title { font-size: var(--fs-lg); font-weight: 600; line-height: 1.5; }
.tc-title .problem-english { font-size: var(--fs-xs); }
.tc-code { font: 400 var(--fs-2xs) var(--mono); color: var(--dim); margin-top: 6px; overflow-wrap: anywhere; }
.tc-tags { margin-top: 8px; }
.tc-meta { margin-top: 8px; display: flex; gap: 10px; align-items: center; font-size: var(--fs-2xs); color: var(--dim); }
.tc-side { min-width: 0; font-size: var(--fs-xs); }
.score-wrap { display: flex; gap: 16px; align-items: center; justify-content: flex-end; }
.score-untried, .score-solved { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.score-untried { color: var(--dim); }
.score-solved { color: var(--green); }
.status-ring { width: 9px; height: 9px; border: 1px solid var(--border); border-radius: 50%; }
.score-bar { flex: 1; min-width: 90px; max-width: 150px; height: 6px; border-radius: 3px; background: var(--panel2); border: 1px solid var(--border); overflow: hidden; }
.score-fill { height: 100%; background: var(--link); border-radius: 3px; }
@media (max-width: 900px) {
  .tasks-layout { grid-template-columns: 1fr; }
  .side-group { flex-direction: row; }
  #tag-list { flex-direction: row; flex-wrap: wrap; }
}
#archive-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.archive-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 12px 0; }
.archive-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 16px 18px; cursor: pointer; box-shadow: var(--shadow);
}
.archive-card:hover { border-color: var(--dim); }
.archive-card:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.arch-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.arch-title { display: flex; align-items: center; gap: 8px; font-size: var(--fs-lg); font-weight: 700; min-width: 0; }
.arch-bar { flex: 1; max-width: 150px; height: 6px; border-radius: 3px; background: var(--panel2); border: 1px solid var(--border); overflow: hidden; }
.arch-fill { height: 100%; background: var(--link); border-radius: 3px; }
.arch-sub { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: var(--fs-xs); color: var(--dim); }
@media (max-width: 900px) {
  .archive-grid { grid-template-columns: 1fr; }
}
.settings-row { margin: 14px 0; max-width: 420px; }
.settings-row label { display: block; font-size: var(--fs-sm); font-weight: 600; margin-bottom: 6px; }
.settings-row input, .settings-row select {
  width: 100%; border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 9px 12px; font-size: var(--fs-md); background: var(--field); color: var(--text);
}
.settings-row input:focus, .settings-row select:focus { outline: none; border-color: var(--text); }

main { max-width: 1184px; width: 100%; margin: 0 auto; padding: 48px 36px 72px; flex: 1; }
.view { display: none; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* "pick up where you left off" card */
.resume {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 14px 18px; margin: 0 0 var(--sp-5); box-shadow: var(--shadow);
}
.resume-main { min-width: 0; }
.resume-title { font-weight: 700; margin-bottom: 2px; }

/* Home: a practice notebook, with one clear starting point. */
.hero { display: grid; grid-template-columns: 1.15fr 1fr; gap: 80px; align-items: center; padding: 40px 0 64px; }
.eyebrow { font: 500 var(--fs-2xs)/1.5 var(--mono); letter-spacing: .1em; color: var(--dim); margin: 0 0 16px; }
.hero-copy > .eyebrow { display: flex; align-items: center; gap: 14px; letter-spacing: 0; font-family: var(--sans); font-size: var(--fs-sm); }
.index-mark { display: inline-flex; padding: 4px 7px; border: 1px solid var(--border); font: 500 var(--fs-2xs) var(--mono); }
.hero h1 { margin: 0 0 24px; font-size: clamp(56px, 6vw, var(--fs-display)); font-weight: 600; line-height: 1.18; letter-spacing: -3px; }
.hero-em { color: var(--dim); }
.hero .lede { font-size: var(--fs-lg); color: var(--dim); line-height: 1.9; margin: 0 0 28px; }
.hero-btns { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.btn-primary { background: var(--acc); color: var(--on-acc); border: 1px solid var(--acc); padding: 12px 20px; border-radius: var(--r-sm); text-decoration: none; font-size: var(--fs-md); font-weight: 600; justify-content: center; }
.btn-primary span { margin-left: 18px; font-size: var(--fs-xl); }
.btn-primary:hover { opacity: .88; }
.hero-secondary, .text-link { color: var(--text); text-decoration: none; font-size: var(--fs-sm); display: inline-flex; align-items: center; gap: 16px; }
.hero-secondary:hover, .text-link:hover { text-decoration: underline; text-underline-offset: 5px; }
.btn-ghost { border: 1px solid var(--border); color: var(--text); text-decoration: none; padding: 10px 18px; border-radius: var(--r-sm); font-size: var(--fs-md); background: transparent; cursor: pointer; }
.btn-ghost:hover { background: var(--hover); border-color: var(--dim); }
.hero-languages { margin: 24px 0 0; display: flex; flex-wrap: wrap; gap: 12px; font: 400 var(--fs-xs) var(--mono); color: var(--dim); }
.hero-languages > span:first-child { font-family: var(--sans); margin-right: 4px; }
.practice-note { background: var(--note-bg); color: var(--note-fg); border: 1px solid var(--note-line); border-radius: 2px; transform: rotate(1deg); }
.note-top { display: flex; justify-content: space-between; align-items: center; padding: 20px 26px; border-bottom: 1px solid var(--note-line); }
.note-top .eyebrow { margin: 0; color: var(--note-dim); }
.note-index { font: 400 var(--fs-3xl) var(--mono); color: var(--note-dim); }
.note-content { padding: 28px 32px 26px; }
.note-label { color: var(--note-dim); font-size: var(--fs-xs); }
.note-content h2 { margin: 10px 0 12px; font-size: 30px; font-weight: 500; line-height: 1.5; letter-spacing: -.5px; }
.note-content p { font-size: var(--fs-sm); margin: 0 0 20px; color: var(--note-dim); }
.number-study { display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--note-line); border-bottom: 1px solid var(--note-line); }
.number-study span { font: 400 30px/2.2 var(--mono); text-align: center; }
.number-study .marked { color: var(--note-ink); background: var(--note-accent); }
.note-answer { display: flex; justify-content: space-between; gap: 16px; margin-top: 20px; font-size: var(--fs-xs); color: var(--note-dim); }
.note-answer strong { color: var(--note-fg); font: 500 var(--fs-xl) var(--mono); margin-left: 8px; }
.note-link { display: flex; justify-content: space-between; align-items: center; padding: 17px 26px; border-top: 1px solid var(--note-line); color: var(--note-fg); text-decoration: none; font-size: var(--fs-sm); }
.note-link:hover { background: var(--note-line); }
.home-ledger { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 28px 0; }
.ledger-intro .eyebrow { margin-bottom: 7px; }
.ledger-intro p:last-child { margin: 0; font-size: var(--fs-sm); color: var(--dim); }
.stat { padding-left: 28px; border-left: 1px solid var(--border); display: flex; flex-direction: column; justify-content: center; }
.stat-num { font: 500 var(--fs-stat)/1.3 var(--mono); letter-spacing: -1px; }
.stat-label { color: var(--dim); font-size: var(--fs-xs); margin-top: 9px; }
.home-start { padding: 64px 0 54px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 24px; }
.section-heading .eyebrow { margin-bottom: 8px; }
.section-heading h2 { margin: 0; font-size: 30px; font-weight: 500; letter-spacing: -.6px; }
.home-problems { border-top: 1px solid var(--border); }
.home-problem { display: grid; grid-template-columns: 60px 1fr 28px; gap: 12px; align-items: center; border-bottom: 1px solid var(--border); padding: 21px 8px; color: var(--text); text-decoration: none; }
.home-problem:hover { background: var(--hover); }
.home-problem-no { font: 400 var(--fs-lg) var(--mono); color: var(--dim); }
.problem-name { display: block; }
.problem-english { display: block; font-size: var(--fs-sm); font-weight: 400; color: var(--dim); margin-top: 2px; }
.home-problem .problem-name { font-size: var(--fs-lg); font-weight: 500; }
.home-problem .problem-english { display: inline; margin-right: 16px; }
.home-problem-topic { font: 400 var(--fs-2xs) var(--mono); color: var(--dim); }
.row-arrow { color: var(--dim); font-size: var(--fs-xl); }
.community-note { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 32px; background: var(--panel2); }
.community-note .eyebrow { margin-bottom: 8px; }
.community-note h2 { margin: 0 0 8px; font-size: var(--fs-2xl); font-weight: 500; }
.community-note p:last-child { margin: 0; font-size: var(--fs-sm); color: var(--dim); }
.community-note .btn-ghost { white-space: nowrap; }

/* pages */
.page-head { display: flex; align-items: baseline; gap: 14px; margin: 0 0 20px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 38px; font-weight: 500; letter-spacing: -1px; }
.dim { color: var(--dim); }
.meta { font-size: var(--fs-xs); color: var(--dim); font-family: var(--mono); }
.card { border-top: 1px solid var(--border); padding: 20px 0; min-width: 0; }
.table-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 0; overflow-x: auto; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: var(--fs-lg); font-weight: 600; }

/* filter */
.filterbar {
  display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap;
  background: transparent; border: none; border-radius: 0;
  padding: 0 0 24px; box-shadow: none; border-bottom: 1px solid var(--border);
}
.filterbar input[type="search"] {
  width: 100%; flex: 1; min-width: 140px; border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 11px 12px; font-size: var(--fs-md); background: var(--field); color: var(--text);
}
.filterbar input[type="search"]:focus { outline: none; border-color: var(--text); }
.filterbar select, .history-tools select {
  border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 10px;
  font-size: var(--fs-sm); background: var(--field); color: var(--text);
}

/* tables */
table.tests { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
table.tests th, table.tests td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--border); }
table.tests th {
  color: var(--dim); font-weight: 600; font-size: var(--fs-xs);
  white-space: nowrap;
}
table.tests td:last-child, table.tests th:last-child { text-align: right; }
table.tests td:last-child { padding-right: 20px; font-variant-numeric: tabular-nums; }
table.tests tbody tr:last-child td { border-bottom: none; }
.diff-tag {
  display: inline-block; font-size: var(--fs-2xs); font-weight: 600; border-radius: var(--r-pill);
  padding: 2px 10px; margin-right: 6px;
  background: var(--panel2); color: var(--dim); border: 1px solid var(--border);
}
.diff-easy { color: var(--green); border-color: var(--ok-line); background: var(--ok-bg); }
.diff-medium { color: var(--yellow); border-color: var(--warn-line); background: var(--warn-bg); }
.diff-hard { color: var(--red); border-color: var(--err-line); background: var(--err-bg); }
.tag-chip {
  display: inline-block; font-size: var(--fs-2xs); border-radius: var(--r-pill); padding: 2px 10px;
  margin: 1px 4px 1px 0; color: var(--dim);
  font-family: var(--mono);
}
.tag-chip::before { content: "#"; }

.badge {
  display: inline-block; min-width: 40px; text-align: center;
  font-family: var(--mono); font-weight: 600; font-size: var(--fs-2xs);
  border-radius: var(--r-pill); padding: 2px 10px; color: var(--badge-fg);
}
.b-AC { background: var(--green-solid); }
.b-WA, .b-RE, .b-CE { background: var(--red-solid); }
.b-TLE, .b-OLE { background: var(--yellow-solid); }
.b-MLE { background: var(--magenta-solid); }
.b-SKIP { background: var(--neutral-solid); }

/* task detail */
.backlink { display: inline-flex; align-items: center; gap: 6px; margin-bottom: var(--sp-4); color: var(--link); text-decoration: none; font-size: var(--fs-md); font-weight: 500; }
.backlink:hover { text-decoration: underline; }
.task-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); margin-bottom: 14px; flex-wrap: wrap; }
.task-head h2, .task-head h1 { margin: 0 0 4px; font-size: var(--fs-3xl); letter-spacing: -0.5px; }
.notice {
  margin-top: 10px; padding: 10px 14px; border-radius: var(--r-sm); font-size: var(--fs-sm);
  background: var(--notice-bg); border: 1px solid var(--notice-line); color: var(--notice-fg);
}
#pdf-frame { width: 100%; height: 88vh; min-height: 540px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--field); }
/* Thai has no case: uppercase + letter-spacing only made headings harder to read */
.pane-h { margin: var(--sp-5) 0 var(--sp-2); font-size: var(--fs-sm); color: var(--dim); font-weight: 600; }
.pane-h:first-of-type { margin-top: 4px; }
.score-box {
  text-align: right; border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 6px var(--sp-4); background: var(--card); min-width: 130px; box-shadow: var(--shadow);
}
.score-box span { display: block; font-size: var(--fs-2xs); color: var(--dim); }
.score-box strong { font-size: var(--fs-2xl); }
.tabbar { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.tab-btn {
  background: none; border: none; padding: 10px 18px; cursor: pointer;
  font-size: var(--fs-md); color: var(--dim); border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tab-btn:hover { color: var(--text); background: var(--panel2); border-radius: var(--r-sm) var(--r-sm) 0 0; }
.tab-btn.active { color: var(--text); font-weight: 700; border-bottom-color: var(--link); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.md { font-size: var(--fs-base); line-height: var(--lh-body); overflow-wrap: anywhere; }
.md h1 { font-size: var(--fs-2xl); margin: 1.2em 0 .5em; }
.md h2 { font-size: var(--fs-xl); margin: 1.2em 0 .5em; }
.md h3 { font-size: var(--fs-lg); margin: 1.2em 0 .5em; color: var(--text); }
.md pre {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--r-sm); padding: var(--sp-3) 14px; overflow-x: auto;
  font-family: var(--mono); font-size: var(--fs-xs);
}
.md code { font-family: var(--mono); background: var(--panel2); border: 1px solid var(--border); padding: 0 5px; border-radius: 4px; font-size: var(--fs-xs); }
.md pre code { background: none; border: none; padding: 0; }
.md ul { padding-left: 20px; }
.md li { margin: 3px 0; }

.lang-group { display: flex; gap: 2px; background: var(--panel2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 2px; }
.lang-btn {
  background: transparent; color: var(--dim); border: none; border-radius: 6px;
  padding: 5px 14px; cursor: pointer; font-size: var(--fs-sm);
}
.lang-btn.active { background: var(--field); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.dropzone {
  border: 1px dashed var(--border); border-radius: var(--r-sm);
  text-align: center; padding: var(--sp-5); margin: 14px 0 10px;
  cursor: pointer; font-size: var(--fs-sm); color: var(--dim); background: var(--field);
}
.dropzone:hover, .dropzone.over { border-color: var(--text); color: var(--text); background: var(--panel2); }
.dropzone p { margin: 4px 0; }
.file-chip {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 6px var(--sp-3); margin-bottom: 10px; font-size: var(--fs-xs);
  font-family: var(--mono);
}
.file-chip button { cursor: pointer; font-size: var(--fs-xs); background: none; border: none; color: var(--link); padding: 0; }
#file-clear { margin-left: auto; }
.hidden { display: none !important; }
#editor {
  width: 100%; min-height: 300px; resize: vertical;
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-family: var(--mono); font-size: var(--fs-xs); line-height: 1.6;
  padding: 14px; tab-size: 4;
}
#editor:focus { outline: none; border-color: var(--text); background: var(--field); }
.submit-row { display: flex; gap: 10px; margin-top: var(--sp-3); align-items: center; }
#draft-hint { margin-left: auto; font-size: var(--fs-xs); }
.ghost-btn {
  background: transparent; color: var(--dim);
  border: none; padding: var(--sp-2) 4px; cursor: pointer; font-size: var(--fs-sm);
  text-decoration: none;
}
.ghost-btn:hover { color: var(--text); }
.submit-btn {
  margin-left: auto; background: var(--acc); color: var(--on-acc);
  border: 1px solid var(--acc); border-radius: var(--r-sm); padding: 9px 28px;
  font-weight: 600; cursor: pointer; font-size: var(--fs-md);
}
.submit-btn:hover:not(:disabled) { opacity: .8; }
.submit-btn:disabled { opacity: 0.5; cursor: wait; }
.status { font-size: var(--fs-xs); margin-top: var(--sp-2); font-family: var(--mono); color: var(--dim); }
.status.bad { color: var(--red); }
.auth-card { max-width: 460px; }
.sep { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
tr.test-row { cursor: pointer; }
tr.test-row:hover td { background: var(--panel2); }
table.tests td.detail-cell:last-child { text-align: left; }
.detail-cell pre {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--r-sm); padding: 10px var(--sp-3); overflow-x: auto;
  font-size: var(--fs-xs); white-space: pre-wrap; margin: 6px 0;
  font-family: var(--mono);
}
.score-big { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.5px; }
.score-big.ok { color: var(--green); }
.score-big.bad { color: var(--red); }
/* "fix this first" line + the coloured diff */
.verdict-sum { margin: 10px 0 4px; font-size: var(--fs-md); line-height: 1.6; }
.verdict-sum.ok { color: var(--green); }
.verdict-sum.bad { color: var(--red); }
.diff-pre {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--r-sm); padding: 10px var(--sp-3); margin: 6px 0; overflow-x: auto;
  font-family: var(--mono); font-size: var(--fs-xs); line-height: 1.55; white-space: pre;
}
.diff-pre span { display: block; }
.d-add { color: var(--green); }
.d-del { color: var(--red); }
.d-hunk { color: var(--dim); }
.d-ctx { color: var(--text); }
.code-view { margin-top: 14px; }
.code-view summary { cursor: pointer; font-size: var(--fs-sm); color: var(--dim); }
.code-view summary:hover { color: var(--text); }
.code-view pre {
  background: var(--panel2); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: var(--sp-3) 14px; overflow-x: auto; font-size: var(--fs-xs); max-height: 420px;
  overflow-y: auto; font-family: var(--mono); white-space: pre;
}
.tk-k { color: var(--tk-k); font-weight: 600; }
.tk-s { color: var(--tk-s); }
.tk-c { color: var(--tk-c); font-style: italic; }
.tk-n { color: var(--tk-n); }
.tk-f { color: var(--tk-f); }
.tk-p { color: var(--tk-p); }

/* history */
.history-tools { display: flex; gap: var(--sp-2); align-items: center; margin-left: auto; flex-wrap: wrap; }
.mine-check { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--dim); }
#hist-stats { margin-bottom: var(--sp-3); }

.foot {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-5) 28px; border-top: 1px solid var(--border);
  font-size: var(--fs-xs); color: var(--dim);
}
.foot-brand { font-weight: 700; letter-spacing: 2px; font-size: var(--fs-xs); color: var(--text); display: inline-flex; align-items: center; gap: var(--sp-2); }
.foot-brand .brand-logo { width: 22px; height: 22px; border-radius: 6px; }
.foot p { margin: 0; }

/* ---- async judging status (spinner + live state) ---- */
#submit-status, #run-status { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.spinner {
  flex: none; width: 13px; height: 13px; margin-right: var(--sp-2);
  border: 2px solid var(--border); border-top-color: var(--link);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- hidden tests, playground + contest verdicts ---- */
.b-hidden, .b-ended { background: var(--neutral-solid); }
.b-OK, .b-running { background: var(--green-solid); }
.b-upcoming { background: var(--yellow-solid); }

/* ---- sample viewer / monospace io blocks (input, output, stdout, ids) ---- */
.sample-box { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 6px; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip-btn {
  font: inherit; font-size: var(--fs-xs); font-family: var(--mono);
  background: var(--panel2); color: var(--dim);
  border: 1px solid var(--border); border-radius: var(--r-pill);
  padding: 4px var(--sp-3); cursor: pointer;
}
.chip-btn:hover { color: var(--text); border-color: var(--text); }
.chip-btn.active { color: var(--text); border-color: var(--link); font-weight: 600; }
.io-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.io-block { min-width: 0; }
.io-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.io-title {
  font-size: var(--fs-2xs); color: var(--dim); font-family: var(--mono);
  overflow-wrap: anywhere;
}
.io-pre {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--r-sm); padding: 10px var(--sp-3); margin: 4px 0 0;
  font-family: var(--mono); font-size: var(--fs-xs); white-space: pre-wrap;
  overflow-wrap: anywhere; max-height: 340px; overflow: auto;
}
.icon-btn.copied { color: var(--green); border-color: var(--green); }

/* ---- playground (Run tab) ---- */
#run-input {
  width: 100%; min-height: 110px; resize: vertical;
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-family: var(--mono); font-size: var(--fs-xs); line-height: 1.6; padding: var(--sp-3);
  tab-size: 4;
}
#run-input:focus { outline: none; border-color: var(--text); background: var(--field); }
.run-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 6px; }

/* ---- contests ---- */
.tlink { color: var(--link); text-decoration: none; font-weight: 600; font-family: var(--mono); font-size: var(--fs-sm); }
.tlink:hover { text-decoration: underline; }

/* ---- admin tools ---- */
.mono-num { font-family: var(--mono); color: var(--text); }
.check-row { display: flex; align-items: center; gap: var(--sp-2); }
#plag-body, #ct-list { overflow-x: auto; }
#ct-problems { min-height: 170px; }
#run-btn { margin-left: 0; }
.sim-hi { color: var(--red); font-weight: 700; }
.sim-mid { color: var(--yellow); font-weight: 700; }
.sim-lo { color: var(--dim); }

/* press feedback: every clickable surface reacts on mousedown */
.btn-primary:active, .submit-btn:active:not(:disabled), .signup-btn:active,
.btn-ghost:active, .ghost-btn:active, .icon-btn:active, .chip-btn:active,
.lang-btn:active, .tab-btn:active, .side-btn:active, .tag-row:active,
.task-card:active, .archive-card:active, .tlink:active { transform: translateY(1px); }

@media (max-width: 900px) {
  .features { grid-template-columns: 1fr; }
  .feature + .feature { padding-left: 0; border-left: none; border-top: 1px solid var(--border); padding-top: 16px; }
  .hero h1 { font-size: var(--fs-stat); }
  main { padding: var(--sp-6) var(--sp-4) 48px; }
  .io-grid { grid-template-columns: 1fr; }
}

/* numeric problem id (#19) — shown before titles so numbers are scannable */
.pno {
  display: inline-block;
  min-width: 2.6em;
  margin-right: 6px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel2);
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.85em;
}

/* contest join bar (Register / countdown / participants) */
.join-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0 2px; }

/* Consistent flat surfaces and quiet active states. */
.score-fill, .arch-fill { background: var(--link); }
.tab-btn.active { border-bottom-width: 2px; }

/* inputs: visible focus ring on top of the border change */
.filterbar input[type="search"]:focus, .settings-row input:focus, .settings-row select:focus,
.report-row input[type="text"]:focus, #editor:focus, #run-input:focus {
  box-shadow: 0 0 0 3px var(--sel);
}

/* countdown badge breathes while a round is live */
.b-running { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .72; } }

/* quiet scrollbars that follow the theme */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--dim); }
::-webkit-scrollbar-track { background: transparent; }

/* small screens: scrollable nav, stacked cards */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; padding-bottom: 2px; }
  .nav-link { white-space: nowrap; }
  .health { margin-left: 0; }
  .tc-side { width: 100%; }
  .task-card { flex-direction: column; align-items: stretch; }
  .score-wrap { justify-content: flex-start; }
}

/* ================= interaction upgrade: palette, toast, skeleton ========= */
/* command palette (Ctrl/⌘K): fuzzy-jump to any problem */
.palette-overlay {
  position: fixed; inset: 0; z-index: 120; background: var(--topbar);
  backdrop-filter: blur(4px); display: flex; justify-content: center;
  padding: 12vh 16px 16px;
}
.palette-box {
  width: 100%; max-width: 560px; height: fit-content;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow); overflow: hidden;
}
#palette-input {
  width: 100%; border: none; border-bottom: 1px solid var(--border);
  background: var(--field); color: var(--text);
  padding: 14px 18px; font-size: var(--fs-lg); font-family: inherit;
}
#palette-input:focus { outline: none; }
.palette-list { max-height: 320px; overflow-y: auto; padding: 6px; }
.palette-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; cursor: pointer; text-align: left;
  padding: 9px 12px; border-radius: var(--r-sm); color: var(--text);
  font-size: var(--fs-md);
}
.palette-item .dim { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item.active { background: var(--panel2); }
.palette-hint { padding: 8px 14px; border-top: 1px solid var(--border); }

/* toasts: bottom-right stack, auto-dismiss */
#toast-stack {
  position: fixed; right: 16px; bottom: 16px; z-index: 130;
  display: flex; flex-direction: column; gap: 8px; max-width: min(360px, 90vw);
}
.toast {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 10px 14px; box-shadow: var(--shadow); font-size: var(--fs-sm);
  animation: toast-in .2s ease; cursor: pointer;
}
.toast.t-ok { border-color: var(--ok-line); }
.toast.t-err { border-color: var(--err-line); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* skeleton shimmer while lists load */
.skel { padding: 4px 0; }
.skel-line {
  height: 14px; border-radius: 6px; margin: 10px 0;
  background: linear-gradient(90deg, var(--panel2) 25%, var(--border) 50%, var(--panel2) 75%);
  background-size: 200% 100%; animation: skel 1.2s ease-in-out infinite;
}
@keyframes skel { to { background-position: -200% 0; } }

/* contest timeline: start → now → end */
.ct-track { height: 6px; border-radius: 3px; background: var(--panel2); border: 1px solid var(--border); overflow: hidden; margin-top: 8px; }
.ct-fill { height: 100%; background: var(--link); }
.ct-when { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; }

/* archive progress rings */
.ring { width: 46px; height: 46px; flex: none; }
.ring-bg { fill: none; stroke: var(--border); stroke-width: 3; }
.ring-fg { fill: none; stroke: var(--link); stroke-width: 3; stroke-linecap: round; }
.ring-lbl { font-size: var(--fs-2xs); font-weight: 700; fill: var(--text); text-anchor: middle; }
.arch-top .arch-bar { display: none; }

/* brand icons (fill-based) + social links */
.ic-fill { fill: currentColor; stroke: none; }
.social-row { display: flex; gap: 10px; align-items: center; margin-left: auto; }
.social-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 12px; color: var(--dim);
  border: 1px solid transparent;
}
.social-link:hover { color: var(--text); background: var(--panel2); border-color: var(--border); }
.social-link .brand-img { width: 24px; height: 24px; }
.about-links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.about-link {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 10px 18px; text-decoration: none; color: var(--text);
  font-size: var(--fs-md); font-weight: 600; background: var(--card);
}
.about-link:hover { border-color: var(--dim); transform: translateY(-1px); box-shadow: var(--shadow); }
.about-link .dim { font-weight: 400; }

/* user-supplied brand badges (PNG): round, theme-safe */
.brand-img { width: 18px; height: 18px; border-radius: 50%; flex: none; background: var(--brand-ring); }

/* production pass: skip link, meta chips, empty states */
.skip-link {
  position: fixed; top: -48px; left: 12px; z-index: 200;
  background: var(--acc); color: var(--on-acc); text-decoration: none;
  padding: 8px 16px; border-radius: var(--r-sm); font-size: var(--fs-sm);
  transition: top var(--t-fast);
}
.skip-link:focus { top: 12px; }
#task-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.meta-chip {
  font-size: var(--fs-2xs); font-family: var(--mono); color: var(--dim);
  border: 1px solid var(--border); border-radius: var(--r-pill);
  padding: 2px 10px; white-space: nowrap;
}
.empty-state { text-align: center; padding: 40px 16px; }
.empty-state p { color: var(--dim); margin: 8px 0 16px; }

/* production pass: sticky submit, statement code copy, meta chips handled in JS */
.submit-bar {
  position: sticky; bottom: 0; z-index: 5;
  background: var(--bg); padding: 10px 0;
  border-top: 1px solid var(--border);
}
.md h2 {
  padding-left: 12px; border-left: 4px solid var(--link);
  margin-top: 1.6em;
}
.code-copy-wrap { position: relative; }
.code-copy-wrap pre { margin: 0; }
.code-copy {
  position: absolute; top: 8px; right: 8px;
  background: var(--field);
}

/* Shared shell and compact work surfaces. */
input, select, textarea { font-family: inherit; }
.quick-search { margin-left: auto; display: flex; align-items: center; gap: 8px; background: transparent; color: var(--dim); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 7px 9px; cursor: pointer; font-size: var(--fs-xs); }
.quick-search kbd { border: 1px solid var(--border); border-radius: 3px; padding: 0 4px; font: 400 var(--fs-2xs)/1.6 var(--mono); margin-left: 12px; }
.health { white-space: nowrap; }
.health.ok::before { content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--green); margin-right: 5px; vertical-align: 2px; }
.nav { min-width: 0; }
.page-head { margin-bottom: 32px; }
.page-head .eyebrow { margin-bottom: 6px; }
.page-head p.dim { margin: 8px 0 0; font-size: var(--fs-sm); }
.heading-period { color: var(--dim); }
.problem-search { display: flex; align-items: center; flex: 1; min-width: 220px; background: var(--field); border: 1px solid var(--border); border-radius: var(--r-sm); padding-left: 14px; color: var(--dim); }
.filterbar .problem-search input { border: none; background: transparent; outline: none; box-shadow: none; min-width: 0; }
.problem-search:focus-within { outline: var(--focus); outline-offset: 2px; }
.filterbar .mine-check { font-size: var(--fs-xs); margin-left: 8px; }
.tasks-layout { grid-template-columns: 176px minmax(0, 1fr); gap: 32px; margin-top: 24px; }
.side { position: sticky; top: 100px; }
.side-head { margin: 0 0 12px; }
.side-head h3 { font-weight: 500; }
.tag-row { font-size: var(--fs-xs); padding: 7px 12px; }
.tag-row.on { background: var(--hover); box-shadow: inset 2px 0 var(--link); }
.diff-tag { background: transparent; border: none; padding: 0; border-radius: 0; font-family: var(--mono); font-size: var(--fs-2xs); }
.diff-tag::before { content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 2px; }
.tag-chip { padding: 0; margin: 1px 10px 1px 0; font-size: 10px; }
.task-head { margin: 8px 0 28px; }
.task-head h2, .task-head h1 { font-size: 34px; font-weight: 500; line-height: var(--lh-tight); }
.task-head .problem-english { margin-top: 9px; font-size: var(--fs-lg); }
.task-number { display: block; margin-bottom: 20px; font: 400 var(--fs-xs)/1.7 var(--mono); color: var(--dim); letter-spacing: .04em; overflow-wrap: anywhere; }
.task-number > span { letter-spacing: 0; font-size: var(--fs-2xs); }
#task-meta { margin-top: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#task-meta .meta-chip { margin: 0; border-radius: 3px; }
.statement-open { display: inline-block; margin-top: 14px; font-size: var(--fs-xs); color: var(--link); text-underline-offset: 4px; }
.score-box { border: 0; border-left: 1px solid var(--border); border-radius: 0; padding: 4px 0 4px 24px; box-shadow: none; background: transparent; margin-top: 38px; }
.score-box strong { display: block; font: 500 var(--fs-stat)/1.4 var(--mono); }
.tabbar { border-bottom-width: 1px; gap: 12px; flex-wrap: nowrap; overflow-x: auto; }
.tab-btn { white-space: nowrap; padding: 12px 8px; margin-bottom: 0; border-bottom-width: 2px; }
.tab-btn.active { border-bottom-color: var(--text); }
#pane-statement { border: 0; padding-top: 0; }
#pane-statement > .card-head { margin: 20px 0 14px; }
#pane-statement > .card-head h2 { font-size: var(--fs-xs); color: var(--dim); font-weight: 400; }
#pdf-frame { border-radius: 2px; height: 80vh; }
#task-body { max-width: 800px; margin: 0 auto; padding: 24px; background: var(--card); border: 1px solid var(--border); }
#editor { font-size: var(--fs-sm); line-height: 1.85; min-height: 380px; }
.dropzone { padding: 16px; }
.dropzone .ic-lg { width: 20px; height: 20px; }
.submit-bar { flex-wrap: wrap; }
.auth-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md); padding: 28px; }
.foot { flex-wrap: wrap; padding: 24px max(24px, calc((100vw - 1112px) / 2)); gap: 20px; }
.foot-brand { letter-spacing: -.3px; font-size: var(--fs-lg); }
.foot > p:last-child { margin-left: auto; }
.archive-card:hover { background: var(--hover); }
.table-card, .archive-card, .resume { box-shadow: none; }
@media (max-width: 1180px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 24px 0; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; padding-bottom: 12px; }
  .nav-link { white-space: nowrap; }
  .hero { gap: 40px; }
  .quick-search { margin-left: auto; }
}
@media (max-width: 900px) {
  .hero { gap: 28px; grid-template-columns: 1fr 1fr; padding-top: 24px; }
  .hero h1 { font-size: 60px; }
  .hero .lede { font-size: var(--fs-md); }
  .note-content { padding: 22px; }
  .note-content h2 { font-size: var(--fs-3xl); }
  .tasks-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .side { position: static; }
  .side .sep { display: none; }
  .side-head { margin-top: 20px; }
  .side-group { gap: 8px; }
  #tag-list { flex-direction: row; flex-wrap: wrap; }
  .task-card { align-items: center; }
  .tc-side { width: auto; }
  .score-wrap { justify-content: flex-end; }
}
@media (max-width: 640px) {
  main { padding: 28px 20px 48px; }
  .topbar { padding: 12px 16px 0; gap: 10px; }
  .brand { font-size: var(--fs-lg); gap: 6px; letter-spacing: -.7px; }
  .brand-logo { width: 24px; height: 24px; }
  .health, .quick-search span, .quick-search kbd { display: none; }
  .quick-search { padding: 6px; border: none; }
  .auth { gap: 8px; }
  .signup-btn { display: none; }
  #login-btn { font-size: var(--fs-xs); white-space: nowrap; }
  #user-chip { max-width: 80px; font-size: var(--fs-xs); }
  .nav { gap: 8px; }
  .nav-link { font-size: var(--fs-sm); padding: 7px 9px; }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 40px; padding: 16px 0 40px; }
  .hero h1 { font-size: clamp(54px, 13vw, 72px); letter-spacing: -2px; }
  .hero .lede { font-size: var(--fs-base); }
  .hero-btns { gap: 20px; }
  .hero-copy > .eyebrow { font-size: var(--fs-xs); }
  .hero-languages { gap: 9px; font-size: var(--fs-2xs); }
  .practice-note { transform: none; }
  .note-content { padding: 24px; }
  .note-content h2 { font-size: 28px; }
  .home-ledger { grid-template-columns: repeat(3, 1fr); gap: 20px 0; padding: 24px 0; }
  .ledger-intro { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
  .ledger-intro .eyebrow { margin: 0; }
  .ledger-intro p:last-child { font-size: var(--fs-xs); }
  .ledger-intro br { display: none; }
  .stat { padding-left: 16px; }
  .stat:nth-child(2) { padding-left: 0; border: 0; }
  .stat-num { font-size: var(--fs-3xl); }
  .stat-label { font-size: 10px; }
  .home-start { padding: 40px 0; }
  .section-heading h2 { font-size: var(--fs-2xl); }
  .section-heading .text-link { font-size: var(--fs-xs); gap: 8px; }
  .home-problem { grid-template-columns: 34px minmax(0, 1fr) 16px; padding: 20px 0; }
  .home-problem .problem-name { font-size: var(--fs-base); }
  .home-problem-topic { display: block; margin-top: 6px; }
  .community-note { padding: 24px; align-items: flex-start; flex-direction: column; }
  .page-head h2 { font-size: 32px; }
  .filterbar { gap: 10px; }
  .problem-search { flex-basis: 100%; min-width: 0; }
  .filterbar select { flex: 1; min-width: 0; font-size: var(--fs-xs); padding: 10px 6px; }
  .filterbar .mine-check { margin-left: 0; }
  .task-list-head { display: none; }
  .task-card { grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; padding: 20px 0; }
  .tc-title { font-size: var(--fs-base); }
  .tc-difficulty { grid-column: 2; }
  .tc-side { grid-column: 3; grid-row: 1 / 3; font-size: 10px; }
  .tc-side .row-arrow { display: none; }
  .tc-tags { display: flex; flex-wrap: wrap; }
  .tc-number { font-size: var(--fs-xs); }
  .score-wrap { gap: 0; }
  .task-head { gap: 20px; }
  .task-head h2, .task-head h1 { font-size: 27px; overflow-wrap: anywhere; }
  .score-box { margin-top: 0; min-width: 0; border: 0; padding: 0; text-align: left; }
  .score-box strong { font-size: var(--fs-2xl); }
  .tabbar { gap: 12px; }
  .tab-btn { font-size: var(--fs-sm); padding: 10px 4px; }
  .io-grid { grid-template-columns: minmax(0, 1fr); }
  #task-body { padding: 18px; }
  #pdf-frame { height: 65vh; min-height: 400px; }
  .foot { padding: 24px 20px; gap: 12px; }
  .foot > p { flex-basis: 100%; }
  .foot > p:last-child { margin-left: 0; }
  .auth-card { padding: 20px; }
  .submit-row { flex-wrap: wrap; }
}

.view h1[tabindex="-1"]:focus, .view h2[tabindex="-1"]:focus { outline: none; }
.cookie-notice { position: fixed; right: 24px; bottom: 24px; z-index: 90; width: min(400px, calc(100vw - 32px)); background: var(--card); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: var(--r-md); padding: 24px; max-height: calc(100dvh - 48px); overflow-y: auto; }
.cookie-notice .eyebrow { margin-bottom: 8px; }
.cookie-notice h2 { font-size: var(--fs-xl); margin: 0 0 10px; font-weight: 500; }
.cookie-notice p:not(.eyebrow) { font-size: var(--fs-sm); color: var(--dim); margin: 8px 0; line-height: 1.8; }
.cookie-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; gap: 16px; }
.cookie-actions .submit-btn { margin: 0; font-size: var(--fs-xs); padding: 9px 20px; }
.cookie-details { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 8px; }
.cookie-notice strong { color: var(--text); font-weight: 500; }
.privacy-settings { display: flex; align-items: start; justify-content: space-between; gap: 20px; padding: 24px 0; border-top: 1px solid var(--border); }
.privacy-settings h3 { font-size: var(--fs-lg); font-weight: 500; margin: 0 0 8px; }
.privacy-settings p { font-size: var(--fs-sm); color: var(--dim); margin: 6px 0; }
.privacy-settings .btn-ghost { flex: none; }
@media (max-width: 640px) {
  .cookie-notice { bottom: 16px; right: 16px; padding: 20px; }
  .privacy-settings { flex-direction: column; }
}
.tag-disclosure > summary { display: none; cursor: pointer; font-size: var(--fs-sm); padding: 14px 0; list-style: none; }
.tag-disclosure > summary::-webkit-details-marker { display: none; }
.tag-disclosure > summary::after { content: "+"; float: right; font-family: var(--mono); color: var(--dim); }
.tag-disclosure[open] > summary::after { content: "−"; }
@media (max-width: 900px) {
  .tag-disclosure > summary { display: block; border-bottom: 1px solid var(--border); }
  .tag-disclosure .side-head { margin-top: 14px; }
}
#task-body > h1:first-child { display: none; }
#task-body { line-height: 1.95; padding: 28px 40px; }
#task-body h2 { font-weight: 600; margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); }
#task-body p { margin: 12px 0; }
#task-body pre { font-size: var(--fs-sm); line-height: 1.8; }
@media (max-width: 640px) {
  #task-body { padding: 20px; }
}
