/* Next Town — screen styles.
   Palette: warm cream paper, deep forest green ink, gold for over-index badges, coral for the route.
   Fonts: Fredoka (headings), Nunito (body). Light/dark follow prefers-color-scheme.
   Sections: tokens · base · header · buttons/chips · landing · route screen · agent log (trace.js)
             · map · route rail (route.js) · playbook/tour shells · receipts drawer · toast · phone. */

/* ---------- Tokens ---------- */
:root {
  --cream: #fbf6ec;
  --paper: #fffdf8;
  --paper-2: #f3ecdd;
  --line: #e3d9c4;
  --line-strong: #cdbf9f;
  --ink: #1f2a22;
  --ink-2: #4a5a4f;
  --ink-3: #5f6b63;
  --forest: #1f4d3a;
  --forest-deep: #163a2b;
  --forest-tint: #e3efe6;
  --forest-tint-2: #cfe3d5;
  --gold: #c8962e;
  --gold-soft: #f6e7bf;
  --coral: #e8694f;
  --coral-text: #b3432f; /* coral as text on paper: the lighter coral fails contrast */
  --coral-soft: #fbe1da;
  --grey-dot: #9aa09b;
  --ok: #2f7d4f;
  --warn: #b7791f;
  --bad: #b23b2a;
  --focus: #8a6417; /* focus ring: dark gold on cream */
  --shadow: 0 1px 2px rgba(31, 42, 34, 0.06), 0 8px 24px rgba(31, 42, 34, 0.08);
  --shadow-lg: 0 2px 6px rgba(31, 42, 34, 0.08), 0 24px 48px rgba(31, 42, 34, 0.14);
  --radius: 18px;
  --radius-sm: 10px;
  --font-head: "Fredoka", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --gutter: 24px;
  --topbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --cream: #141d18;
    --paper: #1b2620;
    --paper-2: #22302a;
    --line: #2d3d34;
    --line-strong: #3f5347;
    --ink: #f1ebdf;
    --ink-2: #c1c9c2;
    --ink-3: #8a968d;
    --forest: #7fc39b;
    --forest-deep: #9ad4b1;
    --forest-tint: #1f3329;
    --forest-tint-2: #27412f;
    --gold: #e4b860;
    --gold-soft: #3c3220;
    --coral: #f08066;
    --coral-text: #f08066;
    --coral-soft: #3d241f;
    --grey-dot: #6f7a72;
    --ok: #7fc39b;
    --warn: #e4b860;
    --bad: #f08066;
    --focus: #e4b860;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.4), 0 24px 48px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --cream: #141d18;
  --paper: #1b2620;
  --paper-2: #22302a;
  --line: #2d3d34;
  --line-strong: #3f5347;
  --ink: #f1ebdf;
  --ink-2: #c1c9c2;
  --ink-3: #8a968d;
  --forest: #7fc39b;
  --forest-deep: #9ad4b1;
  --forest-tint: #1f3329;
  --forest-tint-2: #27412f;
  --gold: #e4b860;
  --gold-soft: #3c3220;
  --coral: #f08066;
  --coral-text: #f08066;
  --coral-soft: #3d241f;
  --grey-dot: #6f7a72;
  --ok: #7fc39b;
  --warn: #e4b860;
  --bad: #f08066;
  --focus: #e4b860;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--cream);
  background-image: radial-gradient(1200px 500px at 10% -10%, var(--forest-tint) 0%, transparent 60%);
  background-repeat: no-repeat;
  min-height: 100vh;
}
h1, h2, h3, h4 {
  font-family: var(--font-head);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 0.4em;
  letter-spacing: -0.01em;
}
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: var(--forest); }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
pre { margin: 0; font-family: var(--font-mono); font-size: 0.78rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.muted { color: var(--ink-3); }
.hidden, [hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.skip-link { position: absolute; left: -9999px; top: 8px; background: var(--forest); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }
/* Visually hidden but read by screen readers (the playbook and tour screens keep their <h1> this way). */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

main { max-width: 1440px; margin: 0 auto; padding: 0 var(--gutter) 48px; }
.screen { display: none; }
.screen.active { display: block; animation: rise 0.35s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen.active { animation: none; } }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap;
  min-height: var(--topbar-h); padding: 6px var(--gutter);
  background: color-mix(in srgb, var(--cream) 86%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; background: none; border: 0; padding: 4px 6px; cursor: pointer; border-radius: 10px; }
.brand-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--forest); box-shadow: inset 0 0 0 5px var(--forest), inset 0 0 0 9px var(--coral); }
.brand-name { font-family: var(--font-head); font-weight: 600; font-size: 1.35rem; color: var(--forest); white-space: nowrap; }
.crumbs { display: flex; gap: 4px; }
.crumb { background: none; border: 0; padding: 6px 12px; border-radius: 999px; color: var(--ink-2); cursor: pointer; font-weight: 700; }
.crumb[aria-current="page"] { background: var(--forest-tint); color: var(--forest); }
.crumb:disabled { opacity: 0.45; cursor: default; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.mode-pill {
  font-size: 0.78rem; font-weight: 800; letter-spacing: 0.02em; text-transform: uppercase;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--ink-2); background: var(--paper);
  white-space: nowrap;
}
.mode-pill.is-live { background: var(--forest); border-color: var(--forest); color: #fff; }
.mode-pill.is-recorded { background: var(--gold-soft); border-color: var(--gold); color: var(--ink); }
.count { display: inline-block; min-width: 22px; padding: 1px 7px; margin-left: 4px; border-radius: 999px; background: var(--forest); color: #fff; font-size: 0.75rem; font-weight: 800; text-align: center; }

/* ---------- Buttons, chips, tags ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; border: 1.5px solid transparent;
  font-weight: 800; cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--forest); color: #fff; box-shadow: 0 6px 18px rgba(31, 77, 58, 0.28); }
.btn-primary:hover:not(:disabled) { background: var(--forest-deep); }
.btn-secondary { background: var(--paper); color: var(--forest); border-color: var(--forest); }
.btn-secondary:hover:not(:disabled) { background: var(--forest-tint); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--paper-2); }
.btn-sm { padding: 6px 12px; font-size: 0.88rem; }
.btn-lg { padding: 14px 26px; font-size: 1.1rem; }
.btn-coral { background: var(--coral); color: #fff; }
.btn-icon { padding: 6px 10px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--forest); font-weight: 700; text-decoration: underline; cursor: pointer; }
/* Dark mode: anything sitting on a bright forest/coral/gold fill takes dark ink. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary { color: #0f1a14; }
  :root:not([data-theme="light"]) .count { color: #0f1a14; }
  :root:not([data-theme="light"]) .mode-pill.is-live { color: #0f1a14; }
  :root:not([data-theme="light"]) .how-n,
  :root:not([data-theme="light"]) .skip-link,
  :root:not([data-theme="light"]) .stop-day,
  :root:not([data-theme="light"]) .marker-day,
  :root:not([data-theme="light"]) .toast.is-error,
  :root:not([data-theme="light"]) .pill-live { color: #0f1a14; }
}
:root[data-theme="dark"] .btn-primary, :root[data-theme="dark"] .count, :root[data-theme="dark"] .mode-pill.is-live,
:root[data-theme="dark"] .how-n, :root[data-theme="dark"] .skip-link, :root[data-theme="dark"] .stop-day,
:root[data-theme="dark"] .marker-day, :root[data-theme="dark"] .toast.is-error, :root[data-theme="dark"] .pill-live { color: #0f1a14; }

.tag, .chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 800;
  background: var(--paper-2); color: var(--ink-2); border: 1px solid var(--line);
}
.tag-fictional { background: var(--coral-soft); color: var(--coral-text); border-color: transparent; text-transform: lowercase; }
.tag-gold { background: var(--gold-soft); color: var(--ink); border-color: var(--gold); }
/* The over-index pill in the rail: same gold badge as the playbook header (cards.css .pb-badge-gold). */
.badge-overindex {
  display: inline-flex; align-items: center; padding: 0.25em 0.7em; border-radius: 999px;
  background: var(--gold); color: #1d1604; font-family: var(--font-head); font-weight: 600; font-size: 0.75rem; letter-spacing: 0.02em; line-height: 1.3;
}
.tag-green { background: var(--forest-tint); color: var(--forest); border-color: transparent; }
.chip-why { background: var(--forest-tint); color: var(--forest); border-color: transparent; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* Generic card used by the rail, playbooks and the tour */
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
.card h3 { margin-bottom: 6px; }

/* ---------- Landing ---------- */
.screen-landing { padding-top: 48px; }
.hero { max-width: 760px; margin: 0 auto; text-align: center; }
.eyebrow { font-weight: 800; text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.78rem; color: var(--forest); margin-bottom: 14px; }
.headline { font-size: clamp(2.4rem, 6vw, 4.2rem); font-weight: 600; color: var(--forest); margin-bottom: 18px; }
.subhead { font-size: 1.15rem; color: var(--ink-2); max-width: 620px; margin: 0 auto 28px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.resume-row { margin-top: 14px; }
/* Honesty banner under the sample card: the fixtures are placeholders until the Qloo key arrives. */
.honesty-banner {
  max-width: 560px; margin: 14px auto 0; text-align: left; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--gold-soft); border-left: 4px solid var(--gold); color: var(--ink); font-size: 0.88rem; line-height: 1.45;
}

.sample-card {
  margin: 36px auto 0; max-width: 560px; text-align: left;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; box-shadow: var(--shadow);
}
.sample-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.sample-name { font-family: var(--font-head); font-size: 1.3rem; font-weight: 600; color: var(--forest); }
.sample-blurb { color: var(--ink-2); margin-bottom: 10px; }
.sample-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px 16px; margin: 0; }
.sample-facts div { display: flex; flex-direction: column; }
.sample-facts dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 800; }
.sample-facts dd { margin: 0; font-weight: 700; }

.how { list-style: none; padding: 0; margin: 56px auto 0; max-width: 980px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.how li { display: flex; gap: 14px; align-items: flex-start; padding: 18px; border-radius: var(--radius); background: var(--paper); border: 1px solid var(--line); }
.how li div { display: flex; flex-direction: column; gap: 4px; }
.how li span:not(.how-n) { color: var(--ink-2); font-size: 0.95rem; }
.how-n { flex: 0 0 34px; height: 34px; border-radius: 50%; background: var(--forest); color: #fff; display: grid; place-items: center; font-family: var(--font-head); font-weight: 600; }

.act-form { max-width: 820px; margin: 56px auto 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.form-head h2 { margin-bottom: 4px; }
.act-form fieldset { border: 0; padding: 0; margin: 18px 0 0; }
.act-form legend { font-weight: 800; padding: 0; margin-bottom: 8px; }
.comps-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.form-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 10px; margin-top: 16px; }
.act-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 800; font-size: 0.9rem; }
.act-form input, .act-form select {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm); border: 1.5px solid var(--line-strong); background: var(--cream); font-weight: 600;
}
.act-form input:focus, .act-form select:focus { outline: none; border-color: var(--forest); box-shadow: 0 0 0 3px var(--forest-tint-2); }
.act-form input[aria-invalid="true"] { border-color: var(--bad); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.form-error { margin: 12px 0 0; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--coral-soft); color: var(--bad); font-weight: 700; }
.fineprint { max-width: 760px; margin: 28px auto 0; text-align: center; font-size: 0.85rem; color: var(--ink-3); }

/* ---------- Route screen ---------- */
.screen-route { padding-top: 20px; }
.route-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.screen-title { font-size: clamp(1.6rem, 3vw, 2.2rem); color: var(--forest); margin-bottom: 2px; }
.screen-sub { color: var(--ink-2); margin: 0; }
.route-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.run-status { font-size: 0.85rem; color: var(--ink-3); font-weight: 700; }
.run-status.is-running::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--coral); margin-right: 7px; animation: pulse 1.2s ease-in-out infinite; vertical-align: 1px; }
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

