/* Contest OJ — AtCoder / CSES density, light paper, semantic verdicts. */

:root {
  --bg: #f4f5f7;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #eceef1;
  --fill: #eef0f3;
  --fill-2: #f3f4f6;
  --ink: #1b1f24;
  --ink-2: #3c434c;
  --muted: #6b7380;
  --separator: #d8dce3;
  --border: #d8dce3;
  --border-str: #c5cad3;

  --accent: #1565c0;
  --accent-ink: #ffffff;
  --accent-bg: #e8f1fb;
  --accent-br: #90caf9;

  --glass-bg: #ffffff;
  --glass-stroke: #d8dce3;
  --glass-highlight: transparent;
  --glass-shadow: none;
  --glass-filter: none;

  --ac: #2e7d32;  --ac-bg: #e8f5e9;  --ac-br: #a5d6a7;
  --wa: #c62828;  --wa-bg: #fdecea;  --wa-br: #ef9a9a;
  --tle: #ef6c00; --tle-bg: #fff3e0; --tle-br: #ffcc80;
  --rte: #6a1b9a; --rte-bg: #f3e5f5; --rte-br: #ce93d8;
  --ce: #546e7a;  --ce-bg: #eceff1;  --ce-br: #b0bec5;
  --ie: #ad1457;  --ie-bg: #fce4ec;  --ie-br: #f48fb1;

  --r-sm: 3px;
  --r: 4px;
  --r-lg: 4px;
  --r-xl: 4px;
  --r-pill: 4px;
  --shadow: none;
  --shadow-lg: none;

  --sans: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: Consolas, "Liberation Mono", Menlo, Monaco, monospace;

  --ease: ease;
  --t: 120ms;
  --t-fast: 80ms;
  --nav-h: 48px;
}

:root[data-theme="dark"] {
  --bg: #1e2126;
  --bg-elevated: #2a2e35;
  --surface: #2a2e35;
  --surface-2: #343940;
  --fill: #343940;
  --fill-2: #3c424a;
  --ink: #e8eaed;
  --ink-2: #c5c9d0;
  --muted: #8b929c;
  --separator: #3e444d;
  --border: #3e444d;
  --border-str: #515862;

  --accent: #64b5f6;
  --accent-ink: #0d1117;
  --accent-bg: #1a3348;
  --accent-br: #1565c0;

  --glass-bg: #2a2e35;
  --glass-stroke: #3e444d;
  --glass-highlight: transparent;
  --glass-shadow: none;
  --glass-filter: none;

  --ac: #81c784;  --ac-bg: #1b3a24;  --ac-br: #2e7d32;
  --wa: #ef9a9a;  --wa-bg: #3a1c1c;  --wa-br: #c62828;
  --tle: #ffcc80; --tle-bg: #3a2a14; --tle-br: #ef6c00;
  --rte: #ce93d8; --rte-bg: #2e1a38; --rte-br: #6a1b9a;
  --ce: #90a4ae;  --ce-bg: #263238;  --ce-br: #546e7a;
  --ie: #f48fb1;  --ie-bg: #3a1524;  --ie-br: #ad1457;

  --shadow-lg: none;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; opacity: 1; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.25; letter-spacing: 0; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 0.95rem; font-weight: 650; }

code, kbd, pre, .mono { font-family: var(--mono); font-variant-ligatures: none; letter-spacing: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: none;
}
.glass::before { display: none; }

/* ---------- Layout ---------- */

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.wrap-narrow { max-width: 520px; margin: 0 auto; padding: 0 16px; }
.wrap-full { max-width: 1280px; width: 100%; margin: 0 auto; padding: 0 16px; }

.site-head {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0;
}
.site-head .glass-bar {
  max-width: 1280px;
  margin: 0 auto;
  min-height: 48px;
  border-radius: 0;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  box-shadow: none;
}
.site-head.is-scrolled .glass-bar { box-shadow: none; }

.brand {
  font-weight: 650;
  font-size: 0.95rem;
  color: var(--ink);
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}
.brand:hover { opacity: 1; color: var(--ink); text-decoration: none; }

