/* Khan docket. Mobile first: phone layout by default, wider screens add room. */
:root {
  --bg: #fbfaf7; --panel: #ffffff; --ink: #1f2328; --muted: #5f6368; --line: #e3e0d8;
  --accent: #1f4e79; --accent-ink: #ffffff; --red: #a32d2d; --red-bg: #fcebeb; --orange: #854f0b; --orange-bg: #faeeda;
  --yellow: #5f5e5a; --yellow-bg: #f1efe8; --green: #0f6e56; --green-bg: #e1f5ee;
  --radius: 12px; --gutter: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181b; --panel: #1e2124; --ink: #e8e6e1; --muted: #a8a59e; --line: #34373b;
    --accent: #8ab4e8; --accent-ink: #10202f; --red: #f09595; --red-bg: #3a1f1f; --orange: #ef9f27; --orange-bg: #3a2c16;
    --yellow: #c9c6bd; --yellow-bg: #2b2c2a; --green: #5dcaa5; --green-bg: #173229;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow-wrap: anywhere;
}
a { color: var(--accent); }

/* Header: sticky, brand on top, sections as a swipeable row of chips. */
header.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: calc(8px + env(safe-area-inset-top)) var(--gutter) 0;
}
header.top .brand { display: block; font-weight: 600; font-size: 1.05rem; text-decoration: none; color: var(--ink); padding-bottom: 6px; }
header.top nav {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) 10px;
  -webkit-overflow-scrolling: touch;
}
header.top nav::-webkit-scrollbar { display: none; }
header.top nav a {
  flex: 0 0 auto; text-decoration: none; color: var(--ink);
  padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; font-size: 0.92rem; min-height: 36px;
}
header.top nav a:active { background: var(--yellow-bg); }

.banner { padding: 6px var(--gutter); font-size: 0.8rem; color: var(--muted); background: var(--yellow-bg); border-bottom: 1px solid var(--line); }
main { max-width: 60rem; margin: 0 auto; padding: 16px var(--gutter) 40px; }
footer {
  max-width: 60rem; margin: 0 auto; padding: 16px var(--gutter) calc(24px + env(safe-area-inset-bottom));
  color: var(--muted); font-size: 0.9rem; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
}
footer a, footer button.link { padding: 4px 0; }
footer form { display: inline; }

h1 { font-size: 1.4rem; line-height: 1.25; margin: 4px 0 12px; font-weight: 600; }
h2 { font-size: 1.1rem; margin: 28px 0 10px; font-weight: 600; }
h3 { font-size: 1rem; margin: 16px 0 6px; font-weight: 600; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.grid .card { margin: 0; }
.grid .card a { font-weight: 600; }

.badge { display: inline-block; font-size: 0.74rem; line-height: 1.5; padding: 1px 8px; border-radius: 999px; background: var(--yellow-bg); color: var(--yellow); white-space: nowrap; }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.orange { background: var(--orange-bg); color: var(--orange); white-space: normal; }
.badge.green { background: var(--green-bg); color: var(--green); }

/* Docket entries: whole-card links, big enough to tap. */
.entries { display: flex; flex-direction: column; gap: 8px; }
a.entry {
  display: block; text-decoration: none; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
}
a.entry:active { background: var(--yellow-bg); }
.entry-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 4px; font-size: 0.86rem; }
.entry-meta .ecf { font-weight: 600; }
.entry-meta .date { color: var(--muted); }
.entry-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: 0.95rem; }

/* Tables: real tables on wide screens, labeled stacks on phones. */
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; vertical-align: top; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 719px) {
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr:first-child:has(th) { display: none; }
  table.stack tr { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 8px; }
  table.stack td { border: none; padding: 3px 0; white-space: normal; display: flex; justify-content: space-between; gap: 12px; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: 0.84rem; flex: 0 0 auto; }
  table.stack td[data-label=""]::before { content: none; }
  table.stack td.lead { font-weight: 600; font-size: 1rem; padding-bottom: 4px; }
  table.stack td.lead::before { content: none; }
  table.stack tr.total { background: var(--yellow-bg); }
}

blockquote.verbatim {
  margin: 8px 0; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; line-height: 1.5; white-space: pre-wrap;
}
.machine { border: 1px dashed var(--line); border-radius: var(--radius); padding: 4px 14px 12px; background: var(--panel); }
.machine .label { font-size: 0.8rem; color: var(--muted); margin-top: 10px; }
.correction { background: var(--green-bg); border-radius: var(--radius); padding: 10px 14px; margin: 12px 0; }
.cite { font-size: 0.78rem; text-decoration: none; margin-left: 2px; padding: 2px 3px; }
ul { padding-left: 1.2rem; }
.timeline { padding-left: 1rem; }
.timeline li { margin: 8px 0; }

/* Forms and buttons: 16px text so iOS doesn't zoom, 44px targets. */
.filters { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 14px; }
.filters input, .filters select {
  font: inherit; font-size: 16px; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); width: 100%;
}
button, .button {
  font: inherit; font-size: 1rem; min-height: 44px; padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  width: 100%;
}
button:disabled { opacity: 0.6; }
button.link { background: none; border: none; color: var(--accent); padding: 0; min-height: 0; width: auto; text-decoration: underline; font-size: inherit; }
.status { margin-top: 12px; color: var(--muted); }
.status.error { color: var(--red); }
.ok { color: var(--green); } .bad { color: var(--red); }
details { margin: 8px 0; }
details summary { cursor: pointer; color: var(--muted); padding: 8px 0; }
code { font-size: 0.85em; }

/* Wider screens: more room, side-by-side where it helps. */
@media (min-width: 720px) {
  :root { --gutter: 24px; }
  header.top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding-top: 10px; }
  header.top .brand { padding-bottom: 10px; }
  header.top nav { margin: 0; padding: 0 0 10px; }
  h1 { font-size: 1.6rem; }
  .grid { grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
  .filters { flex-direction: row; }
  .filters input { flex: 1; }
  .filters select, .filters button { width: auto; }
  button, .button { width: auto; }
  footer { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 16px; }
  .entry-text { -webkit-line-clamp: 2; }
}
