/* =============================================================
   AGORA — design system
   Dark-first, Steam-adjacent: deep blue-charcoal ground, brass
   accent, phosphor-teal arcade zone. One accent per zone; category
   colors stay low-chroma so the accent stays in charge.
   ============================================================= */
@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/assets/fonts/bricolage.woff2') format('woff2');
  font-weight: 300 800;
  font-stretch: 75% 125%;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/assets/fonts/jetbrains-mono.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}

:root {
  /* ground: blue-charcoal ramp, elevation by lightness */
  --bg0: #0D1117;         /* page */
  --bg1: #131A23;         /* cards, rails */
  --bg2: #1A2330;         /* raised: inputs, hover */
  --bg3: #222E3E;         /* overlays, menus */
  --line: #26313F;
  --line-strong: #384657;

  --text: #E7EDF3;
  --text-2: #9FB0C0;      /* 7.2:1 on bg0 */
  --text-3: #8494A5;      /* ~6:1 on bg0; ~5.3:1 on bg2 for pill-muted headroom */

  /* brass accent (forum zone) */
  --accent: #E3A94C;
  --accent-hi: #F0BE6C;
  --accent-ink: #1F1503;
  --accent-soft: rgba(227, 169, 76, 0.14);
  --accent-line: rgba(227, 169, 76, 0.38);

  --good: #58C08A;  --good-soft: rgba(88, 192, 138, 0.15);
  --bad:  #E06C6C;  --bad-soft: rgba(224, 108, 108, 0.15);

  --display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --sans: system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;

  --t-11: 0.6875rem; --t-12: 0.75rem; --t-13: 0.8125rem; --t-14: 0.875rem;
  --t-15: 0.9375rem; --t-17: 1.0625rem; --t-20: 1.25rem; --t-24: 1.5rem;
  --t-32: 2rem; --t-44: 2.75rem;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px;
  --s6: 32px; --s7: 48px; --s8: 64px;

  --r1: 6px; --r2: 10px; --r3: 14px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.35);
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --fast: 110ms; --med: 220ms;
  --measure: 68ch;
  --head-h: 3.5rem;
}
/* the arcade runs on phosphor, not brass */
[data-zone="arcade"] {
  --accent: #5BD8B7;
  --accent-hi: #83E5CC;
  --accent-ink: #062019;
  --accent-soft: rgba(91, 216, 183, 0.13);
  --accent-line: rgba(91, 216, 183, 0.36);
}

/* ----------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--head-h) + 12px); }
body {
  margin: 0; background: var(--bg0); color: var(--text);
  font-family: var(--sans); font-size: var(--t-15); line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.12; margin: 0; letter-spacing: -0.015em; text-wrap: balance; }
h1 { font-size: var(--t-32); font-weight: 640; }
h2 { font-size: var(--t-20); font-weight: 600; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s5) 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
::selection { background: var(--accent-line); }
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--accent); color: var(--accent-ink); padding: var(--s2) var(--s4);
  border-radius: 0 0 var(--r1) 0; font-weight: 600;
}
.skip-link:focus { left: 0; }
.muted { color: var(--text-3); }
.sep { color: var(--line-strong); margin: 0 0.35em; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* --------------------------------------------------------- header */
.site-head {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--bg0) 86%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.site-head-in {
  max-width: 76rem; margin: 0 auto; height: var(--head-h);
  display: flex; align-items: center; gap: var(--s4); padding: 0 var(--s4);
}
.brand {
  display: flex; align-items: center; gap: 9px; text-decoration: none;
  font-family: var(--display); font-weight: 700; font-size: var(--t-17); letter-spacing: -0.02em;
}
.brand-mark { width: 21px; height: 21px; fill: var(--accent); transition: fill var(--med) var(--ease); }
.site-nav { display: flex; gap: 2px; }
.site-nav a {
  padding: 6px 11px; border-radius: var(--r1); text-decoration: none;
  font-size: var(--t-13); font-weight: 550; color: var(--text-2);
  transition: background var(--fast) linear, color var(--fast) linear;
}
.site-nav a:hover { background: var(--bg2); color: var(--text); }
.site-nav a[aria-current] { color: var(--text); background: var(--bg2); }
.site-search {
  flex: 1; max-width: 22rem; margin-left: auto;
  display: flex; align-items: center; gap: var(--s2);
  background: var(--bg1); border: 1px solid var(--line); border-radius: var(--r1);
  padding: 0 var(--s3); height: 2.125rem;
  transition: border-color var(--fast) linear;
}
.site-search:focus-within { border-color: var(--accent-line); }
.site-search svg { width: 15px; height: 15px; stroke: var(--text-3); fill: none; stroke-width: 1.8; flex: none; }
.site-search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font-size: var(--t-13); color: var(--text); }
.site-search input::placeholder { color: var(--text-3); }
.site-actions { display: flex; align-items: center; gap: var(--s2); }
.icon-btn {
  position: relative; width: 2.125rem; height: 2.125rem; display: grid; place-items: center;
  border-radius: var(--r1); color: var(--text-2);
  transition: background var(--fast) linear, color var(--fast) linear;
}
.icon-btn:hover { background: var(--bg2); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.badge-dot {
  position: absolute; top: 5px; right: 5px; min-width: 8px; height: 8px;
  border-radius: 99px; background: var(--accent); border: 2px solid var(--bg0);
}
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; display: grid; place-items: center; border-radius: 99px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu[open] summary::after { content: ''; position: fixed; inset: 0; z-index: -1; }
.user-menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 80; min-width: 12rem;
  background: var(--bg3); border: 1px solid var(--line-strong); border-radius: var(--r2);
  box-shadow: var(--shadow); padding: var(--s1);
  display: flex; flex-direction: column;
}
.user-menu-panel a, .user-menu-panel button {
  display: block; width: 100%; text-align: left; padding: 8px 12px; border-radius: var(--r1);
  text-decoration: none; font-size: var(--t-13); color: var(--text-2);
  background: none; border: 0; cursor: pointer;
}
.user-menu-panel a:hover, .user-menu-panel button:hover { background: var(--bg2); color: var(--text); }
.user-menu-panel hr { margin: var(--s1) 0; }
.avatar { border-radius: 99px; flex: none; background: var(--bg2); }

