@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./fonts/fraunces-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("./fonts/fraunces-latin-italic.woff2") format("woff2");
}

@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("./fonts/source-sans-3-latin.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --bg: #101416;
  --bg-raise: #1b2226;
  --bg-sink: #0c1012;
  --field: #0c1012;
  --ink: #f4f0e6;
  --muted: #b7bcb2;
  --line: #3a4743;
  --accent: #c43222;
  --accent-text: #ff8d7d;
  --accent-ink: #fff7f4;
  --accent-soft: rgba(226, 61, 43, 0.16);
  --gold: #e4b45c;
  --gold-soft: rgba(228, 180, 92, 0.16);
  --sage: #9dccab;
  --sage-soft: rgba(157, 204, 171, 0.16);
  --sea: #9ec4d4;
  --sea-soft: rgba(158, 196, 212, 0.16);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
  --serif: "Fraunces", "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: "Source Sans 3", "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 20px;
  --content: 1080px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #efe6d4;
  --bg-raise: #fffdf8;
  --bg-sink: #f4efe4;
  --field: #fffefb;
  --ink: #1c1915;
  --muted: #4e4940;
  --line: #ddd0b8;
  --accent: #b52d1e;
  --accent-text: #b52d1e;
  --accent-ink: #fff8f5;
  --accent-soft: rgba(181, 45, 30, 0.1);
  --gold: #8a5d10;
  --gold-soft: rgba(138, 93, 16, 0.12);
  --sage: #1d6a38;
  --sage-soft: rgba(29, 106, 56, 0.12);
  --sea: #1a5a74;
  --sea-soft: rgba(26, 90, 116, 0.12);
  --shadow: 0 18px 40px rgba(70, 48, 16, 0.08);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  background:
    radial-gradient(820px 380px at 0% -8%, var(--accent-soft), transparent 60%),
    radial-gradient(640px 340px at 100% 0%, var(--gold-soft), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.5;
  overflow-x: clip;
  text-rendering: optimizeLegibility;
}

@media (pointer: fine) {
  html { overscroll-behavior: none; }
}

body::before {
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--bg-raise);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 6;
}

.skip:focus { top: 12px; }

:focus { outline: none; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  scroll-margin-top: 80px;
}

h1, h2, h3 { scroll-margin-top: 24px; }

button, .btn, a, summary, .pill, .check, input, textarea {
  touch-action: manipulation;
}

.top, .wrap, .colophon, #app {
  width: min(var(--content), calc(100% - 40px));
  margin-left: auto;
  margin-right: auto;
}

.top {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px 0 16px;
}

.top::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 100vw;
  transform: translateX(-50%);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.mark { width: 40px; height: 40px; flex: none; color: var(--ink); }

.word {
  margin: 0;
  font-family: var(--serif);
  font-weight: 560;
  font-size: 1.5rem;
  letter-spacing: -0.03em;
  line-height: 1;
}

.tag { margin: 4px 0 0; color: var(--muted); font-size: 0.95rem; }

.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

button, .btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--ink);
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 44px;
  padding: 0 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

button:hover, .btn:hover {
  border-color: var(--gold);
  background: color-mix(in srgb, var(--bg-raise) 84%, var(--gold) 16%);
}

button:active, .btn:active { transform: translateY(1px); }

button:disabled { opacity: 0.5; cursor: not-allowed; }

.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}

.primary:hover {
  background: color-mix(in srgb, var(--accent) 86%, white);
  border-color: transparent;
}

.primary:active { background: color-mix(in srgb, var(--accent) 88%, black); }

.ghost { background: transparent; }

.ghost:hover { background: var(--accent-soft); }

.danger { color: var(--accent-text); }

.file { position: relative; }

.file:focus-within {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.file input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.wrap { margin-top: 8px; margin-bottom: 28px; }

.kicker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}

