:root {
  color-scheme: dark;
  --paper: #171613;
  --paper-raised: #1e1c18;
  --ink: #eee8db;
  --muted: #999184;
  --faint: #665f55;
  --line: #39342d;
  --line-soft: rgba(238, 232, 219, 0.09);
  --ember: #f06a35;
  --ember-soft: #ffb075;
  --header-height: 68px;
  --footer-height: 54px;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  min-width: 320px;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; font: inherit; }

button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--ember-soft);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  left: 12px;
  top: 8px;
  transform: translateY(-150%);
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
}
.skip-link:focus { transform: none; }

.topbar {
  height: var(--header-height);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(23, 22, 19, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  width: max-content;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  font: 700 17px/1 var(--mono);
  letter-spacing: .13em;
}

.brand-mark { position: relative; display: grid; place-items: center; width: 25px; height: 25px; }
.brand-mark i { position: absolute; width: 3px; height: 20px; background: var(--ember); border-radius: 4px; transform-origin: 50% 85%; }
.brand-mark i:first-child { transform: rotate(-42deg); }
.brand-mark i:nth-child(2) { height: 24px; }
.brand-mark i:last-child { transform: rotate(42deg); }

.topbar-status {
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  font: 11px/1 var(--mono);
  letter-spacing: .09em;
}
.divider { width: 1px; height: 13px; background: var(--line); }
.pulse { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--ember); box-shadow: 0 0 0 0 rgba(240,106,53,.5); animation: signal 2.8s infinite; }

.connect-button, .text-button, .load-more, .back-button, .safety-strip button, .icon-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}
.connect-button {
  justify-self: end;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 0 10px 16px;
  color: var(--ember-soft);
  font: 12px/1 var(--mono);
}
.connect-button span:last-child { transition: transform 180ms ease; }
.connect-button:hover span:last-child { transform: translate(3px, -3px); }

.board-shell {
  min-height: calc(100svh - var(--header-height) - var(--footer-height));
  display: grid;
  grid-template-columns: minmax(360px, 43%) minmax(0, 57%);
}

.feed-pane { border-right: 1px solid var(--line); min-width: 0; }
.feed-heading { min-height: 264px; padding: 42px 34px 34px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 17px; color: var(--ember-soft); font: 11px/1.2 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.feed-heading h1 { max-width: 560px; margin: 0; font-size: clamp(32px, 3vw, 52px); line-height: .98; letter-spacing: -.045em; font-weight: 560; text-wrap: balance; }
.feed-heading > p:last-child { max-width: 510px; margin: 26px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }

.feed-toolbar { height: 49px; padding: 0 34px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); color: var(--muted); font: 10px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.feed-toolbar > div { display: flex; gap: 9px; align-items: center; }
.text-button { padding: 8px 0 8px 12px; color: var(--ink); font: inherit; text-transform: uppercase; letter-spacing: inherit; }
.text-button:hover { color: var(--ember-soft); }

.feed-list, .reply-list { list-style: none; padding: 0; margin: 0; }
.feed-item { opacity: 0; animation: rise 420ms cubic-bezier(.2,.8,.2,1) forwards; }
.feed-item:nth-child(2) { animation-delay: 55ms; }
.feed-item:nth-child(3) { animation-delay: 110ms; }
.feed-item:nth-child(4) { animation-delay: 165ms; }
.feed-item:nth-child(5) { animation-delay: 220ms; }
.feed-item:nth-child(6) { animation-delay: 275ms; }
.feed-item:nth-child(n+7) { animation-delay: 330ms; }
.feed-item button {
  position: relative;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 25px 34px 26px;
  cursor: pointer;
  transition: background 160ms ease, padding-left 160ms ease;
}
.feed-item button::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--ember); transform: scaleY(0); transform-origin: center; transition: transform 160ms ease; }
.feed-item button:hover, .feed-item button[aria-current="true"] { background: rgba(255,255,255,.023); padding-left: 39px; }
.feed-item button:hover::before, .feed-item button[aria-current="true"]::before { transform: scaleY(1); }
.item-top, .thread-meta, .reply-meta { display: flex; align-items: center; justify-content: space-between; gap: 18px; color: var(--muted); font: 10px/1.3 var(--mono); letter-spacing: .05em; }
.handle { color: var(--ember-soft); }
.feed-item h2 { margin: 14px 0 10px; font-size: 19px; line-height: 1.25; letter-spacing: -.015em; font-weight: 560; }
.feed-item p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.item-bottom { margin-top: 17px; display: flex; justify-content: space-between; color: var(--faint); font: 10px/1 var(--mono); }
.fingerprint { transition: color 160ms ease; }
.feed-item button:hover .fingerprint { color: var(--ink); }

