/* ============================================================
   MSBSU.COM — design system
   Tech-dark by default, light theme via [data-theme="light"].
   ============================================================ */

:root {
  --font: 'Inter', 'SolaimanLipi', 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', sans-serif;
  --mono: 'JetBrains Mono', 'SolaimanLipi', 'Fira Code', 'Cascadia Code', Consolas, monospace;
  --radius: 14px;
  --radius-sm: 9px;
  --nav-h: 64px;
  --top-h: 56px;
  --max-w: 980px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070b12;
  --bg-2: #0b111c;
  --card: rgba(17, 24, 39, 0.72);
  --card-solid: #101826;
  --border: rgba(120, 150, 200, 0.16);
  --text: #e6edf7;
  --text-2: #92a3bd;
  --accent: #1f9d5c;
  /* Brighter than the light-theme value on purpose: this dark maroon needs
     more luminance to stay legible against the near-black background —
     the original #b0294b measured ~2.9:1 contrast on --bg-2 (icons using
     it in the ic-grad gradient were nearly invisible at that end). */
  --accent-2: #d6336c;
  --accent-glow: rgba(31, 157, 92, 0.35);
  --danger: #f87171;
  --ok: #0d9488;
  --grid-line: rgba(90, 130, 190, 0.05);
  --rain: rgba(170, 205, 190, 0.32);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --board-light: #e8e2c9;
  --board-dark: #2f6f4e;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6fb;
  --bg-2: #e9eef7;
  --card: rgba(255, 255, 255, 0.85);
  --card-solid: #ffffff;
  --border: rgba(30, 60, 110, 0.14);
  --text: #14202f;
  --text-2: #5a6c84;
  --accent: #0f7a45;
  --accent-2: #8c2239;
  --accent-glow: rgba(15, 122, 69, 0.22);
  --danger: #dc2626;
  --ok: #0f766e;
  --grid-line: rgba(30, 60, 110, 0.05);
  --rain: rgba(90, 130, 115, 0.32);
  --shadow: 0 8px 26px rgba(30, 50, 90, 0.12);
  --board-light: #f3efdd;
  --board-dark: #3b8059;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  overflow-x: hidden;
  transition: background 0.35s, color 0.35s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button { font-family: inherit; }

/* ---------- atmosphere layers ---------- */
#rain-canvas {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  opacity: 0; transition: opacity 1.2s ease;
}
#rain-canvas.raining { opacity: 1; }
#lightning {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(ellipse at 50% -10%, rgba(190, 220, 255, 0.9), rgba(140, 170, 255, 0.25) 45%, transparent 75%);
  opacity: 0;
}
#lightning.flash { animation: thunder-flash 0.9s ease-out; }
@keyframes thunder-flash {
  0% { opacity: 0; } 6% { opacity: .85; } 12% { opacity: .1; }
  20% { opacity: .6; } 32% { opacity: .05; } 45% { opacity: .25; } 100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #rain-canvas, #lightning, #scroll-progress { display: none !important; }
}

/* ---------- background ---------- */
/* A static CSS gradient pattern — no JS, no animation, painted once. */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, black 30%, transparent 80%);
  mask-image: radial-gradient(ellipse at 50% 0%, black 30%, transparent 80%);
}

.sr-svg-sprite { position: absolute; }

.ic-grad-stop-start { stop-color: var(--accent); }

.ic-grad-stop-end { stop-color: var(--accent-2); }

/* Reading-progress bar: the one motion effect kept, since it's genuinely
   useful (shows how far down the page you are) and cheap (one rAF-gated
   transform on scroll, nothing else running). Rain, lightning, drifting
   background orbs, scroll-reveal and pointer-tilt were all removed —
   decorative only, and the continuous per-frame work was the actual
   source of the reported lag. */
#scroll-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 120;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform: scaleX(0); transform-origin: 0 50%;
  box-shadow: 0 0 10px var(--accent-glow);
  pointer-events: none;
}

/* Cards keep a plain CSS :hover lift — cheap, GPU-composited, no JS. */
.content-card, .tool-card { transition: transform .25s ease, border-color .22s, box-shadow .22s; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.05rem; color: var(--text); letter-spacing: 0.06em; }
.brand:hover { text-decoration: none; }
.brand-mark { filter: drop-shadow(0 0 8px var(--accent-glow)); }
.icon { display: inline-block; vertical-align: -0.2em; flex: none; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 1px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.icon-btn:hover { border-color: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: none; }
.avatar-mini { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); cursor: pointer; }
.user-chip { display: flex; align-items: center; gap: 8px; }