.kicker {
  margin: 0;
  color: var(--accent-text);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero { position: relative; padding: 28px 0 4px; min-width: 0; }

.hero h1, .dest h1, .missing h1 {
  font-family: var(--serif);
  font-weight: 560;
  letter-spacing: -0.03em;
  line-height: 1.02;
  margin: 0;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.hero h1 { font-size: clamp(2.7rem, 4.4vw, 3.85rem); max-width: 12em; }

.lede, .done {
  color: var(--muted);
  font-size: 1.125rem;
  max-width: 38rem;
}

.lede { margin: 16px 0 0; text-wrap: pretty; }

.rose {
  position: static;
  width: 28px;
  height: 28px;
  flex: none;
  color: var(--gold);
  opacity: 1;
  pointer-events: none;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(300px, 0.92fr);
  gap: 28px 40px;
  align-items: start;
}

.chart-card { margin-top: 28px; }

.card {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

.card h2 {
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 560;
  letter-spacing: -0.02em;
  text-transform: none;
  color: var(--ink);
  margin: 0 0 14px;
  text-wrap: balance;
}

.types legend, label, .k {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

.stack { display: flex; flex-direction: column; gap: 12px; }

.stack > button, .stack > .btn { align-self: flex-start; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.row input { flex: 1 1 180px; width: auto; min-width: 0; }

input[type="text"], textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 48px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

textarea { min-height: 104px; resize: vertical; line-height: 1.45; }

#notes { min-height: 148px; }

input[type="text"]:hover, textarea:hover {
  border-color: color-mix(in srgb, var(--gold) 55%, var(--line));
}

input[type="text"]:focus-visible, textarea:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

::placeholder { color: var(--muted); opacity: 1; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 20px;
  align-items: start;
  margin-top: 22px;
}

.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.dest { padding-top: 22px; min-width: 0; }

.dest h1 { font-size: clamp(2rem, 4vw, 3.15rem); line-height: 1.05; }

.dest-top, .meta-row, .line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.dest-top { justify-content: space-between; margin-bottom: 14px; }

.done {
  margin: 12px 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 460;
  text-wrap: pretty;
}

.tally {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  font-variant-numeric: tabular-nums;
}

.meter {
  height: 6px;
  background: var(--line);
  border-radius: 99px;
  margin: 16px 0 8px;
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 420ms cubic-bezier(.22, .8, .28, 1);
}

.now {
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background:
    linear-gradient(180deg, var(--accent-soft), transparent 88px),
    var(--bg-raise);
}

.badge {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--bg-sink);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  width: fit-content;
  align-self: flex-start;
}

.badge.live, .badge.done, .badge.task { color: var(--sage); background: var(--sage-soft); }
.badge.archived, .badge.progress, .badge.prototype { color: var(--gold); background: var(--gold-soft); }
.badge.hitl, .badge.grilling { color: var(--accent-text); background: var(--accent-soft); }
.badge.afk, .badge.research { color: var(--sea); background: var(--sea-soft); }

.ticket {
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  background: color-mix(in srgb, var(--bg-raise) 70%, transparent);
}

.ticket + .ticket, .lines li + li, .decisions li + li { margin-top: 12px; }

.ticket.grilling { border-left-color: var(--accent); }
.ticket.prototype { border-left-color: var(--gold); }
.ticket.research { border-left-color: var(--sea); }
.ticket.task { border-left-color: var(--sage); }

.q, .name {
  font-family: var(--serif);
  font-size: 1.28rem;
  font-weight: 520;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 0;
  overflow-wrap: break-word;
  text-wrap: balance;
}

.ticket.done .q { color: var(--muted); }

.why, .meta, .gist { color: var(--muted); margin: 0; overflow-wrap: break-word; }

.resolution {
  margin: 0;
  padding-left: 12px;
  border-left: 2px solid var(--gold);
}

.types { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.types legend { width: 100%; padding: 0; margin-bottom: 2px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--field);
}

.pill:focus-within {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.pill.grilling:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.pill.prototype:has(input:checked) { border-color: var(--gold); background: var(--gold-soft); }
.pill.research:has(input:checked) { border-color: var(--sea); background: var(--sea-soft); }
.pill.task:has(input:checked) { border-color: var(--sage); background: var(--sage-soft); }
.pill input { accent-color: var(--accent); }

.legend {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 0.98rem;
}

.legend li { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.legend b { color: var(--ink); font-weight: 650; }

.key {
  width: 9px;
  height: 9px;
  margin-top: 0.5em;
  border-radius: 99px;
  flex: none;
  background: var(--line);
}

.key.grilling { background: var(--accent); }
.key.prototype { background: var(--gold); }
.key.research { background: var(--sea); }
.key.task { background: var(--sage); }

.checks { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

.check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.98rem;
  font-weight: 400;
  color: var(--ink);
  cursor: pointer;
}

.check input { margin-top: 4px; accent-color: var(--accent); }

details summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
}

details summary:hover { color: var(--accent-text); }

.edit { margin-top: 12px; }

.maplist, .lines, .decisions { list-style: none; padding: 0; margin: 0; }

.maplist { display: flex; flex-direction: column; gap: 10px; }

.maplist li {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 16px 16px 16px 18px;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 16px;
  min-width: 0;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.maplist a {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  color: inherit;
  text-decoration: none;
  flex: 1;
  min-width: 0;
}

.maplist li:hover {
  border-color: color-mix(in srgb, var(--gold) 70%, var(--line));
  background: color-mix(in srgb, var(--bg-raise) 88%, var(--gold-soft));
}

.maplist strong {
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 540;
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
}

.decisions li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; }
.num {
  font-family: var(--mono);
  color: var(--gold);
  font-size: 0.8rem;
  padding-top: 6px;
  font-variant-numeric: tabular-nums;
}

.line { justify-content: space-between; align-items: flex-start; gap: 12px; }
.line > span:first-child { overflow-wrap: break-word; min-width: 0; flex: 1; }
.line .row { flex: none; }
.row > button, .row > .btn { align-self: stretch; }

.handoff, .now.handoff {
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: none;
}

.section-gap { margin-top: 36px; }

.section-gap h2 {
  font-family: var(--serif);
  font-weight: 560;
  letter-spacing: -0.02em;
  font-size: 1.7rem;
  text-transform: none;
  color: var(--ink);
  margin: 0 0 12px;
}

.empty {
  border: 1px dashed color-mix(in srgb, var(--gold) 45%, var(--line));
  background: color-mix(in srgb, var(--bg-raise) 72%, transparent);
  border-radius: var(--radius);
  padding: 22px 20px;
}

.empty p {
  margin: 0;
  max-width: 42rem;
  color: var(--muted);
}

.colophon {
  color: var(--muted);
  font-size: 0.92rem;
  margin-top: 32px;
  margin-bottom: calc(28px + env(safe-area-inset-bottom));
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.loading {
  margin: 48px 0;
  color: var(--muted);
}

#toast {
  width: min(var(--content), calc(100% - 40px));
  margin: 0 auto;
}

#toast:empty { display: none; }

#toast:not(:empty) {
  position: sticky;
  top: 8px;
  z-index: 5;
  width: max-content;
  max-width: min(520px, calc(100% - 40px));
  margin: 8px auto 0;
  background: var(--ink);
  color: var(--bg);
  padding: 12px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  text-align: center;
}

.index { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }

.index-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  min-width: 0;
  background: var(--field);
}

.index-row.grilling { border-left-color: var(--accent); }
.index-row.prototype { border-left-color: var(--gold); }
.index-row.research { border-left-color: var(--sea); }
.index-row.task { border-left-color: var(--sage); }
.index-row.done .q { color: var(--muted); }

.index-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.index-row .q { font-size: 1.12rem; }
.index-row summary { overflow-wrap: anywhere; }

.now .ticket > button { align-self: flex-start; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

/* ponytail: ticket lists cap at 80, so the index is not virtualized. Upgrade path: content-visibility or a window if that cap rises. */

@media (prefers-reduced-motion: no-preference) {
  #app.arrive > * {
    animation: rise 460ms cubic-bezier(.22, .8, .28, 1) both;
  }

  #app.arrive > :nth-child(2) { animation-delay: 70ms; }
  #app.arrive > :nth-child(3) { animation-delay: 120ms; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 860px) {
  .hero-grid, .layout { grid-template-columns: 1fr; gap: 14px; }
  .chart-card { margin-top: 0; }
  .chart-card .stack { gap: 8px; }
  .chart-card h2 { margin-bottom: 8px; }
  .hero { padding-top: 10px; }
  .hero h1 { font-size: clamp(2.05rem, 8vw, 2.6rem); }
  .lede { margin-top: 8px; font-size: 1.02rem; }
  .section-gap { margin-top: 16px; }
  .section-gap h2 { margin-bottom: 8px; }
  .top { padding: 10px 0 10px; }
  .chart-card textarea { min-height: 72px; }
  .kicker-row { margin-bottom: 6px; }
  .empty { padding: 12px 14px; }
}

@media (max-width: 640px) {
  .top { align-items: stretch; }
  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .top-actions > button,
  .top-actions > .btn { width: 100%; padding-inline: 8px; }
}

@media (max-width: 420px) {
  .top, .wrap, .colophon, #app { width: min(var(--content), calc(100% - 28px)); }
  .maplist li { align-items: stretch; flex-direction: column; }
  .line, .index-row { flex-direction: column; }
  .card { padding: 16px; }
  .hero h1 { font-size: 2.2rem; }
}

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