.nav {
  display: flex;
  gap: 2px;
  margin-left: 8px;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.nav a {
  color: var(--ink-2);
  padding: 14px 10px;
  border-radius: 0;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.nav a:hover { background: transparent; color: var(--accent); opacity: 1; text-decoration: none; }
.nav a[aria-current="page"] {
  background: transparent;
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.whoami {
  font-size: 0.8rem;
  color: var(--muted);
  padding-left: 10px;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.whoami:has(.whoami-profile) {
  border-left: 0.5px solid var(--separator);
}
.whoami b { color: var(--ink); font-weight: 600; }
.whoami-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
}
.whoami-profile:hover { opacity: 1; }
.nav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.nav-avatar-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--fill);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
}

.icon-btn, .text-btn {
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--ink-2);
  border-radius: var(--r);
  padding: 4px 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn { width: 32px; padding: 0; }
.icon-btn:hover, .text-btn:hover { background: var(--fill); color: var(--ink); }
.icon-btn:active, .text-btn:active { transform: scale(0.96); }

main {
  padding: 18px 0 48px;
  animation: none;
}

.page-head { margin-bottom: 14px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; font-weight: 400; }

/* ---------- Surfaces ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: none;
}
.card-pad { padding: 14px 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
  border-radius: var(--r);
  padding: 0 14px;
  min-height: 32px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast);
}
.btn:hover { filter: none; opacity: 1; text-decoration: none; background: #0d47a1; }
.btn:active { transform: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--fill-2); filter: none; color: var(--accent); }
.btn-sm { min-height: 28px; padding: 0 10px; font-size: 12px; }

input[type=text], input[type=password], input[type=search], select, textarea {
  width: 100%;
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  box-shadow: none;
  border-color: var(--accent);
  background: var(--surface);
}

label.field { display: block; margin-bottom: 14px; }
label.field > span {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.hint { font-size: 0.82rem; color: var(--muted); }

.msg {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  margin-bottom: 14px;
}
.msg-err  { background: var(--wa-bg); color: var(--wa); }
.msg-warn { background: var(--tle-bg); color: #c77c02; }
.msg-ok   { background: var(--ac-bg); color: #248a3d; }
:root[data-theme="dark"] .msg-warn { color: var(--tle); }
:root[data-theme="dark"] .msg-ok { color: var(--ac); }

/* ---------- Verdicts ---------- */

.verdict {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--r);
  border: 1px solid transparent;
  letter-spacing: 0;
  white-space: nowrap;
}
.v-AC  { color: var(--ac);  background: var(--ac-bg); border-color: var(--ac-br); }
.v-WA  { color: var(--wa);  background: var(--wa-bg); border-color: var(--wa-br); }
.v-TLE { color: var(--tle); background: var(--tle-bg); border-color: var(--tle-br); }
.v-RTE { color: var(--rte); background: var(--rte-bg); border-color: var(--rte-br); }
.v-CE  { color: var(--ce);  background: var(--ce-bg); border-color: var(--ce-br); }
.v-IE  { color: var(--ie);  background: var(--ie-bg); border-color: var(--ie-br); }
.v-pending, .v-judging {
  color: var(--muted);
  background: var(--fill);
}
.v-judging::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
}

.tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: var(--r);
  background: var(--fill);
  color: var(--muted);
  border: 1px solid var(--border);
}
.diff {
  font-size: 11px;
  font-weight: 650;
  padding: 1px 6px;
  border-radius: var(--r);
  border: 1px solid transparent;
}
.diff-easy   { color: var(--ac);  background: var(--ac-bg); }
.diff-medium { color: #c77c02; background: var(--tle-bg); }
.diff-hard   { color: var(--wa);  background: var(--wa-bg); }
:root[data-theme="dark"] .diff-medium { color: var(--tle); }

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--border);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--fill-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--separator);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--t-fast) var(--ease); }
tbody tr:hover { background: var(--fill-2); }
td.num, th.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
td.mono { font-family: var(--mono); font-size: 0.84rem; }

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---------- Problem list + filters ---------- */