.build-progress { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.progress-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 800; background: var(--paper-2); color: var(--ink-3); border: 1px solid var(--line); }
.progress-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.progress-chip.running { color: var(--ink); border-color: var(--coral); }
.progress-chip.running::before { background: var(--coral); animation: pulse 1s ease-in-out infinite; }
.progress-chip.done { color: var(--forest); background: var(--forest-tint); border-color: transparent; }
.progress-chip.done::before { background: var(--forest); }
.progress-chip.failed { color: var(--bad); background: var(--coral-soft); border-color: transparent; }
.progress-chip.failed::before { background: var(--bad); }

.route-grid {
  display: grid; grid-template-columns: minmax(280px, 340px) minmax(0, 1fr) minmax(300px, 380px);
  gap: 18px; align-items: start;
}
/* Grid items default to min-width:auto, so one long nowrap line in the log would widen the page. */
.route-grid > * { min-width: 0; }
.col-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.col-head h2 { font-size: 1.1rem; margin: 0; }
.agent-col, .rail-col { position: sticky; top: calc(var(--topbar-h) + 12px); }
.agent-log {
  height: calc(100vh - var(--topbar-h) - 140px); min-height: 360px; overflow: auto;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow);
  scroll-behavior: smooth;
}
.map-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
/* isolation keeps Leaflet's z-index:1000 controls inside the map instead of above the sticky header. */
.map-wrap { position: relative; isolation: isolate; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); background: var(--paper-2); }
.map { height: calc(100vh - var(--topbar-h) - 190px); min-height: 420px; width: 100%; }
.map-legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 500;
  display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--paper) 90%, transparent); border: 1px solid var(--line); font-size: 0.78rem; font-weight: 700; color: var(--ink-2);
}
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--forest); display: inline-block; }
.lg-gold { box-shadow: 0 0 0 2.5px var(--gold); }
.lg-grey { background: var(--grey-dot); }
.lg-line { width: 18px; height: 3px; background: var(--coral); border-radius: 2px; display: inline-block; }
.agent-closing {
  background: var(--forest-tint); border-left: 4px solid var(--forest); border-radius: 12px; padding: 14px 18px; color: var(--ink);
  font-size: 1rem; white-space: pre-line;
}
.agent-closing .label { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 800; color: var(--forest); margin-bottom: 4px; }

