:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --border: #dfe2dc;
  --text: #1d2420;
  --muted: #6b756e;
  --accent: #2f6d4f;
  --accent-text: #ffffff;
  --danger: #a6342b;
  --ok: #2f6d4f;
  --radius: 10px;

  /* Header illustration — dusk palette. */
  --hero-sky-top: #cfe3ea;
  --hero-sky-bottom: #f4e3cf;
  --hero-sun: #f0b464;
  --hero-star: #ffffff;
  --hero-hill-far: #9dbfa8;
  --hero-hill-near: #6f9d80;
  --hero-trees: #2f6d4f;
  --hero-tent: #e8eae6;
  --hero-tent-line: #2f6d4f;
  --hero-log: #7a5c3e;
  --hero-fire: #e8873a;
  --hero-ground: #3f6b52;
  --hero-scrim: #ffffff;
  --hero-title: #1d2420;
  --hero-sub: #3c4a42;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --surface: #1c221f;
    --border: #2e3733;
    --text: #e8ece9;
    --muted: #96a19a;
    --accent: #5fb287;
    --accent-text: #0e1412;
    --danger: #e0796e;
    --ok: #5fb287;

    /* Night version of the same scene. */
    --hero-sky-top: #10192a;
    --hero-sky-bottom: #2a3347;
    --hero-sun: #6f86b8;
    --hero-star: #dbe6ff;
    --hero-hill-far: #223047;
    --hero-hill-near: #1b2a3a;
    --hero-trees: #14241d;
    --hero-tent: #c7d2cb;
    --hero-tent-line: #5fb287;
    --hero-log: #4a3828;
    --hero-fire: #f0924a;
    --hero-ground: #101c16;
    --hero-scrim: #141816;
    --hero-title: #eef2ef;
    --hero-sub: #b3bdb6;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; text-decoration: none; color: var(--text); }
.topbar nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); text-decoration: none; }
.topbar nav a:hover { color: var(--text); }

