/* Masterphub Forum: "night ledger" — editorial serif headlines, mono counters, brand gold on warm ink. */
.forum-page {
  --fm-bg: hsl(36 14% 7%);
  --fm-panel: hsl(36 12% 10%);
  --fm-panel-2: hsl(36 10% 13%);
  --fm-line: hsl(38 10% 20%);
  --fm-text: hsl(40 25% 91%);
  --fm-dim: hsl(38 8% 62%);
  --fm-gold: #FFC107;
  --fm-gold-soft: hsl(45 100% 51% / .12);
  --fm-ai: hsl(172 48% 52%);
  --fm-ai-soft: hsl(172 40% 40% / .12);
  --fm-red: hsl(6 72% 62%);
  --fm-green: hsl(140 42% 56%);
  --fm-display: 'Instrument Serif', 'Frank Ruhl Libre', Georgia, serif;
  --fm-body: 'Space Grotesk', 'Heebo', system-ui, sans-serif;
  --fm-mono: 'JetBrains Mono', ui-monospace, monospace;
  background: var(--fm-bg); color: var(--fm-text); font-family: var(--fm-body);
}
.forum-page::before { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.forum-page.is-he { direction: rtl; --fm-body: 'Heebo', 'Space Grotesk', system-ui, sans-serif; --fm-display: 'Frank Ruhl Libre', 'Instrument Serif', serif; }
.fm-main { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 24px 20px 80px; min-height: 70dvh; }
.fm-skip { position: absolute; inset-inline-start: -9999px; }
.fm-skip:focus { inset-inline-start: 12px; top: 12px; z-index: 100; background: var(--fm-gold); color: #1a1405; padding: 8px 12px; border-radius: 8px; }
.fm-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.fm-mono { font-family: var(--fm-mono); }
.fm-dim { color: var(--fm-dim); }
.fm-main a { color: inherit; }
.fm-main :focus-visible { outline: 2px solid var(--fm-gold); outline-offset: 2px; border-radius: 6px; }

.fm-navmenu { display: none; position: relative; }
.fm-navmenu summary { list-style: none; cursor: pointer; padding: 6px; }
.fm-navmenu summary svg { width: 22px; height: 22px; }
.fm-navmenu nav { position: absolute; inset-inline-end: 0; top: 40px; background: var(--fm-panel); border: 1px solid var(--fm-line); border-radius: 12px; padding: 8px; z-index: 50; min-width: 180px; }
.fm-navmenu ul { list-style: none; margin: 0; padding: 0; }
.fm-navmenu a { display: block; padding: 8px 10px; color: var(--fm-text); text-decoration: none; }
@media (max-width: 860px) { .forum-page .nav-links { display: none; } .fm-navmenu { display: block; } }

/* crumbs */
.fm-crumbs ol { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0 0 18px; font-size: 13px; color: var(--fm-dim); }
.fm-crumbs li + li::before { content: '/'; margin-inline-end: 6px; opacity: .5; }
.fm-crumbs a { text-decoration: none; } .fm-crumbs a:hover { color: var(--fm-gold); }
.fm-crumbs li[aria-current] { color: var(--fm-text); max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* hero */
.fm-kicker { font-size: 11px; letter-spacing: .18em; color: var(--fm-gold); margin: 0 0 14px; }
.fm-hero { padding: 36px 0 34px; border-bottom: 1px solid var(--fm-line); margin-bottom: 34px; animation: fm-rise .6s ease both; }
.fm-hero-title { font-family: var(--fm-display); font-weight: 400; font-size: clamp(38px, 6vw, 76px); line-height: 1; letter-spacing: -.01em; margin: 0 0 18px; max-width: 18ch; }
.fm-hero-title::first-line { color: var(--fm-gold); }
.fm-hero-sub { color: var(--fm-dim); font-size: 17px; max-width: 60ch; line-height: 1.55; margin: 0; }
.fm-page-title { font-family: var(--fm-display); font-weight: 400; font-size: clamp(32px, 4.6vw, 56px); line-height: 1.05; margin: 0 0 12px; overflow-wrap: anywhere; }
.fm-cat-head { padding: 12px 0 26px; border-bottom: 1px solid var(--fm-line); margin-bottom: 26px; animation: fm-rise .5s ease both; }
.fm-search { display: flex; gap: 8px; margin-top: 26px; max-width: 620px; }
.fm-search input, .fm-field input, .fm-field select, .fm-main textarea, .fm-reason input {
  flex: 1; width: 100%; background: var(--fm-panel); border: 1px solid var(--fm-line); color: var(--fm-text); border-radius: 10px; padding: 12px 14px; font: inherit; font-size: 15px; }
.fm-main textarea { resize: vertical; line-height: 1.55; font-family: var(--fm-body); }
.fm-search input:focus, .fm-field input:focus, .fm-field select:focus, .fm-main textarea:focus { border-color: var(--fm-gold); outline: none; }

/* buttons */
.fm-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--fm-gold); color: #1d1604; border: 1px solid var(--fm-gold); border-radius: 10px; padding: 10px 18px; font: 600 14px var(--fm-body); text-decoration: none; cursor: pointer; transition: transform .15s ease, opacity .15s; }
.fm-main a.fm-btn { color: #1d1604; }
.fm-btn:hover { transform: translateY(-1px); }
.fm-btn-ghost, .fm-main a.fm-btn-ghost { background: transparent; color: var(--fm-text); border-color: var(--fm-line); }
.fm-btn-ghost:hover { border-color: var(--fm-gold); }
.fm-btn.is-off { opacity: .35; pointer-events: none; }
.fm-btn:disabled, .is-busy { opacity: .55; cursor: progress; }
.fm-btn-block { width: 100%; }
.fm-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.fm-link { color: var(--fm-gold) !important; font-size: 14px; }

/* layout */
.fm-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 40px; align-items: start; }
.fm-col { min-width: 0; display: grid; gap: 34px; }
.fm-rail { position: sticky; top: 88px; display: grid; gap: 10px; }
.fm-rail-link { color: var(--fm-dim) !important; font-size: 14px; text-decoration: none; padding: 4px 0; }
.fm-rail-link:hover { color: var(--fm-gold) !important; }
.fm-rail-cats { margin-top: 14px; border-top: 1px solid var(--fm-line); padding-top: 14px; }
.fm-rail-cats h2 { font: 600 11px var(--fm-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--fm-dim); margin: 0 0 8px; }
.fm-rail-cats ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.fm-rail-cats a { display: block; padding: 6px 10px; border-radius: 8px; text-decoration: none; font-size: 14px; }
.fm-rail-cats a:hover, .fm-rail-cats a[aria-current] { background: var(--fm-gold-soft); color: var(--fm-gold); }
.fm-h2 { font: 600 12px var(--fm-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--fm-dim); margin: 0 0 14px; }
.fm-h2-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.fm-h3 { font-family: var(--fm-display); font-weight: 400; font-size: 28px; margin: 0 0 12px; }

/* categories: ledger */
.fm-cats { display: grid; border-top: 1px solid var(--fm-line); }
.fm-cat { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 20px 6px; border-bottom: 1px solid var(--fm-line); text-decoration: none; animation: fm-rise .5s ease both; animation-delay: calc(var(--i) * 40ms); transition: background .2s; }
.fm-cat:hover { background: linear-gradient(90deg, var(--fm-gold-soft), transparent 70%); }
.is-he .fm-cat:hover { background: linear-gradient(270deg, var(--fm-gold-soft), transparent 70%); }
.fm-cat-n { color: var(--fm-gold); font-size: 13px; }
.fm-cat-body { display: grid; gap: 4px; }
.fm-cat-name { font-family: var(--fm-display); font-size: 26px; line-height: 1.1; }
.fm-cat-desc { color: var(--fm-dim); font-size: 14px; line-height: 1.45; }
.fm-cat-stats { display: grid; gap: 4px; text-align: end; font-size: 13px; }
.fm-cat-last { color: var(--fm-dim); font-size: 12px; }

/* thread list */
.fm-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--fm-line); }
.fm-row { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 16px; padding: 16px 4px; border-bottom: 1px solid var(--fm-line); }
.fm-row.is-pinned { background: var(--fm-gold-soft); }
.fm-row-count { display: grid; place-items: center; height: 48px; border: 1px solid var(--fm-line); border-radius: 10px; font-size: 16px; }
.fm-row-count.is-zero { color: var(--fm-dim); border-style: dashed; }
.fm-row-count.is-solved { border-color: var(--fm-green); color: var(--fm-green); }
.fm-row-title { margin: 2px 0 6px; font-size: 18px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.fm-row-title a { text-decoration: none; } .fm-row-title a:hover { color: var(--fm-gold); }
.fm-row-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; color: var(--fm-dim); font-size: 13px; margin: 0; }
.fm-row-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.fm-badge, .fm-cat-chip { display: inline-flex; align-items: center; font: 600 10.5px var(--fm-mono); letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--fm-line); color: var(--fm-dim); text-decoration: none; }
.fm-cat-chip { color: var(--fm-gold); border-color: hsl(45 100% 51% / .35); }
.fm-badge-pin { color: var(--fm-gold); border-color: var(--fm-gold); }
.fm-badge-solved { color: var(--fm-green); border-color: var(--fm-green); }
.fm-badge-pending { color: hsl(30 90% 64%); border-color: currentColor; }
.fm-badge-hidden, .fm-badge-removed { color: var(--fm-red); border-color: currentColor; }
.fm-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--fm-line); margin-bottom: 4px; }
.fm-tabs a { padding: 10px 14px; text-decoration: none; color: var(--fm-dim) !important; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.fm-tabs a.is-on, .fm-tabs a:hover { color: var(--fm-text) !important; border-color: var(--fm-gold); }
.fm-pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 22px; font-size: 13px; color: var(--fm-dim); }