/* --------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 2.25rem; padding: 0 var(--s4); border-radius: var(--r1); border: 1px solid transparent;
  font-size: var(--t-13); font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background var(--fast) linear, border-color var(--fast) linear, transform var(--fast) var(--ease);
  background: none;
}
.btn:active { transform: translateY(1px); }
.btn-solid { background: var(--accent); color: var(--accent-ink); }
.btn-solid:hover { background: var(--accent-hi); }
.btn-ghost { border-color: var(--line-strong); color: var(--text-2); }
.btn-ghost:hover { border-color: var(--accent-line); color: var(--text); }
.btn-danger { border: 1px solid var(--bad); color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { height: 1.75rem; padding: 0 var(--s3); font-size: var(--t-12); }
.btn-wide { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px;
  font-family: var(--mono); font-size: var(--t-11); font-weight: 600; letter-spacing: 0.04em;
  vertical-align: 2px;
}
.pill-solved { background: var(--good-soft); color: var(--good); }
.pill-muted { background: var(--bg2); color: var(--text-3); border: 1px solid var(--line); }
.pill-flag { background: var(--bad-soft); color: var(--bad); }
.pill-daily { background: var(--accent-soft); color: var(--accent); }
.pill-role[data-role="admin"] { background: var(--accent-soft); color: var(--accent); }
.pill-role[data-role="mod"] { background: var(--good-soft); color: var(--good); }

/* ---------------------------------------------------------- layout */
.site-main { max-width: 76rem; margin: 0 auto; padding: var(--s6) var(--s4) var(--s8); min-height: 70vh; }
.site-foot { border-top: 1px solid var(--line); }
.site-foot-in {
  max-width: 76rem; margin: 0 auto; padding: var(--s5) var(--s4);
  display: flex; justify-content: space-between; align-items: center;
  color: var(--text-3); font-size: var(--t-13);
}
.site-foot nav { display: flex; gap: var(--s4); }
.site-foot a { color: var(--text-3); text-decoration: none; }
.site-foot a:hover { color: var(--text-2); }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-sub { color: var(--text-2); font-size: var(--t-14); margin-top: 6px; max-width: var(--measure); }
.page-head-actions { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.section-label {
  font-family: var(--mono); font-size: var(--t-12); font-weight: 600; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--text-3); margin: var(--s6) 0 var(--s3);
}
.seg { display: inline-flex; background: var(--bg1); border: 1px solid var(--line); border-radius: var(--r1); padding: 2px; gap: 2px; }
.seg a {
  padding: 4px 12px; border-radius: 4px; font-size: var(--t-12); font-weight: 550;
  color: var(--text-3); text-decoration: none; transition: background var(--fast) linear, color var(--fast) linear;
}
.seg a:hover { color: var(--text); }
.seg a[aria-current] { background: var(--bg3); color: var(--text); }

.empty-state { padding: var(--s8) var(--s5); text-align: center; color: var(--text-3); }
.empty-state h2 { color: var(--text-2); margin-bottom: var(--s2); }
.empty-line { color: var(--text-3); font-size: var(--t-14); padding: var(--s4) 0; }
.pager { display: flex; align-items: center; justify-content: space-between; margin-top: var(--s5); }
.pager-page { font-family: var(--mono); font-size: var(--t-12); color: var(--text-3); }