/* ---------- global search ---------- */
.search-overlay {
  position: fixed; inset: 0; z-index: 200; background: rgba(5, 8, 14, 0.7);
  display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 20px;
}
.search-box {
  width: 100%; max-width: 560px; background: var(--card-solid); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; max-height: 72vh;
  display: flex; flex-direction: column;
}
.search-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.search-icon { flex: none; display: flex; opacity: 0.7; }
.search-input { flex: 1; border: none; background: none; outline: none; color: var(--text); font-size: 1.02rem; font-family: inherit; }
.search-input::-webkit-search-cancel-button { display: none; }
.search-results { overflow-y: auto; }
.search-result {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); color: var(--text);
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--bg-2); text-decoration: none; }
.sr-ico { flex: none; margin-top: 2px; opacity: 0.85; }
.sr-body { min-width: 0; }
.sr-body b { display: inline; }
.sr-kind {
  margin-left: 8px; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--accent); vertical-align: middle;
}
.sr-body p { margin: 2px 0 0; font-size: 0.83rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- layout ---------- */
#app { position: relative; z-index: 5; max-width: var(--max-w); margin: 0 auto; padding: 0 16px; }
.view { animation: view-in 0.35s ease; }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.view-head { padding: 26px 0 10px; }
.view-head h1 { font-size: 1.7rem; letter-spacing: -0.02em; }
.section { margin: 34px 0; }

/* Generic "two sections side by side on desktop, stacked on mobile" grid —
   used for Education/experience and for On this day/Math & science search.
   Sections keep their own heading; the grid item itself carries no margin
   (gap does the spacing) and only the wrapper does, so grid items' margins
   don't fight the gap in the gutter direction. */
.edu-exp-grid { display: grid; grid-template-columns: 1fr; gap: 34px; margin: 34px 0; }
.edu-exp-grid .section { margin: 0; }
@media (min-width: 880px) {
  .edu-exp-grid { grid-template-columns: 1fr 1fr; column-gap: 44px; }
}
.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 1.15rem; margin-bottom: 14px; letter-spacing: -0.01em;
}
.section-title span { position: relative; padding-left: 14px; }
.section-title span::before {
  content: ''; position: absolute; left: 0; top: 3px; bottom: 3px; width: 4px;
  border-radius: 4px; background: linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 10px var(--accent-glow);
}
.see-all { font-size: 0.85rem; font-weight: 600; }
.muted { color: var(--text-2); }
/* ---------- footer ---------- */
.site-footer {
  margin-top: 46px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
}
.footer-inner {
  max-width: var(--max-w); margin: 0 auto;
  padding: 40px 20px 26px;
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 30px;
}
.footer-brand { max-width: 340px; }
.footer-logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; color: var(--text); }
.footer-logo:hover { text-decoration: none; }
.footer-tagline { margin-top: 8px; color: var(--text-2); font-size: 0.88rem; line-height: 1.6; }
.footer-brand .socials { justify-content: flex-start; margin-top: 16px; gap: 8px; }
.footer-brand .socials a { width: 32px; height: 32px; }
.footer-col h4 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-2); margin-bottom: 12px; }
.footer-col { display: flex; flex-direction: column; gap: 10px; }
.footer-col a { color: var(--text-2); font-size: 0.9rem; }
.footer-col a:hover { color: var(--accent); text-decoration: none; }
.footer-bottom {
  max-width: var(--max-w); margin: 0 auto;
  padding: 16px 20px calc(18px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  text-align: center; color: var(--text-2); font-size: 0.82rem;
}
@media (max-width: 640px) {
  .footer-inner { grid-template-columns: 1fr; gap: 26px; }
  .footer-brand { max-width: none; }
}

/* ---------- cards, buttons, inputs ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  padding: 18px;
}
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.content-card { padding: 0; overflow: hidden; cursor: pointer; transition: transform 0.22s, border-color 0.22s, box-shadow 0.22s; }
.content-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 10px 34px var(--accent-glow); }
.content-card .cover { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; background: var(--bg-2); }
.content-card .cover-ph { width: 100%; aspect-ratio: 16/9; display: flex; align-items: center; justify-content: center; font-size: 2rem; background: linear-gradient(135deg, var(--bg-2), var(--card-solid)); color: var(--accent); }
.content-card .body { padding: 14px 16px 16px; }
.content-card h3 { font-size: 1.02rem; margin-bottom: 6px; }
.content-card p { font-size: 0.86rem; color: var(--text-2); line-height: 1.5; max-height: 4.2em; overflow: hidden; }
.card-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; font-size: 0.75rem; color: var(--text-2); }

.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--card-solid); color: var(--text);
  padding: 10px 18px; font-size: 0.92rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none; color: #fff;
  box-shadow: 0 4px 18px var(--accent-glow);
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
/* Icons normally use the brand gradient (see icons.js) so they read fine on
   plain backgrounds — but placed on a button that's filled with that same
   gradient, an icon in its own colors blends straight into it. Force these
   to the button's own (white) text color instead. */
.btn-primary .icon, .nav-home-btn .icon { stroke: currentColor; }
.btn-primary .icon [fill="url(#ic-grad)"], .nav-home-btn .icon [fill="url(#ic-grad)"] { fill: currentColor; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; border-radius: 8px; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.input, textarea.input, select.input {
  width: 100%; background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 14px; font-size: 0.95rem; font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--border);
  padding: 5px 12px; border-radius: 999px; font-size: 0.78rem; color: var(--text-2);
}
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip.sel, .chip:hover { border-color: var(--accent); color: var(--accent); cursor: pointer; }
.tabs { display: inline-flex; background: var(--bg-2); border: 1px solid var(--border); border-radius: 11px; padding: 4px; gap: 4px; margin-top: 10px; }
.tab { border: none; background: transparent; color: var(--text-2); padding: 7px 18px; border-radius: 8px; font-weight: 600; font-size: 0.88rem; cursor: pointer; }
.tab.active { background: var(--card-solid); color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,0.25); }
.pager { display: flex; justify-content: center; gap: 8px; margin: 22px 0; }
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 18px); left: 50%; transform: translateX(-50%);
  background: var(--card-solid); border: 1px solid var(--accent); color: var(--text);
  padding: 11px 20px; border-radius: 12px; z-index: 200; font-size: 0.9rem;
  box-shadow: 0 6px 26px var(--accent-glow); max-width: 92vw;
}

