/* ============================================================================
   CodeJudge's look: a warm dark theme and a warm light one, one red for the
   main action, gold for links in the dark, Geologica for text and JetBrains
   Mono for code, square corners. The variable names are the ones every page
   and script already use.
   ============================================================================ */

@import url('/fonts/fonts.css');

/* ── Light ──────────────────────────────────────────────────────────────────── */
:root {
  --bg: #f4ecdd;
  --bg2: #fbf6ec;
  --bg3: #efe5d3;
  --sunk: #ebe0cc;
  --border: #ddd0b8;
  --border2: #c9b89c;
  --text: #22180f;
  --text2: #5b4a3b;
  --text3: #85725f;
  --accent: #a3302b;          /* text, borders, active states */
  --accent-h: #8f2924;
  --accent-dim: rgba(163, 48, 43, 0.1);
  --primary: #a3302b;         /* filled buttons */
  --primary-h: #8f2924;
  --primary-ink: #fff8ee;
  --link: #9a2a25;
  --focus: #25325f;
  --success: #3b7531;
  --success-dim: rgba(59, 117, 49, 0.11);
  --error: #b3291f;
  --error-dim: rgba(179, 41, 31, 0.09);
  --warn: #8d6110;
  --warn-dim: rgba(141, 97, 16, 0.11);
  --info: #25427e;
  --info-dim: rgba(37, 66, 126, 0.09);
  --chart: #3f609b;             /* one calm colour for every chart bar */
  --easy: #3b7531;
  --medium: #8d6110;
  --hard: #b3291f;
  --radius: 6px;
  --radius-sm: 3px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 18px 40px -26px rgba(60, 30, 10, 0.45);
  --code-bg: #fffaf1;
  --code-text: #2a1d14;

  /* fixed colours, the same in both themes */
  --red: #a3302b;
  --wine: #6c2027;
  --navy: #25325f;
  --gold: #dba43a;
  --cream: #eee1c4;
  --ink: #2a1c17;
  --leaf: #4e7b45;
  --sky: #8eb0cc;
  --teal: #2d7671;

  --font: 'Geologica', 'Segoe UI', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

/* ── Dark ───────────────────────────────────────────────────────────────────── */
html.dark {
  --bg: #15100d;
  --bg2: #1c1511;
  --bg3: #241b16;
  --sunk: #100c0a;
  --border: #34291f;
  --border2: #4a3a2e;
  --text: #f1e7d3;
  --text2: #c7b79f;
  --text3: #93826d;
  --accent: #e9b552;
  --accent-h: #f2c56c;
  --accent-dim: rgba(233, 181, 82, 0.13);
  --chart: #8eb0cc;
  --primary: #b3362f;
  --primary-h: #c53f37;
  --primary-ink: #fff4e6;
  --link: #e9b552;
  --focus: #e9b552;
  --success: #86b96f;
  --success-dim: rgba(134, 185, 111, 0.13);
  --error: #ec6a56;
  --error-dim: rgba(236, 106, 86, 0.13);
  --warn: #e3ae4a;
  --warn-dim: rgba(227, 174, 74, 0.13);
  --info: #8eb0cc;
  --info-dim: rgba(142, 176, 204, 0.13);
  --easy: #86b96f;
  --medium: #e3ae4a;
  --hard: #ec6a56;
  --shadow: 0 1px 0 rgba(255, 240, 220, 0.04) inset, 0 18px 50px -24px rgba(0, 0, 0, 0.7);
  --code-bg: #110d0b;
  --code-text: #eadfca;
  color-scheme: dark;
}

/* ── Base ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-optical-sizing: auto;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link); text-decoration: underline; text-underline-offset: 0.18em; }
img { max-width: 100%; }
input, textarea, select, button { font-family: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--gold); color: #1c130e; }
[hidden] { display: none !important; }

h1, h2, h3, h4 { letter-spacing: -0.02em; line-height: 1.15; text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 3vw, 2.6rem); font-weight: 780; letter-spacing: -0.035em; }
h2 { font-size: 1.5rem; font-weight: 720; }
h3 { font-size: 1.2rem; font-weight: 680; }
h4 { font-size: 1rem; font-weight: 650; }
p { text-wrap: pretty; }

.text-muted { color: var(--text2); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.muted { color: var(--text3); }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.container { max-width: 1240px; margin: 0 auto; padding: 0 clamp(16px, 3.5vw, 40px); }
.page { padding: clamp(1.75rem, 4vw, 3rem) 0 5rem; }

/* A page's title: big, tight, with its lead underneath. */
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem 2rem; margin-bottom: 2rem; }
.page-head h1 { font-size: clamp(2.2rem, 4.6vw, 3.6rem); line-height: 1; letter-spacing: -0.045em; font-weight: 790; }
.page-head p { color: var(--text2); max-width: 52ch; margin-top: 0.6rem; }