/* ------------------------------------------------------ forum grid */
.forum-grid { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: var(--s6); align-items: start; }
.forum-rail { position: sticky; top: calc(var(--head-h) + 24px); display: flex; flex-direction: column; gap: var(--s3); }
.rail-label { font-family: var(--mono); font-size: var(--t-11); font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-3); }
.cat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.cat-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 9px; margin: 0 -9px;
  border-radius: var(--r1); text-decoration: none; font-size: var(--t-13); font-weight: 500; color: var(--text-2);
  transition: background var(--fast) linear, color var(--fast) linear;
}
.cat-link:hover { background: var(--bg2); color: var(--text); }
.cat-dot, .thread-cat-dot { width: 8px; height: 8px; border-radius: 2.5px; background: var(--cat, var(--text-3)); flex: none; }
.cat-count { margin-left: auto; font-family: var(--mono); font-size: var(--t-11); color: var(--text-3); }

/* ------------------------------------------------------ thread list */
.thread-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.thread-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s4);
  align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--line);
  transition: background var(--fast) linear;
}
.thread-row:hover { background: var(--bg1); }
.thread-row.is-unread .thread-title { font-weight: 650; }
.thread-main { min-width: 0; }
.thread-title {
  display: flex; align-items: center; gap: 7px; min-width: 0;
  font-size: var(--t-15); font-weight: 520; color: var(--text); text-decoration: none;
  letter-spacing: -0.006em;
}
.thread-title:hover { text-decoration: underline; text-decoration-color: var(--text-3); }
.thread-title .ico { width: 13px; height: 13px; stroke: var(--text-3); fill: none; stroke-width: 1.8; flex: none; }
.unread-dot { width: 7px; height: 7px; border-radius: 99px; background: var(--accent); flex: none; }
.thread-meta { display: flex; align-items: center; margin-top: 2px; font-size: var(--t-12); color: var(--text-3); min-width: 0; overflow: hidden; white-space: nowrap; }
.thread-meta a, .thread-cat { color: var(--text-2); text-decoration: none; }
.thread-meta a:hover { text-decoration: underline; }
.thread-stats { display: flex; align-items: center; gap: var(--s4); flex: none; }
.stat { font-family: var(--mono); font-size: var(--t-12); color: var(--text-2); text-align: right; min-width: 3.4rem; }
.stat i { font-style: normal; color: var(--text-3); margin-left: 4px; }
.thread-when { font-family: var(--mono); font-size: var(--t-12); color: var(--text-3); min-width: 4.2rem; text-align: right; }
.thread-when time { color: inherit; }

/* -------------------------------------------------------- thread page */
.thread-page { max-width: 56rem; }
.crumbs { display: flex; gap: 7px; font-size: var(--t-12); color: var(--text-3); margin-bottom: var(--s2); }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.thread-head { padding-bottom: var(--s4); border-bottom: 1px solid var(--line); margin-bottom: var(--s2); }
.thread-head h1 { font-size: var(--t-24); overflow-wrap: anywhere; }
.thread-head-meta { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: var(--t-12); color: var(--text-3); flex-wrap: wrap; }
.thread-mod-tools { display: inline-flex; gap: 6px; margin-left: auto; }

.post-list { list-style: none; margin: 0; padding: 0; }
.post {
  display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: var(--s5);
  padding: var(--s5) 0; border-bottom: 1px solid var(--line);
}
.post.is-solution { background: linear-gradient(to right, var(--good-soft), transparent 30%); margin: 0 calc(-1 * var(--s3)); padding-inline: var(--s3); border-radius: var(--r2); }
.post-tombstone { padding: var(--s3) 0; }
.tombstone { color: var(--text-3); font-style: italic; font-size: var(--t-13); }
.post-author { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.post-author-name { font-weight: 600; font-size: var(--t-13); color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.post-author-name:hover { text-decoration: underline; }
.post-author-level { font-family: var(--mono); font-size: var(--t-11); color: var(--text-3); }
.post-head { display: flex; align-items: center; gap: 8px; font-size: var(--t-12); color: var(--text-3); margin-bottom: var(--s2); flex-wrap: wrap; }
.post-number { font-family: var(--mono); color: var(--text-3); text-decoration: none; }
.post-number:hover { color: var(--accent); }
.reply-ref { color: var(--text-2); text-decoration: none; background: var(--bg1); border: 1px solid var(--line); border-radius: 4px; padding: 1px 7px; font-size: var(--t-11); }
.reply-ref:hover { border-color: var(--line-strong); }
.post:target { animation: flash 2s var(--ease); }
@keyframes flash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }

.post-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-top: var(--s3); flex-wrap: wrap; }
.reacts { display: flex; gap: 5px; flex-wrap: wrap; }
.react {
  display: inline-flex; align-items: center; gap: 5px; height: 1.65rem; padding: 0 9px;
  border-radius: 99px; border: 1px solid var(--line); background: none; cursor: pointer;
  font-size: var(--t-12); color: var(--text-2);
  transition: border-color var(--fast) linear, background var(--fast) linear, transform var(--fast) var(--ease);
}
.react:hover:not([disabled]) { border-color: var(--line-strong); background: var(--bg2); }
.react.is-on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.react[disabled] { cursor: default; }
.react-n { font-family: var(--mono); font-size: var(--t-11); }
.react.bump { animation: bump 350ms var(--ease); }
@keyframes bump { 35% { transform: scale(1.25); } }
.post-actions { display: flex; gap: 4px; }