/* Custom right-click menu (see assets/js/content-guard.js) — replaces the
   native context menu on public pages with just Copy/Paste/Select all. */
.ctx-menu {
  position: fixed; z-index: 500; min-width: 150px;
  background: var(--card-solid); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 5px; display: flex; flex-direction: column; gap: 1px;
}
.ctx-menu button {
  border: none; background: transparent; color: var(--text); text-align: left;
  padding: 8px 12px; border-radius: 6px; font-size: 0.88rem; font-family: inherit; cursor: pointer;
}
.ctx-menu button:hover { background: var(--bg-2); color: var(--accent); }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 46px 0 8px; }
.hero-avatar-ring {
  width: 132px; height: 132px; margin: 0 auto 18px; border-radius: 50%;
  padding: 4px; background: conic-gradient(from 180deg, var(--accent), var(--accent-2), var(--accent));
  box-shadow: 0 0 34px var(--accent-glow);
}
.hero-avatar-ring img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: var(--bg-2); display: block; }
.hero-name { font-size: clamp(1.9rem, 6vw, 2.8rem); letter-spacing: -0.03em; }
.hero-tagline {
  margin-top: 8px; font-size: clamp(1rem, 3.4vw, 1.25rem); font-weight: 600;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-details { margin: 12px auto 0; max-width: 560px; color: var(--text-2); line-height: 1.6; }
.hero-meta { margin-top: 16px; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.socials { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.socials a {
  width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--border); color: var(--text-2);
  transition: all 0.2s;
}
.socials a:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 6px 16px var(--accent-glow); }
.about-card { line-height: 1.75; color: var(--text); }
.about-text { white-space: pre-wrap; margin: 0; }
.about-text.clamp {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4;
  overflow: hidden;
}
.about-toggle { margin-top: 10px; }
/* Compact by default: only the first couple of timeline items show, the
   rest fade out under a hard cap until "Show all" is clicked. */
.timeline-collapsed .timeline-extra { display: none; }
.timeline-toggle { margin: 14px 0 0 50px; }
@media (max-width: 640px) { .timeline-toggle { margin-left: 0; } }
/* A connecting rail with the logo/icon as a circular marker on it, like a
   resume timeline — replaces the earlier flat stack of identical cards. */
.timeline { position: relative; display: flex; flex-direction: column; gap: 20px; padding-left: 50px; }
.timeline::before {
  content: ''; position: absolute; left: 19px; top: 6px; bottom: 6px; width: 2px;
  background: linear-gradient(var(--accent), var(--accent-2)); opacity: 0.32;
}
.timeline-item { position: relative; min-width: 0; }
.timeline-logo {
  position: absolute; left: -50px; top: 0; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--card-solid); display: flex; align-items: center; justify-content: center;
  overflow: hidden; border: 2px solid var(--accent);
  box-shadow: 0 0 0 4px var(--bg);
}
.timeline-logo img { width: 100%; height: 100%; object-fit: contain; }
.timeline-body {
  min-width: 0; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
}
.timeline-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.timeline-head b { font-size: 0.98rem; }
.timeline-period { margin-left: auto; font-size: 0.78rem; color: var(--text-2); white-space: nowrap; }
.timeline-sub { font-size: 0.86rem; color: var(--text-2); margin-top: 2px; }
.contact-cta { text-align: center; padding: 30px; }
.contact-cta h3 { margin-bottom: 8px; }
.contact-cta .btn { margin-top: 14px; }
/* Featured: swipeable snap carousel on phones (cards peek 85% wide so the
   next one is visibly cut off — the affordance that there's more), a clean
   3-per-row grid on desktop. */
.featured-strip {
  display: grid; grid-auto-flow: column; grid-auto-columns: 85%;
  gap: 14px; overflow-x: auto; padding-bottom: 10px;
  scroll-snap-type: x mandatory;
}
.featured-strip::-webkit-scrollbar { display: none; }
.featured-strip .content-card { scroll-snap-align: center; }
@media (min-width: 760px) {
  .featured-strip {
    grid-auto-flow: row; grid-auto-columns: unset;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow-x: visible; scroll-snap-type: none; gap: 16px;
  }
}
.badge {
  display: inline-block; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #fff;
  padding: 3px 9px; border-radius: 999px; margin-bottom: 8px;
}
.otd-teaser { font-size: 0.92rem; line-height: 1.65; }
.otd-year { color: var(--accent); font-weight: 700; font-family: var(--mono); margin-right: 8px; }

/* ---------- math & science / knowledge search ---------- */
.sci-search-card { padding: 14px; }
.sci-seg.seg { padding: 3px; }
.sci-seg button { padding: 7px 8px; font-size: 0.8rem; color: white; }
.sci-search-compact #sci-q { font-size: 0.9rem; }
.sci-result {
  display: flex; gap: 10px; align-items: flex-start; padding: 8px 6px;
  border-radius: var(--radius-sm); color: var(--text); cursor: default;
}
a.sci-result:hover { background: var(--bg-2); text-decoration: none; }
button.sci-result { width: 100%; border: none; background: none; font: inherit; text-align: left; cursor: pointer; }
button.sci-result:hover { background: var(--bg-2); }
.sci-result img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; flex: none; }
.sci-result b { font-size: 0.88rem; }
.sci-result p { color: var(--text-2); line-height: 1.4; }

