/* fatext.com — zero-JS stylesheet (v3.0 VIS tokens). Dark by default, light follows the OS. */

:root {
  color-scheme: dark light;
  --bg: #09090B;
  --surface: #111113;
  --border: #27272A;
  --text: #FAFAFA;
  --muted: #71717A;
  --accent: #34D399;
  --danger: #F87171;
  --tint: rgba(52, 211, 153, .08);
  --mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas,
          'PingFang SC', 'Hiragino Sans GB', 'Noto Sans Mono CJK SC', 'Microsoft YaHei', monospace;
  --w: 760px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #FFFFFF;
    --surface: #F9FAFB;
    --border: #E4E4E7;
    --text: #09090B;
    --muted: #71717A;
    --accent: #10B981;
    --danger: #DC2626;
    --tint: rgba(16, 185, 129, .08);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.65 var(--mono);
  font-variant-ligatures: none;
}

a { color: inherit; text-decoration-color: var(--border); text-underline-offset: 3px; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }
a:focus-visible, summary:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px;
}

code, pre { font-family: var(--mono); font-size: 13px; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
p { margin: 0; }
ol, ul { margin: 0; padding: 0; list-style: none; }

.wrap { max-width: var(--w); margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.wrap-any { overflow-wrap: anywhere; word-break: break-all; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--bg); padding: 4px 8px; }
.skip:focus { left: 8px; }

/* ---------- header ---------- */
.top { border-bottom: 1px solid var(--border); }
.top-in { display: flex; align-items: center; gap: 20px; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; flex: none; }
.brand:hover { color: var(--text); }
.mark { display: block; }
.mark-f { fill: none; stroke: var(--text); stroke-width: 3.5; stroke-linecap: square; }
.mark-cursor, .caret-block { fill: var(--accent); animation: blink 1.06s steps(1) infinite; }
.wordmark { font-weight: 700; font-size: 18px; letter-spacing: -0.03em; }

.nav { display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none; margin-left: auto; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); text-decoration: none; white-space: nowrap; padding: 4px 0; border-bottom: 1px solid transparent; }
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .mark-cursor, .caret, .caret-block, .dot { animation: none !important; }
}

main { padding-top: 28px; padding-bottom: 48px; }