/* ------------------------------------------------------------ prose */
.prose { max-width: var(--measure); overflow-wrap: break-word; line-height: 1.6; }
.prose > * + * { margin-top: 0.8em; }
.prose h2 { font-size: var(--t-17); margin-top: 1.4em; }
.prose h3, .prose h4 { font-size: var(--t-15); margin-top: 1.3em; font-family: var(--sans); font-weight: 650; }
.prose a { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent-line); }
.prose a:hover { text-decoration-color: var(--accent); }
.prose a.mention { text-decoration: none; background: var(--accent-soft); border-radius: 4px; padding: 0.05em 0.3em; font-weight: 550; }
.prose code { font-family: var(--mono); font-size: 0.86em; background: var(--bg1); border: 1px solid var(--line); border-radius: 4px; padding: 0.1em 0.35em; }
.prose pre { background: var(--bg1); border: 1px solid var(--line); border-radius: var(--r2); padding: var(--s4); overflow-x: auto; }
.prose pre code { background: none; border: 0; padding: 0; font-size: var(--t-13); line-height: 1.6; }
.prose blockquote { border-left: 2px solid var(--accent-line); padding-left: var(--s4); color: var(--text-2); margin-left: 0; }
.prose ul, .prose ol { padding-left: 1.4em; margin-top: 0.8em; }
.prose li { margin-top: 0.3em; }
.prose li::marker { color: var(--text-3); }
.prose img { border-radius: var(--r2); max-height: 480px; }

/* --------------------------------------------------------- composer */
.composer { margin-top: var(--s5); border: 1px solid var(--line); border-radius: var(--r2); background: var(--bg1); overflow: hidden; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.composer-head { display: flex; align-items: center; gap: var(--s2); padding: 9px var(--s4); background: var(--bg2); font-size: var(--t-13); border-bottom: 1px solid var(--line); }
.composer-hint { margin-left: auto; font-size: var(--t-12); color: var(--accent); display: inline-flex; gap: 6px; align-items: center; }
.composer-hint button { background: none; border: 0; color: inherit; cursor: pointer; font-size: var(--t-14); }
.composer textarea {
  display: block; width: 100%; min-height: 7.5rem; padding: var(--s4); background: none; border: 0; outline: 0;
  resize: vertical; color: var(--text); line-height: 1.6;
}
.composer-foot { display: flex; align-items: center; justify-content: space-between; padding: var(--s2) var(--s4) var(--s3); }
.composer-note { font-size: var(--t-12); color: var(--text-3); }
.thread-locked-note { margin-top: var(--s5); color: var(--text-3); font-size: var(--t-14); }
.thread-locked-note a { color: var(--accent); }

/* ------------------------------------------------------------ forms */
.auth-card { max-width: 24rem; margin: var(--s7) auto; background: var(--bg1); border: 1px solid var(--line); border-radius: var(--r3); padding: var(--s6); }
.auth-card h1 { font-size: var(--t-24); margin-bottom: var(--s2); }
.auth-sub { color: var(--text-2); font-size: var(--t-14); margin-bottom: var(--s4); }
.auth-alt { margin-top: var(--s4); font-size: var(--t-13); color: var(--text-3); }
.auth-alt a { color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s4); flex: 1; }
.field > span { font-size: var(--t-13); font-weight: 600; }
.field > span em { font-style: normal; font-weight: 400; color: var(--text-3); }
.field input, .field select, .field textarea {
  background: var(--bg0); border: 1px solid var(--line); border-radius: var(--r1);
  padding: 9px 12px; color: var(--text); font-size: var(--t-14);
  transition: border-color var(--fast) linear;
}
/* full-strength accent border + ring so keyboard focus clears 3:1 non-text contrast */
.field input:focus, .field select:focus, .field textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.field-row { display: flex; gap: var(--s4); }
/* checkbox row — used by the notification preferences form */
.check { display: flex; align-items: flex-start; gap: var(--s2); margin-bottom: var(--s3); }
.check input[type="checkbox"] {
  width: 16px; height: 16px; margin-top: 2px; flex: none;
  accent-color: var(--accent); cursor: pointer;
}
.check span { font-size: var(--t-14); color: var(--text-2); cursor: pointer; }
.check:hover span { color: var(--text); }
.compose-page { max-width: 46rem; }
.compose-form textarea { font-family: var(--sans); }
.compose-foot { display: flex; justify-content: flex-end; align-items: center; gap: var(--s4); }
.inline-form { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin: var(--s3) 0; }
.inline-form input, .inline-form select {
  background: var(--bg0); border: 1px solid var(--line); border-radius: var(--r1); padding: 7px 10px; font-size: var(--t-13); color: var(--text);
}