/* NASA result full-view modal: enlarged image (fullscreen-able, downloadable)
   plus the complete, untruncated title/date/description. */
.nasa-modal { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; padding: 5vh 16px; }
.nasa-modal-backdrop { position: absolute; inset: 0; background: rgba(2, 4, 8, 0.78); }
.nasa-modal-card {
  position: relative; width: 100%; max-width: 620px; max-height: 90vh; overflow-y: auto;
  background: var(--card-solid); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.nasa-modal-close { position: absolute; top: 10px; right: 10px; z-index: 2; background: var(--card-solid); }
.nasa-modal-img-wrap { position: relative; background: var(--bg-2); }
.nasa-modal-img { display: block; width: 100%; max-height: 50vh; object-fit: contain; }
.nasa-modal-imgbar { position: absolute; bottom: 10px; right: 10px; display: flex; gap: 8px; }
.nasa-modal-imgbar .icon-btn { background: rgba(10, 14, 22, 0.72); border-color: rgba(255, 255, 255, 0.25); color: #fff; }
.nasa-modal-imgbar .icon-btn .icon { stroke: currentColor; }
.nasa-modal-body { padding: 16px 18px 20px; }
.nasa-modal-title { font-size: 1.05rem; }
.nasa-modal-desc { color: var(--text-2); font-size: 0.92rem; }

/* ---------- post detail / blocks ---------- */
#post-detail { padding: 20px 0 40px; }
.post-hero { margin-bottom: 20px; }
.post-hero img { border-radius: var(--radius); width: 100%; max-height: 380px; object-fit: cover; }
.post-title { font-size: clamp(1.5rem, 5vw, 2.2rem); letter-spacing: -0.02em; margin: 14px 0 8px; }
.post-meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--text-2); font-size: 0.83rem; align-items: center; }
.post-content { margin-top: 26px; line-height: 1.8; font-size: 1.02rem; }
.post-content > * + * { margin-top: 18px; }
.post-content h2 { font-size: 1.45rem; margin-top: 34px; }
.post-content h3 { font-size: 1.18rem; margin-top: 26px; }
.post-content img { border-radius: var(--radius-sm); }
.post-content blockquote {
  border-left: 3px solid var(--accent); padding: 10px 18px; background: var(--card);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-2); font-style: italic;
}
.post-content pre {
  background: #0a0f18; color: #d6e4ff; border: 1px solid var(--border);
  padding: 16px; border-radius: var(--radius-sm); overflow-x: auto;
  font-family: var(--mono); font-size: 0.87rem; line-height: 1.6;
}
[data-theme="light"] .post-content pre { background: #101826; }
.post-content ul, .post-content ol { padding-left: 26px; }
.post-content hr { border: none; border-top: 1px dashed var(--border); }
.post-content figcaption { text-align: center; font-size: 0.8rem; color: var(--text-2); margin-top: 6px; }
.align-center { text-align: center; }

/* ---------- legal pages (privacy policy, etc.) ---------- */
.legal-doc { padding: 28px 30px; line-height: 1.75; }
.legal-doc h2 { font-size: 1.2rem; margin-top: 28px; margin-bottom: 6px; }
.legal-doc h2:first-of-type { margin-top: 18px; }
.legal-doc p { margin: 10px 0; color: var(--text-2); }
.legal-doc ul { padding-left: 22px; margin: 10px 0; color: var(--text-2); }
.legal-doc li { margin: 6px 0; }
.legal-doc code { background: var(--bg-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; font-family: var(--mono); font-size: 0.85em; }
.legal-doc b { color: var(--text); }

/* ---------- row/column, table & gallery blocks ---------- */
.block-row { display: grid; grid-template-columns: repeat(var(--cols, 2), 1fr); gap: 22px; }
.block-col > * + * { margin-top: 18px; }
@media (max-width: 640px) { .block-row { grid-template-columns: 1fr; } }
.table-scroll { overflow-x: auto; }
.content-table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
.content-table th, .content-table td { padding: 9px 14px; border: 1px solid var(--border); text-align: left; }
.content-table th { background: var(--card); font-weight: 700; }
.block-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.block-gallery img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: var(--radius-sm); }
.align-right { text-align: right; }
.align-justify { text-align: justify; }
.block-btn-wrap { text-align: center; }

/* reactions & comments */
.reactions-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 26px 0 8px; }
.react-btn {
  border: 1px solid var(--border); background: var(--card); border-radius: 999px;
  padding: 7px 14px; cursor: pointer; font-size: 0.95rem; color: var(--text); transition: all 0.15s;
}
.react-btn:hover { border-color: var(--accent); transform: scale(1.06); }
.react-btn.mine { border-color: var(--accent); background: var(--accent-glow); }
.react-btn small { color: var(--text-2); margin-left: 5px; }
.comments { margin-top: 34px; }
.comment { display: flex; gap: 12px; padding: 14px 0; border-top: 1px solid var(--border); }
.comment img { width: 36px; height: 36px; border-radius: 50%; flex: none; }
.comment .c-body { flex: 1; min-width: 0; }
.comment .c-head { font-size: 0.85rem; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.comment .c-head b { color: var(--text); }
.comment .c-head time { color: var(--text-2); font-size: 0.75rem; }
.comment p { margin-top: 4px; font-size: 0.93rem; line-height: 1.6; overflow-wrap: break-word; }
.comment .replies { margin-top: 8px; padding-left: 14px; border-left: 2px solid var(--border); }
.comment-form { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.reply-note { font-size: 0.8rem; color: var(--accent); display: flex; gap: 8px; align-items: center; }

/* ---------- tools ---------- */
.privacy-banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 20px; font-size: 0.86rem; color: var(--text-2);
}
.privacy-banner .icon { flex: none; }
.section-title-icon { margin-right: 2px; }
/* Off-screen tool sections skip layout/paint until scrolled near — the hub
   has 40+ cards and this keeps first render fast on low-end phones. */
.tool-section { content-visibility: auto; contain-intrinsic-size: auto 300px; }
.tools-search { position: relative; margin-bottom: 18px; }
.tools-search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.tools-search input { padding-left: 42px; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin: 14px 0 26px; }
.tool-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 14px; text-align: center; cursor: pointer; transition: all 0.2s; color: var(--text);
  min-height: 118px;
}
.tool-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 8px 22px var(--accent-glow); }
.tool-card .t-ico {
  width: 52px; height: 52px; margin: 0 auto 10px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent-glow), color-mix(in srgb, var(--accent-2) 18%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
}
.tool-card:hover .t-ico { box-shadow: 0 0 16px var(--accent-glow); }
.tool-card h4 { font-size: 0.9rem; margin-bottom: 4px; }
.tool-card p { font-size: 0.73rem; color: var(--text-2); }
@media (max-width: 560px) {
  .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}
