:root {
  --bg: #f3efe6;
  --surface: #faf7f0;
  --ink: #1d1b17;
  --muted: #655f55;
  --line: #d8d0be;
  --line-soft: #e4dcca;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --live: #2a7a4b;
  --warn: #b7791f;
  --down: #c0262d;
  --code-bg: #ece6d6;
  --code-ink: #2a2620;
  --hover: rgba(194, 65, 12, 0.055);
  --grain: 0.55;

  --font-display: 'Fraunces Variable', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --font-body: 'Inter Variable', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono Variable', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --gutter: clamp(16px, 4vw, 32px);
  --measure: 900px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14130f;
    --surface: #1b1a15;
    --ink: #eee8da;
    --muted: #a39b8b;
    --line: #36332b;
    --line-soft: #28261f;
    --accent: #ff8a5c;
    --accent-ink: #1a0e08;
    --live: #5ec58a;
    --warn: #e8b04a;
    --down: #ff6b6b;
    --code-bg: #201f19;
    --code-ink: #e6dfce;
    --hover: rgba(255, 138, 92, 0.07);
    --grain: 0.22;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #14130f;
  --surface: #1b1a15;
  --ink: #eee8da;
  --muted: #a39b8b;
  --line: #36332b;
  --line-soft: #28261f;
  --accent: #ff8a5c;
  --accent-ink: #1a0e08;
  --live: #5ec58a;
  --warn: #e8b04a;
  --down: #ff6b6b;
  --code-bg: #201f19;
  --code-ink: #e6dfce;
  --hover: rgba(255, 138, 92, 0.07);
  --grain: 0.22;
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 24px; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  font-feature-settings: 'cv11', 'ss03';
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grain);
  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 type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .28 0 0 0 0 .16 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 10;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
  transition: top 0.15s;
}
.skip:focus { top: 12px; }

.dim { color: var(--muted); }

/* ---------- chrome ---------- */

.top {
  width: 100%;
  max-width: calc(var(--measure) + var(--gutter) * 2);
  margin: 0 auto;
  padding: 22px var(--gutter) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand-mark { width: 26px; height: 26px; }
.brand-mark rect { fill: var(--accent); }
.brand-mark path { fill: none; stroke: var(--accent-ink); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.brand .dim { font-weight: 500; }

.theme {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.theme:hover { border-color: var(--ink); background: var(--hover); }
.theme svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }

main {
  width: 100%;
  max-width: calc(var(--measure) + var(--gutter) * 2);
  margin: 0 auto;
  padding: 0 var(--gutter) 72px;
  flex: 1;
  outline: none;
}

.foot {
  width: 100%;
  max-width: calc(var(--measure) + var(--gutter) * 2);
  margin: 0 auto;
  padding: 22px var(--gutter) 32px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.notice {
  margin: 48px 0;
  padding: 16px 18px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
}

/* ---------- hero ---------- */

.hero { padding: clamp(40px, 9vw, 88px) 0 clamp(24px, 4vw, 40px); }

.eyebrow {
  margin: 0 0 18px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 540;
  font-size: clamp(2.35rem, 6.2vw, 4.25rem);
  line-height: 1.04;
  letter-spacing: -0.025em;
  text-wrap: balance;
  outline: none;
}
h1:focus, h1:focus-visible { outline: none; }
h1 em { font-style: italic; font-weight: 480; color: var(--accent); }

.lede {
  margin: 20px 0 0;
  max-width: 56ch;
  font-size: 1.08rem;
  color: var(--muted);
  text-wrap: pretty;
}

.tally {
  margin: 26px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--muted);
}
.tally b { color: var(--ink); font-weight: 600; }

/* ---------- controls ---------- */

.controls {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 0 calc(var(--gutter) * -1);
  padding: 12px var(--gutter);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}

.search {
  position: relative;
  flex: 1 1 260px;
  min-width: 0;
}
.search input {
  width: 100%;
  height: 42px;
  padding: 0 44px 0 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search input::placeholder { color: var(--muted); opacity: 0.8; }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.search svg {
  position: absolute;
  left: 13px;
  top: 50%;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
  stroke-linecap: round;
  pointer-events: none;
}
.search kbd {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  pointer-events: none;
}

.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.pill:hover { border-color: var(--ink); }
.pill[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.pill .n { margin-left: 6px; font-family: var(--font-mono); font-size: 0.75rem; opacity: 0.65; }

/* ---------- list ---------- */

.group { margin-top: 44px; }

.group-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 14px;
  align-items: baseline;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ink);
}
.group-no { grid-row: span 2; font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent); font-weight: 600; }
.group-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 560;
  font-size: 1.45rem;
  letter-spacing: -0.012em;
  line-height: 1.2;
}
.group-head p { margin: 0; font-size: 0.9rem; color: var(--muted); }