/* ----------------------------------------------------------- search */
.search-page { max-width: 50rem; }
.search-big { display: flex; gap: var(--s3); margin-bottom: var(--s4); }
.search-big input { flex: 1; background: var(--bg1); border: 1px solid var(--line); border-radius: var(--r1); padding: 10px 14px; font-size: var(--t-15); color: var(--text); }
.search-big input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.search-count { color: var(--text-3); font-size: var(--t-13); margin-bottom: var(--s4); }
.search-results { list-style: none; margin: 0; padding: 0; }
.search-hit { padding: var(--s4) 0; border-bottom: 1px solid var(--line); }
.search-hit-title { font-weight: 600; text-decoration: none; color: var(--text); }
.search-hit-title:hover { text-decoration: underline; }
.search-snippet { color: var(--text-2); font-size: var(--t-14); margin: 6px 0; }
.search-snippet mark { background: var(--accent-soft); color: var(--accent); border-radius: 3px; padding: 0 2px; }

/* ---------------------------------------------------------- profile */
.profile-page { max-width: 52rem; }
.profile-head { display: flex; gap: var(--s5); align-items: flex-start; flex-wrap: wrap; }
.profile-id { flex: 1; min-width: 16rem; }
.profile-handle { color: var(--text-3); font-family: var(--mono); font-size: var(--t-13); margin-top: 4px; }
.profile-bio { margin-top: var(--s3); color: var(--text-2); max-width: var(--measure); }
.profile-facts { margin-top: var(--s2); font-size: var(--t-13); color: var(--text-3); }
.profile-facts a { color: var(--accent); }
.profile-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.profile-level { display: flex; align-items: center; gap: var(--s3); margin: var(--s5) 0; }
.level-chip { font-family: var(--mono); font-size: var(--t-12); font-weight: 700; color: var(--accent); white-space: nowrap; }
.level-track { flex: 1; height: 6px; border-radius: 4px; background: var(--bg2); overflow: hidden; }
.level-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 600ms var(--ease); }
.level-next { font-family: var(--mono); font-size: var(--t-11); color: var(--text-3); white-space: nowrap; }
.stat-band {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr)); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--r2); overflow: hidden;
  margin: var(--s4) 0;
}
.stat-cell { background: var(--bg1); padding: var(--s3) var(--s4); }
.stat-cell b { display: block; font-family: var(--mono); font-size: var(--t-20); font-weight: 600; }
.stat-cell span { font-family: var(--mono); font-size: var(--t-11); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.07em; }
.badge-row { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2); }
.badge-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--bg1); font-size: var(--t-12); font-weight: 550;
}
.badge-chip[data-tier="gold"] { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }
.badge-chip[data-tier="silver"] { color: var(--text); }
.badge-chip[data-tier="bronze"] { color: var(--text-2); }
.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.mini-list a { color: var(--text); text-decoration: none; font-weight: 550; }
.mini-list a:hover { text-decoration: underline; }
.mini-list .muted, .mini-list span { font-size: var(--t-12); }

/* --------------------------------------------------- members / friends */
.member-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--s3); }
.member-card a {
  display: flex; gap: var(--s3); align-items: center; padding: var(--s3); border: 1px solid var(--line);
  border-radius: var(--r2); background: var(--bg1); text-decoration: none;
  transition: border-color var(--fast) linear;
}
.member-card a:hover { border-color: var(--line-strong); }
.member-name { display: block; font-weight: 600; }
.member-meta { display: block; font-size: var(--t-12); color: var(--text-2); }
.friend-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.friend-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--line); }
.friend-row > a { display: flex; align-items: center; gap: var(--s3); text-decoration: none; color: var(--text); font-weight: 550; }
.friend-row-actions { margin-left: auto; display: flex; gap: var(--s2); }

