:root,
[data-theme="light"] {
  --page: #e9ebf0;
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --bg-elev-2: #f4f5f8;
  --line: #dfe2e9;
  --ink: #141b2d;
  --ink-2: #3c4458;
  --ink-3: #6b7387;
  --nav: #1b2a63;
  --nav-2: #24367a;
  --nav-ink: #ffffff;
  --head: #233571;
  --link: #1d3d91;
  --accent: #1d3d91;
  --accent-ink: #ffffff;
  --hot: #c62f2f;
  --pin: #9a6a00;
  --lock: #a04b12;
  --good: #1e7a45;
  --shadow: 0 1px 2px rgba(20, 27, 45, 0.06);
  color-scheme: light;
}

[data-theme="dark"] {
  --page: #0b0f1c;
  --bg: #121829;
  --bg-elev: #151c30;
  --bg-elev-2: #1b2339;
  --line: #273150;
  --ink: #e8ebf3;
  --ink-2: #c1c7d6;
  --ink-3: #8b93a8;
  --nav: #16224f;
  --nav-2: #1f2f69;
  --nav-ink: #ffffff;
  --head: #1f2f69;
  --link: #9db7ff;
  --accent: #6f8ff0;
  --accent-ink: #0b0f1c;
  --hot: #ff7a7a;
  --pin: #f0c766;
  --lock: #f0a46a;
  --good: #8fd6a8;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button, input, select, textarea { font-family: inherit; font-size: 14px; line-height: 1.4; color: inherit; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0 0 0.7em; }

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 18px; }

/* ---------- header ---------- */
.masthead { background: var(--nav); }
.masthead-row { display: flex; align-items: center; gap: 14px; height: 76px; }
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand img { display: block; width: auto; }
.brand .mark { height: 40px; }
.brand .wordmark { height: 26px; }
.tagline { color: rgba(255, 255, 255, 0.66); font-size: 12.5px; letter-spacing: 0.02em; }
.navbar {
  background: var(--nav-2);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}
.navbar-row { display: flex; align-items: center; gap: 8px; min-height: 44px; }
#topnav { display: flex; align-self: stretch; }
#topnav a {
  display: flex;
  align-items: center;
  color: rgba(255, 255, 255, 0.86);
  padding: 0 14px;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}
#topnav a:hover { color: #fff; background: rgba(255, 255, 255, 0.07); }
#topnav a.active { color: #fff; background: var(--nav); }
#account { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.topsearch input {
  width: 180px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 3px;
  color: #fff;
  padding: 6px 9px;
}
.topsearch input::placeholder { color: rgba(255, 255, 255, 0.62); }
.topsearch input:focus { outline: none; background: rgba(255, 255, 255, 0.2); }
#themeToggle {
  background: transparent;
  color: rgba(255, 255, 255, 0.86);
  border: 0;
  padding: 6px 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