/* ---------- Agent log (classes emitted by js/trace.js) ---------- */
.trace-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 800; background: var(--paper-2); border: 1px solid var(--line); color: var(--ink-2); font-family: var(--font-mono); }
.pill-live { background: var(--forest); color: #fff; border-color: var(--forest); }
.pill-demo { background: var(--gold-soft); color: var(--ink); border-color: var(--gold); }
.trace-turn { font-family: var(--font-head); font-weight: 600; color: var(--forest); margin: 14px 0 6px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 0.95rem; }
.trace-turn:first-of-type { border-top: 0; margin-top: 4px; padding-top: 0; }
.trace-status { font-size: 0.85rem; color: var(--ink-2); padding: 4px 0 4px 10px; border-left: 2px solid var(--line-strong); margin: 6px 0; font-style: italic; }
.trace-thinking { font-size: 0.82rem; color: var(--ink-3); margin: 6px 0; display: flex; gap: 8px; }
.trace-thinking .label { flex: 0 0 auto; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 800; padding-top: 2px; }
.trace-thinking .body { white-space: pre-wrap; }
.trace-text { font-size: 0.95rem; color: var(--ink); margin: 8px 0; white-space: pre-wrap; line-height: 1.5; }
.trace-call { border: 1px solid var(--line); border-radius: 12px; margin: 8px 0; background: var(--cream); }
.trace-call summary { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; font-size: 0.85rem; list-style: none; }
.trace-call summary::-webkit-details-marker { display: none; }
.trace-call .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); flex: 0 0 auto; }
.trace-call.pending .dot { background: var(--coral); animation: pulse 1s ease-in-out infinite; }
.trace-call.ok .dot { background: var(--ok); }
.trace-call.fail .dot { background: var(--bad); }
.trace-call .name { font-family: var(--font-mono); font-weight: 700; color: var(--forest); }
.trace-call .summary-text { color: var(--ink-2); flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.trace-call .ms { color: var(--ink-3); font-size: 0.72rem; font-family: var(--font-mono); white-space: nowrap; flex: 0 0 auto; }
.call-body { border-top: 1px solid var(--line); padding: 8px 10px 10px; }
.call-section { margin-top: 8px; }
.call-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 800; color: var(--ink-3); margin-bottom: 4px; }
.call-body pre { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 8px; max-height: 260px; overflow: auto; }
.call-body .method { font-weight: 800; color: var(--forest); }
.call-body a, .call-body code { word-break: break-all; }
.call-body .copy-curl { font: inherit; font-size: 0.72rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink-2); cursor: pointer; margin-top: 4px; }
.call-body .copy-curl:hover:not(:disabled) { background: var(--paper-2); }
.trace-error { background: var(--coral-soft); color: var(--bad); border-radius: 10px; padding: 8px 12px; margin: 8px 0; font-weight: 700; font-size: 0.9rem; }
.trace-note { font-size: 0.85rem; color: var(--ink-3); padding: 8px; }