.filters-bar {
  position: sticky;
  top: 48px;
  z-index: 30;
  border-radius: var(--r);
  padding: 8px 10px;
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
}
.filters-bar .search-field {
  flex: 1 1 220px;
  min-width: 180px;
  position: relative;
}
.filters-bar .search-field svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}
.filters-bar .search-field input {
  padding-left: 34px;
  min-height: 36px;
  background: var(--fill-2);
}
.filters-bar select {
  width: auto;
  min-height: 36px;
  padding: 6px 28px 6px 12px;
  font-size: 0.84rem;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M1 1l4 4 4-4' fill='none' stroke='%238e8e93' stroke-width='1.4' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.seg {
  display: inline-flex;
  background: var(--fill-2);
  border-radius: var(--r);
  padding: 2px;
  gap: 0;
  border: 1px solid var(--border);
}
.seg button, .seg a {
  border: none;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  transition: background var(--t) var(--ease), color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.seg button:hover, .seg a:hover { color: var(--ink); opacity: 1; }
.seg button[aria-pressed="true"],
.seg a.is-on,
.seg a[aria-current="page"] {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.filter-meta {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.problem-board { display: block; }
.problem-section.is-hidden { display: none; }
.problem-table { width: 100%; border: 1px solid var(--border); background: var(--surface); }
.problem-table .topic-head td {
  background: var(--fill-2);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
  padding: 7px 10px;
}
.problem-table .topic-head .n { float: right; color: var(--muted); font-weight: 600; }
.problem-cover {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  overflow: hidden;
  line-height: 0;
}
.problem-cover-svg { display: block; width: 28px; height: 28px; }
.problem-cover-lg { width: 40px; height: 40px; border-radius: 4px; }
.problem-cover-lg .problem-cover-svg { width: 40px; height: 40px; }
.problem-page-head { display: flex; align-items: flex-start; gap: 12px; }
.problem-page-head .row { margin-bottom: 4px; }

tr.problem-row td { padding: 6px 10px; }
tr.problem-row:hover td { background: var(--accent-bg); }
tr.problem-row.is-hidden { display: none; }
tr.problem-row .name { font-weight: 700; font-family: var(--mono); font-size: 13px; }
tr.problem-row .name a { color: var(--accent); text-decoration: none; }
tr.problem-row .name a:hover { text-decoration: underline; }
tr.problem-row .sub { color: var(--muted); font-size: 12px; }
tr.problem-row .meta { font-size: 12px; color: var(--muted); font-family: var(--mono); white-space: nowrap; }
tr.problem-row .best { font-weight: 700; font-family: var(--mono); font-size: 13px; }

.filter-empty { display: none; }
.filter-empty.is-visible { display: block; }

/* ---------- Problem page ---------- */

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 1000px) { .split { grid-template-columns: minmax(0, 1fr); } }

.statement { padding: 22px 24px; }
.statement h2 { margin: 24px 0 9px; font-size: 1.05rem; }
.statement h2:first-child { margin-top: 0; }
.statement p { margin: 0 0 12px; }
.statement ul, .statement ol { margin: 0 0 12px; padding-left: 22px; }
.statement li { margin-bottom: 5px; }
.statement code {
  background: var(--fill-2);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.87em;
}

.limits {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 12px 16px;
  background: var(--surface);
  border: none;
  border-radius: 14px;
  margin-bottom: 14px;
  font-size: 0.84rem;
}
.limits div { display: flex; gap: 6px; align-items: baseline; }
.limits dt { color: var(--muted); }
.limits dd { margin: 0; font-family: var(--mono); font-weight: 600; }

.sample { margin-bottom: 14px; }
.sample-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .sample-grid { grid-template-columns: 1fr; } }
.io-box {
  border: none;
  border-radius: 12px;
  overflow: hidden;
  background: var(--fill-2);
}
.io-box header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: transparent;
  border-bottom: 0.5px solid var(--separator);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.io-box pre {
  margin: 0;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow: auto;
}
.copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  font: inherit;
  font-size: 0.7rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0;
}
.copy-btn:hover { opacity: 0.7; }

.explain {
  margin-top: 9px;
  padding: 10px 12px;
  font-size: 0.86rem;
  color: var(--ink-2);
  background: var(--accent-bg);
  border-left: none;
  border-radius: 10px;
}

.run-panel { margin-top: 0; }
.run-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--separator);
}
@media (max-width: 720px) { .run-grid { grid-template-columns: 1fr; } }
.run-grid .io-box { border-radius: 0; background: var(--surface); }
.run-grid textarea, .run-file-body {
  width: 100%;
  border: none;
  border-radius: 0;
  background: transparent;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 120px;
  padding: 10px 12px;
}
.run-out {
  margin: 0;
  padding: 10px 12px;
  min-height: 120px;
  max-height: 280px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.84rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.run-files, .run-extra { padding: 0 0 8px; }
.run-file {
  margin: 10px 12px 0;
  background: var(--fill-2);
  border-radius: 12px;
  overflow: hidden;
}
.run-file-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
}
.run-file-name {
  width: 180px;
  min-height: 32px;
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: 0.84rem;
}
.run-extra .io-box { margin: 10px 12px 0; border-radius: 12px; }

.editor-panel { position: sticky; top: 56px; }
@media (max-width: 1000px) { .editor-panel { position: static; } }