#themeToggle:hover { color: #fff; }
.navbar .btn { color: #fff; background: transparent; border-color: transparent; font-size: 14px; }
.navbar .btn:hover { background: rgba(255, 255, 255, 0.08); }
.navbar .btn-primary { background: transparent; border-color: transparent; }
.acct { display: inline-flex; align-items: center; gap: 8px; color: #fff; padding: 0 8px; font-weight: 600; }
.acct:hover { text-decoration: none; }
.acct-name { color: #fff; }
.count {
  display: inline-block;
  min-width: 1.4em;
  padding: 1px 5px;
  border-radius: 9px;
  background: var(--hot);
  color: #fff;
  font-size: 11px;
  text-align: center;
}

/* ---------- page ---------- */
.page {
  background: var(--bg);
  min-height: calc(100vh - 120px);
  padding-top: 4px;
  padding-bottom: 48px;
  box-shadow: var(--shadow);
}
.crumb { padding: 12px 0 8px; color: var(--ink-3); font-size: 13px; }
.crumb a { color: var(--ink-2); }
.crumb-sep { margin: 0 6px; color: var(--ink-3); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 12px; }
.side-actions { display: flex; justify-content: flex-end; gap: 6px; }
.widget, .cat, .tl, .post, .coin-head, .compose, .reply-box, .notice, .report, .rules, .member-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 3px;
}
.widget, .cat, .tl { overflow: hidden; }
.widget-head, .cat-head, .tl-head {
  padding: 9px 12px;
  background: var(--head);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
}
.cat { margin-bottom: 14px; }
.cat-title { font-size: 16px; font-weight: 600; }
.cat-desc { font-size: 12px; font-weight: 400; color: rgba(255, 255, 255, 0.72); margin-top: 1px; }
.widget-body { padding: 4px 12px; }

.stat-list { margin: 6px 0; }
.stat-list > div { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.stat-list dt { color: var(--ink-2); }
.stat-list dd { margin: 0; font-weight: 600; color: var(--ink); }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-cell .v { font-weight: 600; font-size: 16px; }
.stat-cell .l, .lp-meta, .mp-meta, .tr-meta, .meta, .mc-stats, .mc-title, .coin-meta, .coin-note, .node-empty {
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.35;
}

/* ---------- board list ---------- */
.node-row, .thread-row {
  display: grid;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.cat-head + .node-row, .tl-head + div > .thread-row:first-child { border-top: 0; }
.node-row:hover, .thread-row:hover { background: var(--bg-elev-2); }
.node-row { grid-template-columns: 44px minmax(0, 1.6fr) 130px minmax(190px, 1fr); }
.thread-row { grid-template-columns: 36px minmax(0, 1fr) 110px minmax(170px, 0.75fr); }
.node-icon {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  flex: 0 0 auto;
  background: var(--tone-bg);
  box-shadow: inset 0 0 0 1px var(--tone-line);
}
.node-title { font-size: 16px; font-weight: 600; color: var(--link); }
.t, .lp-title, .mp-title { font-weight: 600; color: var(--link); }
.node-desc { color: var(--ink-2); font-size: 13px; margin-top: 1px; }
.node-stats { display: flex; justify-content: center; gap: 22px; margin: 0; text-align: center; }
.node-stats dt { color: var(--ink-3); font-size: 12px; }
.node-stats dd { margin: 0; font-weight: 600; font-size: 14px; color: var(--ink); }
.node-last, .tr-last, .mini-post { display: flex; gap: 9px; align-items: center; min-width: 0; }
.lp-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.ll, .mp-body { min-width: 0; }
.ll { display: flex; flex-direction: column; }
.mini-post { align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); }
.mini-post:last-child { border-bottom: 0; }
.mp-line { line-height: 1.5; }
.mp-title { font-size: 13.5px; }

.node-head { display: flex; align-items: center; gap: 12px; }

/* board colors */
.tone-general { --tone: #4b5a7d; --tone-bg: #e8ecf5; --tone-line: #cfd6e6; }
.tone-shill { --tone: #13894a; --tone-bg: #e3f5ea; --tone-line: #bfe4cd; }
.tone-slander { --tone: #c62f2f; --tone-bg: #fbe6e6; --tone-line: #f0c3c3; }
.tone-jfl { --tone: #b07800; --tone-bg: #fdf3d9; --tone-line: #f1dca2; }
.tone-news { --tone: #1f6fd6; --tone-bg: #e3eefc; --tone-line: #bfd5f5; }
[data-theme="dark"] .tone-general { --tone-bg: #222c46; --tone-line: #34405f; }
[data-theme="dark"] .tone-shill { --tone: #1f9d58; --tone-bg: #16352a; --tone-line: #23523d; }
[data-theme="dark"] .tone-slander { --tone: #d23c3c; --tone-bg: #3a1c22; --tone-line: #5a2a31; }
[data-theme="dark"] .tone-jfl { --tone: #b8860b; --tone-bg: #3a3018; --tone-line: #5a4a22; }
[data-theme="dark"] .tone-news { --tone: #2f7be0; --tone-bg: #172c4d; --tone-line: #24426f; }

.prefix {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 6px;
  padding: 1px 7px 1px 5px;
  border-radius: 3px;
  background: var(--tone);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.6;
  vertical-align: 1px;
  white-space: nowrap;
}
.prefix:hover { text-decoration: none; filter: brightness(1.08); }
.prefix span { font-size: 12px; }

.tl-head { display: grid; grid-template-columns: minmax(0, 1fr) 110px minmax(170px, 0.75fr); gap: 12px; padding-left: 60px; font-size: 13px; }
.tr-stats { color: var(--ink-3); font-size: 12px; line-height: 1.35; text-align: right; }
.tr-stats .n { color: var(--ink); font-weight: 600; }
.c-r { text-align: right; }
.empty, .notice { padding: 14px; color: var(--ink-2); }

.page-head { margin: 4px 0 14px; }
.page-head h1, .thread-title-block h1 { margin: 0 0 4px; font-size: 24px; }
.page-head p { margin: 0; color: var(--ink-2); }
.page-head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.filters { display: flex; gap: 6px; }

/* ---------- controls ---------- */
.chip, .btn, .react-btn {
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg-elev);
  color: var(--ink);
  padding: 7px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 13px;
  line-height: 1;
}
.chip.active, .btn-primary { background: var(--nav-2); color: #fff; border-color: var(--nav-2); }
.btn-primary:hover { background: var(--nav); }
.btn-ghost { background: transparent; }
.btn-sm, .react-btn { padding: 5px 9px; font-size: 12px; }
.react-btn.on { color: var(--hot); border-color: var(--hot); }
a.btn:hover { text-decoration: none; }

.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 2px 6px;
  margin-right: 6px;
  border-radius: 3px;
  border: 1px solid var(--line);
  color: var(--ink-2);
  vertical-align: 1px;
}
.badge.hot { color: var(--hot); border-color: var(--hot); }
.badge.pin { color: var(--pin); border-color: var(--pin); }
.badge.lock { color: var(--lock); border-color: var(--lock); }
.badge.tag { color: var(--accent); border-color: var(--accent); }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 4px;
  background: #3b4a7a;
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  flex: 0 0 auto;
  object-fit: cover;
}
.a-28 { width: 24px; height: 24px; font-size: 9px; border-radius: 50%; }
.a-34 { width: 30px; height: 30px; font-size: 10px; }
.a-44 { width: 36px; height: 36px; font-size: 11px; }
.a-80 { width: 96px; height: 96px; font-size: 22px; }

/* ---------- posts ---------- */
.post { display: grid; grid-template-columns: 170px minmax(0, 1fr); margin-bottom: 10px; overflow: hidden; }
.post-user { padding: 14px 12px; background: var(--bg-elev-2); border-right: 1px solid var(--line); text-align: center; }
.post-user .avatar { margin: 0 auto; }
.pu-name { font-weight: 700; margin-top: 8px; }
.post-body { padding: 12px 14px; min-width: 0; }
.post-top { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 12px; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.pu-title, .pu-stats { color: var(--ink-3); font-size: 12px; line-height: 1.35; }
.pu-title.guest { font-style: italic; }
.pu-rankbar { height: 4px; border-radius: 2px; background: var(--line); margin: 8px 0; overflow: hidden; }
.pu-rankbar i { display: block; height: 100%; background: var(--accent); }
.pu-stats { text-align: left; }
.pu-stats .row { display: flex; justify-content: space-between; gap: 8px; }
.pu-stats b { color: var(--ink-2); font-weight: 600; }
.post-content { overflow-wrap: anywhere; font-size: 15px; }
.ticker { font-weight: 700; }
.quote { border-left: 3px solid var(--accent); background: var(--bg-elev-2); padding: 8px 10px; margin: 0 0 10px; color: var(--ink-2); }
.q-who { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 4px; }
.sig { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 13px; }
.post-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.likes { color: var(--ink-3); font-size: 12px; }
.spacer { flex: 1; }
.disclosure, .removed-banner, .removed-note {
  display: block;
  margin-bottom: 8px;
  padding: 6px 8px;
  border-radius: 3px;
  background: var(--bg-elev-2);
  color: var(--ink-2);
  font-size: 13px;
}
.post-stub { display: block; padding: 12px 14px; }
.guest-name { color: var(--ink-3); }

.coin-head { padding: 12px 14px; margin-bottom: 12px; }
.coin-top, .coin-ca, .modbar, .ra, .report-actions, .posting-as { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.coin-ticker { font-size: 22px; font-weight: 600; }
.coin-ca { margin-top: 8px; }
.coin-label { color: var(--ink-3); font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.mono, .coin-ca code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.coin-note { margin-top: 8px; }
.thread-title-block { margin: 4px 0 12px; }
.thread-title-block .meta { display: flex; flex-wrap: wrap; align-items: center; }

/* ---------- forms ---------- */
.reply-box, .compose { padding: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; flex: 1; }
.field span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field em { font-style: normal; color: var(--ink-3); font-weight: 500; }
.field input, .field textarea, .field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 8px 10px;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field textarea { min-height: 140px; resize: vertical; }
.field-row { display: flex; gap: 10px; }
.check { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; color: var(--ink-2); font-size: 13px; }
.form-error { color: var(--hot); background: var(--bg-elev-2); border-radius: 3px; padding: 8px 10px; margin: 8px 0; font-size: 13px; }
.form-error[hidden] { display: none; }
.ra { justify-content: flex-end; }
.posting-as { margin-bottom: 8px; color: var(--ink-2); font-size: 13px; }
.linklike { background: none; border: 0; color: var(--link); padding: 0; cursor: pointer; font: inherit; }
.modbar { margin-bottom: 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 3px; }
.modbar-label { font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; z-index: 5; min-width: 180px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 3px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.menu-list button, .menu-list .btn { justify-content: flex-start; }

.rules { padding: 4px 18px 16px; }
.rules li { margin: 8px 0; }
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.member-card { display: flex; gap: 12px; padding: 12px; align-items: center; text-decoration: none; color: inherit; }
.member-card:hover { background: var(--bg-elev-2); text-decoration: none; }
.mc-name { font-weight: 600; color: var(--link); }
.report { padding: 12px 14px; margin-bottom: 10px; }
.report blockquote { margin: 8px 0; color: var(--ink-2); }
.report-note { font-size: 13px; color: var(--ink-3); }
.log-row { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.log-row em { margin-left: auto; color: var(--ink-3); font-style: normal; }

#toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--nav);
  color: #fff;
  border-radius: 3px;
  padding: 8px 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 40;
  font-size: 13px;
}
#toast.show { opacity: 1; }

#dlg {
  width: min(440px, calc(100vw - 32px));
  border: 0;
  border-radius: 4px;
  background: var(--bg-elev);
  color: var(--ink);
  padding: 0;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(11, 15, 28, 0.35);
}
#dlg::backdrop { background: rgba(11, 15, 28, 0.5); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--head); color: #fff; }
.dlg-head h2 { margin: 0; font-size: 16px; }
.dlg-x { background: none; border: 0; color: #fff; font-size: 20px; cursor: pointer; }
.dlg-body { padding: 8px 14px 14px; }
.dlg-note { color: var(--ink-3); font-size: 13px; }

@media (max-width: 900px) {
  .wrap { padding: 0 12px; }
  .masthead-row { height: 60px; }
  .tagline { display: none; }
  .navbar-row { flex-wrap: wrap; padding-bottom: 6px; }
  #topnav { overflow-x: auto; }
  #topnav a { padding: 10px 10px; }
  .topsearch { order: 5; flex-basis: 100%; }
  .topsearch input { width: 100%; }
  .layout, .post, .thread-row { display: block; }
  .node-row { grid-template-columns: 42px minmax(0, 1fr); }
  .node-stats { justify-content: flex-start; grid-column: 2; }
  .node-last { grid-column: 2; }
  .tr-stats, .tr-last { margin-top: 8px; text-align: left; }
  .tl-head { display: none; }
  .side { margin-top: 14px; }
  .post-user { border-right: 0; border-bottom: 1px solid var(--line); }
  .page-head-row, .field-row { display: block; }
  .page-head-row .btn { margin-top: 10px; }
}