main { max-width: 860px; margin: 0 auto; padding: 24px 16px 48px; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0; }
h2.section { margin: 32px 0 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card.narrow { max-width: 460px; }
.card.empty { text-align: center; }
.card.starter { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.card.starter label { margin-bottom: 8px; }
.card.starter p { margin: 0; font-size: .88rem; }

label { display: block; margin-bottom: 14px; font-weight: 550; }
label .muted { font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=date], input[type=number], select {
  width: 100%; margin-top: 5px; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg); color: var(--text); font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

fieldset {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin: 0 0 16px;
}
legend { padding: 0 6px; font-weight: 550; }

.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
label.check {
  display: flex; align-items: center; gap: 7px;
  font-weight: 400; margin: 0;
}
label.check input { width: auto; margin: 0; }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > label { flex: 1 1 170px; }

button, .button {
  display: inline-block; padding: 9px 15px;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); color: var(--text);
  font: inherit; text-decoration: none; cursor: pointer;
}
button:hover, .button:hover { border-color: var(--accent); }
button.primary, .button.primary {
  background: var(--accent); color: var(--accent-text); border-color: var(--accent);
  font-weight: 550;
}
button.danger { color: var(--danger); border-color: var(--danger); }
button.linkish { border: none; background: none; color: var(--muted); padding: 0; }
button.linkish:hover { color: var(--text); }
form.inline { display: inline; }

.muted { color: var(--muted); }

.alert { padding: 11px 14px; border-radius: 7px; margin-bottom: 16px; }
.alert.error { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.alert.notice { background: color-mix(in srgb, var(--accent) 14%, transparent); }

.watch-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pill {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .05em;
  padding: 3px 9px; border-radius: 99px; border: 1px solid var(--border); color: var(--muted);
}
.pill.active { color: var(--ok); border-color: var(--ok); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px 20px; margin: 14px 0; }
.facts dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.facts dd { margin: 2px 0 0; }

.small { font-size: .85rem; }
.watch-meta { font-size: .85rem; margin-bottom: 12px; line-height: 1.7; }
.watch-meta strong { color: var(--text); }
/* Shown only while the morning release window is open, so it should read as
   "something is happening right now" rather than as a permanent label. */
.burst-pill {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 600; letter-spacing: .02em;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  vertical-align: 1px; cursor: help;
}
.watch-actions { display: flex; gap: 9px; flex-wrap: wrap; }

table.log { width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.log th, table.log td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: .92rem; }
table.log th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
table.log tr:last-child td { border-bottom: none; }

/* --- header illustration -------------------------------------------- */
.hero {
  position: relative;
  height: 150px;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: var(--hero-sky-bottom);   /* shown before the SVG paints */
}
.hero > svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}
.hero-text {
  position: relative;          /* above the SVG */
  max-width: 860px;
  margin: 0 auto;
  height: 100%;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}
.hero-title {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: var(--hero-title);
}
.hero-tagline {
  font-size: .95rem;
  color: var(--hero-sub);
  max-width: 24em;
}

/* The scene crops rather than squashes as the strip shortens, because the
   SVG is sliced from the bottom. Text scales down with it. */
@media (max-width: 720px) {
  .hero { height: 116px; }
  .hero-title { font-size: 1.5rem; }
  .hero-tagline { font-size: .86rem; }
}
@media (max-width: 460px) {
  .hero { height: 96px; }
  .hero-title { font-size: 1.28rem; }
  .hero-tagline {
    font-size: .8rem;
    /* Keep the tagline to one line on a phone so the strip stays shallow. */
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
}
@media (max-width: 360px) {
  .hero-tagline { display: none; }
}

/* --- site type tiles ------------------------------------------------ */
.tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px;
}
.tile { margin: 0; cursor: pointer; }
.tile input { position: absolute; opacity: 0; width: 0; height: 0; }
.tile-body {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 10px; text-align: center;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--surface); transition: border-color .12s, background .12s;
}
.tile-body .icon { width: 2.1em; height: 2.1em; color: var(--muted); stroke-width: 1.4; }
.tile-label { font-size: .88rem; font-weight: 550; color: var(--muted); }
.tile:hover .tile-body { border-color: var(--accent); }
.tile input:checked + .tile-body {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}
.tile input:checked + .tile-body .icon,
.tile input:checked + .tile-body .tile-label { color: var(--accent); }
.tile input:focus-visible + .tile-body { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- matching sites list -------------------------------------------- */
.looplist { display: flex; flex-direction: column; }
label.loop {
  display: flex; align-items: center; gap: 11px; margin: 0;
  padding: 11px 4px; border-bottom: 1px solid var(--border);
  font-weight: 400; cursor: pointer;
}
label.loop:last-child { border-bottom: none; }
label.loop input { width: auto; margin: 0; }
.loop-name { flex: 1; }
.loop-count { font-size: .84rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.loop-count.zero { color: var(--danger); }
.loop-count.unknown { font-style: italic; }
legend .pill { margin-left: 6px; }
.hookup-note { font-size: .84rem; margin: 12px 0 0; }

/* --- legal pages ---------------------------------------------------- */
.card.legal { max-width: 720px; }
.card.legal h2 { margin: 26px 0 8px; font-size: 1.12rem; }
.card.legal h3 { margin: 18px 0 6px; font-size: .98rem; }
.card.legal p, .card.legal li { margin: 0 0 10px; }
.card.legal ul { padding-left: 20px; }
.card.legal a { color: var(--accent); }
.card.legal .callout {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border-left: 3px solid var(--accent);
  border-radius: 6px; padding: 14px 16px; margin: 12px 0 16px;
}
.card.legal .callout p:last-child { margin-bottom: 0; }

/* Public opt-in demonstration page. */
.optin-demo {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); padding: 16px 18px; margin: 14px 0 20px;
}
.optin-demo input[disabled], .optin-demo button[disabled] { opacity: .75; }
.optin-demo .demo-note {
  font-size: .82rem; color: var(--muted); margin: 10px 0 0;
}
.card.legal ol.steps { padding-left: 20px; }
.card.legal ol.steps li { margin-bottom: 8px; }
pre.sample {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 12px 14px; font-size: .84rem; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
}

label.check.consent {
  align-items: flex-start; gap: 10px;
  margin: 4px 0 16px; line-height: 1.45; font-size: .9rem;
}
label.check.consent input { margin-top: 3px; }
label.check.consent a { color: var(--accent); }

footer p.footlinks { margin-bottom: 6px; }
footer p.footlinks a { color: var(--muted); }
footer p.footlinks a:hover { color: var(--text); }

/* --- phone verification -------------------------------------------- */
.codeinput {
  font-size: 1.35rem; letter-spacing: .32em; font-family: ui-monospace, monospace;
  text-align: center; max-width: 200px;
}
p.verified { display: flex; align-items: center; gap: 7px; }
p.verified .icon { color: var(--ok); }
.stacked-actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 12px; }
details.changephone { margin-top: 16px; }
details.changephone summary {
  cursor: pointer; color: var(--muted); font-size: .9rem; margin-bottom: 10px;
}
details.changephone summary:hover { color: var(--text); }

/* --- camping icons ------------------------------------------------- */
.sprite { display: none; }