/* --------------------------------------------------------- messages */
.inbox-page, .convo-page { max-width: 46rem; }
.convo-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.convo-row a {
  display: grid; grid-template-columns: 11rem minmax(0, 1fr) auto; gap: var(--s4); align-items: center;
  padding: var(--s3) var(--s2); border-bottom: 1px solid var(--line); text-decoration: none;
  transition: background var(--fast) linear;
}
.convo-row a:hover { background: var(--bg1); }
.convo-row.is-unread .convo-subject { font-weight: 700; color: var(--text); }
.convo-with { font-size: var(--t-13); font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-subject { font-size: var(--t-14); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-meta { font-family: var(--mono); font-size: var(--t-11); color: var(--text-3); }
.msg-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s4); }
.msg { display: flex; gap: var(--s3); max-width: 85%; }
.msg.is-mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-bubble { background: var(--bg1); border: 1px solid var(--line); border-radius: var(--r2); padding: var(--s3) var(--s4); }
.msg.is-mine .msg-bubble { background: var(--accent-soft); border-color: var(--accent-line); }
.msg-bubble header { font-size: var(--t-12); color: var(--text-3); margin-bottom: 4px; }
.msg-bubble header b { color: var(--text-2); }

/* ------------------------------------------------------ notifications */
.notif-page { max-width: 44rem; }
.notif-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.notif-row a {
  display: flex; justify-content: space-between; gap: var(--s4); align-items: baseline;
  padding: var(--s3) var(--s2); border-bottom: 1px solid var(--line);
  text-decoration: none; color: var(--text-2); font-size: var(--t-14);
  transition: background var(--fast) linear;
}
.notif-row a:hover { background: var(--bg1); }
.notif-row.is-unread a { color: var(--text); background: var(--accent-soft); }
.notif-row.is-unread a:hover { background: var(--accent-soft); }
.notif-row b { color: var(--text); }
.notif-when { font-family: var(--mono); font-size: var(--t-11); color: var(--text-3); flex: none; }

/* ------------------------------------------------------- moderation */
.mod-page { max-width: 56rem; }
.flag-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s4); }
.flag-row { border: 1px solid var(--line); border-radius: var(--r2); background: var(--bg1); padding: var(--s4); }
.flag-reason { font-size: var(--t-13); color: var(--text-2); }
.flag-detail { color: var(--text-3); font-size: var(--t-13); margin-top: 4px; font-style: italic; }
.flag-quote { margin: var(--s3) 0 0; border-left: 2px solid var(--bad); padding-left: var(--s4); }
.flag-quote-meta { font-size: var(--t-12); color: var(--text-3); margin-bottom: 4px; }
.flag-quote-meta a { color: var(--text-2); }
.flag-actions { display: flex; gap: var(--s2); margin-top: var(--s3); flex-wrap: wrap; }
.modlog-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.modlog-row { display: flex; align-items: baseline; gap: var(--s2); padding: 7px 0; border-bottom: 1px solid var(--line); font-size: var(--t-13); flex-wrap: wrap; }
.modlog-when { margin-left: auto; font-family: var(--mono); font-size: var(--t-11); color: var(--text-3); }
.sanction-form input[name="reason"] { min-width: 16rem; }
.admin-cat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.admin-cat-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--line); font-size: var(--t-14); flex-wrap: wrap; }
.admin-cat-row code { font-family: var(--mono); font-size: var(--t-12); color: var(--text-3); }
.admin-cat-row .btn { margin-left: auto; }

/* --------------------------------------------------------- settings */
.settings-page { max-width: 42rem; }
.avatar-form { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.tfa-box { border: 1px solid var(--line); border-radius: var(--r2); background: var(--bg1); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.tfa-secret code { font-family: var(--mono); font-size: var(--t-14); background: var(--bg0); padding: 6px 10px; border-radius: var(--r1); border: 1px solid var(--line); letter-spacing: 0.1em; }
.tfa-codes { font-family: var(--mono); font-size: var(--t-13); background: var(--bg0); border: 1px solid var(--accent-line); border-radius: var(--r1); padding: var(--s3); line-height: 1.9; }
.session-list { list-style: none; margin: 0 0 var(--s4); padding: 0; }
.session-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--line); font-size: var(--t-13); }
.session-desc { font-family: var(--mono); font-size: var(--t-12); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 20rem; }
.session-row .btn { margin-left: auto; }