.rows { list-style: none; margin: 0; padding: 0; }

.row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 20px;
  margin: 0 -14px;
  padding: 22px 14px 20px;
  border-bottom: 1px solid var(--line-soft);
  transition: background 0.15s;
}
.row:hover { background: var(--hover); }

.row-title { grid-column: 1; margin: 0; display: flex; align-items: center; gap: 11px; min-width: 0; }
.row-title a {
  font-family: var(--font-display);
  font-weight: 560;
  font-size: 1.45rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
  text-decoration: none;
}
.row-title a::after { content: ''; position: absolute; inset: 0; }
.row-title a:focus-visible { outline: none; }
.row-title a:focus-visible::after { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.row:hover .row-title a { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 5px; text-decoration-color: var(--accent); }

.dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 50%, transparent);
  animation: beat 2.8s ease-out infinite;
}
.dot.planned { background: transparent; border: 1.5px dashed var(--muted); animation: none; }
.dot.paused { background: var(--muted); animation: none; opacity: 0.6; }
.dot.h-up { background: var(--live); }
.dot.h-slow { --live: var(--warn); background: var(--warn); }
.dot.h-down { --live: var(--down); background: var(--down); animation-duration: 1.2s; }
.dot.h-unknown { background: var(--muted); opacity: 0.55; animation: none; }

.health {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
  white-space: nowrap;
}
.health.h-slow { color: var(--warn); }
.health.h-down { color: var(--down); font-weight: 600; }

.tally .sum { display: inline-flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.tally .sum.bad { color: var(--down); }
.tally .sum.bad b { color: var(--down); }
.tally .sum .dot { animation: none; }
.tally .sum.good .dot { animation: beat 2.8s ease-out infinite; }

.uptime { margin-top: 24px; max-width: 640px; }
.uptime-head, .uptime-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); }
.uptime-head b { color: var(--ink); font-family: var(--font-mono); }
.uptime-foot { margin-top: 6px; font-family: var(--font-mono); font-size: 0.68rem; opacity: 0.75; }
.bars { display: flex; gap: 2px; height: 30px; margin-top: 10px; }
.bars i { flex: 1; min-width: 2px; border-radius: 2px; background: var(--live); opacity: 0.85; }
.bars i.b-s { background: var(--warn); }
.bars i.b-d { background: var(--down); opacity: 1; }
.bars i.b-n { background: var(--line); opacity: 0.6; }
.doc-meta .state .health { font-size: 0.8rem; }
.bars i:hover { opacity: 1; transform: scaleY(1.08); }

@keyframes beat {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 45%, transparent); }
  70%, 100% { box-shadow: 0 0 0 8px transparent; }
}

