:root,
[data-theme="light"] {
  --ink: #111111;
  --muted: #6a6a60;
  --paper: #ffffff;
  --paper-2: #fbfbf7;
  --accent: #e8b923;
  --accent-deep: #c99700;
  --line: #e6e6dc;
  --bad: #b42318;
  --ok: #c99700;
  --bar-track: #efefe6;
  --btn-on-accent: #111111;
  --glow: rgba(232, 185, 35, 0.2);
  --glow-2: rgba(232, 185, 35, 0.08);
  --rail: 13.5rem;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --display: "Bricolage Grotesque", "IBM Plex Sans", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --theme-meta: #ffffff;
  color-scheme: light;
}

[data-theme="dark"] {
  --ink: #f2f2f0;
  --muted: #8f8f86;
  --paper: #050505;
  --paper-2: #111111;
  --accent: #3ce06a;
  --accent-deep: #2bb853;
  --line: #262626;
  --bad: #ff6b6b;
  --ok: #3ce06a;
  --bar-track: #1c1c1c;
  --btn-on-accent: #050505;
  --glow: rgba(60, 224, 106, 0.16);
  --glow-2: rgba(60, 224, 106, 0.07);
  --theme-meta: #050505;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(900px 480px at 8% -8%, var(--glow), transparent 55%),
    radial-gradient(700px 420px at 92% 0%, var(--glow-2), transparent 50%),
    linear-gradient(168deg, var(--paper) 0%, var(--paper-2) 52%, var(--paper) 100%);
  overflow-x: hidden;
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.14;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

.rail {
  padding: 2.1rem 1.4rem;
  padding-top: max(2.1rem, env(safe-area-inset-top));
  padding-left: max(1.4rem, env(safe-area-inset-left));
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2rem;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
}

.brand {
  text-decoration: none;
  color: inherit;
  display: grid;
  animation: rise 0.7s ease both;
}
.brand-mark {
  font-family: var(--display);
  font-size: 2.15rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.95;
  color: var(--ink);
}
.brand-mark::first-letter {
  color: var(--accent);
}

.rail nav { display: grid; gap: 0.35rem; }
.rail nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 0.55rem 0;
  min-height: 2.5rem;
  display: flex;
  align-items: center;
  border-bottom: 1px solid transparent;
}
.rail nav a[aria-current="page"] {
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.rail-note {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}
.rail-foot {
  margin-top: auto;
  display: grid;
  gap: 0.75rem;
  padding-bottom: env(safe-area-inset-bottom);
}
.theme-toggle {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  padding: 0.55rem 0.7rem;
  min-height: 2.5rem;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.theme-toggle:hover {
  border-color: var(--accent);
}

.stage {
  padding: 2.2rem 2.6rem 3.5rem;
  padding-bottom: max(3.5rem, env(safe-area-inset-bottom));
  max-width: 1120px;
  min-width: 0;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  margin-bottom: 1.8rem;
  animation: rise 0.55s ease both;
}
.page-head h1 {
  font-family: var(--display);
  font-size: clamp(1.8rem, 4vw, 3.1rem);
  letter-spacing: -0.04em;
  margin: 0 0 0.25rem;
  line-height: 0.95;
  overflow-wrap: anywhere;
}
.page-head p, .lede {
  margin: 0;
  color: var(--muted);
  max-width: 36rem;
}
.kicker {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.4rem !important;
}
.head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: end;
}

.btn {
  appearance: none;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font: inherit;
  padding: 0.65rem 1rem;
  min-height: 2.75rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.btn-accent {
  background: var(--accent);
  color: var(--btn-on-accent);
  border-color: var(--accent);
}
.btn-accent:hover {
  filter: brightness(1.05);
}
.btn:disabled { opacity: 0.45; cursor: wait; transform: none; }
.log-title {
  font-family: var(--display);
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  margin: 2rem 0 0.6rem;
}
.tabs {
  display: flex;
  gap: 0.35rem;
  margin: 0 0 1.4rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.55rem;
}
.tabs a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.95rem;
  padding: 0.45rem 0.75rem;
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  margin-bottom: -0.6rem;
}
.tabs a.is-on {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--ink);
}
.tabs-sub {
  margin: 0 0 1.1rem;
}
.pool-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.85rem;
  align-items: end;
  margin: 1.2rem 0 0.4rem;
}
.pool-tools > label {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
}
.pool-tools select {
  width: auto;
  min-width: 8.5rem;
  max-width: 12rem;
  padding: 0.55rem 0.65rem;
  min-height: 2.6rem;
}
.pool-reset {
  align-self: end;
  margin-bottom: 0.35rem;
  white-space: nowrap;
}