/* ----------------------------------------------------------- arcade */
.arcade-page { max-width: 64rem; }
.arcade-hero { padding: var(--s6) 0 var(--s5); }
.eyebrow { font-family: var(--mono); font-size: var(--t-12); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.arcade-hero h1 { font-size: clamp(2rem, 5vw, var(--t-44)); font-weight: 720; margin-top: var(--s2); }
.arcade-sub { color: var(--text-2); max-width: 46ch; margin-top: var(--s3); }
.cabinet-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--s4); }
.cabinet a {
  display: flex; flex-direction: column; gap: var(--s2); height: 100%;
  border: 1px solid var(--line); border-radius: var(--r2); background: var(--bg1); padding: var(--s4);
  text-decoration: none; color: var(--text); transition: border-color var(--fast) linear;
}
.cabinet a:hover { border-color: var(--accent-line); }
.cabinet-art { height: 5.5rem; border-radius: var(--r1); background: var(--bg2); position: relative; overflow: hidden; }
.cabinet-art::after {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 30% 40%, var(--accent-soft), transparent 55%),
    repeating-linear-gradient(to bottom, rgba(255,255,255,0.025) 0 1px, transparent 1px 3px);
}
.cabinet h2 { font-size: var(--t-17); }
.cabinet p { font-size: var(--t-13); color: var(--text-2); flex: 1; }
.cabinet-foot { font-family: var(--mono); font-size: var(--t-12); color: var(--text-3); }
.crown { color: var(--accent); }
.arcade-note { margin-top: var(--s5); color: var(--text-3); }
.arcade-note a { color: var(--accent); }

.game-page { max-width: 64rem; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: var(--s6); align-items: start; }
.game-rail { position: sticky; top: calc(var(--head-h) + 24px); }
.game-stage {
  border: 1px solid var(--line); border-radius: var(--r2); background: var(--bg1);
  min-height: 24rem; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--s5); gap: var(--s4); position: relative;
}
.game-stage-locked { color: var(--text-3); }
.game-stage-locked a { color: var(--accent); }
.board { list-style: none; margin: 0 0 var(--s5); padding: 0; counter-reset: rank; }
.board-row { display: flex; align-items: center; gap: var(--s2); padding: 6px 0; border-bottom: 1px solid var(--line); font-size: var(--t-13); }
.board-row.is-top .board-rank { color: var(--accent); }
.board-rank { font-family: var(--mono); font-size: var(--t-12); width: 1.4rem; text-align: right; color: var(--text-3); flex: none; }
.board-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); text-decoration: none; font-weight: 550; }
.board-name:hover { text-decoration: underline; }
.board-score { font-family: var(--mono); font-size: var(--t-13); font-weight: 700; }

/* in-game UI bits (built by game modules) */
.game-hud { display: flex; gap: var(--s5); align-items: baseline; font-family: var(--mono); font-size: var(--t-13); color: var(--text-3); }
.game-hud b { font-size: var(--t-20); color: var(--text); font-weight: 600; }
.game-msg { font-size: var(--t-14); color: var(--text-2); text-align: center; }
.game-over-card { text-align: center; display: flex; flex-direction: column; gap: var(--s3); align-items: center; }
.game-over-card .big { font-family: var(--mono); font-size: var(--t-32); font-weight: 700; color: var(--accent); }
canvas.game-canvas { border-radius: var(--r1); image-rendering: pixelated; touch-action: none; max-width: 100%; }