/* thread */
.fm-thread { background: var(--fm-panel); border: 1px solid var(--fm-line); border-radius: 18px; padding: 28px; animation: fm-rise .5s ease both; }
.fm-thread-head { display: grid; gap: 12px; padding-bottom: 18px; border-bottom: 1px solid var(--fm-line); margin-bottom: 20px; }
.fm-thread-body { font-size: 16.5px; }
.fm-thread footer, .fm-post footer { margin-top: 18px; }
.fm-posts { display: grid; gap: 14px; }
.fm-post { border: 1px solid var(--fm-line); border-radius: 14px; padding: 18px 20px; background: hsl(36 12% 9%); }
.fm-post.is-best { border-color: var(--fm-green); box-shadow: inset 3px 0 0 var(--fm-green); }
.is-he .fm-post.is-best { box-shadow: inset -3px 0 0 var(--fm-green); }
.fm-post.is-ai { background: linear-gradient(180deg, var(--fm-ai-soft), transparent 60%), hsl(180 10% 9%); border-color: hsl(172 40% 40% / .45); }
.fm-post-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 10px; font-size: 13px; color: var(--fm-dim); }
.fm-post-time { text-decoration: none; }
.fm-author { display: inline-flex; align-items: center; gap: 8px; color: var(--fm-text); font-weight: 600; font-size: 14px; }
.fm-avatar { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font: 600 11px var(--fm-mono); background: hsl(var(--hue) 30% 22%); color: hsl(var(--hue) 70% 80%); }
.fm-author-ai { color: var(--fm-ai); }
.fm-ai-mark { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-family: var(--fm-display); font-size: 18px; border: 1px solid var(--fm-ai); color: var(--fm-ai); }
.fm-dot { opacity: .6; }
.fm-op { font: 600 10px var(--fm-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--fm-gold); border: 1px solid hsl(45 100% 51% / .4); padding: 1px 6px; border-radius: 999px; }
.fm-entry-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.fm-react, .fm-chip-btn { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 1px solid var(--fm-line); color: var(--fm-dim); border-radius: 999px; padding: 6px 12px; font: 500 13px var(--fm-body); cursor: pointer; text-decoration: none; transition: border-color .15s, color .15s, transform .15s; }
.fm-react:hover, .fm-chip-btn:hover { color: var(--fm-text); border-color: var(--fm-dim); }
.fm-react:active { transform: scale(.96); }
.fm-react.is-on { color: var(--fm-gold); border-color: var(--fm-gold); background: var(--fm-gold-soft); }
.fm-chip-best { color: var(--fm-green); border-color: hsl(140 42% 56% / .5); }
.fm-chip-danger:hover { color: var(--fm-red); border-color: var(--fm-red); }
.fm-mod { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--fm-line); }
.fm-mod-remove, .fm-mod-hide { color: var(--fm-red); }
.fm-mod-approve { color: var(--fm-green); }
.fm-modnote { font-size: 13px; color: hsl(30 90% 70%); background: hsl(30 80% 50% / .08); padding: 8px 12px; border-radius: 8px; }
.fm-notice { border: 1px solid hsl(45 100% 51% / .35); background: var(--fm-gold-soft); padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.5; }
.fm-notice-lg { padding: 22px 24px; font-size: 16px; margin: 20px 0 24px; max-width: 70ch; }
.fm-notice p { margin: 0 0 8px; } .fm-notice p:last-child { margin: 0; }