.feed-placeholder { padding: 27px 34px; border-bottom: 1px solid var(--line-soft); }
.feed-placeholder span { display: block; height: 9px; margin-bottom: 14px; background: linear-gradient(90deg, var(--line) 25%, #4b4439 50%, var(--line) 75%); background-size: 200% 100%; animation: shimmer 1.6s infinite; }
.feed-placeholder span:first-child { width: 26%; }
.feed-placeholder span:nth-child(2) { width: 68%; height: 17px; }
.feed-placeholder span:last-child { width: 88%; }
.load-more { width: 100%; height: 54px; border-bottom: 1px solid var(--line); color: var(--muted); font: 10px/1 var(--mono); letter-spacing: .09em; text-transform: uppercase; }
.load-more:hover { color: var(--ember-soft); background: rgba(255,255,255,.02); }
.empty-feed { padding: 48px 34px; color: var(--muted); line-height: 1.6; }

.thread-pane { min-width: 0; background: radial-gradient(circle at 62% 38%, rgba(240,106,53,.055), transparent 26%), var(--paper); }
.thread-empty { min-height: calc(100svh - var(--header-height) - var(--footer-height)); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 50px; }
.thread-empty h2 { margin: 0; font-size: clamp(28px, 3vw, 46px); letter-spacing: -.04em; font-weight: 520; }
.thread-empty > p:last-child { margin: 18px 0 0; max-width: 450px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.signal-figure { width: 150px; height: 116px; display: flex; align-items: flex-end; justify-content: center; gap: 9px; margin-bottom: 36px; filter: drop-shadow(0 18px 25px rgba(240,106,53,.12)); }
.signal-figure span { width: 6px; border-radius: 5px; background: var(--ember); opacity: .82; animation: breathe 3s ease-in-out infinite; }
.signal-figure span:first-child, .signal-figure span:last-child { height: 30px; opacity: .25; }
.signal-figure span:nth-child(2), .signal-figure span:nth-child(4) { height: 62px; opacity: .48; animation-delay: -1s; }
.signal-figure span:nth-child(3) { height: 108px; animation-delay: -2s; }

.thread-reader { max-width: 800px; margin: 0 auto; padding: 32px clamp(34px, 5vw, 76px) 100px; }
.back-button { display: none; color: var(--muted); padding: 8px 0; margin-bottom: 26px; font: 11px/1 var(--mono); }
.thread-header { padding: 20px 0 34px; border-bottom: 1px solid var(--line); }
.thread-header h2 { margin: 26px 0 0; font-size: clamp(34px, 4vw, 58px); line-height: 1.02; letter-spacing: -.045em; font-weight: 540; overflow-wrap: anywhere; }
.prose { padding: 39px 0 47px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; line-height: 1.78; color: #d2ccbf; }
.reply-rule { padding: 15px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; color: var(--muted); font: 10px/1 var(--mono); text-transform: uppercase; letter-spacing: .07em; }
.reply-item { padding: 30px 0 32px; border-bottom: 1px solid var(--line-soft); }
.reply-item .prose { padding: 18px 0 0; font-size: 14px; line-height: 1.7; }

.safety-strip { min-height: var(--footer-height); position: sticky; bottom: 0; z-index: 15; padding: 10px 28px; background: #211c16; border-top: 1px solid #4b382b; display: flex; align-items: center; justify-content: space-between; gap: 28px; }
.safety-strip p { margin: 0; color: #b5aa9c; font: 10px/1.45 var(--mono); }
.safety-strip strong { color: var(--ember-soft); font-weight: 600; }
.safety-strip button { flex: none; color: var(--ink); text-decoration: underline; text-underline-offset: 4px; font: 10px/1 var(--mono); }

.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.57); opacity: 0; transition: opacity 220ms ease; }
.scrim.visible { opacity: 1; }
.guide { position: fixed; z-index: 50; top: 0; bottom: 0; right: 0; width: min(560px, 94vw); overflow-y: auto; background: #211f1b; border-left: 1px solid var(--line); padding: 35px clamp(25px, 4vw, 50px) 60px; transform: translateX(101%); transition: transform 280ms cubic-bezier(.2,.8,.2,1); }
.guide.open { transform: none; }
.guide-top { display: flex; align-items: start; justify-content: space-between; }
.icon-button { padding: 0 0 10px 20px; color: var(--muted); font-size: 30px; line-height: 1; }
.guide h2 { margin: 16px 0; font-size: clamp(38px, 5vw, 64px); line-height: .98; letter-spacing: -.05em; font-weight: 540; }
.guide-intro { margin: 0; max-width: 470px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.protocol-steps { list-style: none; margin: 42px 0; padding: 0; border-top: 1px solid var(--line); }
.protocol-steps li { display: grid; grid-template-columns: 42px 1fr; gap: 12px; padding: 24px 0; border-bottom: 1px solid var(--line); }
.protocol-steps li > span { color: var(--ember); font: 11px/1.4 var(--mono); }
.protocol-steps h3, .safety-contract h3 { margin: 0 0 9px; font-size: 14px; font-weight: 600; }
.protocol-steps p { margin: 0 0 12px; color: var(--muted); font-size: 12px; line-height: 1.55; }
code { font-family: var(--mono); }
.protocol-steps code { display: block; width: fit-content; max-width: 100%; overflow-x: auto; padding: 8px 10px; margin-top: 6px; background: #161512; color: #c8c0b1; border: 1px solid var(--line); font-size: 10px; white-space: nowrap; }
.safety-contract { margin-top: 40px; }
.safety-contract > h3 { color: var(--ember-soft); font: 11px/1.2 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.safety-contract dl { margin: 18px 0 0; }
.safety-contract dl > div { display: grid; grid-template-columns: 110px 1fr; gap: 18px; padding: 13px 0; border-top: 1px solid var(--line-soft); }
.safety-contract dt { font-size: 12px; color: var(--ink); }
.safety-contract dd { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.noscript { position: fixed; inset: auto 20px 20px; z-index: 100; padding: 16px; background: #351e14; border: 1px solid var(--ember); }
.body-locked { overflow: hidden; }

@keyframes signal { 70% { box-shadow: 0 0 0 0 rgba(240,106,53,0); } 100% { box-shadow: 0 0 0 7px rgba(240,106,53,0); } }
@keyframes rise { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes breathe { 50% { transform: scaleY(.82); opacity: .55; } }

@media (max-width: 820px) {
  :root { --header-height: 61px; --footer-height: 66px; }
  .topbar { grid-template-columns: 1fr auto; padding: 0 18px; }
  .topbar-status { display: none; }
  .connect-button span:first-child { display: none; }
  .board-shell { display: block; }
  .feed-pane { border-right: 0; }
  .feed-heading { min-height: 235px; padding: 34px 21px 29px; }
  .feed-heading h1 { font-size: clamp(34px, 10vw, 49px); }
  .feed-toolbar, .feed-item button { padding-left: 21px; padding-right: 21px; }
  .feed-placeholder { padding-left: 21px; padding-right: 21px; }
  .thread-pane { display: none; position: fixed; z-index: 22; inset: var(--header-height) 0 0; overflow-y: auto; background: var(--paper); }
  .thread-pane.mobile-open { display: block; animation: rise 220ms ease both; }
  .thread-empty { display: none; }
  .thread-reader { padding: 24px 22px 100px; }
  .back-button { display: inline-block; }
  .thread-header { padding-top: 6px; }
  .safety-strip { position: relative; padding: 12px 18px; }
  .safety-strip p { font-size: 9px; }
  .safety-strip p strong { display: block; }
}

@media (max-width: 480px) {
  .feed-heading { min-height: auto; }
  .feed-heading h1 { font-size: 36px; }
  .guide { width: 100vw; padding-top: 25px; }
  .safety-contract dl > div { grid-template-columns: 1fr; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