.lexeme-grid { display: grid; grid-template-rows: repeat(6, 1fr); gap: 5px; }
.lexeme-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.lexeme-cell {
  width: 3.1rem; height: 3.1rem; display: grid; place-items: center;
  border: 2px solid var(--line-strong); border-radius: var(--r1);
  font-family: var(--display); font-size: var(--t-24); font-weight: 700; text-transform: uppercase;
  transition: transform 120ms var(--ease);
}
.lexeme-cell.filled { border-color: var(--text-3); }
.lexeme-cell.hit { background: var(--good); border-color: var(--good); color: #08130D; }
.lexeme-cell.near { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.lexeme-cell.miss { background: var(--bg2); border-color: var(--bg2); color: var(--text-3); }
.lexeme-kb { display: flex; flex-direction: column; gap: 5px; width: 100%; max-width: 26rem; }
.lexeme-kb-row { display: flex; gap: 4px; justify-content: center; }
.lexeme-kb button {
  flex: 1; min-width: 1.4rem; height: 2.6rem; border-radius: var(--r1); border: 0;
  background: var(--bg3); color: var(--text); font-weight: 600; text-transform: uppercase; cursor: pointer;
  font-size: var(--t-13);
}
.lexeme-kb button.wide { flex: 1.6; font-size: var(--t-11); font-family: var(--mono); }
.lexeme-kb button.hit { background: var(--good); color: #08130D; }
.lexeme-kb button.near { background: var(--accent); color: var(--accent-ink); }
.lexeme-kb button.miss { background: var(--bg1); color: var(--text-3); }

.recall-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: min(22rem, 90vw); }
.recall-card {
  aspect-ratio: 1; border-radius: var(--r1); background: var(--bg3); border: 0; cursor: pointer;
  display: grid; place-items: center; font-size: var(--t-24); color: transparent;
  transition: background var(--med) var(--ease);
}
.recall-card.up, .recall-card.done { background: var(--bg2); border: 1px solid var(--accent-line); color: var(--text); }
.recall-card.done { background: var(--accent-soft); cursor: default; }

.reflex-pad {
  width: min(26rem, 90vw); aspect-ratio: 1.6; border-radius: var(--r2); border: 0; cursor: pointer;
  display: grid; place-items: center; font-size: var(--t-17); font-weight: 700;
  background: var(--bg3); color: var(--text-2);
}
/* dark ink on the red pad: #fff was 3.22:1 (fails AA); #2A0D0D is ~9:1 */
.reflex-pad.wait { background: var(--bad); color: #2A0D0D; }
.reflex-pad.go { background: var(--good); color: #08130D; }

.cascade-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; background: var(--bg2); padding: 8px; border-radius: var(--r2); width: min(21rem, 88vw); aspect-ratio: 1; touch-action: none; }
.cascade-tile { display: grid; place-items: center; border-radius: var(--r1); font-family: var(--display); font-weight: 700; font-size: var(--t-20); background: var(--bg1); }

/* --------------------------------------------------------- misc pages */
.prose-page { max-width: var(--measure); }
.prose-page h1 { margin-bottom: var(--s4); }
.prose-page h2 { margin: var(--s5) 0 var(--s2); }
.prose-page p, .prose-page li { color: var(--text-2); }
.prose-page ul { padding-left: 1.4em; }
.prose-page li { margin-top: 0.4em; }
.page-error { display: grid; place-items: center; min-height: 100vh; }
.error-box { text-align: center; }
.error-code { font-family: var(--mono); font-size: var(--t-13); color: var(--accent); letter-spacing: 0.2em; }
.error-box h1 { margin: var(--s3) 0 var(--s5); }

.toast-region { position: fixed; right: var(--s4); bottom: var(--s4); z-index: 120; display: flex; flex-direction: column; gap: var(--s2); align-items: flex-end; }
.toast {
  background: var(--bg3); border: 1px solid var(--line-strong); border-radius: var(--r2);
  box-shadow: var(--shadow); padding: 10px 16px; font-size: var(--t-13); max-width: 22rem;
  animation: toast-in 240ms var(--ease);
}
.toast[data-kind="error"] { border-color: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateX(12px); } }

/* ------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .forum-grid { grid-template-columns: minmax(0, 1fr); }
  .forum-rail { position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .cat-list { flex-direction: row; flex-wrap: wrap; gap: 2px; }
  .cat-link { margin: 0; }
  .cat-count { display: none; }
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  .game-rail { position: static; }
  .post { grid-template-columns: minmax(0, 1fr); gap: var(--s2); }
  .post-author { flex-direction: row; align-items: center; gap: var(--s2); }
  .site-search { display: none; }
  .thread-stats .stat { display: none; }
  .msg { max-width: 100%; }
  .field-row { flex-direction: column; gap: 0; }
}
@media (max-width: 560px) {
  .site-nav a { padding: 6px 8px; }
  .site-main { padding-inline: var(--s3); }
  .thread-row { gap: var(--s2); }
  .thread-when { min-width: auto; }
  .lexeme-cell { width: 2.6rem; height: 2.6rem; font-size: var(--t-20); }
}

/* attach control in the composers */
.attach { display: inline-flex; cursor: pointer; }
.attach span { pointer-events: none; }

/* Discord sign-in — brand colour, kept to the one control that needs it */
.btn-discord {
  background: #5865F2; color: #fff; border-color: #5865F2;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-discord:hover { background: #4752C4; border-color: #4752C4; color: #fff; }
.auth-or {
  display: flex; align-items: center; gap: var(--s3);
  margin: var(--s4) 0; color: var(--text-3); font-size: var(--t-12);
}
.auth-or::before, .auth-or::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}

/* ---- profile guestbook ---- */
.profile-comments { margin-top: var(--s6); }
.pc-form textarea {
  width: 100%; background: var(--bg2); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: var(--s3);
  font: inherit; resize: vertical;
}
.pc-form textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.pc-list { list-style: none; margin: var(--s5) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--s4); }
.pc-item { display: flex; gap: var(--s3); align-items: flex-start; }
.pc-avatar { flex: none; line-height: 0; }
.pc-body { flex: 1; min-width: 0; }
.pc-head { display: flex; align-items: baseline; gap: var(--s2); font-size: var(--t-12); color: var(--text-3); }
.pc-name { font-weight: 600; font-size: var(--t-13); color: var(--text); text-decoration: none; }
.pc-name:hover { text-decoration: underline; }
.pc-del {
  margin-left: auto; background: none; border: 0; cursor: pointer;
  color: var(--text-3); font-size: var(--t-15); line-height: 1; padding: 0 4px;
}
.pc-del:hover { color: var(--accent); }
.pc-text { margin-top: 2px; font-size: var(--t-14); }
.pc-text > *:first-child { margin-top: 0; }