.editor-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 0.5px solid var(--separator);
  background: transparent;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.editor-head .title { font-size: 0.82rem; font-weight: 650; color: var(--ink-2); }
.editor-head .spacer { margin-left: auto; }
.editor-head select {
  width: auto;
  min-height: 32px;
  padding: 4px 28px 4px 10px;
  font-size: 0.8rem;
}

.CodeMirror {
  height: 460px;
  font-family: var(--mono) !important;
  font-size: 13.5px;
  line-height: 1.55;
  border: none;
  background: var(--surface);
  color: var(--ink);
}
@media (max-width: 1000px) { .CodeMirror { height: 380px; } }

.editor-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-top: 0.5px solid var(--separator);
  background: transparent;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.editor-foot .spacer { margin-left: auto; }
kbd {
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--fill);
  border: none;
  box-shadow: none;
  color: var(--muted);
}

.result { margin-top: 14px; }
.result-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 0.5px solid var(--separator);
}
.result-score {
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.result-note { color: var(--muted); font-size: 0.87rem; }

.test-grid { display: flex; flex-wrap: wrap; gap: 5px; padding: 14px 18px; }
.test-chip {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--r-pill);
  border: none;
  cursor: pointer;
  display: inline-flex;
  gap: 5px;
  align-items: baseline;
}
.test-chip small { font-weight: 500; opacity: 0.75; }

.test-detail { padding: 0 18px 16px; }
.test-detail pre {
  margin: 4px 0 0;
  padding: 9px 12px;
  background: var(--fill-2);
  border: none;
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
  max-height: 180px;
  overflow: auto;
}
.compile-log {
  margin: 0;
  padding: 13px 16px;
  background: var(--fill-2);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 340px;
  overflow: auto;
  border-top: 0.5px solid var(--separator);
  color: var(--ink-2);
}

/* ---------- Gate (login / register) ---------- */

.gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  position: relative;
}
.gate::before { display: none; }
.gate-box {
  width: 100%;
  max-width: 360px;
  border-radius: var(--r);
  padding: 24px 22px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.gate-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--r);
  margin-bottom: 14px;
  background: var(--fill);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
}
.gate h1 { font-size: 1.35rem; font-weight: 700; margin-bottom: 4px; }
.gate .hint { margin-bottom: 20px; }
.gate form { display: flex; flex-direction: column; gap: 10px; }
.gate footer { margin-top: 28px; font-size: 0.78rem; color: var(--muted); }

/* ---------- Ranking ---------- */