/* ---------- Map markers (Leaflet divIcons built in js/map.js) ---------- */
.leaflet-container { font-family: var(--font-body); background: var(--paper-2); }
.leaflet-container a { color: var(--forest); }
.marker-home { width: 28px; height: 28px; display: grid; place-items: center; color: var(--forest); filter: drop-shadow(0 1px 2px rgba(0,0,0,0.35)); }
.marker-home svg { width: 28px; height: 28px; }
.marker-day {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--coral); color: #fff; font-family: var(--font-head); font-weight: 600; font-size: 0.78rem;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
.marker-day.is-focus { transform: scale(1.3); }
.leaflet-tooltip.nt-tip { border-radius: 10px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); box-shadow: var(--shadow); padding: 8px 10px; font-size: 0.82rem; line-height: 1.4; }
.leaflet-tooltip.nt-tip .tip-title { font-family: var(--font-head); font-weight: 600; font-size: 0.95rem; color: var(--forest); display: block; }
.leaflet-tooltip.nt-tip .tip-why { color: var(--ink-3); font-size: 0.75rem; }
.leaflet-tooltip.nt-tip .tip-gold { color: var(--gold); font-weight: 800; }
.leaflet-tooltip.nt-tip.leaflet-tooltip-top::before { border-top-color: var(--line); }
.leaflet-bar a { background: var(--paper); color: var(--ink); border-bottom-color: var(--line); }
.leaflet-bar a:hover { background: var(--paper-2); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--paper) 80%, transparent) !important; color: var(--ink-3) !important; font-size: 0.65rem; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .leaflet-tile-pane { filter: brightness(0.6) contrast(1.05) saturate(0.6) sepia(0.15) hue-rotate(80deg); }
  :root:not([data-theme="light"]) .marker-day { border-color: var(--paper); }
}
:root[data-theme="dark"] .leaflet-tile-pane { filter: brightness(0.6) contrast(1.05) saturate(0.6) sepia(0.15) hue-rotate(80deg); }

