:root {
  --ink: #0f1c24;
  --ink-2: #15262f;
  --paper: #f4efe4;
  --card: #fffaf2;
  --line: #d9d0bf;
  --muted: #5c564c;
  --maple: #b42318;
  --maple-ink: #fff7f5;
  --forest: #1f4d3a;
  --amber: #9a6700;
  --ok: #1f4d3a;
  --focus: #0b6e4f;
  --serif: "Newsreader", "Iowan Old Style", Palatino, serif;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --measure: 68ch;
  --wrap: 1120px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: light; }
body {
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
}
a { color: var(--forest); }
a:hover { color: var(--maple); }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 20;
  background: var(--card);
  color: var(--ink);
  padding: 8px 12px;
}
.skip:focus { top: 12px; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.site-head {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--ink);
  color: #e8e2d6;
}
.site-head__inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 14px 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  align-items: center;
}
.mark {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #f4efe4;
  text-decoration: none;
  border-bottom: 2px solid var(--maple);
  line-height: 1.1;
  padding-bottom: 1px;
}
.site-nav { display: flex; gap: 16px; }
.site-nav a {
  color: #c9c2b4;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 4px;
}
.site-nav a[aria-current="page"] {
  color: var(--ink);
  background: #f4efe4;
}
.site-nav a:hover { color: #fff; }
.site-nav a[aria-current="page"]:hover { color: var(--ink); }
.desk-status {
  margin: 0 0 0 auto;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #b7b0a3;
}
.desk-status[data-run-status="running"] { color: #f3d39a; }

main {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 28px 22px 48px;
}
.site-foot {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 22px 32px;
  color: var(--muted);
  font-size: 13px;
}
.site-foot p { margin: 0; }

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-end;
  margin-bottom: 22px;
}
.kicker {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--maple);
}
.page-head h1,
.dossier h1,
.empty h2,
.runs-wrap h2 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}
.page-head h1 { font-size: clamp(32px, 5vw, 44px); line-height: 1.05; }
.page-head__meta {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.page-head__meta strong { color: var(--ink); font-weight: 600; }
.lede { margin: 8px 0 0; color: var(--muted); max-width: 58ch; }

.search { margin-bottom: 16px; }
.search-card {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 12px;
}
.search-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.search-bar input[type="search"] {
  border: 0;
  background: transparent;
  padding: 10px 12px;
  font: 18px/1.3 var(--serif);
  color: var(--ink);
  min-width: 0;
}
.search-bar input[type="search"]::placeholder { color: #8a8376; }
.search-bar input[type="search"]:focus { outline: none; }
.search-card:focus-within { border-color: var(--ink); }
.toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.toolbar label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.toolbar select {
  font: 14px/1.3 var(--sans);
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  width: 100%;
  min-width: 0;
}

button, .btn {
  font: 500 14px/1.2 var(--sans);
  background: var(--ink);
  color: #f4efe4;
  border: 0;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}
button:hover, .btn:hover { color: #fff; filter: brightness(1.08); }
.btn--primary, .search-bar button, .scrape-all button {
  background: var(--maple);
  color: var(--maple-ink);
}
button:disabled, .btn[disabled] { opacity: 0.45; cursor: not-allowed; filter: none; }

.chips, .source-strip {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chips li, .source-strip li { flex: 0 1 auto; max-width: 100%; }
.chips a, .source-strip a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 5px 10px;
  font-size: 13px;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}
.chips a span:first-child,
.source-strip a {
  color: var(--muted);
}
.chips a:hover, .source-strip a:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.chips__x { color: var(--muted); }
.source-strip a b { color: var(--ink); font-weight: 600; }

.banner {
  background: #efe3c8;
  border: 1px solid #ddc896;
  padding: 10px 14px;
  margin: 0 0 18px;
}
.banner.is-running { background: #f6ead0; color: #5c4300; }

.empty { padding: 48px 0; }
.empty h2 { font-size: 30px; margin-bottom: 8px; }
.empty p { color: var(--muted); }

.results { list-style: none; padding: 0; margin: 8px 0 0; }
.results > li { border-top: 1px solid var(--line); }
.result {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 28px;
  padding: 16px 4px;
  text-decoration: none;
  color: inherit;
}
.result:hover { background: rgba(255, 250, 242, 0.7); }
.result h2 {
  font-family: var(--serif);
  font-size: clamp(20px, 2.4vw, 26px);
  font-weight: 600;
  line-height: 1.2;
  margin: 6px 0 4px;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.src { color: var(--maple); }
.fr { font-style: italic; color: var(--muted); margin: 0 0 6px; }
.buyer { margin: 0; color: var(--muted); font-size: 14px; }
.result__close {
  text-align: right;
  min-width: 9.5rem;
  align-self: start;
  padding-top: 2px;
}
.result__close time {
  display: block;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 500;
}
.result__close span { font-size: 12px; color: var(--muted); }
.tone-urgent, .tone-urgent span { color: var(--maple); }
.tone-soon, .tone-soon span { color: var(--amber); }
.tone-ok time { color: var(--ink); }
.tone-closed, .tone-none { color: var(--muted); }

.pager {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 22px;
  font-size: 14px;
}
.pager a { font-weight: 500; }
.pager .is-disabled { color: #b3ab9d; }

.dossier { max-width: 820px; }
.crumbs {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 14px;
}
.dossier__head h1 {
  font-size: clamp(30px, 5vw, 42px);
  line-height: 1.12;
  margin: 8px 0 6px;
}
.callout {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: baseline;
  margin: 16px 0;
  padding: 12px 14px;
  background: var(--card);
  border-left: 3px solid var(--line);
}
.callout.tone-urgent { border-left-color: var(--maple); }
.callout.tone-soon { border-left-color: var(--amber); }
.callout.tone-ok { border-left-color: var(--forest); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.actions .btn { color: #f4efe4; }
.actions .btn:hover { color: #fff; }
.actions .btn:not(.btn--primary) { background: var(--ink); }

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin: 22px 0;
}
.facts div {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 10px 12px;
}
dt {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
dd { margin: 4px 0 0; }

.prose { max-width: var(--measure); overflow-wrap: anywhere; }
.prose p { margin: 0 0 12px; line-height: 1.7; text-wrap: pretty; }
.dossier h2, .source-card h2 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  margin: 28px 0 10px;
}
.docs { list-style: none; padding: 0; margin: 0; }
.docs li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.pill {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  padding: 3px 7px;
  white-space: nowrap;
}
.pill--saved, .pill--ok, .pill--done { color: var(--ok); border-color: #b7cfc3; }
.pill--login_required, .pill--pending { color: var(--amber); border-color: #e4d09a; }
.pill--error, .pill--failed, .pill--http_403, .pill--http_401 { color: var(--maple); border-color: #e8b4ae; }
.pill--running { color: #5c4300; border-color: #e4d09a; background: #f6ead0; }
.muted { color: var(--muted); }

.source-grid {
  list-style: none;
  padding: 0;
  margin: 8px 0 36px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.source-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  padding: 16px;
}
.source-card h2 { margin: 0 0 6px; font-size: 22px; overflow-wrap: anywhere; }
.source-card p { margin: 0 0 8px; color: var(--muted); }
.source-card > div:first-child { min-width: 0; flex: 1; }
.source-card form { flex-shrink: 0; }
.source-card.is-disabled { opacity: 0.62; }
.runs-wrap h2 { font-size: 26px; margin-bottom: 12px; }
.table-scroll { overflow-x: auto; }
.runs { width: 100%; border-collapse: collapse; font-size: 14px; }
.runs th, .runs td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.runs th { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.runs .err pre { white-space: pre-wrap; color: var(--maple); font-size: 12px; margin: 0; }

@media (max-width: 720px) {
  .site-head__inner { padding: 12px 16px; }
  .desk-status { margin-left: 0; width: 100%; }
  main { padding: 20px 16px 36px; }
  .page-head, .source-card { display: block; }
  .page-head { align-items: start; }
  .scrape-all { margin-top: 12px; }
  .result { grid-template-columns: 1fr; gap: 8px; }
  .result__close { text-align: left; min-width: 0; }
  .source-grid { grid-template-columns: 1fr; }
  .search-bar { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

@media print {
  .site-head, .site-foot, .actions, .skip { display: none; }
  body { background: #fff; }
  .dossier { max-width: none; }
}