#tool-panel-body { margin-top: 14px; }
#tool-panel-body h3 { margin-bottom: 12px; }
.tool-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; align-items: center; }
.tool-row label { font-size: 0.85rem; color: var(--text-2); }
.tool-out { margin-top: 14px; }

/* scan-to-pdf page thumbnails */
.scan-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin-top: 14px; }
.scan-page { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg-2); }
.scan-page img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; }
.scan-page-bar { display: flex; justify-content: space-between; align-items: center; padding: 5px 8px; font-size: 0.72rem; color: var(--text-2); }
.scan-page-bar button { border: none; background: transparent; color: var(--text-2); cursor: pointer; font-size: 0.85rem; padding: 1px 5px; border-radius: 5px; }
.scan-page-bar button:not(:disabled):hover { background: var(--bg); color: var(--accent); }
.scan-page-bar button:disabled { opacity: 0.3; cursor: default; }

.drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 34px 16px;
  text-align: center; color: var(--text-2); cursor: pointer; transition: all 0.2s;
}
.drop-zone:hover, .drop-zone.drag { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.otd-list { list-style: none; }
.otd-list li { padding: 12px 0; border-bottom: 1px solid var(--border); line-height: 1.6; font-size: 0.93rem; }
textarea.tool-ta { min-height: 140px; font-family: var(--mono); font-size: 0.86rem; resize: vertical; }

/* ---------- toolkit: progress ---------- */
.tk-progress { margin: 12px 0; }
.tk-progress-label { font-size: .82rem; color: var(--text-2); margin-bottom: 6px; }
.tk-progress-track { height: 8px; border-radius: 5px; background: var(--bg-2); overflow: hidden; border: 1px solid var(--border); }
.tk-progress-fill {
  height: 100%; width: 0; border-radius: 5px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .25s ease;
}

/* ---------- pdf tools ---------- */
.pdf-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin: 14px 0; }
.pdf-thumb { text-align: center; border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: var(--bg-2); }
.pdf-thumb.deleted { opacity: .35; }
.pdf-thumb .pt-img img { width: 100%; border-radius: 6px; display: block; background: #fff; }
.pdf-thumb .pt-img { transition: transform .25s; }
.pt-blank { aspect-ratio: 3/4; display: flex; align-items: center; justify-content: center; color: var(--text-2); background: #fff2; border: 1px dashed var(--border); border-radius: 6px; }
.pt-num { font-size: .72rem; color: var(--text-2); margin-top: 6px; }
.pt-actions { display: flex; justify-content: center; gap: 2px; margin-top: 4px; flex-wrap: wrap; }
.pt-actions button {
  border: 1px solid var(--border); background: var(--card-solid); color: var(--text);
  border-radius: 6px; cursor: pointer; font-size: .72rem; padding: 3px 6px;
}
.pt-actions button:hover { border-color: var(--accent); color: var(--accent); }
.file-list { margin: 12px 0; }
.file-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .88rem; }

.anno-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0; }
.anno-stage { overflow: auto; max-height: 66vh; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-2); padding: 10px; }
.anno-stack { position: relative; margin: 0 auto; width: fit-content; }
.anno-base { display: block; max-width: 100%; border-radius: 4px; }
.anno-overlay { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.sig-pad { width: 100%; background: #fff; border-radius: 10px; border: 1px dashed var(--border); touch-action: none; cursor: crosshair; }
.sig-box { position: absolute; transform: translate(-50%, -50%); cursor: grab; filter: drop-shadow(0 2px 8px rgba(0,0,0,.35)); touch-action: none; }
.sig-box:active { cursor: grabbing; }

/* ---------- video tools ---------- */
.vt-video { width: 100%; max-height: 46vh; border-radius: 12px; border: 1px solid var(--border); background: #000; display: block; }
.vt-range { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; margin: 10px 0; font-size: .85rem; color: var(--text-2); }
.vt-range input[type="range"] { width: 100%; accent-color: var(--accent); }
.vt-time { font-family: var(--mono); font-size: .82rem; }
.rec-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1.2s infinite; margin-right: 6px; }

/* ---------- image crop tool ---------- */
.crop-stage { position: relative; margin: 12px auto; width: fit-content; max-width: 100%; touch-action: none; }
.crop-stage canvas { display: block; max-width: 100%; border-radius: 10px; }
.crop-box {
  position: absolute; border: 2px dashed #fff; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  cursor: move; touch-action: none;
}
.crop-handle {
  position: absolute; right: -9px; bottom: -9px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--accent); border: 2px solid #fff; cursor: nwse-resize; touch-action: none;
}

/* ---------- games ---------- */
.game-hud { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.game-canvas { width: 100%; max-width: 480px; display: block; margin: 0 auto; border-radius: 12px; border: 1px solid var(--border); touch-action: none; }

/* text-diff viewer */
.diff-view { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; overflow-x: auto; font-family: var(--mono); font-size: 0.85rem; line-height: 1.6; white-space: pre; }
.diff-view span { display: block; }
.df-add { background: rgba(52, 211, 153, 0.14); color: var(--ok); }
.df-del { background: rgba(248, 113, 113, 0.14); color: var(--danger); }
.df-ctx { color: var(--text-2); }

/* Connect Four board */
.c4-board {
  display: grid; gap: 6px; max-width: 420px; margin: 0 auto; padding: 10px;
  background: linear-gradient(160deg, var(--accent), var(--accent-2)); border-radius: 14px;
}
.c4-cell {
  aspect-ratio: 1; border: none; border-radius: 50%; cursor: pointer;
  background: var(--bg); transition: transform .1s;
}
.c4-cell:hover { transform: scale(1.06); }
.c4-cell.red { background: radial-gradient(circle at 35% 30%, #ff6b6b, #d1263a); }
.c4-cell.yellow { background: radial-gradient(circle at 35% 30%, #ffe066, #f0b000); }
.g2-board {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  max-width: 380px; margin: 0 auto; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 14px; padding: 8px;
  touch-action: none; transition: opacity .3s;
}
.g2-board.g2-over { opacity: .45; }
.g2-cell {
  aspect-ratio: 1/1; border-radius: 9px; background: var(--card-solid);
  display: flex; align-items: center; justify-content: center; font-weight: 800;
}
.me-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 400px; margin: 0 auto; }
.me-card {
  aspect-ratio: 1/1; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card-solid); cursor: pointer; position: relative;
  transform-style: preserve-3d; transition: transform .4s; font-size: 1.7rem;
}
.me-card .me-front, .me-card .me-back {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  backface-visibility: hidden; border-radius: 12px;
}
.me-card .me-front { color: var(--text-2); }
.me-card .me-back { transform: rotateY(180deg); background: var(--accent-glow); }
.me-card.open, .me-card.done { transform: rotateY(180deg); }
.me-card.done { border-color: var(--ok); cursor: default; }
.tt-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 320px; margin: 0 auto; }
.tt-cell {
  aspect-ratio: 1/1; font-size: 2.2rem; font-weight: 800; border-radius: 12px;
  border: 1px solid var(--border); background: var(--card-solid); color: var(--accent); cursor: pointer;
  transition: all .15s;
}
.tt-cell:hover:not(.filled) { border-color: var(--accent); }

/* ---------- portfolio generator ---------- */
.pf-layout { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .pf-layout { grid-template-columns: 1fr; } }
.pf-form { display: grid; gap: 12px; max-height: 72vh; overflow-y: auto; padding-right: 4px; }
.pf-h { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-2); margin-bottom: 8px; }
.pf-frame { width: 100%; height: 68vh; border: 1px solid var(--border); border-radius: 12px; background: #fff; }

/* ---------- chat (fixed floating widget) ---------- */
.chat-widget {
  position: fixed; z-index: 150;
  right: 20px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px);
  width: min(380px, calc(100vw - 32px));
  /* dvh, not vh: tracks the browser chrome expanding/collapsing on mobile.
     The on-screen keyboard is handled separately in JS via visualViewport
     (initChatWidget) since neither vh nor dvh reacts to it. */
  height: min(560px, calc(100vh - var(--nav-h) - env(safe-area-inset-bottom) - 90px));
  height: min(560px, calc(100dvh - var(--nav-h) - env(safe-area-inset-bottom) - 90px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card-solid); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  transform: translateY(24px) scale(0.97); opacity: 0; pointer-events: none;
  transition: transform 0.28s cubic-bezier(.22,.65,.3,1), opacity 0.22s ease;
}
.chat-widget.open { transform: none; opacity: 1; pointer-events: auto; }
.chat-widget-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border); flex: none;
}
.chat-widget-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 0.92rem; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 86%; padding: 11px 15px; border-radius: 16px; font-size: 0.9rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: break-word; animation: view-in 0.25s ease; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--bg-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.sys { align-self: center; background: transparent; color: var(--text-2); font-size: 0.78rem; text-align: center; }
.msg.typing::after { content: '▍'; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }
.chat-form { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--border); flex: none; }
.chat-captcha { padding: 12px 18px; border-top: 1px solid var(--border); flex: none; }
@media (max-width: 560px) {
  .chat-widget { right: 8px; left: 8px; width: auto; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); }
}