/* markdown */
.fm-md { line-height: 1.65; overflow-wrap: anywhere; }
.fm-md p { margin: 0 0 12px; } .fm-md > :last-child { margin-bottom: 0; }
.fm-md h3, .fm-md h4, .fm-md h5 { font-family: var(--fm-display); font-weight: 400; font-size: 22px; margin: 18px 0 8px; }
.fm-md a { color: var(--fm-gold); }
.fm-md code { font-family: var(--fm-mono); font-size: .9em; background: var(--fm-panel-2); padding: 1px 6px; border-radius: 5px; }
.fm-md blockquote { margin: 0 0 12px; padding: 4px 14px; border-inline-start: 3px solid var(--fm-gold); color: var(--fm-dim); }
.fm-md ul, .fm-md ol { padding-inline-start: 22px; margin: 0 0 12px; }
.fm-code { position: relative; margin: 0 0 14px; border: 1px solid var(--fm-line); border-radius: 12px; background: hsl(36 14% 5%); }
.fm-code pre { margin: 0; padding: 38px 16px 16px; overflow-x: auto; text-align: left; }
.fm-code pre code { background: none; padding: 0; font-size: 13.5px; line-height: 1.55; white-space: pre; }
.fm-code-lang { position: absolute; top: 9px; inset-inline-start: 14px; font: 600 10px var(--fm-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--fm-dim); }
.fm-copy { position: absolute; top: 6px; inset-inline-end: 6px; background: var(--fm-panel-2); color: var(--fm-text); border: 1px solid var(--fm-line); border-radius: 7px; font: 600 11px var(--fm-mono); padding: 4px 10px; cursor: pointer; }
.fm-copy.is-done { color: var(--fm-green); border-color: var(--fm-green); }
.fm-img { display: inline-block; max-width: 100%; }
.fm-img img { max-width: 100%; max-height: 520px; border-radius: 10px; border: 1px solid var(--fm-line); display: block; }