.ledger {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--ink);
}
.ledger-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  align-items: start;
  padding: 1.05rem 0;
  border-bottom: 1px solid var(--line);
  animation: rise 0.5s ease both;
  animation-delay: calc(var(--i) * 40ms);
}
.pool-bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin: 0.6rem 0 0.2rem;
}
.pool-check-all,
.pool-pick {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  cursor: pointer;
  user-select: none;
}
.pool-pick {
  padding-top: 0.55rem;
}
.pool-check-all input,
.pool-pick input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
  cursor: pointer;
}
.pool-bulk-bar .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.ledger-main {
  display: grid;
  grid-template-columns: 5.2rem 1fr;
  gap: 1rem;
  align-items: start;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.who { display: grid; gap: 0.12rem; min-width: 0; }
.who strong {
  font-family: var(--display);
  font-size: clamp(1.15rem, 3.4vw, 1.42rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.who em { font-style: normal; color: var(--muted); font-size: 0.95rem; overflow-wrap: anywhere; }
.who .where { color: var(--muted); font-size: 0.86rem; }
.blurb {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  font-weight: 400;
}
.ledger-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.9rem;
  align-items: center;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 0.86rem;
}
.hint { color: var(--accent-deep); }
.flag {
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
}

.score {
  font-family: var(--mono);
  display: flex;
  align-items: baseline;
  gap: 0.15rem;
}
.score-n { font-size: 1.7rem; font-weight: 500; color: var(--accent); }
.score-k { color: var(--muted); font-size: 0.75rem; }

.empty {
  padding: 4rem 0;
  animation: rise 0.6s ease both;
}
.empty h2 { font-family: var(--display); font-size: 2rem; margin: 0 0 0.4rem; }

.ingest { display: grid; gap: 1.1rem; max-width: 48rem; }
.ingest-row, .stack {
  display: grid;
  gap: 0.8rem;
}
.ingest-row { grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
label, .quiet { display: grid; gap: 0.3rem; font-size: 0.84rem; color: var(--muted); }
input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--line);
  padding: 0.7rem 0.75rem;
  width: 100%;
  max-width: 100%;
  border-radius: 0;
}
textarea { min-height: 16rem; resize: vertical; line-height: 1.45; }
.paste span { font-size: 0.92rem; color: var(--ink); }

.split {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 2.4rem;
  align-items: start;
}
.split h2, .side h2 {
  font-family: var(--display);
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  margin: 1.8rem 0 0.6rem;
}
.split > div > h2:first-child, .side > h2:first-child { margin-top: 0; }
.num { font-family: var(--mono); font-weight: 500; }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.55rem; }
.bars li {
  display: grid;
  grid-template-columns: minmax(5rem, 9.5rem) 1fr 2.2rem;
  gap: 0.6rem;
  align-items: center;
  font-size: 0.92rem;
}
.bar {
  height: 0.42rem;
  background: var(--bar-track);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  animation: fill 0.8s ease forwards;
  --w: calc(var(--score) * 1%);
}
.bars b { font-family: var(--mono); font-weight: 500; text-align: right; }

.signals { color: var(--muted); font-size: 0.92rem; }

.approach {
  display: grid;
  gap: 0.55rem;
}
.approach button {
  display: flex;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  font: inherit;
  background: transparent;
  border: 1px solid var(--line);
  padding: 0.85rem 0.95rem;
  min-height: 3rem;
  cursor: pointer;
  color: inherit;
}
.approach button.is-on {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--paper-2));
}
.approach strong { font-weight: 600; }
.approach span { font-family: var(--mono); }