/* ---------- chess ---------- */
.chess-mode-tabs { margin-bottom: 18px; }
.chess-puzzle-block { margin-top: 40px; }
/* "Back to lobby" sits above the board, its own row. */
.chess-game-head { margin-bottom: 14px; }
/* Single-line control bar (nav + draw/resign/etc.) stuck to the bottom of
   the viewport (above the mobile bottom-nav) so it's always reachable
   without scrolling back up, however long the move list gets. */
.chess-sticky-toolbar {
  position: sticky;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 10px);
  z-index: 20;
  margin-top: 16px;
  display: flex; align-items: center; gap: 8px;
  overflow-x: auto; white-space: nowrap;
  padding: 10px 12px;
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.chess-sticky-toolbar::-webkit-scrollbar { height: 0; }
.chess-sticky-toolbar .btn, .chess-sticky-toolbar .icon-btn { flex: none; }
.toolbar-sep { flex: none; width: 1px; align-self: stretch; background: var(--border); margin: 0 2px; }
@media (min-width: 761px) { .chess-sticky-toolbar { bottom: 16px; } }
/* Nudges mobile visitors that this bar scrolls sideways for more actions —
   a fading edge plus a pulsing chevron, both gone once they've scrolled it. */
@media (max-width: 760px) {
  .chess-sticky-toolbar.has-more::after {
    content: '\203A';
    position: absolute; top: 1px; right: 1px; bottom: 1px; width: 30px;
    display: flex; align-items: center; justify-content: flex-end; padding-right: 5px;
    background: linear-gradient(to right, transparent, var(--card-solid) 55%);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--accent); font-size: 1.3rem; font-weight: 800; line-height: 1;
    pointer-events: none;
    animation: chess-scroll-hint 1.4s ease-in-out infinite;
  }
}
@keyframes chess-scroll-hint {
  0%, 100% { opacity: 0.55; transform: translateX(0); }
  50% { opacity: 1; transform: translateX(3px); }
}
.chess-layout { display: grid; grid-template-columns: minmax(0, 560px) minmax(220px, 1fr); gap: 18px; align-items: start; }
.chess-layout-sm { grid-template-columns: minmax(0, 380px) minmax(180px, 1fr); }
.board-wrap-sm { max-width: 380px; }
.board-col { display: flex; justify-content: center; min-width: 0; }
/* Width & height are set once in JS (integer px, floored to a multiple of 8)
   and only recomputed on real container resizes — never as a byproduct of
   repainting pieces after a move. That's what keeps the board's on-screen
   size perfectly constant while playing. */
  .board-wrap { position: relative; -webkit-user-select: none; user-select: none; }