/* forms */
.fm-reply, .fm-gate { border-top: 1px solid var(--fm-line); padding-top: 26px; }
.fm-gate { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.fm-gate p { margin: 0; flex-basis: 100%; color: var(--fm-dim); }
.fm-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fm-preview { background: var(--fm-panel); border: 1px dashed var(--fm-line); border-radius: 10px; padding: 12px 14px; min-height: 140px; max-height: 480px; overflow: auto; font-size: 15px; }
.fm-form-msg { min-height: 1.2em; font-size: 14px; color: var(--fm-red); margin: 10px 0; }
.fm-new { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; }
.fm-new-fields { display: grid; gap: 18px; }
.fm-new-preview { position: sticky; top: 88px; }
.fm-new-preview .fm-preview { min-height: 360px; max-height: 70vh; }
.fm-field { display: grid; gap: 6px; font-size: 13px; color: var(--fm-dim); border: 0; padding: 0; margin: 0; }
.fm-field legend { padding: 0; margin-bottom: 6px; }
.fm-seg { display: inline-flex; border: 1px solid var(--fm-line); border-radius: 10px; overflow: hidden; width: fit-content; }
.fm-seg input { position: absolute; opacity: 0; }
.fm-seg span { display: block; padding: 8px 14px; cursor: pointer; color: var(--fm-dim); font-size: 14px; }
.fm-seg input:checked + span { background: var(--fm-gold); color: #1d1604; }
.fm-seg input:focus-visible + span { outline: 2px solid var(--fm-gold); }
.fm-lang-auto { margin: 0 0 6px; font-size: 13px; }
.fm-check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.45; }
.fm-check input { width: 18px; height: 18px; accent-color: var(--fm-gold); margin-top: 2px; }
.fm-check a { color: var(--fm-gold); }
.fm-edit { display: grid; gap: 10px; }

/* states */
.fm-state { text-align: center; padding: 70px 20px; max-width: 560px; margin: 0 auto; }
.fm-state-code { color: var(--fm-gold); letter-spacing: .3em; font-size: 13px; }
.fm-state h1 { font-family: var(--fm-display); font-weight: 400; font-size: 44px; margin: 8px 0 12px; }
.fm-state p { color: var(--fm-dim); }
.fm-state .fm-actions { justify-content: center; }
.fm-empty { border: 1px dashed var(--fm-line); border-radius: 16px; padding: 44px 24px; text-align: center; }
.fm-empty h3 { font-family: var(--fm-display); font-weight: 400; font-size: 30px; margin: 0 0 6px; }
.fm-empty p { color: var(--fm-dim); margin: 0 0 16px; }
.fm-skel { display: grid; gap: 12px; }
.fm-skel-row { display: grid; grid-template-columns: 56px 1fr; gap: 16px; padding: 12px 0; }
.fm-skel-row span { height: 48px; border-radius: 10px; background: linear-gradient(90deg, var(--fm-panel) 25%, var(--fm-panel-2) 50%, var(--fm-panel) 75%); background-size: 200% 100%; animation: fm-shimmer 1.3s linear infinite; }

/* admin */
.fm-admin-sec { margin-top: 34px; }
.fm-count { color: var(--fm-gold); margin-inline-start: 6px; }
.fm-q { border: 1px solid var(--fm-line); border-radius: 12px; padding: 16px; margin-bottom: 12px; background: var(--fm-panel); }
.fm-q-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 14px; }
.fm-q-body { max-height: 220px; overflow: auto; font-size: 14px; color: var(--fm-dim); }
.fm-reason { max-width: 420px; margin-top: 18px; }
.fm-table-wrap { overflow-x: auto; border: 1px solid var(--fm-line); border-radius: 12px; }
.fm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fm-table th, .fm-table td { padding: 10px 12px; border-bottom: 1px solid var(--fm-line); text-align: start; white-space: nowrap; }
.fm-table th { font: 600 11px var(--fm-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--fm-dim); }
.fm-rules { max-width: 760px; }
.fm-rules-copy { line-height: 1.85; margin-block: 24px 32px; overflow-wrap: anywhere; }
.fm-rules-copy h2 { font-size: 1.25rem; margin-block: 28px 10px; }
.fm-rules-copy p { margin-block: 12px; }
.fm-rules-copy ol { list-style: decimal; padding-inline-start: 28px; margin-block: 12px; }
.fm-rules-copy li { margin-block: 8px; }