.banner {
  border-left: 3px solid var(--accent);
  padding: 0.4rem 0 0.4rem 0.9rem;
  color: var(--ink);
}

.desc { margin: 1.6rem 0 0; }
.desc pre {
  white-space: pre-wrap;
  font-family: var(--font);
  background: var(--paper-2);
  padding: 1rem;
  border: 1px solid var(--line);
  max-height: 22rem;
  overflow: auto;
}

.search-titles {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  font-size: 0.84rem;
  color: var(--muted);
}
.search-titles li { padding: 0.18rem 0; }
.search-titles span { color: var(--muted); }

.people { list-style: none; margin: 0 0 1rem; padding: 0; }
.people li {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}
.people strong { display: block; }
.people em, .people span { display: block; font-style: normal; color: var(--muted); font-size: 0.86rem; }
.people-act { display: flex; gap: 0.6rem; align-items: start; flex-wrap: wrap; }
.people-act a { color: var(--accent-deep); }

.textish {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.letter {
  margin: 1rem 0;
  padding: 0.9rem 0;
  border-top: 1px solid var(--line);
}
.letter header { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }
.letter p { white-space: pre-wrap; line-height: 1.5; }
.letter small { color: var(--muted); }

.log { list-style: none; margin: 0; padding: 0; color: var(--muted); font-size: 0.82rem; }
.log li { padding: 0.25rem 0; }
.log time { font-family: var(--mono); margin-right: 0.4rem; }

.flashes { display: grid; gap: 0.4rem; margin-bottom: 1rem; }
.flash { margin: 0; padding: 0.5rem 0; }
.flash-ok { color: var(--ok); }
.flash-error { color: var(--bad); }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes fill {
  to { width: var(--w); }
}

.paste-hero textarea { min-height: 14rem; }
.ingest-fold {
  max-width: 48rem;
  margin: 0 0 0.4rem;
}
.ingest-fold > summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-deep);
  user-select: none;
  padding: 0.35rem 0;
  min-height: 2.5rem;
}
.ingest-fold > summary::-webkit-details-marker { display: none; }
.ingest-fold > summary::before {
  content: "+";
  font-family: var(--mono);
  font-weight: 500;
  color: var(--muted);
}
.ingest-fold[open] > summary {
  margin-bottom: 0.75rem;
}
.ingest-fold[open] > summary::before { content: "–"; }
.ingest-fold .ingest { margin-top: 0; }
.desc-open {
  white-space: pre-wrap;
  font-family: var(--font);
  background: var(--paper-2);
  padding: 1rem;
  border: 1px solid var(--line);
  max-height: 28rem;
  overflow: auto;
  line-height: 1.5;
}
.search-titles a {
  color: var(--accent-deep);
  margin-left: 0.55rem;
}
.search-titles > li { padding: 0.45rem 0; border-bottom: 1px solid var(--line); }
.search-titles > li:last-child { border-bottom: 0; }
.title-head { color: var(--ink); }
.people-under { margin: 0.15rem 0 0.2rem; }
.people-under li { padding: 0.35rem 0; border-bottom: 0; }
.people-under strong { font-size: 0.92rem; }
.people-brief {
  white-space: pre-wrap;
  line-height: 1.5;
  margin: 0.4rem 0 1rem;
  padding: 0.85rem 0.9rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.92rem;
}
.quiet-label {
  margin: 0.8rem 0 0.2rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.google-finds { margin-bottom: 0.6rem; }
.side h2 { margin-top: 1.4rem; }
.watch {
  border-top: 1px solid var(--ink);
  padding: 1.2rem 0 1.6rem;
  animation: rise 0.45s ease both;
  min-width: 0;
  max-width: 100%;
}
.watch header {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 0.8rem;
  min-width: 0;
}
.watch h2 {
  font-family: var(--display);
  font-size: clamp(1.2rem, 3.5vw, 1.5rem);
  letter-spacing: -0.03em;
  margin: 0;
  overflow-wrap: anywhere;
}
.watch header p {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
  font-size: 0.86rem;
  line-height: 1.4;
}
.found {
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.found li {
  border-bottom: 1px solid var(--line);
  min-width: 0;
  max-width: 100%;
}
.found a {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.95rem 0 0.35rem;
  text-decoration: none;
  color: inherit;
  align-items: start;
  min-width: 0;
}
.found .who strong,
.found .who em,
.found .blurb,
.found .lede {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.found > li > .lede {
  margin: 0 0 0.75rem;
  padding-left: 0;
  font-size: 0.84rem;
}
.found-act {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0 0 0.9rem 5.25rem;
  flex-wrap: wrap;
  min-width: 0;
}
.found-act .btn { padding: 0.5rem 0.85rem; font-size: 0.86rem; min-height: 2.4rem; }
.scan-add {
  margin-top: 1.6rem;
  max-width: 48rem;
  width: 100%;
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: sticky;
    top: 0;
    z-index: 20;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    padding: 0.85rem 1rem;
    padding-top: max(0.85rem, env(safe-area-inset-top));
  }
  .brand-mark { font-size: 1.55rem; }
  .rail nav {
    display: flex;
    gap: 0.35rem;
    flex: 1 1 auto;
    justify-content: center;
  }
  .rail nav a {
    padding: 0.45rem 0.7rem;
    border: 1px solid transparent;
    min-height: 2.4rem;
  }
  .rail nav a[aria-current="page"] {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, var(--paper-2));
  }
  .rail-note { display: none; }
  .rail-foot {
    margin-top: 0;
    width: auto;
  }
  .theme-toggle {
    width: auto;
    min-width: 6.5rem;
    padding: 0.45rem 0.6rem;
  }
  .stage {
    padding: 1.2rem 1rem 2.5rem;
    padding-bottom: max(2.5rem, env(safe-area-inset-bottom));
  }
  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  .head-actions { width: 100%; }
  .head-actions .btn,
  .head-actions form { flex: 1 1 auto; }
  .split { grid-template-columns: 1fr; gap: 1.5rem; }
  .ledger-main {
    grid-template-columns: 4.2rem minmax(0, 1fr);
    gap: 0.75rem;
  }
  .found a {
    grid-template-columns: 3rem minmax(0, 1fr);
    gap: 0.55rem;
  }
  .found .score-k { display: none; }
  .found .score-n { font-size: 1.15rem; }
  .score-n { font-size: 1.35rem; }
  .found-act { padding: 0 0 0.85rem; }
  .found > li > .lede { margin-top: -0.15rem; }
  .pool-tools { gap: 0.65rem; }
  .pool-tools > label { flex: 1 1 9rem; }
  .pool-tools select {
    width: 100%;
    max-width: none;
    min-width: 0;
  }
  .tabs {
    flex-wrap: wrap;
    gap: 0.25rem;
  }
  .tabs a {
    margin-bottom: 0;
    border-bottom-width: 2px;
  }
  .tabs-sub {
    border-bottom: 0;
    padding-bottom: 0;
  }
  .ingest-row { grid-template-columns: 1fr; }
  .scan-add .btn { width: 100%; }
  .page-head p,
  .lede {
    max-width: none;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .bars li {
    grid-template-columns: 1fr 2.2rem;
    grid-template-areas: "label score" "bar bar";
  }
  .bars li > span:first-child { grid-area: label; }
  .bars li > .bar { grid-area: bar; }
  .bars li > b { grid-area: score; }
  .people li { flex-direction: column; align-items: stretch; }
  .approach button { flex-wrap: wrap; gap: 0.35rem; }
}

@media (max-width: 420px) {
  .rail nav a { padding: 0.4rem 0.5rem; font-size: 0.92rem; }
  .ledger-main { grid-template-columns: 3.4rem minmax(0, 1fr); }
  .found a { grid-template-columns: 2.6rem minmax(0, 1fr); }
}