.icon {
  width: 1.15em; height: 1.15em;
  vertical-align: -0.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.brand { display: inline-flex; align-items: center; gap: 9px; }
.brandmark { width: 1.35em; height: 1.35em; color: var(--accent); }

h2 .watchmark { color: var(--accent); margin-right: 5px; }
label.check .icon { color: var(--muted); }
label.check:hover .icon { color: var(--accent); }

/* A tiny campsite for the empty state. */
.campscene {
  display: flex; align-items: flex-end; justify-content: center;
  gap: 6px; margin-bottom: 14px; color: var(--muted);
}
.campscene .icon { stroke-width: 1.3; }
.campscene .pine { width: 2.4em; height: 2.4em; opacity: .5; }
.campscene .pine.far { width: 1.9em; height: 1.9em; opacity: .35; }
.campscene .tent { width: 3.2em; height: 3.2em; color: var(--accent); }
.campscene .fire { width: 2.3em; height: 2.3em; color: #d98324; }
.campscene .rv   { width: 2.9em; height: 2.9em; opacity: .75; }

@media (prefers-reduced-motion: no-preference) {
  .campscene .fire { animation: flicker 2.6s ease-in-out infinite; transform-origin: 50% 80%; }
}
@keyframes flicker {
  0%, 100% { transform: scale(1);      opacity: 1;   }
  45%      { transform: scale(1.06);   opacity: .85; }
  70%      { transform: scale(.98);    opacity: 1;   }
}

/* Pine treeline above the footer. */
.treeline { line-height: 0; margin-top: 30px; }
.treeline svg { width: 100%; height: 46px; display: block; }
.treeline path { fill: color-mix(in srgb, var(--accent) 22%, transparent); }

.statbar {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 10px;
}
.statbar > div {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.statnum { display: block; font-size: 1.6rem; font-weight: 650; line-height: 1.1; }
.statlbl { display: block; font-size: .8rem; color: var(--muted); margin-top: 3px; }

td.nowrap { white-space: nowrap; }
td.wrap { max-width: 230px; }

/* Donation: a filled button in the header, plus one banner line under it. */
.button.donate {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  font-weight: 600;
  padding: 7px 14px;
}
.button.donate:hover { filter: brightness(1.08); }
.button.donate span { margin-right: 2px; }

.support-banner {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
}
.support-banner p {
  max-width: 860px; margin: 0 auto; padding: 11px 16px;
  font-size: .92rem; line-height: 1.45;
}
.support-banner a {
  color: var(--accent); font-weight: 600; text-underline-offset: 2px;
}

@media (max-width: 560px) {
  .support-banner p { font-size: .87rem; }
  .button.donate { padding: 6px 11px; }
}

.row-actions { white-space: nowrap; text-align: right; }
.row-actions button { padding: 4px 9px; font-size: .85rem; }
tr.inactive td { opacity: .55; }
table.log code, .alert code {
  background: color-mix(in srgb, var(--text) 8%, transparent);
  padding: 1px 5px; border-radius: 4px; font-size: .9em;
}

.ok { color: var(--ok); }
.bad { color: var(--danger); }
.status-list { list-style: none; padding: 0; }
.status-list li { padding: 5px 0; }

footer { max-width: 860px; margin: 0 auto; padding: 0 16px 36px; }
footer p { color: var(--muted); font-size: .84rem; }

/* --- admin tabs ------------------------------------------------------- */
/* Server-rendered links rather than a JS widget, so they survive a POST
   redirect and work with scripting off. */
.tabs {
  display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 20px;
  border-bottom: 1px solid var(--border); padding-bottom: 0;
}
.tabs .tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px; border-radius: var(--radius) var(--radius) 0 0;
  text-decoration: none; color: var(--muted); font-weight: 600;
  font-size: .92rem; border: 1px solid transparent; border-bottom: none;
  margin-bottom: -1px; white-space: nowrap;
}
.tabs .tab:hover { color: var(--text); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.tabs .tab.current {
  color: var(--accent); background: var(--surface);
  border-color: var(--border); border-bottom-color: var(--surface);
}
.tabs .tab .icon { width: 17px; height: 17px; }
.tabs .count {
  font-size: .75rem; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}
@media (max-width: 520px) {
  .tabs .tab { padding: 8px 10px; font-size: .85rem; }
  .tabs .tab span:not(.count) { display: none; }  /* icons only when tight */
  .tabs .tab.current span:not(.count) { display: inline; }
}

/* --- system status ---------------------------------------------------- */
.status-card h2 { display: flex; align-items: center; gap: 10px; margin-top: 0; }
.status-list { margin: 14px 0 0; }
.status-row {
  display: grid; grid-template-columns: minmax(150px, 210px) 1fr;
  gap: 4px 16px; padding: 11px 0; border-top: 1px solid var(--border);
}
.status-row dt {
  display: flex; align-items: baseline; gap: 9px;
  font-weight: 600; color: var(--muted);
}
.status-row dd { margin: 0; line-height: 1.55; }
.status-row dd .muted { font-size: .88rem; }
@media (max-width: 560px) {
  .status-row { grid-template-columns: 1fr; gap: 2px; }
}
/* A dot rather than colour alone: state also reads from the text next to it,
   so this stays legible to anyone who cannot distinguish the hues. */
.dot {
  width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto;
  display: inline-block; background: var(--muted);
}
.dot.ok   { background: #3fa46a; }
.dot.warn { background: #d6912f; }
.dot.bad  { background: #cc4b3c; }
.dot.idle { background: var(--border); border: 1px solid var(--muted); }
.status-card.warn { border-color: color-mix(in srgb, #d6912f 45%, var(--border)); }
.status-card.bad  { border-color: color-mix(in srgb, #cc4b3c 50%, var(--border)); }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
}
.section-head .section { margin-bottom: 8px; }

/* A last resort for tables that genuinely cannot be narrowed. Prefer
   .stacked below, which needs no sideways scrolling at all. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* --- stacked tables --------------------------------------------------- */
/* A real table while there is room, a list of cards once there isn't. No
   min-width and no horizontal scrollbar at any width: reaching the columns
   that actually change should never require dragging a scrollbar. */
table.log.stacked { table-layout: auto; }
table.log.stacked td { vertical-align: top; }
table.log.stacked .muted { font-size: .86rem; }

@media (max-width: 780px) {
  table.log.stacked,
  table.log.stacked tbody,
  table.log.stacked tr,
  table.log.stacked td { display: block; width: auto; }
  table.log.stacked thead { display: none; }
  table.log.stacked tr {
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 4px 2px; margin-bottom: 10px; background: var(--surface);
  }
  table.log.stacked td {
    border: none; padding: 6px 12px;
    display: grid; grid-template-columns: 116px 1fr; gap: 10px;
    align-items: baseline;
  }
  /* The heading each cell lost when the table stopped being a table. */
  table.log.stacked td::before {
    content: attr(data-label);
    font-size: .74rem; font-weight: 700; letter-spacing: .04em;
    text-transform: uppercase; color: var(--muted);
  }
  table.log.stacked td:empty { display: none; }
  /* The actions cell has no heading worth printing; let it use the full
     width rather than leaving an empty label column beside the buttons. */
  table.log.stacked td[data-label=""] {
    grid-template-columns: 1fr; padding-top: 2px; padding-bottom: 10px;
  }
  table.log.stacked td[data-label=""]::before { content: none; }
}

/* --- per-site picker -------------------------------------------------- */
.loopblock { border-bottom: 1px solid var(--border); }
.loopblock:last-child { border-bottom: none; }
.loopblock.off .loop-sites { display: none; }   /* loop off = sites moot */

.loop-sites { padding: 0 0 10px 30px; }
.loop-sites summary {
  cursor: pointer; font-size: .85rem; color: var(--muted);
  padding: 2px 0 6px; list-style: none; display: flex; align-items: center; gap: 8px;
}
.loop-sites summary::-webkit-details-marker { display: none; }
.loop-sites summary::before {
  content: "▸"; display: inline-block; transition: transform .12s ease;
}
.loop-sites[open] summary::before { transform: rotate(90deg); }
.loop-sites summary:hover .sites-toggle { color: var(--accent); }
.sites-picked {
  font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent);
}
.sitebar {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  margin: 0 0 8px; font-size: .82rem;
}
.sitechips { display: flex; flex-wrap: wrap; gap: 6px; }
/* Chips, not a checkbox list: a loop can hold 40+ sites and the point is to
   scan for a number, not to read a column of labels. */
.sitechip input { position: absolute; opacity: 0; pointer-events: none; }
.sitechip span {
  display: inline-block; min-width: 42px; text-align: center;
  padding: 5px 9px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); font-size: .82rem; font-variant-numeric: tabular-nums;
  cursor: pointer; user-select: none;
}
.sitechip span:hover { border-color: var(--accent); }
.sitechip input:checked + span {
  background: var(--accent); color: var(--accent-text); border-color: var(--accent);
  font-weight: 600;
}
.sitechip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 520px) {
  .loop-sites { padding-left: 14px; }
  .sitechip span { min-width: 38px; padding: 5px 7px; }
}

/* Selection feedback on the new-watch form. */
.loop-warning { margin: 12px 0 0; }
.pill.zero { background: color-mix(in srgb, #cc4b3c 15%, transparent); color: #cc4b3c; }