/* toast */
.fm-toast { position: fixed; bottom: 24px; inset-inline-start: 50%; transform: translate(-50%, 12px); opacity: 0; z-index: 200; background: var(--fm-panel-2); color: var(--fm-text); border: 1px solid var(--fm-gold); border-radius: 12px; padding: 12px 18px; font-size: 14px; max-width: min(92vw, 520px); transition: opacity .25s, transform .25s; }
.is-he .fm-toast { transform: translate(50%, 12px); }
.fm-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.is-he .fm-toast.is-on { transform: translate(50%, 0); }
.fm-toast.is-bad { border-color: var(--fm-red); }

@keyframes fm-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fm-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .forum-page * { animation: none !important; transition: none !important; } }

@media (max-width: 900px) {
  .fm-layout, .fm-new { grid-template-columns: 1fr; }
  .fm-rail, .fm-new-preview { position: static; }
  .fm-rail { order: -1; grid-template-columns: 1fr auto; align-items: center; }
  .fm-rail-cats { display: none; }
  .fm-editor { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .fm-main { padding: 16px 14px 60px; }
  .fm-cat { grid-template-columns: 30px 1fr; }
  .fm-cat-stats { grid-column: 2; text-align: start; }
  .fm-thread { padding: 18px; }
  .fm-search { flex-direction: column; }
  .fm-row { grid-template-columns: 44px 1fr; gap: 12px; }
}