/* Both axes use fixed fractional tracks and every piece is absolutely
   positioned, so square size comes ONLY from the board's own dimensions —
   an empty rank/file can never shrink and a full one can never stretch. */
.chess-board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  width: 100%; height: 100%; aspect-ratio: 1 / 1;
  border-radius: 10px; overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow);
  touch-action: manipulation;
}
.sq { position: relative; overflow: hidden; cursor: pointer; }
.sq.light { background: var(--board-light); }
.sq.dark { background: var(--board-dark); }
.sq img { position: absolute; left: 6%; top: 6%; width: 88%; height: 88%; object-fit: contain; pointer-events: none; }
.sq.sel::after, .sq.last::after {
  content: ''; position: absolute; inset: 0; background: rgba(255, 220, 80, 0.35);
}
.sq.hint::before {
  content: ''; position: absolute; left: 35%; top: 35%; width: 30%; height: 30%; border-radius: 50%;
  background: rgba(20, 30, 40, 0.35); z-index: 2;
}
.sq.hint.occ::before { left: 4%; top: 4%; width: 92%; height: 92%; background: transparent; border: 4px solid rgba(20,30,40,0.35); }
.sq.check::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle, rgba(255,60,60,0.7), transparent 70%); }
.sq .coord { position: absolute; font-size: 0.55rem; font-weight: 700; opacity: 0.75; pointer-events: none; }
.sq.light .coord { color: var(--board-dark); }
.sq.dark .coord { color: var(--board-light); }
.sq .coord.file { right: 3px; bottom: 2px; }
.sq .coord.rank { left: 3px; top: 2px; }
.chess-side { display: flex; flex-direction: column; gap: 12px; }
.chess-side .card { padding: 14px; }
.movelist {
  font-family: var(--mono); font-size: 0.84rem; line-height: 1.9; max-height: 220px; overflow-y: auto;
  display: grid; grid-template-columns: 2.2em 1fr 1fr; gap: 0 8px;
}
.movelist span.mv { cursor: default; padding: 0 4px; border-radius: 4px; }
.movelist span.mv.cur { background: var(--accent-glow); color: var(--accent); }
.movelist span.no { color: var(--text-2); }
.chess-status { font-weight: 600; }
.chess-toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.captured { font-size: 1.05rem; letter-spacing: 2px; min-height: 1.4em; }
.chess-clocks { display: flex; gap: 8px; margin-top: 10px; }
.chess-clock {
  flex: 1; text-align: center; padding: 8px; border-radius: 9px;
  background: var(--bg-2); border: 1px solid var(--border);
}
.cc-label { display: block; font-size: 0.68rem; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; }
.cc-time { display: block; font-family: var(--mono); font-size: 1.15rem; font-weight: 700; }
.chess-clock.running { border-color: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }
.chess-clock.running .cc-time { color: var(--accent); }

.form-grid { display: grid; gap: 12px; text-align: left; }
.f-label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; letter-spacing: 0.03em; }