/* ── Navigation ─────────────────────────────────────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--border);
}
.navbar .container { display: flex; align-items: center; gap: 1.75rem; height: 62px; }
.logo {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-size: 1.15rem; font-weight: 760; letter-spacing: -0.03em;
  color: var(--text) !important; white-space: nowrap; text-decoration: none !important;
}
/* the judge from sir's logo (2026-11-26); the word stays text so it follows the theme */
.logo::before { content: ''; flex: none; width: 40px; height: 40px; background: url(/img/logo-mark.svg) center / contain no-repeat; }
.logo-judge { color: #8b5cf6; }
.nav-links { display: flex; gap: 2px; flex: 1; }
.nav-links a {
  position: relative; padding: 0.45rem 0.7rem; border-radius: var(--radius-sm);
  color: var(--text2); font-size: 0.94rem; font-weight: 500; text-decoration: none;
  transition: color 0.15s, background-color 0.15s;
}
.nav-links a:hover { color: var(--text); background: var(--bg3); text-decoration: none; }
.nav-links a.active { color: var(--text); }
/* the page you are on is underlined */
.nav-links a.active::after { content: ''; position: absolute; left: 0.7rem; right: 0.7rem; bottom: -1px; height: 2px; background: var(--accent); }
.nav-user { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.nav-username {
  display: inline-flex; align-items: center; gap: 0.5rem;
  color: var(--text); font-size: 0.94rem; font-weight: 600; padding: 0.25rem 0.6rem 0.25rem 0.25rem;
  border-radius: var(--radius-sm); text-decoration: none;
}
.nav-username:hover { background: var(--bg3); text-decoration: none; color: var(--text); }
.nav-username .av { width: 26px; height: 26px; }
.nav-toggle {
  display: none; margin-left: auto; width: 38px; height: 38px; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--border2); border-radius: var(--radius-sm); color: var(--text); cursor: pointer; font-size: 0;
}
.nav-toggle svg, .icon-sw svg { width: 18px; height: 18px; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  min-height: 40px; padding: 0 1rem;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 0.94rem; font-weight: 600; letter-spacing: -0.005em; line-height: 1.2;
  cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.1s var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn-primary {
  background: var(--primary); color: var(--primary-ink); border-color: var(--primary);
  box-shadow: 0 -2px 0 rgba(0, 0, 0, 0.22) inset;   /* a heavier lower edge */
}
.btn-primary:hover:not(:disabled) { background: var(--primary-h); border-color: var(--primary-h); color: var(--primary-ink); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border2); }
.btn-outline:hover:not(:disabled) { color: var(--text); border-color: var(--text3); background: var(--bg3); }
.btn-danger { background: transparent; color: var(--error); border-color: color-mix(in srgb, var(--error) 55%, transparent); }
.btn-danger:hover:not(:disabled) { background: var(--error-dim); color: var(--error); border-color: var(--error); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
html.dark .btn-success { color: #10140c; }
.btn-success:hover:not(:disabled) { filter: brightness(1.08); }
.btn-sm { min-height: 32px; padding: 0 0.7rem; font-size: 0.84rem; }
.btn-lg { min-height: 50px; padding: 0 1.4rem; font-size: 1.02rem; }
.btn-full { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
/* EN / RU / AZ in the top bar (js/i18n.js) */
.lang-switch { min-height: 32px; padding: 0 0.35rem; font: inherit; font-size: 0.8rem; font-weight: 600;
  color: var(--text); background: transparent; border: 1px solid var(--border2); border-radius: var(--radius-sm); cursor: pointer; }
.lang-switch:hover { border-color: var(--text3); background: var(--bg3); }
.lang-switch option { color: var(--text); background: var(--bg2); }
.lang-switch-menu { display: none; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.card-sm { padding: 1rem; }
.card-hover { cursor: pointer; transition: border-color 0.15s, transform 0.2s var(--ease); }
.card-hover:hover, .card-hover:focus-visible { border-color: var(--text3); }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.15rem; }
.form-label { display: block; font-size: 0.9rem; font-weight: 600; color: var(--text); margin-bottom: 0.4rem; }
.form-control {
  width: 100%; min-height: 42px;
  background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius-sm);
  color: var(--text); padding: 0.55rem 0.8rem; font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
html.dark .form-control { background: var(--sunk); }
.form-control:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.form-control::placeholder { color: var(--text3); }
textarea.form-control { min-height: 120px; resize: vertical; line-height: 1.5; }
.form-error { font-size: 0.85rem; color: var(--error); margin-top: 0.35rem; }
select.form-control, select.lang-select {
  cursor: pointer; appearance: none; padding-right: 2.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%2393826d' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.7rem center; background-size: 12px;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 0.35em;
  padding: 0.18rem 0.5rem; border-radius: var(--radius-sm);
  font-size: 0.78rem; font-weight: 650; letter-spacing: 0; line-height: 1.4; white-space: nowrap;
}
/* verdicts carry a small square before the word */
.badge-success::before, .badge-error::before, .badge-warning::before, .badge-info::before { content: ''; width: 7px; height: 7px; background: currentColor; flex: none; }
.badge-easy, .badge-success { background: var(--success-dim); color: var(--success); }
.badge-medium, .badge-warning { background: var(--warn-dim); color: var(--warn); }
.badge-hard, .badge-error { background: var(--error-dim); color: var(--error); }
.badge-info { background: var(--info-dim); color: var(--info); }
.badge-muted { background: var(--bg3); color: var(--text3); }
.badge-accent { background: var(--accent-dim); color: var(--accent); }

/* problem rating: five tiers, five colours */
.rating { display: inline-flex; align-items: baseline; gap: 1px; padding: 0.14rem 0.45rem; border-radius: var(--radius-sm); font-size: 0.8rem; font-weight: 700; font-variant-numeric: tabular-nums; border: 1px solid currentColor; }
.rating small { font-size: 0.72em; font-weight: 500; opacity: 0.65; }
.rating.r1 { color: var(--success); }
.rating.r2 { color: #2d7671; }
html.dark .rating.r2 { color: #6fb6ad; }
.rating.r3 { color: var(--warn); }
.rating.r4 { color: var(--error); }
.rating.r5 { color: #5b3a8a; }
html.dark .rating.r5 { color: #b79ae0; }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg2); }
table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
thead tr { background: transparent; }
th {
  text-align: left; padding: 0.7rem 1rem; font-weight: 600; color: var(--text3); font-size: 0.82rem;
  border-bottom: 1px solid var(--border2); white-space: nowrap;
}
td { padding: 0.72rem 1rem; border-bottom: 1px solid var(--border); color: var(--text); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg3); }
tbody tr.highlight { background: var(--accent-dim); }

/* ── Stats ──────────────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; border-block: 1px solid var(--border); }
.stat-card { padding: 1rem 1.2rem; display: flex; flex-direction: column-reverse; border-left: 1px solid var(--border); }
.stat-card:first-child { border-left: 0; padding-left: 0; }
.stat-card .stat-value { font-size: clamp(1.6rem, 2.6vw, 2.1rem); font-weight: 740; letter-spacing: -0.035em; line-height: 1.1; color: var(--text); font-variant-numeric: tabular-nums; }
.stat-card .stat-label { font-size: 0.86rem; color: var(--text3); margin-top: 0.15rem; }

/* ── Sign-in page ───────────────────────────────────────────────────────────── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2.5rem clamp(16px, 4vw, 48px); }
.auth-box { width: 100%; max-width: 400px; }
.auth-logo { margin-bottom: 2rem; }
.auth-logo .logo-text { font-size: clamp(2rem, 3.4vw, 2.6rem); font-weight: 790; letter-spacing: -0.045em; color: var(--text); line-height: 1.05; }
.auth-logo .logo-sub { color: var(--text2); font-size: 1rem; margin-top: 0.5rem; }
.auth-tabs { display: flex; border-bottom: 1px solid var(--border2); margin-bottom: 1.6rem; gap: 1.25rem; }
.auth-tab {
  position: relative; padding: 0.55rem 0; cursor: pointer; font-size: 1rem; font-weight: 600;
  color: var(--text3); border: none; background: transparent; margin-bottom: -1px; border-bottom: 2px solid transparent;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.active { color: var(--text); border-bottom-color: var(--primary); }
.auth-form { display: none; }
.auth-form.active { display: block; }

/* ── Problem list ───────────────────────────────────────────────────────────── */
.filter-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 1.4rem; }
.search-input {
  flex: 1; min-width: 220px; min-height: 42px;
  background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius-sm);
  color: var(--text); padding: 0.55rem 0.9rem 0.55rem 2.3rem; font-size: 0.95rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2393826d' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='m16 16 4.5 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 0.75rem center; background-size: 16px;
}
html.dark .search-input { background-color: var(--sunk); }
.search-input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.filter-btn, .status-filter, .sort-filter {
  min-height: 36px; padding: 0 0.85rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border2); background: transparent; color: var(--text2);
  cursor: pointer; font-size: 0.88rem; font-weight: 550; transition: all 0.15s;
}
.filter-spacer { flex: 1; }
.filter-btn:hover, .status-filter:hover, .sort-filter:hover { color: var(--text); border-color: var(--text3); }
.filter-btn.active, .status-filter.active, .sort-filter.active { background: var(--text); border-color: var(--text); color: var(--bg); }
.question-row td:first-child { font-weight: 600; }
.question-row:hover { cursor: pointer; }

/* ── Problem page ───────────────────────────────────────────────────────────── */
.question-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
.question-panel { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.panel-header {
  padding: 0.65rem 1rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; background: var(--bg2);
}
.panel-header h4 { font-size: 0.92rem; color: var(--text); font-weight: 650; }
.panel-body { padding: 1.4rem 1.5rem; }
.question-meta { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin: 0.8rem 0 1.2rem; }
.question-description { font-size: 1.04rem; line-height: 1.68; color: var(--text); }
.question-description p + p { margin-top: 0.8rem; }

/* statement maths, drawn by js/statement-format.js */
.stmt var { font-family: KaTeX_Math, 'STIX Two Math', 'Cambria Math', 'Times New Roman', serif; font-style: italic; font-size: 1.1em; padding: 0 0.04em; }
.stmt sub, .stmt sup { font-size: 0.72em; line-height: 0; }
.stmt sub var, .stmt sup var { font-size: 1.1em; }
.stmt-h { font-weight: 700; font-size: 1rem; margin: 1.3rem 0 0.4rem; color: var(--text); }
.stmt-h:first-child { margin-top: 0; }
.stmt .katex { font-size: 1.08em; }
.stmt .katex-display { margin: 0.6rem 0; overflow-x: auto; overflow-y: hidden; }
.stmt-tex { font-family: var(--mono); font-size: 0.85em; }
.question-description pre { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.9rem; overflow-x: auto; font-size: 0.88rem; margin: 0.75rem 0; }
.question-description h3, .question-description h4 { margin: 1.2rem 0 0.45rem; }

.example-box { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.75rem 0.9rem; margin: 0.35rem 0; }
.example-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.3rem; }
.example-label { font-size: 0.84rem; font-weight: 600; color: var(--text3); }
.copy-btn { font-size: 0.78rem; padding: 0.15rem 0.55rem; border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent; color: var(--text2); cursor: pointer; transition: background 0.15s, color 0.15s; line-height: 1.4; }
.copy-btn:hover { background: var(--bg3); color: var(--text); }
.copy-btn--copied { color: var(--success); border-color: var(--success); }
.example-box pre { font-family: var(--mono); font-variant-ligatures: none; font-size: 0.92rem; color: var(--text); white-space: pre-wrap; margin: 0; }

/* editor (Monaco keeps its own colours; its frame follows the theme) */
#editor-container { border-radius: 0; overflow: hidden; border: 0; border-bottom: 1px solid var(--border); }
#editor { height: 460px; }
.editor-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 1rem; background: var(--bg2); border-bottom: 1px solid var(--border); gap: 0.5rem; }

/* judge results */
.result-panel { margin-top: 1rem; }
.result-header { display: flex; align-items: center; flex-wrap: wrap; gap: 0.6rem; margin: 0.9rem 0 0.75rem; }
.result-progress { background: transparent; border: 0; padding: 0; font-size: 0.92rem; color: var(--text2); }
.result-bar-track { height: 6px; background: var(--bg3); border-radius: 0; margin-top: 0.5rem; overflow: hidden; }
.result-bar-fill { height: 100%; border-radius: 0; background: var(--success); transition: width 0.3s; }
.result-error { background: var(--error-dim); border: 1px solid color-mix(in srgb, var(--error) 50%, transparent); border-radius: var(--radius-sm); padding: 0.9rem; font-family: var(--mono); font-size: 0.84rem; color: var(--error); white-space: pre-wrap; max-height: 220px; overflow-y: auto; }

/* a submission's tests, one square each: green passed, red failed, gold too
   slow, an outline while it waits */
.tests { display: flex; flex-wrap: wrap; gap: 3px; }
.t { width: 14px; height: 14px; position: relative; border: 1.5px solid var(--border2); }
.t.pass, .t.fail, .t.part, .t.run, .t.tle { border: 0; }
.t.pass { background: var(--success); }
.t.fail { background: var(--error); }
.t.tle { background: var(--warn); }
.t.part { background: linear-gradient(135deg, var(--success) 50%, var(--warn) 50%); }
.t.run::before { content: ''; position: absolute; inset: 3px; border: 2px solid var(--gold); animation: sq-spin 0.8s linear infinite; }
.tests.anim .t.pass, .tests.anim .t.fail, .tests.anim .t.part, .tests.anim .t.tle { animation: sq-in 0.28s var(--ease) backwards; }
@keyframes sq-in { from { transform: scale(0.2); opacity: 0; } 60% { transform: scale(1.15); } to { transform: none; opacity: 1; } }
@keyframes sq-spin { to { transform: rotate(90deg); } }

/* ── Leaderboard ────────────────────────────────────────────────────────────── */
.rank-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 6px; border-radius: var(--radius-sm); font-weight: 700; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.rank-1 { background: var(--gold); color: #2a1c17; }
.rank-2 { background: var(--cream); color: #2a1c17; box-shadow: inset 0 0 0 1px var(--border2); }
.rank-3 { background: #b9784a; color: #fff8ee; }
.rank-other { background: transparent; color: var(--text3); }

/* ── Profile ────────────────────────────────────────────────────────────────── */
.profile-header { display: flex; gap: 1.5rem; align-items: center; margin-bottom: 2rem; }

/* ── Admin ──────────────────────────────────────────────────────────────────── */
.admin-grid { display: grid; grid-template-columns: 236px 1fr; gap: 2rem; align-items: start; }
/* The admin menu (js/admin-sidebar.js): five groups that fold, Guide and
   Compiler at the foot. .is-drawer = the other admin pages, where it slides in
   from the "Admin" button; admin.html does the same on phones. */
.admin-sidebar { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow-y: auto; display: flex; flex-direction: column; gap: 0.9rem; padding-bottom: 1rem; scrollbar-width: thin; }
.admin-nav-title {
  display: flex; align-items: center; width: 100%; padding: 0 0.75rem 0.3rem; background: none; border: 0; cursor: pointer;
  font: inherit; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text3);
}
.admin-nav-title:hover { color: var(--text); }
.admin-nav-chev { margin-left: auto; font-size: 0.8rem; transition: transform 0.15s; }
.admin-nav-group.folded .admin-nav-chev { transform: rotate(-90deg); }
.admin-nav-group.folded .admin-nav-items { display: none; }
.admin-nav-items { display: flex; flex-direction: column; gap: 1px; }
.admin-nav-item {
  display: flex; align-items: center; gap: 0.65rem; padding: 0.42rem 0.75rem; cursor: pointer; text-decoration: none;
  font-size: 0.92rem; color: var(--text2); border-radius: var(--radius-sm); border: 0; transition: color 0.15s, background-color 0.15s;
}
.admin-nav-item svg { flex: none; opacity: 0.7; }
.admin-nav-item:hover { background: var(--bg3); color: var(--text); }
.admin-nav-item.active svg { opacity: 1; color: var(--primary); }
.admin-nav-footer { display: flex; flex-direction: column; gap: 1px; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.admin-menu-btn {
  display: none; position: fixed; left: 16px; bottom: 16px; z-index: 900; align-items: center; gap: 0.45rem;
  padding: 0.55rem 0.9rem; border-radius: 999px; border: 1px solid var(--border); background: var(--bg2); color: var(--text);
  font: inherit; font-size: 0.88rem; font-weight: 600; cursor: pointer; box-shadow: var(--shadow);
}
.admin-menu-btn.always { display: inline-flex; }
.admin-sidebar.is-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 264px; max-height: none; z-index: 950; padding: 1.25rem 0.75rem;
  background: var(--bg); border-right: 1px solid var(--border); box-shadow: var(--shadow);
  transform: translateX(-105%); transition: transform 0.2s;
}
.admin-menu-open .admin-sidebar { transform: none; }
/* An instructor shares some admin pages (requireStaff in js/api.js); what is
   only for admins is marked .admin-only. The server refuses it anyway. */
.role-instructor .admin-only { display: none !important; }
:root:not(.role-instructor) .instructor-only { display: none !important; }
.admin-nav-item.active { background: var(--bg2); color: var(--text); font-weight: 650; box-shadow: inset 3px 0 0 var(--primary); }
.admin-section { display: none; }
.admin-section.active { display: block; }

/* ── Toasts ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999;
  display: flex; align-items: center; gap: 0.6rem; padding: 0.75rem 1rem 0.75rem 0.85rem;
  border-radius: var(--radius-sm); font-size: 0.94rem; font-weight: 550; max-width: 360px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow);
  transform: translateY(16px); opacity: 0; transition: transform 0.3s var(--ease), opacity 0.3s;
}
/* The percentage of a file on its way to the site (createUploadBar in api.js). */
#uploadBars { position: fixed; left: 1rem; bottom: 1rem; z-index: 10000; display: flex; flex-direction: column; gap: 0.5rem; width: min(22rem, calc(100vw - 2rem)); }
.upload-bar { background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius); padding: 0.7rem 0.85rem; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); }
.upload-bar-top { display: flex; justify-content: space-between; gap: 0.75rem; font-size: 0.85rem; color: var(--text); }
.upload-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.upload-bar-pct { font-variant-numeric: tabular-nums; }
.upload-bar-track { height: 6px; margin-top: 0.45rem; background: var(--bg3); border-radius: 99px; overflow: hidden; }
.upload-bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width 0.15s linear; }
.upload-bar-detail { margin-top: 0.35rem; min-height: 1.1em; font-size: 0.75rem; color: var(--text3); }
.upload-bar-waiting .upload-bar-fill { animation: upload-bar-pulse 1.1s ease-in-out infinite; }
@keyframes upload-bar-pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .upload-bar-waiting .upload-bar-fill { animation: none; } .upload-bar-fill { transition: none; } }

.toast::before { content: ''; width: 10px; height: 10px; flex: none; background: var(--gold); }
.toast.show { transform: none; opacity: 1; }
.toast-success::before { background: var(--success); }
.toast-error::before { background: var(--error); }
.toast-warning::before { background: var(--warn); }
html.dark .toast-success::before { background: #3b7531; }
html.dark .toast-error::before { background: #b3291f; }
html.dark .toast-warning::before { background: #8d6110; }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(20, 12, 8, 0.6); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 1rem; }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.55); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.modal-close { width: 34px; height: 34px; display: grid; place-items: center; background: none; border: 1px solid transparent; border-radius: var(--radius-sm); color: var(--text2); cursor: pointer; font-size: 1.2rem; line-height: 1; }
.modal-close:hover { color: var(--text); background: var(--bg3); }

/* Find a user (the top bar's magnifier) */
.people-results { margin-top: 0.75rem; max-height: 50vh; overflow-y: auto; }
.people-row { display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0.6rem; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
.people-row:hover, .people-row:focus-visible { background: var(--bg3); }
.people-name { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-id { color: var(--text3); font-family: monospace; font-size: 0.8rem; }
.people-none { margin: 0.5rem 0.6rem; }

/* ── Colours (js/themes.js) ─────────────────────────────────────────────────── */
/* Each choice is a little page drawn in its own colours: top bar with a link,
   a card with two lines of text, a button and three test squares. */
.modal.theme-modal { max-width: 760px; }
.theme-lead { color: var(--text2); margin: -0.3rem 0 1.2rem; }
.theme-chip { display: inline-grid; place-items: center; width: 1.7em; height: 1.7em; vertical-align: -0.5em; border: 1px solid var(--border2); border-radius: var(--radius-sm); color: var(--text); }
.theme-chip svg { width: 1.05em; height: 1.05em; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 0.7rem; }
.theme-tile { display: flex; flex-direction: column; gap: 0.45rem; padding: 0.35rem; background: none; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-align: left; cursor: pointer; transition: border-color 0.15s; }
.theme-tile:hover { border-color: var(--border2); }
.theme-tile[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.theme-tile[aria-pressed="true"] .theme-name::after { content: ' ✓'; color: var(--accent); }
.theme-name { padding: 0 0.2rem 0.1rem; font-size: 0.85rem; font-weight: 600; line-height: 1.3; }
.tp { position: relative; display: block; height: 76px; padding: 0 8px 8px; overflow: hidden; border-radius: var(--radius-sm); }
.tp-bar { display: flex; align-items: center; height: 13px; margin: 0 -8px 8px; padding: 0 8px; border-bottom: 1px solid; }
.tp-bar span { width: 20px; height: 3px; }
.tp-card { display: flex; flex-direction: column; gap: 5px; padding: 7px; border: 1px solid; border-radius: 2px; }
.tp-line { display: block; width: 80%; height: 4px; }
.tp-line.short { width: 48%; }
.tp-row { display: flex; align-items: center; gap: 4px; margin-top: 3px; }
.tp-btn { width: 26px; height: 10px; margin-right: auto; }
.tp-sq { width: 8px; height: 8px; }
.tp-split { position: relative; display: block; }
.tp-split .tp + .tp { position: absolute; inset: 0; clip-path: polygon(58% 0, 100% 0, 100% 100%, 42% 100%); }
.theme-own { display: flex; flex-wrap: wrap; align-items: center; gap: 0.7rem 1.4rem; margin-top: 1.3rem; padding-top: 1.1rem; border-top: 1px solid var(--border); }
.theme-own-head { width: 100%; font-weight: 650; }
.theme-own label { display: inline-flex; align-items: center; gap: 0.55rem; font-size: 0.9rem; color: var(--text2); cursor: pointer; }
.theme-own input[type="color"] { width: 46px; height: 32px; padding: 2px; background: var(--bg); border: 1px solid var(--border2); border-radius: var(--radius-sm); cursor: pointer; }
.theme-note { width: 100%; font-size: 0.82rem; color: var(--text3); }
.theme-foot { display: flex; justify-content: flex-end; margin-top: 1.3rem; }
/* After a new account's first pick: where to change it later. */
#themeBtn.nudge { animation: nudge 1.2s var(--ease) 3; }
@keyframes nudge { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 45% { box-shadow: 0 0 0 5px var(--accent-dim), 0 0 0 1px var(--accent); } }
@media (prefers-reduced-motion: reduce) {
  #themeBtn.nudge { animation: none; outline: 2px solid var(--accent); outline-offset: 2px; }
}
@media (max-width: 520px) {
  .theme-grid { gap: 0.5rem; }
  .tp { height: 58px; }
  .tp-bar { margin-bottom: 6px; }
  .tp-card { gap: 4px; padding: 5px; }
}

/* Rating history on the profile (js/profile.js) */
.rating-chart { width: 100%; height: 140px; display: block; margin-bottom: 0.75rem; }
.rating-chart polyline { fill: none; stroke: var(--chart); stroke-width: 2; vector-effect: non-scaling-stroke; }
.rating-up { color: var(--success); font-weight: 600; }
.rating-down { color: var(--error); font-weight: 600; }

/* ── Carpet (js/carpet.js): profile and dashboard ───────────────────────────── */
.carpet { display: block; max-width: 100%; height: auto; image-rendering: pixelated; }
.carpet-key { display: flex; flex-direction: column; gap: 0.45rem; list-style: none; }
.carpet-key li { display: flex; align-items: center; gap: 0.6rem; font-size: 0.92rem; color: var(--text2); }
.carpet-key i { width: 12px; height: 12px; flex: none; }
.carpet-key b { min-width: 3.2ch; color: var(--text); font-weight: 650; text-align: right; }

/* During an exam (js/api.js, examNav): no way out but Leave contest. */
.in-exam .site-foot, .in-exam .exam-hide { display: none !important; }

/* ── Pagination ─────────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 0.3rem; justify-content: center; margin-top: 1.6rem; flex-wrap: wrap; }
.page-btn { min-width: 36px; height: 36px; padding: 0 0.6rem; border-radius: var(--radius-sm); border: 1px solid var(--border2); background: transparent; color: var(--text2); cursor: pointer; font-size: 0.9rem; font-variant-numeric: tabular-nums; transition: all 0.15s; }
.page-btn:hover { border-color: var(--text3); color: var(--text); }
.page-btn.active { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 650; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Loading and empty states ───────────────────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; padding: 3rem; color: var(--text2); gap: 0.75rem; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--gold); border-radius: 0; animation: sq-spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text2); }
.empty-state .empty-icon { display: none; }
.empty-state p { font-size: 0.98rem; }

/* ── Section headers and tabs ───────────────────────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.1rem; gap: 1rem; flex-wrap: wrap; }
.section-header h2 { font-size: 1.4rem; letter-spacing: -0.03em; }
.tabs { display: flex; gap: 1.4rem; border-bottom: 1px solid var(--border2); margin-bottom: 1.5rem; overflow-x: auto; }
.tab-btn { padding: 0.6rem 0; background: none; border: none; border-bottom: 2px solid transparent; color: var(--text3); cursor: pointer; font-size: 0.96rem; font-weight: 600; transition: color 0.15s, border-color 0.15s; margin-bottom: -1px; white-space: nowrap; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* needs attention (admin dashboard) */
.attn { display: flex; flex-direction: column; gap: 0.5rem; }
.attn-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; background: var(--bg2); border: 1px solid var(--border); border-left: 4px solid var(--border2); border-radius: var(--radius-sm); padding: 0.75rem 1rem; }
.attn-item.red { border-left-color: var(--error); }
.attn-item.amber { border-left-color: var(--warn); }
.attn-item.green { border-left-color: var(--success); }
.attn-item strong { font-size: 0.95rem; }
.live-dot { display: inline-block; width: 8px; height: 8px; background: var(--error); margin-right: 0.45rem; vertical-align: middle; animation: live-pulse 1.6s infinite; }
@keyframes live-pulse { 50% { opacity: 0.35; } }

/* ── Contests ───────────────────────────────────────────────────────────────── */
.contest-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0 2.5rem; }
.contest-group-title { font-size: 0.95rem; font-weight: 650; color: var(--text3); letter-spacing: 0; margin: 2.2rem 0 0.4rem; padding-bottom: 0.6rem; border-bottom: 1px solid var(--border2); grid-column: 1 / -1; }
#contestsGrid > .contest-group-title:first-child { margin-top: 0; }
.contest-archive { margin-top: 2rem; }
.contest-archive > summary { cursor: pointer; margin: 0 0 0.75rem; color: var(--text2); font-weight: 600; }

/* ── Editor full screen ─────────────────────────────────────────────────────── */
.editor-fullscreen { position: fixed !important; inset: 0 !important; z-index: 500 !important; border-radius: 0 !important; display: flex !important; flex-direction: column !important; max-height: 100vh !important; overflow: hidden !important; }
.editor-fullscreen #editor-container { flex: 1; min-height: 0; overflow: hidden; }
.editor-fullscreen #editor { height: 100% !important; }

/* ── Scrollbars ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Code ───────────────────────────────────────────────────────────────────── */
code { font-family: var(--mono); font-variant-ligatures: none; background: var(--bg3); padding: 0.1em 0.38em; border-radius: var(--radius-sm); font-size: 0.88em; }
pre, pre code { font-family: var(--mono); font-variant-ligatures: none; }
pre code { background: none; padding: 0; }

/* clickable rows and cards (navAttrs() in js/api.js) */
[data-nav] { cursor: pointer; }
[data-nav]:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

.lb-problem-link { color: var(--link); font-weight: 700; text-decoration: none; }
.lb-problem-link:hover, .lb-problem-link:focus-visible { text-decoration: underline; }

.login-chip svg { width: 15px; height: 15px; }
.login-chip { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.86rem; color: var(--text2); text-decoration: none; cursor: pointer; padding: 0.35rem 0.75rem; background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius-sm); transition: border-color 0.15s, color 0.15s; }
.login-chip:hover, .login-chip:focus-visible { border-color: var(--text3); color: var(--text); text-decoration: none; }

.back-to-tree { align-items: center; gap: 0.4rem; font-size: 0.9rem; font-weight: 600; color: var(--text); text-decoration: none; padding: 0.3rem 0.7rem; border: 1px solid var(--border2); border-radius: var(--radius-sm); background: transparent; transition: background 0.15s; }
.back-to-tree:hover, .back-to-tree:focus-visible { background: var(--bg3); text-decoration: none; color: var(--text); }

/* ── Admin → Statistics (js/admin-statistics.js) ────────────────────────────── */
.stx-header { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.stx-range { display: inline-flex; border: 1px solid var(--border2); border-radius: var(--radius-sm); overflow: hidden; }
.stx-range button { background: transparent; color: var(--text2); border: 0; border-right: 1px solid var(--border2); padding: 0.4rem 0.8rem; font: inherit; font-size: 0.86rem; cursor: pointer; }
.stx-range button:last-child { border-right: 0; }
.stx-range button:hover { background: var(--bg3); }
.stx-range button[aria-pressed="true"] { background: var(--text); color: var(--bg); font-weight: 650; }
#stxBody { transition: opacity 0.15s; }
#stxBody.stx-refreshing { opacity: 0.55; }
.stx-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; border-block: 1px solid var(--border); }
@media (max-width: 1100px) { .stx-tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }
.stx-tile { background: transparent; border: 0; border-left: 1px solid var(--border); border-radius: 0; padding: 1rem 1.1rem; }
.stx-tile:first-child { border-left: 0; padding-left: 0; }
.stx-tile-label { font-size: 0.86rem; color: var(--text3); }
.stx-tile-value { font-size: 1.9rem; font-weight: 740; letter-spacing: -0.035em; color: var(--text); line-height: 1.2; margin-top: 0.2rem; font-variant-numeric: tabular-nums; }
.stx-delta { font-size: 0.82rem; margin-top: 0.25rem; }
.stx-delta.up { color: var(--success); }
.stx-delta.down { color: var(--error); }
.stx-explain { margin: 0.6rem 0 1.25rem; }
.stx-card { margin-bottom: 1rem; padding: 1.1rem 1.25rem; }
.stx-h { font-size: 1.02rem; margin: 0 0 0.35rem; }
.stx-two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.stx-two > .stx-card { min-width: 0; }
@media (max-width: 1000px) { .stx-two { grid-template-columns: 1fr; } }
.stx-chart { width: 100%; margin-top: 0.5rem; }
.stx-svg { display: block; }
.stx-svg .stx-grid { stroke: var(--border); stroke-width: 1; }
.stx-svg .stx-base { stroke: var(--text3); stroke-width: 1; }
.stx-svg .stx-axis { fill: var(--text3); font-size: 11px; font-variant-numeric: tabular-nums; }
.stx-svg .stx-value { fill: var(--text); font-size: 11px; font-weight: 600; }
.stx-svg .stx-bar { fill: var(--chart); pointer-events: none; }
.stx-svg .stx-hit { fill: transparent; cursor: default; outline: none; }
.stx-svg .stx-hit.on, .stx-svg .stx-hit:focus { fill: color-mix(in srgb, var(--chart) 14%, transparent); }
.stx-hbars { display: grid; gap: 0.55rem; margin-top: 0.6rem; }
.stx-hrow { display: grid; grid-template-columns: 7.5rem 1fr auto; align-items: center; gap: 0.75rem; font-size: 0.88rem; }
.stx-hlabel { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stx-htrack { height: 14px; }
.stx-hbar { height: 14px; background: var(--chart); border-radius: 0; }
.stx-hvalue { color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stx-heat { display: grid; grid-template-columns: 2.4rem repeat(24, minmax(0, 1fr)); gap: 2px; margin-top: 0.6rem; }
.stx-heat-h, .stx-heat-d { font-size: 11px; color: var(--text3); font-variant-numeric: tabular-nums; }
.stx-heat-h { text-align: center; }
.stx-heat-d { align-self: center; }
.stx-cell { aspect-ratio: 1 / 1; border-radius: 0; background: color-mix(in srgb, var(--chart) calc(var(--a, 0) * 100%), var(--bg3)); }
.stx-cell:hover { outline: 2px solid var(--text2); outline-offset: -1px; }
.stx-heat-key { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.6rem; }
.stx-heat-ramp { width: 120px; height: 10px; border-radius: 0; background: linear-gradient(90deg, color-mix(in srgb, var(--chart) 8%, var(--bg3)), var(--chart)); }
.stx-details { margin-top: 0.75rem; }
.stx-details summary { cursor: pointer; color: var(--text2); font-size: 0.88rem; }
.stx-details .table-wrap { margin-top: 0.6rem; max-height: 320px; overflow: auto; }
.stx-table td, .stx-table th { padding: 0.5rem 0.75rem; }
.stx-table th { font-size: 0.82rem; }
.stx-table td:not(:first-child), .stx-table th:not(:first-child) { text-align: right; white-space: nowrap; }
.stx-table td:first-child { min-width: 9rem; }
.stx-table td { font-variant-numeric: tabular-nums; }
.stx-tip { position: fixed; z-index: 1000; display: none; pointer-events: none; background: var(--bg2); color: var(--text2); border: 1px solid var(--border2); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 0.45rem 0.65rem; font-size: 0.84rem; line-height: 1.5; white-space: nowrap; }
.stx-tip strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* main column + sidebar (Dashboard, Profile) */
.side-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; align-items: start; }
.side-layout > * { min-width: 0; }
.stmt .katex-display { overflow-x: auto; overflow-y: hidden; }
.panel-body pre { overflow-x: auto; max-width: 100%; }

/* ── Shared pieces ──────────────────────────────────────────────────────────── */
/* a learner's initial on a coloured square (avatarHtml() in js/api.js) */
.av { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: var(--radius-sm); color: #fff8ee; font-weight: 700; font-size: 12px; line-height: 1; flex: none; text-transform: uppercase; }
img.av { display: inline-block; object-fit: cover; background: var(--bg3); }
.verdict { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; }
.verdict::before { content: ''; width: 10px; height: 10px; background: currentColor; flex: none; }
.v-ok { color: var(--success); }
.v-bad { color: var(--error); }
.v-warn { color: var(--warn); }

/* the footer every page but the full-screen ones ends with */
.site-foot { margin-top: 4rem; border-top: 1px solid var(--border); background: var(--sunk); }
.site-foot .foot-in { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 2rem; padding: 1.4rem 0 2.2rem; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin-right: auto; }
.site-foot nav a { color: var(--text2); font-size: 0.94rem; }
.site-foot .muted { font-size: 0.88rem; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 1080px) {
  .nav-links {
    display: none; position: absolute; top: 62px; left: 0; right: 0;
    background: var(--bg); flex-direction: column; padding: 0.75rem clamp(16px, 3.5vw, 40px) 1rem;
    border-bottom: 1px solid var(--border); gap: 2px;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 0.7rem 0.5rem; font-size: 1.05rem; }
  .nav-links a.active::after { left: auto; right: 0.5rem; bottom: 50%; translate: 0 50%; }
  .nav-toggle { display: inline-flex; }
  .nav-user { margin-left: auto; }
}
@media (max-width: 768px) {
  .question-layout { grid-template-columns: 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
  .admin-sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 264px; max-height: none; z-index: 950; padding: 1.25rem 0.75rem;
    background: var(--bg); border-right: 1px solid var(--border); box-shadow: var(--shadow); transform: translateX(-105%); transition: transform 0.2s; }
  .admin-menu-open .admin-sidebar { transform: none; }
  .admin-menu-btn { display: inline-flex; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card:nth-child(odd) { border-left: 0; padding-left: 0; }
  .stat-card:nth-child(n + 3) { border-top: 1px solid var(--border); }
  .filter-bar { gap: 0.4rem; }
  .filter-bar .search-input { flex-basis: 100%; min-width: 0; }
  .filter-spacer { display: none; }
  .question-layout > * { min-width: 0; }
  .question-meta, #qAdminTags { flex-wrap: wrap; }
  .profile-header { flex-direction: column; align-items: flex-start; }
  .editor-layout { flex-direction: column; }
  #editor { height: 340px; }
  .side-layout { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .nav-user { gap: 0.3rem; }
  /* 3.5rem since the language switch (2026-11-13): "Hesabdan çıx" is long */
  .nav-username span { max-width: 3.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-user .lang-switch { display: none; }
  .nav-links .lang-switch-menu:not([hidden]) { display: block; align-self: flex-start; margin: 0.4rem 0.7rem; min-height: 38px; }
  .btn { min-height: 42px; }
  .btn-sm { min-height: 34px; }
}
@media (max-width: 400px) {
  .logo { font-size: 0; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}

/* Admin -> System -> Rented judge machines (js/admin-cloud-judges.js) */
.cj-plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.5rem; }
.cj-plan { position: relative; cursor: pointer; }
.cj-plan input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.cj-plan-body { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.6rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg2); }
.cj-plan input:checked + .cj-plan-body { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cj-plan input:focus-visible + .cj-plan-body { outline: 2px solid var(--focus); outline-offset: 2px; }
.cj-steps { display: flex; gap: 3px; }
.cj-step { width: 22px; height: 5px; border-radius: 3px; background: var(--border2); }
.cj-step.done { background: var(--success); }
.cj-step.now { background: var(--warn); }

/* An article written in the lesson editor (Quill): a lesson (lesson.html) or
   a blog post (blog.html). The server keeps only these tags (utils/sanitizeLessonHtml.js). */
.lesson-content { line-height: 1.8; color: var(--text); font-size: 1.08rem; overflow-wrap: anywhere; }
.lesson-content h1, .lesson-content h2, .lesson-content h3 {
  margin: 1.5rem 0 0.75rem; font-weight: 700; line-height: 1.3;
}
.lesson-content h1 { font-size: 1.6rem; }
.lesson-content h2 { font-size: 1.3rem; }
.lesson-content h3 { font-size: 1.1rem; }
.lesson-content p { margin: 0 0 1rem; }
.lesson-content ul, .lesson-content ol { margin: 0 0 1rem 1.5rem; }
.lesson-content li { margin-bottom: 0.35rem; }
.lesson-content blockquote {
  border-left: 3px solid var(--gold);
  margin: 1rem 0; padding: 0.5rem 1rem;
  color: var(--text2); background: var(--bg2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.lesson-content pre {
  background: var(--bg3); border-radius: var(--radius-sm);
  padding: 1rem; margin: 1rem 0; overflow-x: auto;
  font-family: var(--mono); font-variant-ligatures: none; font-size: 0.9rem;
}
.lesson-content code {
  font-family: var(--mono); font-variant-ligatures: none;
  background: var(--bg3); border-radius: var(--radius-sm);
  padding: 0.15rem 0.35rem; font-size: 0.875rem;
}
.lesson-content pre code { padding: 0; background: none; }
.lesson-content a { color: var(--link); text-decoration: underline; }
.lesson-content strong { font-weight: 600; }
.lesson-content img { max-width: 100%; border-radius: var(--radius-sm); margin: 0.5rem 0; }
.lesson-content hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* Blog posts in rows, picture and title only: the dashboard's newest and the /blog page */
.post-grid { display: grid; border-top: 1px solid var(--border); }
.post-card { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 1rem; align-items: center; padding: 0.8rem 0; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.post-card:hover { text-decoration: none; }
.post-card:hover .post-title { color: var(--link); }
.post-card:hover .post-pic { border-color: var(--text3); }
.post-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }
.post-pic { display: block; width: 88px; height: 88px; object-fit: cover; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg3); transition: border-color 0.15s; }
.post-pic-none { display: grid; place-items: center; color: var(--text3); font-size: 1.8rem; }
.post-title { font-size: 1.05rem; font-weight: 650; letter-spacing: -0.01em; line-height: 1.35; overflow-wrap: anywhere; }
.post-meta { color: var(--text3); font-size: 0.88rem; }
@media (max-width: 480px) { .post-card { grid-template-columns: 64px minmax(0, 1fr); gap: 0.8rem; } .post-pic { width: 64px; height: 64px; } .post-title { font-size: 0.97rem; } }

/* The daily streak and the day bars (js/api.js streakHtml, dayBarsHtml):
   the dashboard and your own profile */
.streak-top { display: flex; align-items: center; gap: 0.6rem; }
.streak-flame { font-size: 2rem; line-height: 1; }
.streak-flame.off { filter: grayscale(1); opacity: 0.45; }
.streak-n { font: 750 2.4rem/1 var(--font, inherit); letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.streak-l { font-size: 0.92rem; line-height: 1.25; }
.streak-note { margin: 0.5rem 0 0; font-size: 0.9rem; color: var(--text2); }
.streak-note.warn { color: var(--warn); font-weight: 600; }
.daybars { display: flex; align-items: flex-end; gap: 3px; height: 64px; margin-top: 0.9rem; }
.daybar { flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; min-width: 4px; }
.daybar i { display: flex; align-items: flex-end; width: 100%; min-height: 2px; background: var(--bg3); border-radius: 2px 2px 0 0; overflow: hidden; }
.daybar b { display: block; width: 100%; background: var(--success); }
.daybar.today i { box-shadow: 0 0 0 1px var(--text3); }
.day-row { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin-top: 0.7rem; font-size: 0.9rem; color: var(--text2); }
.day-row b { color: var(--text); font-variant-numeric: tabular-nums; }

/* Friends (friends.html, the dashboard, a profile) */
.feed { display: grid; border-top: 1px solid var(--border); }
.feed-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.7rem; align-items: center; padding: 0.65rem 0; border-bottom: 1px solid var(--border); font-size: 0.95rem; }
.feed-item a { color: var(--text); font-weight: 600; }
.feed-item a:hover { color: var(--link); }
.feed-item .when { color: var(--text3); font-size: 0.85rem; white-space: nowrap; }
.friend-streak { white-space: nowrap; font-variant-numeric: tabular-nums; }
.friend-streak.off { color: var(--text3); }
.followers { color: var(--text2); font-size: 0.92rem; }

/* The problem of the day (js/api.js dailyCardHtml): the dashboard and /daily */
.daily-card { padding: 1.2rem 1.3rem; border: 1px solid var(--border); border-left: 3px solid var(--gold); border-radius: var(--radius); background: var(--bg2); }
.daily-card h3 { font-size: 1.35rem; letter-spacing: -0.03em; line-height: 1.15; margin: 0.25rem 0 0.5rem; }
.daily-card h3 a { color: var(--text); }
.daily-card h3 a:hover { color: var(--link); }
.daily-eyebrow { color: var(--text3); font-size: 0.88rem; font-weight: 600; }
.daily-meta { display: flex; flex-wrap: wrap; gap: 0.5rem 0.8rem; align-items: center; color: var(--text2); font-size: 0.9rem; }
.daily-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.9rem; }

/* The streak freeze (2026-11-04): the note under the streak, and a frozen day's bar */
.streak-freeze { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--text3); }
.daybar.frozen i { min-height: 100%; background: repeating-linear-gradient(135deg, rgba(110, 170, 230, 0.35) 0 4px, transparent 4px 8px); }

/* Badges (2026-11-04): the pop-up when one is earned (js/api.js), and the
   profile's Badges section */
.badge-pop { position: fixed; right: 16px; bottom: 16px; z-index: 900; width: min(360px, calc(100vw - 32px)); padding: 1rem 1.1rem 1.1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22); animation: badge-in 0.25s ease-out; }
.badge-pop-h { font-weight: 750; font-size: 1.05rem; margin: 0 1.6rem 0.6rem 0; }
.badge-pop-x { position: absolute; top: 0.5rem; right: 0.5rem; border: 0; background: none; color: var(--text3); font-size: 1rem; cursor: pointer; padding: 0.3rem 0.45rem; }
.badge-pop-x:hover { color: var(--text); }
.badge-pop-row { display: flex; gap: 0.8rem; align-items: center; margin-bottom: 0.7rem; }
.badge-pop-row b { display: block; }
.badge-pop-row span { font-size: 0.86rem; color: var(--text2); }
.badge-pop-more { margin: 0 0 0.7rem; font-size: 0.86rem; color: var(--text3); }
@keyframes badge-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1.2rem 1rem; }
.badge-tile { display: grid; justify-items: center; gap: 0.3rem; text-align: center; }
.badge-tile img { width: 84px; height: 84px; }
.badge-tile b { font-size: 0.92rem; line-height: 1.25; }
.badge-tile span { font-size: 0.8rem; color: var(--text3); line-height: 1.3; }
.badge-tile.locked img { filter: grayscale(1); opacity: 0.28; }
.badge-tile.locked b { color: var(--text3); }

/* Quiz question text (js/quiz-format.js, 2026-11-04): code blocks and inline code */
.quiz-text { line-height: 1.6; overflow-wrap: anywhere; }
.quiz-text .quiz-code { background: var(--bg3); border-radius: var(--radius-sm); padding: 0.75rem 0.9rem; margin: 0.6rem 0; overflow-x: auto; font: 0.9rem/1.5 var(--mono); font-variant-ligatures: none; white-space: pre; }
.quiz-text code { font-family: var(--mono); font-variant-ligatures: none; background: var(--bg3); border-radius: var(--radius-sm); padding: 0.1rem 0.3rem; font-size: 0.9em; }
.quiz-text .quiz-code code { background: none; padding: 0; font-size: inherit; }
.kind-badge { display: inline-block; padding: 0.1rem 0.45rem; border-radius: 3px; font-size: 0.75rem; font-weight: 600; background: var(--bg3); color: var(--text2); white-space: nowrap; }

/* Taking a quiz (js/quiz-runner.js, Quiz v2) */
.qz-head { display: flex; justify-content: space-between; align-items: end; gap: 1rem; flex-wrap: wrap; margin: 1.5rem 0 0.8rem; }
.qz-head h3 { font-size: 1.1rem; margin: 0 0 0.2rem; }
.qz-head p { margin: 0; }
.qz-progress { display: grid; gap: 0.3rem; min-width: 200px; font-size: 0.88rem; color: var(--text2); }
.qz-bar { display: block; height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.qz-bar i { display: block; height: 100%; background: var(--success); transition: width 0.2s; }
.qz-nav { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.9rem; }
.qz-nb { position: relative; width: 2.4rem; height: 2.4rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text2); font: 600 0.9rem var(--mono); cursor: pointer; }
.qz-nb:hover { border-color: var(--text3); }
.qz-nb.done { background: var(--bg3); color: var(--text); }
.qz-nb.flag::after { content: ''; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.qz-nb.right { background: var(--success-dim); border-color: var(--success); color: var(--success); }
.qz-nb.part { background: var(--warn-dim); border-color: var(--warn); color: var(--warn); }
.qz-nb.wrong { border-color: var(--error); color: var(--error); }
.qz-nb.wait { border-style: dashed; }
.qz-nb.cur { outline: 2px solid var(--accent); outline-offset: 1px; }
.qz-nb:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.qz-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem 1.3rem; background: var(--bg2); }
.qz-meta { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; color: var(--text3); font-size: 0.85rem; margin-bottom: 0.7rem; }
.qz-save { margin-left: auto; }
.qz-save.ok { color: var(--success); }
.qz-save.bad { color: var(--error); font-weight: 600; }
.qz-save.warn { color: var(--warn); }
.qz-text { font-size: 1.05rem; }
.qz-img { max-width: 100%; border-radius: var(--radius-sm); margin: 0.7rem 0; }
.qz-answer { margin-top: 1rem; }
.qz-opts { display: grid; gap: 0.45rem; }
.qz-tf { grid-template-columns: 1fr 1fr; }
.qz-opt { display: flex; gap: 0.7rem; align-items: baseline; text-align: left; padding: 0.7rem 0.9rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font: inherit; cursor: pointer; }
.qz-opt:hover:not(:disabled) { border-color: var(--text3); }
.qz-opt:disabled { cursor: default; }
.qz-opt b { color: var(--text3); font-family: var(--mono); }
.qz-opt.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.qz-opt.on b { color: var(--accent); }
.qz-opt.is-right { background: var(--success-dim); border-color: var(--success); }
.qz-opt:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.qz-short { max-width: 26rem; }
.qz-long { font-size: 0.95rem; }
.qz-review { margin-top: 1rem; padding: 0.8rem 1rem; border-radius: var(--radius-sm); background: var(--bg3); font-size: 0.95rem; display: grid; gap: 0.35rem; }
.qz-review.right { background: var(--success-dim); }
.qz-review.part { background: var(--warn-dim); }
.qz-review .qz-comment { color: var(--text2); }
.qz-review .qz-explain-h { font-weight: 650; margin-top: 0.3rem; }
.qz-foot { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 1.2rem; flex-wrap: wrap; }
@media (max-width: 480px) { .qz-tf { grid-template-columns: 1fr; } .qz-save { margin-left: 0; width: 100%; } }

/* In a contest the Communication tab replaces the Chat button for students
   (2026-11-12): the contest page and a problem opened from it (contest.js,
   question.js set the class). */
body.contest-comm #chat-widget { display: none !important; }

/* Admin -> System, compact (2026-11-18): status tiles with a dot, panels,
   charts side by side, folded settings. The dot's colour is the tile's
   data-level (admin.js sysLevel). */
.sys-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.6rem; margin-bottom: 0.6rem; }
.sys-strip-wide { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.sys-tile { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.65rem 0.8rem; display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.sys-k { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text2); }
.sys-v { display: flex; align-items: center; gap: 0.45rem; font-size: 1.15rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.sys-s { font-size: 0.78rem; color: var(--text2); }
.sys-line { display: flex; align-items: flex-start; gap: 0.45rem; font-size: 0.82rem; line-height: 1.45; }
.sys-line .sys-dot { margin-top: 0.4em; }
.sys-dot { flex: none; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--border2); }
.sys-tile[data-level="ok"] .sys-dot { background: var(--success); }
.sys-tile[data-level="warn"] .sys-dot { background: var(--gold); }
.sys-tile[data-level="bad"] .sys-dot { background: var(--error); }
.sys-tile[data-level="bad"] { border-color: var(--error); }
.sys-panel { padding: 1rem 1.15rem; margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.sys-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.sys-head h3 { font-size: 1rem; margin: 0; }
.sys-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.sys-sub { padding-top: 0.8rem; border-top: 1px solid var(--border); }
.sys-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 1rem; }
.sys-charts .sys-panel { margin-bottom: 0; min-width: 0; }
.sys-fold > summary { cursor: pointer; font-size: 0.9rem; font-weight: 600; padding: 0.35rem 0; list-style: none; }
.sys-fold > summary::-webkit-details-marker { display: none; }
.sys-fold > summary::before { content: '▸'; display: inline-block; width: 1.1em; color: var(--text2); transition: transform 0.15s; }
.sys-fold[open] > summary::before { transform: rotate(90deg); }
#cloudJudgeBox .sys-fold { border-top: 1px solid var(--border); margin-top: 0.8rem; padding-top: 0.4rem; }
.sys-rare { margin-top: 1rem; }
@media (prefers-reduced-motion: reduce) { .sys-fold > summary::before { transition: none; } }

/* the carpet festival's card (api.js festivalCard): dashboard, home, paint page */
.fest-card { display: flex; align-items: center; gap: 14px; padding: 0.9rem 1.1rem; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius); background: var(--bg2); color: var(--text); text-decoration: none; }
.fest-card:hover { text-decoration: none; border-color: var(--text3); border-left-color: var(--accent); }
.fest-card:hover b { color: var(--link); }
.fest-card[hidden] { display: none; }
.fest-pic { flex: none; display: flex; }
.fest-text { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.fest-text b { font-size: 1.05rem; font-weight: 700; overflow-wrap: anywhere; }
.fest-eyebrow { font-size: 0.82rem; color: var(--text3); }
.fest-more { font-size: 0.9rem; color: var(--text2); }
.fest-theme { font-size: 0.88rem; color: var(--text2); }
.fest-theme b { font-size: inherit; color: var(--accent); }
.fest-concept { font-size: 0.86rem; color: var(--text2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* The dialogue of a failed example test of an interactive problem
   (api.js renderSampleDialogues): the program's lines beside the
   interactor's, one under the other on a phone. */
.dlg-box { margin-top: 0.75rem; }
.dlg-head { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem; }
.dlg-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.5rem; }
.dlg-label { font-size: 0.75rem; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.2rem; }
.dlg-side pre { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.5rem 0.7rem; margin: 0;
  font-family: var(--mono); font-variant-ligatures: none; font-size: 0.85rem; white-space: pre-wrap; word-break: break-word; max-height: 240px; overflow-y: auto; }
.dlg-input { margin-bottom: 0.5rem; }