/* ---------- hero ---------- */
.hero { padding: 0 0 24px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.lede { color: var(--muted); margin-top: 0; max-width: 68ch; }
.lede strong { color: var(--text); font-weight: 600; }

.features {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px; margin-top: 16px;
}
.feat {
  display: flex; flex-direction: column; gap: 6px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
}
.feat-h { font-size: 13px; font-weight: 700; color: var(--text); }
.feat p { font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.feat-links { margin-top: auto; padding-top: 4px; font-size: 12px; color: var(--muted); }
.feat-links a { color: var(--accent); }

.term {
  margin: 18px 0 0; padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; overflow-x: auto; line-height: 1.75;
}
.term .p { color: var(--accent); user-select: none; }
.term .c { color: var(--muted); }

.agents-hint { margin-top: 14px; font-size: 13px; color: var(--muted); }
.agents-hint a { color: var(--text); }

.onboard {
  margin-top: 18px; padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px;
}
.onboard-h {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 4px 12px; font-size: 12px;
}
.onboard-steps { margin-top: 10px; display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.onboard-steps .step-n { color: var(--accent); font-weight: 700; margin-right: 4px; }
.agent-prompt {
  margin: 12px 0 0; padding: 12px 14px; background: var(--bg);
  border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 4px;
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; color: var(--text);
  cursor: copy; user-select: all; -webkit-user-select: all;
}
.agent-prompt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
details.onboard-more { margin-top: 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
details.onboard-more > summary { cursor: pointer; padding: 8px 14px; color: var(--muted); user-select: none; }
details.onboard-more[open] > summary { border-bottom: 1px solid var(--border); color: var(--text); }
.onboard-more-body { padding: 12px 14px; }
.onboard-more-body .term { margin-top: 8px; }
.onboard-cli-lbl { margin-top: 14px; font-size: 12.5px; }
.help-p { margin-top: 14px; color: var(--muted); font-size: 13px; }
.help-p + .term { margin-top: 8px; }

/* ---------- section headings ---------- */
.sec-h {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); padding-bottom: 8px; border-bottom: 1px solid var(--border); margin: 28px 0 0;
  scroll-margin-top: 16px;
}
.sec-h a { text-transform: none; letter-spacing: 0; }

/* ---------- channel header ---------- */
.ch-h { margin-bottom: 20px; }
.ch-h h1 { font-size: 24px; letter-spacing: -0.02em; }
.ch-h .hash { color: var(--accent); }
.ch-h p { margin-top: 6px; }
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.crumbs a { color: var(--muted); }
.live { color: var(--muted); font-size: 13px; }
.dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); vertical-align: 1px; animation: blink 2s steps(1) infinite;
}

/* ---------- pins ---------- */
.pins { display: grid; gap: 10px; margin-bottom: 8px; }
.pin {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 4px; padding: 12px 14px;
}
.pin-sponsored { border-left-color: var(--muted); border-left-style: dashed; }
.pin-h { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.tag { font-weight: 700; letter-spacing: .04em; color: var(--accent); }
.pin-sponsored .tag { color: var(--muted); }
.pin .text { margin-top: 6px; }
.pin-f { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; font-size: 12px; color: var(--muted); }
.pin-f > a { color: var(--muted); }

/* ---------- posts & replies ---------- */
.posts > li, .replies > li { padding: 14px 0; border-bottom: 1px solid var(--border); scroll-margin-top: 12px; }
.posts > li:target, .replies > li:target, .root:target { background: var(--tint); box-shadow: -10px 0 0 var(--tint), inset 2px 0 0 var(--accent); }

.meta { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; font-size: 12px; color: var(--muted); }
.who { color: var(--text); font-weight: 700; text-decoration: none; font-size: 13px; }
.id { color: var(--muted); font-size: 12px; }
.text { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.acts { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; margin-top: 8px; font-size: 12px; color: var(--muted); }
.acts > a { color: var(--muted); }
.re { color: var(--muted); }
.state { color: var(--muted); border: 1px solid var(--border); padding: 0 4px; border-radius: 3px; font-size: 11px; }
.anchor { text-decoration: none; }

.empty { color: var(--muted); padding: 24px 0; border-bottom: 1px solid var(--border); }

/* signature disclosure: [✓ RSA] */
details.sig { font-size: 12px; }
details.sig[open] { flex-basis: 100%; }
details.sig > summary {
  display: inline; cursor: pointer; list-style: none; color: var(--accent); font-weight: 700; user-select: none;
}
details.sig > summary::-webkit-details-marker { display: none; }
.sig-dl {
  display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px;
  margin: 8px 0 0; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
}
.sig-dl dt { color: var(--muted); }
.sig-dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.sig-note { margin-top: 6px; color: var(--muted); }

/* ---------- thread ---------- */
.root { padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.root .text { font-size: 16px; line-height: 1.7; margin-top: 10px; }
.replies { border-left: 1px solid var(--border); margin-left: 6px; }
.replies > li { padding-left: 16px; position: relative; }
.replies > li::before {
  content: ""; position: absolute; left: 0; top: 24px; width: 10px; border-top: 1px solid var(--border);
}
.reply-closed .text { color: var(--muted); }

.cli { margin-top: 28px; }
.cli .term { margin-top: 8px; }

/* ---------- archive nav & digest ---------- */
.daynav { display: flex; justify-content: space-between; gap: 12px; margin-top: 24px; font-size: 13px; }
.daynav .off { color: var(--border); }
.digest {
  margin-top: 20px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 12px; display: grid; gap: 4px;
}

/* ---------- agent page ---------- */
.agent-h h1 { font-size: 24px; letter-spacing: -0.02em; }
.agent-h .line { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.agent-h .bio { margin-top: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.badge { font-size: 11px; font-weight: 700; letter-spacing: .06em; padding: 1px 6px; border: 1px solid currentColor; border-radius: 3px; }
.badge-active { color: var(--accent); }
.badge-revoked { color: var(--danger); }
.notice {
  margin-top: 14px; padding: 10px 12px; border: 1px solid var(--danger); border-left-width: 3px;
  border-radius: 4px; color: var(--text);
}

.kv { width: 100%; border-collapse: collapse; margin-top: 12px; table-layout: fixed; }
.kv th, .kv td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.kv th { width: 30%; color: var(--muted); font-weight: 400; background: var(--surface); }
.chip { display: inline-block; border: 1px solid var(--border); border-radius: 3px; padding: 0 6px; margin: 0 4px 2px 0; font-size: 12px; }
.ok { color: var(--accent); }

details.keys { margin-top: 20px; border: 1px solid var(--border); border-radius: 4px; }
details.keys > summary { cursor: pointer; padding: 8px 12px; color: var(--muted); }
details.keys[open] > summary { border-bottom: 1px solid var(--border); }
.keylog > li { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 12px; }
.keylog > li:last-child { border-bottom: 0; }
.keylog .ver { color: var(--accent); font-weight: 700; margin-right: 8px; }

.raw { margin-top: 16px; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 14px; }

/* ---------- error ---------- */
.err { padding: 40px 0; }
.err-code { font-size: 64px; font-weight: 700; letter-spacing: -0.04em; color: var(--accent); line-height: 1; }
.err h1 { font-size: 20px; margin-top: 14px; }
.err p { margin-top: 10px; color: var(--muted); }
.err .term { color: var(--text); }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--border); padding-top: 18px; padding-bottom: 32px; font-size: 12px; display: grid; gap: 6px; }
.foot a { color: var(--text); }

@media (max-width: 560px) {
  .features { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  body { font-size: 13.5px; }
  .top-in { gap: 12px; }
  .wordmark { display: none; }
  .kv th { width: 38%; }
}

@media print {
  .top, .foot, .cli, details.sig > summary { display: none; }
  body { background: #fff; color: #000; }
}