/* ---------- Route rail (js/route.js) ---------- */
.rail-col { display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - var(--topbar-h) - 100px); overflow: auto; padding-right: 2px; }
.rail-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.rail-stat { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; text-align: center; }
.rail-stat b { display: block; font-family: var(--font-head); font-size: 1.25rem; color: var(--forest); font-weight: 600; line-height: 1.1; }
.rail-stat span { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 800; }
.rail-fine { margin: 0; font-size: 0.78rem; color: var(--ink-3); }

.obvious-toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.switch { display: inline-flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; cursor: pointer; font-weight: 800; color: var(--ink); text-align: left; }
.switch-track { width: 42px; height: 24px; border-radius: 999px; background: var(--line-strong); position: relative; flex: 0 0 auto; transition: background 0.15s; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.switch[aria-checked="true"] .switch-track { background: var(--forest); }
.switch[aria-checked="true"] .switch-track::after { transform: translateX(18px); }
.obvious-panel { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.obvious-summary { font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.obvious-framing { font-size: 0.92rem; color: var(--ink-2); background: var(--gold-soft); border-left: 3px solid var(--gold); border-radius: 8px; padding: 8px 12px; margin: 0 0 10px; }
.obvious-cities { display: flex; flex-wrap: wrap; gap: 5px; }
.obvious-cities .chip { background: var(--paper-2); color: var(--ink-3); }
.obvious-cities .chip.is-overlap { background: var(--coral-soft); color: var(--coral-text); border-color: transparent; }

.stop-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.stop { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px 10px 12px; display: grid; grid-template-columns: 34px 1fr; gap: 4px 10px; box-shadow: var(--shadow); transition: box-shadow 0.15s, border-color 0.15s; }
.stop:hover { border-color: var(--line-strong); }
.stop.is-pinned { border-color: var(--forest); }
.stop.is-drive-day { border-style: dashed; }
.stop-day { grid-row: 1 / span 2; width: 34px; height: 34px; border-radius: 50%; background: var(--coral); color: #fff; display: grid; place-items: center; font-family: var(--font-head); font-weight: 600; font-size: 0.95rem; align-self: start; }
.stop-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.stop-name { font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.stop-name:hover { color: var(--forest); text-decoration: underline; }
.stop-meta { font-size: 0.8rem; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.stop-meta .leg { color: var(--ink-2); font-weight: 700; }
.stop-meta .drive-day { color: var(--warn); font-weight: 800; }
.stop-meta .top-room { color: var(--ink-2); flex-basis: 100%; }
.stop-actions { grid-column: 2; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.stop-actions .btn { padding: 4px 10px; font-size: 0.78rem; }
.stop-actions .btn.is-on { background: var(--forest-tint); color: var(--forest); border-color: var(--forest); }
.stop-pin-mark { font-size: 0.72rem; color: var(--forest); font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; }

.rail-section-title { display: flex; align-items: center; justify-content: space-between; font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; color: var(--forest); margin: 4px 0 2px; }
.dropped-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dropped-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: 10px; background: var(--paper-2); color: var(--ink-3); font-size: 0.9rem; text-decoration: line-through; }
.dropped-item .btn { text-decoration: none; }
.add-row { display: flex; gap: 6px; }
.add-row select { flex: 1 1 auto; min-width: 0; padding: 8px 10px; border-radius: 10px; border: 1.5px solid var(--line-strong); background: var(--cream); font-weight: 600; }
.notes { margin: 0; }
.notes summary { cursor: pointer; font-weight: 800; color: var(--ink-2); font-size: 0.9rem; }
.notes ul { margin: 8px 0 0; padding-left: 18px; font-size: 0.88rem; color: var(--ink-2); }
.notes li + li { margin-top: 4px; }
.rail-empty { color: var(--ink-3); font-style: italic; }

/* ---------- Playbook & tour shells (content rendered by js/playbook.js and js/tour.js) ---------- */
.screen-playbook, .screen-tour { padding-top: 20px; max-width: 1132px; margin-inline: auto; }
.screen-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.screen-head .screen-title { margin: 0; }
.status-lines { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.status-line { font-size: 0.9rem; color: var(--ink-2); padding-left: 12px; border-left: 2px solid var(--coral); }
.status-line.done { border-left-color: var(--forest); color: var(--ink-3); }
.playbook-view, .tour-view { max-width: 1100px; }
.playbook-view .card, .tour-view .card { margin-bottom: 14px; }
.playbook-view img, .tour-view img { max-width: 100%; border-radius: 10px; }
/* Card and sheet titles (h3 now that the screen's h1 is hidden and the page title is an h2). */
.playbook-view h3, .tour-view h3 { color: var(--forest); }
.playbook-view table, .tour-view table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.playbook-view th, .tour-view th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.playbook-view td, .tour-view td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.placeholder-card { text-align: center; padding: 48px 20px; color: var(--ink-3); }

/* ---------- Receipts drawer ----------
   The drawer itself (position, slide-in, contents) is owned by js/receipts.js + cards.css (.receipts).
   styles.css only adds the page scrim behind it, kept just under the drawer's z-index. */
.drawer-scrim { position: fixed; inset: 0; z-index: 990; background: rgba(20, 29, 24, 0.35); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70;
  background: var(--ink); color: var(--cream); padding: 12px 18px; border-radius: 14px; box-shadow: var(--shadow-lg);
  font-weight: 700; max-width: min(560px, calc(100vw - 32px)); display: flex; gap: 12px; align-items: center;
}
.toast.is-error { background: var(--bad); color: #fff; }
.toast .link-btn { color: inherit; }

.foot { max-width: 1440px; margin: 0 auto; padding: 18px var(--gutter) 28px; color: var(--ink-3); font-size: 0.82rem; text-align: center; }

/* ---------- Tablet & phone: single column, log above the map ---------- */
@media (max-width: 1100px) {
  .route-grid { grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); }
  .rail-col { grid-column: 1 / -1; position: static; max-height: none; }
  .comps-row, .form-grid { grid-template-columns: 1fr 1fr; }
  .how { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  :root { --gutter: 16px; --topbar-h: 56px; }
  /* Not sticky on phones: a wrapped, tall bar would eat the screen, so it scrolls away instead. */
  .topbar { position: relative; gap: 8px; padding: 8px var(--gutter); }
  /* Touch targets: at least 40px tall for anything tappable. */
  .btn, .btn-sm, .stop-actions .btn, .switch, .stop-name, .link-btn, .crumb { min-height: 40px; }
  .stop-name, .link-btn { display: inline-flex; align-items: center; }
  .brand-name { font-size: 1.15rem; }
  .crumbs { display: none; }
  .topbar-right { flex-wrap: nowrap; margin-left: auto; }
  .mode-pill { font-size: 0.62rem; padding: 4px 8px; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
  .route-grid { grid-template-columns: 1fr; }
  .agent-col, .rail-col { position: static; }
  .agent-log { height: 260px; min-height: 0; }
  .map { height: 60vh; min-height: 320px; }
  .map-legend { font-size: 0.7rem; gap: 4px 10px; }
  .comps-row, .form-grid { grid-template-columns: 1fr; }
  .act-form { padding: 20px 16px; }
  .rail-summary { grid-template-columns: repeat(2, 1fr); }
  .screen-landing { padding-top: 28px; }
  .hero-actions .btn { width: 100%; }
  .receipts-drawer { width: 100vw; }
}
@media (max-width: 480px) {
  .topbar-right { flex-wrap: wrap; justify-content: flex-end; width: 100%; margin-left: 0; }
  .mode-pill { max-width: 100%; }
}