/* Segmented selection control (chess color picker etc.) */
.seg {
  display: flex; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 11px; padding: 4px; gap: 4px;
}
.seg button {
  flex: 1; border: none; background: transparent; color: var(--text-2);
  padding: 9px 8px; border-radius: 8px; font-weight: 600; font-size: 0.86rem;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all 0.15s; font-family: inherit;
}
.seg button.sel {
  background: var(--card-solid); color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25), inset 0 0 0 1px var(--accent);
}
.play-btn { width: 100%; margin-top: 14px; font-size: 1rem; padding: 13px 18px; }
.promo-modal {
  position: absolute; inset: 0; background: rgba(5, 8, 14, 0.65); z-index: 10;
  display: flex; align-items: center; justify-content: center; gap: 10px; border-radius: 10px;
}
.promo-modal button { width: 64px; height: 64px; border-radius: 12px; border: 1px solid var(--border); background: var(--card-solid); cursor: pointer; }
.promo-modal img { width: 85%; height: 85%; }
@media (max-width: 760px) {
  .chess-layout, .chess-layout-sm { grid-template-columns: minmax(0, 1fr); }
  .board-col { max-width: 100%; }
}

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-2); font-size: 0.66rem; font-weight: 600; letter-spacing: 0.03em;
  transition: color 0.2s;
  background: none; border: none; font-family: inherit; cursor: pointer; padding: 0;
  position: relative;
}
.nav-item:hover { text-decoration: none; }
/* "it's your move" notification dot (set by checkChessTurn in main.js) */
.nav-item.has-dot::after {
  content: ''; position: absolute; top: 4px; right: calc(50% - 16px);
  width: 9px; height: 9px; border-radius: 50%; background: var(--danger);
  border: 2px solid var(--bg); box-sizing: content-box;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--accent); }
.nav-item.active svg { filter: drop-shadow(0 0 8px var(--accent-glow)); }
.nav-home { transform: translateY(-14px); }
.nav-home-btn {
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; box-shadow: 0 6px 22px var(--accent-glow);
  border: 3px solid var(--bg);
  transition: transform 0.2s;
}
.nav-home:hover .nav-home-btn { transform: scale(1.07); }
.nav-home.active span:last-child { color: var(--accent); }
.nav-home svg { width: 24px; height: 24px; }

/* ---------- 404 page ---------- */
.nf-wrap { position: relative; z-index: 5; max-width: 560px; margin: 0 auto; padding: 40px 16px 60px; text-align: center; }
.nf-code {
  font-size: clamp(5rem, 22vw, 9rem); font-weight: 800; line-height: 1; letter-spacing: -0.04em;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 30px var(--accent-glow));
}
.nf-title { margin-top: 6px; font-size: clamp(1.2rem, 5vw, 1.6rem); }
.nf-clock { margin: 22px auto 0; max-width: 340px; padding: 16px; }
.nf-time { display: block; font-family: var(--mono); font-size: 2rem; font-weight: 700; letter-spacing: 0.06em; }
.nf-date { display: block; font-size: 0.8rem; margin-top: 4px; }
.nf-puzzle { margin-top: 18px; text-align: center; }
.nf-puzzle-hint { font-size: 0.85rem; }
.nf-question { font-family: var(--mono); font-size: 1.25rem; font-weight: 700; margin: 14px 0; }
.nf-answer-row { display: flex; gap: 10px; justify-content: center; }
.nf-answer-row .input { max-width: 180px; text-align: center; font-family: var(--mono); }
.nf-result { margin-top: 12px; font-size: 0.9rem; font-weight: 600; }
.nf-result.ok { color: var(--ok); }
.nf-result.bad { color: var(--danger); }
.nf-actions { margin-top: 12px; display: flex; gap: 10px; justify-content: center; align-items: center; }
.nf-back { margin-top: 20px; }

/* ---------- public debug panel ---------- */
.debug-panel {
  position: fixed; left: 10px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 10px);
  z-index: 140; width: min(430px, calc(100vw - 20px));
  background: var(--card-solid); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); font-size: 0.74rem; overflow: hidden;
}
.debug-panel .dbg-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.debug-panel .dbg-head b { display: inline-flex; align-items: center; gap: 5px; font-size: 0.78rem; }
.debug-panel .dbg-head .muted { font-size: 0.68rem; margin-left: auto; }
.debug-panel .dbg-close { width: 24px; height: 24px; border-radius: 7px; flex: none; }
.debug-panel .dbg-body { max-height: 42vh; overflow-y: auto; padding: 6px 10px 10px; }
.debug-panel .dbg-row {
  display: flex; justify-content: space-between; gap: 12px; padding: 4px 0;
  border-bottom: 1px dashed color-mix(in srgb, var(--border) 60%, transparent);
}
.debug-panel .dbg-row > span:first-child { color: var(--text-2); flex: none; }
.debug-panel .dbg-row > span:last-child { text-align: right; overflow-wrap: anywhere; font-family: var(--mono); }
.dbg-ok { color: var(--ok); }
.dbg-bad { color: var(--danger); }

/* ---------- misc responsive ---------- */
@media (max-width: 560px) {
  .view-head h1 { font-size: 1.4rem; }
  .card-grid { grid-template-columns: 1fr 1fr; }
  .content-card p { display: none; }
  #posts-controls { display: block; }
}
@media (max-width: 380px) {
  .card-grid { grid-template-columns: 1fr; }
}
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
::selection { background: var(--accent-glow); }