.chip {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  white-space: nowrap;
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.chip.public { color: var(--live); border-color: color-mix(in srgb, var(--live) 45%, var(--line)); }
.chip.key { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.chip.private { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.row-summary { grid-column: 1 / -1; margin: 0; max-width: 66ch; color: var(--muted); text-wrap: pretty; }

.row-foot {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-top: 8px;
}

.link {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.82rem;
  text-decoration: none;
  overflow-wrap: anywhere;
  transition: border-color 0.15s, color 0.15s;
}
.link.mono { font-family: var(--font-mono); font-size: 0.78rem; }
.link:hover { border-color: var(--accent); color: var(--accent); }
.link .arr { font-family: var(--font-mono); opacity: 0.6; }

.tags { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; margin-left: 4px; font-family: var(--font-mono); font-size: 0.74rem; color: var(--muted); }

.go {
  margin-left: auto;
  font-size: 0.85rem;
  font-weight: 560;
  color: var(--accent);
  white-space: nowrap;
}
.go .arr { display: inline-block; transition: transform 0.18s; }
.row:hover .go .arr { transform: translateX(4px); }

.row.planned { border-bottom-style: dashed; }
.empty { margin: 14px 0 0; padding: 18px 0; color: var(--muted); font-size: 0.92rem; }
.no-results { margin: 56px 0; text-align: center; color: var(--muted); }
.no-results b { color: var(--ink); }

/* staggered entrance, first paint of the list only */
.enter .row { animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- detail ---------- */

.crumbs { padding-top: 28px; }
.crumbs a {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: none;
}
.crumbs a:hover { color: var(--accent); }

.doc-head { padding: clamp(24px, 5vw, 48px) 0 28px; border-bottom: 1px solid var(--ink); }
.doc-head h1 { font-size: clamp(2.2rem, 5.5vw, 3.6rem); }
.doc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 24px; }
.doc-meta .chip { grid-column: auto; grid-row: auto; }
.doc-meta .state { display: inline-flex; align-items: center; gap: 9px; margin-right: 6px; font-size: 0.85rem; color: var(--muted); }

.prose { max-width: 70ch; padding-top: 12px; overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h2 {
  margin: 2.2em 0 0.6em;
  font-family: var(--font-display);
  font-weight: 560;
  font-size: 1.55rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
}
.prose h2::before { content: '§'; margin-right: 10px; font-weight: 400; color: var(--accent); }
.prose h3 { margin: 1.8em 0 0.4em; font-size: 1.05rem; }
.prose p, .prose ul, .prose ol { margin: 0.9em 0; }
.prose li { margin: 0.3em 0; }
.prose li::marker { color: var(--accent); }
.prose a { color: var(--accent); text-underline-offset: 3px; }
.prose strong { font-weight: 640; }

.prose code {
  padding: 0.12em 0.4em;
  border-radius: 5px;
  background: var(--code-bg);
  color: var(--code-ink);
  font-family: var(--font-mono);
  font-size: 0.86em;
  overflow-wrap: anywhere;
}

.codeblock { margin: 1.3em 0; border: 1px solid var(--line); border-radius: 12px; background: var(--code-bg); overflow: hidden; }
.codeblock header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px 6px 14px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.copy {
  min-width: 68px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  text-transform: none;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.copy:hover { border-color: var(--accent); color: var(--accent); }
.codeblock pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.codeblock pre code { padding: 0; background: none; font-size: 0.84rem; line-height: 1.65; white-space: pre; overflow-wrap: normal; }

.prose blockquote {
  margin: 1.4em 0;
  padding: 12px 18px;
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: var(--hover);
}
.prose blockquote p { margin: 0.3em 0; }

.tablewrap { margin: 1.3em 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.prose th, .prose td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
.prose th { font-family: var(--font-mono); font-size: 0.74rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); background: var(--surface); }
.prose tr:last-child td { border-bottom: 0; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 64px; }
.pager a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.pager a:hover { border-color: var(--accent); transform: translateY(-2px); }
.pager small { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.pager span { font-family: var(--font-display); font-size: 1.2rem; font-weight: 560; }
.pager .next { grid-column: 2; text-align: right; }
.pager .prev { grid-column: 1; }

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  .row { grid-template-columns: 1fr; }
  .chip { grid-column: 1; grid-row: auto; justify-self: start; order: -1; margin-bottom: 2px; }
  .row-title a { font-size: 1.3rem; }
  .go { margin-left: 0; width: 100%; padding-top: 4px; }
  .controls { gap: 10px; }
  .search kbd { display: none; }
  .search input { padding-right: 14px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next, .pager .prev { grid-column: 1; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