.rank-pos { font-family: var(--mono); font-weight: 700; color: var(--muted); width: 46px; }
.rank-1 .rank-pos { color: #c9a227; }
.rank-2 .rank-pos { color: #8a8a8e; }
.rank-3 .rank-pos { color: #b08a5b; }
.score-cell { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.score-full { color: var(--ac); font-weight: 700; }
.score-part { color: #c77c02; }
.score-zero { color: var(--muted); }
.score-none { color: var(--muted); }
:root[data-theme="dark"] .score-part { color: var(--tle); }
.cell-user { display: flex; align-items: center; gap: 8px; }
.rank-table { border-collapse: separate; border-spacing: 0; }
.rank-table th:nth-child(1),
.rank-table td:nth-child(1) {
  position: sticky; left: 0; z-index: 2;
  background: var(--surface);
}
.rank-table th:nth-child(2),
.rank-table td:nth-child(2) {
  position: sticky; left: 46px; z-index: 2;
  background: var(--surface);
  min-width: 140px;
}
.rank-table tbody tr:hover td:nth-child(1),
.rank-table tbody tr:hover td:nth-child(2) {
  background: var(--surface-2);
}

/* ---------- Grouped lists (profile / account) ---------- */

.group {
  background: var(--surface);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 16px;
}
.group-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 14px 18px 6px;
}
.group-head h3 { font-size: 0.82rem; font-weight: 650; color: var(--muted); letter-spacing: 0.02em; text-transform: uppercase; }
.group-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-top: 0.5px solid var(--separator);
  min-height: 44px;
}
.group-row .lbl { color: var(--ink); flex: 1; }
.group-row .val {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 590;
}
.group-row .val.emph { color: var(--ink); font-weight: 650; }

.profile-shell {
  background: var(--surface);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 14px;
}
.profile-banner {
  height: 172px;
  border-radius: 0;
  position: relative;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 8% 115%, color-mix(in srgb, var(--banner-tint, #8e8e93) 58%, transparent), transparent 58%),
    radial-gradient(80% 70% at 96% -20%, color-mix(in srgb, var(--banner-tint, #8e8e93) 32%, transparent), transparent 52%),
    var(--surface-2);
}
.profile-banner.has-image {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.profile-banner.has-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 40%, color-mix(in srgb, var(--surface) 55%, transparent));
  pointer-events: none;
}
.profile-header-card {
  position: relative;
  z-index: 1;
  background: transparent;
  border-radius: 0;
  padding: 0 20px 16px;
  margin-top: 0;
}
.profile-avatar-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: -48px;
  margin-bottom: 12px;
}
.profile-meta-info { flex: 1; min-width: 220px; padding-top: 56px; }
.profile-avatar-row > .btn { margin-top: 56px; }
.profile-meta-info h1 {
  margin: 0 0 4px;
  font-size: 1.55rem;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.profile-tagline { color: var(--muted); font-size: 0.88rem; margin: 0; }
.profile-bio {
  margin-top: 8px;
  color: var(--ink-2);
  font-size: 0.95rem;
}

.profile-exp-bar-wrap { margin-top: 4px; }
.profile-exp-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.8rem;
  margin-bottom: 6px;
  color: var(--muted);
}
.profile-exp-labels b { color: var(--ink); font-weight: 650; }
.profile-exp-progress {
  height: 5px;
  background: var(--fill);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.profile-exp-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 480ms var(--ease);
}

.realm-path {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 0.5px solid var(--separator);
}
.realm-node {
  text-align: center;
  padding: 8px 4px 7px;
  border-radius: 12px;
  background: var(--fill-2);
  min-width: 0;
}
.realm-node .dot {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin: 0 auto 5px;
  background: currentColor;
}
.realm-node .nm {
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.realm-node .lv { font-size: 0.62rem; color: var(--muted); margin-top: 1px; }
.realm-node.is-off { opacity: 0.38; }
.realm-node.is-on {
  background: color-mix(in srgb, currentColor 14%, var(--fill-2));
  box-shadow: inset 0 0 0 0.5px color-mix(in srgb, currentColor 35%, transparent);
}
.realm-node.is-done { opacity: 0.9; }

.avatar-ring {
  position: relative;
  z-index: 2;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  padding: 3px;
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--ring, var(--accent));
  flex-shrink: 0;
}
.avatar-ring.ring-dashed { box-shadow: 0 0 0 3px var(--ring, var(--accent)); }
.avatar-ring.ring-double {
  box-shadow: 0 0 0 2px var(--ring, var(--accent)), 0 0 0 5px var(--surface), 0 0 0 7px var(--ring, var(--accent));
}
.avatar-ring img, .avatar-ring .letter {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fill);
  font-size: 32px;
  font-weight: 700;
  color: var(--ink);
}

.stat-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  background: transparent;
  border-radius: 0;
  margin: 14px -20px 0;
  overflow: hidden;
  border-top: 0.5px solid var(--separator);
}
.stat-box {
  padding: 12px 16px 10px;
  text-align: left;
  border-right: 0.5px solid var(--separator);
  background: transparent;
}
.stat-box:last-child { border-right: none; }
.stat-box .val {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.15;
}
.stat-box .lbl {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 4px;
  text-transform: none;
  letter-spacing: 0;
}

.verdict-bar {
  display: flex;
  height: 6px;
  border-radius: var(--r-pill);
  overflow: hidden;
  margin: 12px 0;
  background: var(--fill);
}
.verdict-seg { height: 100%; }
.verdict-seg-AC { background: var(--ac); }
.verdict-seg-WA { background: var(--wa); }
.verdict-seg-TLE { background: var(--tle); }
.verdict-seg-RTE { background: var(--rte); }
.verdict-seg-CE { background: var(--ce); }
.verdict-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.82rem;
  margin-top: 8px;
}
.verdict-item { display: flex; align-items: center; gap: 6px; }
.verdict-dot { width: 8px; height: 8px; border-radius: 50%; }

.heatmap-row { display: block; overflow-x: auto; padding: 8px 16px 14px; }
.heatmap-board { display: flex; gap: 6px; align-items: flex-start; min-width: min-content; }
.heatmap-dows {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  gap: 3px;
  font-size: 9px;
  color: var(--muted);
  line-height: 11px;
  padding-top: 16px;
  flex-shrink: 0;
}
.heatmap-cols { display: flex; flex-direction: column; gap: 4px; }
.heatmap-months {
  display: grid;
  grid-template-columns: repeat(var(--weeks, 53), 14px);
  height: 14px;
  font-size: 10px;
  color: var(--muted);
}
.heatmap-months span { white-space: nowrap; }
.heatmap-grid {
  display: inline-grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 11px);
  gap: 3px;
}
.heatmap-cell {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: var(--fill);
}
.heatmap-cell[data-level="1"] { background: #c6e48b; }
.heatmap-cell[data-level="2"] { background: #7bc96f; }
.heatmap-cell[data-level="3"] { background: #239a3b; }
.heatmap-cell[data-level="4"] { background: #196127; }
:root[data-theme="dark"] .heatmap-cell[data-level="1"] { background: #0e4429; }
:root[data-theme="dark"] .heatmap-cell[data-level="2"] { background: #006d32; }
:root[data-theme="dark"] .heatmap-cell[data-level="3"] { background: #26a641; }
:root[data-theme="dark"] .heatmap-cell[data-level="4"] { background: #39d353; }

.solved-tag-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 18px 16px; }
.solved-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--fill-2);
  border: none;
  border-radius: var(--r-pill);
  font-size: 0.8rem;
  color: var(--ink);
  transition: background var(--t-fast) var(--ease);
}
.solved-pill:hover { background: var(--fill); opacity: 1; }
.solved-pill .score { font-size: 0.72rem; font-weight: 700; color: var(--ac); }

.profile-cta {
  padding: 28px 20px;
  text-align: center;
}
.profile-cta p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.95rem;
}

.account-id {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.account-id h1 { font-size: 1.45rem; margin: 0 0 2px; }
.account-id .sub { color: var(--muted); font-size: 0.88rem; }

/* ---------- Subtask / IO ---------- */

.subtask-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.subtask-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: none;
  border-radius: 12px;
  background: var(--surface);
  font-size: 0.86rem;
}
.subtask-row .st-name { font-weight: 650; white-space: nowrap; }
.subtask-row .st-con { color: var(--ink-2); flex: 1; min-width: 0; }
.subtask-row .st-pts {
  font-family: var(--mono);
  font-weight: 700;
  white-space: nowrap;
  color: var(--muted);
}
.subtask-row.st-ok   { background: var(--ac-bg); }
.subtask-row.st-ok   .st-pts { color: var(--ac); }
.subtask-row.st-fail { background: var(--wa-bg); }
.subtask-row.st-fail .st-pts { color: var(--wa); }
.subtask-row .st-tests { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }

.io-mode {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  color: var(--rte);
  background: var(--rte-bg);
  border: none;
}

/* ---------- Account extras ---------- */

.preview-tile {
  width: 100%;
  height: 140px;
  border-radius: 14px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.crop-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.crop-sheet {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  border: 0.5px solid var(--glass-stroke);
  border-radius: 20px;
  padding: 20px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--glass-shadow);
}

/* ---------- Misc ---------- */

.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { margin-left: auto; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.katex { font-size: 1.02em; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 760px) {
  body { font-size: 16px; }
  h1 { font-size: 1.45rem; }
  .site-head .glass-bar {
    flex-wrap: wrap;
    height: auto;
    border-radius: 0;
    row-gap: 0;
  }
  .nav {
    flex: 1 0 100%;
    width: 100%;
    order: 3;
    margin: 0;
    justify-content: flex-start;
    gap: 2px;
    padding: 2px 4px 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  .whoami { border-left: none; padding-left: 0; }
  .whoami-profile b { display: none; }
  .hide-sm { display: none !important; }
  .filters-bar {
    top: 48px;
    flex-wrap: wrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .filters-bar .search-field { flex: 1 0 100%; min-width: 0; }
  .filters-bar .seg { flex-shrink: 0; }
  .filter-meta { display: none; }
  .problem-table .col-hide { display: none; }
  .problem-cover { width: 24px; height: 24px; }
  .problem-cover-svg { width: 24px; height: 24px; }
  tr.problem-row .sub,
  tr.problem-row .meta { display: none; }
  .diff-medium { font-size: 0; }
  .diff-medium::after { content: "TB"; font-size: 0.72rem; font-weight: 650; }
  .stat-grid-4 { grid-template-columns: 1fr 1fr; }
  .stat-box:nth-child(1), .stat-box:nth-child(2) { border-bottom: 0.5px solid var(--separator); }
  .stat-box:nth-child(2) { border-right: none; }
  .avatar-ring { width: 80px; height: 80px; }
  .realm-path { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .realm-node { min-width: 72px; flex: 1 0 auto; }
  .profile-banner { height: 132px; }
}

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