:root {
  color-scheme: light dark;
  --bg: #f7f5f0;
  --ink: #1d2420;
  --muted: #5b6560;
  --card: #ffffff;
  --line: #d5d8cf;
  --accent: #17604a;
  --accent-ink: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181a;
    --ink: #eef2ee;
    --muted: #a8b3ad;
    --card: #1d2326;
    --line: #333c3f;
    --accent: #6fd0a8;
    --accent-ink: #10221b;
  }
}

* { box-sizing: border-box; }

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

main {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

.head { padding: 0.5rem 0 0.25rem; }

h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  letter-spacing: -0.01em;
}

h2 { margin: 0 0 0.6rem; font-size: 1.15rem; }
h3 { margin: 1.4rem 0 0.35rem; font-size: 1rem; }

.lead { margin: 0 0 1rem; color: var(--muted); }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  margin: 0 0 1rem;
}

.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.8rem; }
.field-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; margin-bottom: 0.6rem; }
.field-row > .field { flex: 1 1 9rem; margin-bottom: 0; }

label, legend { font-weight: 600; font-size: 0.92rem; }

input[type="text"], input[type="number"], input[type="time"] {
  font: inherit;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  max-width: 100%;
}

input[type="number"] { max-width: 8rem; }

button {
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}

button.ghost { background: transparent; color: var(--accent); }

button:hover { filter: brightness(1.06); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.presets-field { margin-bottom: 1rem; }

.preset-label { font-weight: 600; font-size: 0.92rem; }

.presets { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.preset {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.88rem;
  background: transparent;
  color: var(--accent);
}

.preset.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.talk-row { margin-bottom: 0.2rem; }

.zones-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  margin: 0 0 1rem;
}

.zones {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  align-items: start;
}

.zone-block {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.5rem 0.6rem;
  background: var(--bg);
}

.zone-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.zone-head .zone-check { flex: 1 1 auto; }

.zone-actions { display: flex; gap: 0.3rem; flex-wrap: wrap; }

button.mini {
  padding: 0.15rem 0.55rem;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: 999px;
  background: transparent;
  border-color: var(--line);
  color: var(--accent);
}

button.mini:hover { border-color: var(--accent); }

/* Walking-order arrows: quiet by default, greyed out at the ends of the order. */
button.mini.move {
  padding: 0.15rem 0.4rem;
  border-color: transparent;
  line-height: 1.25;
}

button.mini.move:hover:not(:disabled) { border-color: var(--accent); }

button.mini.move:disabled {
  opacity: 0.3;
  cursor: default;
  color: var(--muted);
}

.zone-check { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.zone-check input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }

.animal-list {
  list-style: none;
  margin: 0.45rem 0 0;
  padding: 0 0 0 0.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.animal-list.off { display: none; }

/* One row per enclosure: the tick and the name on the left, that animal's viewing minutes on the
   right, so the number the route will use is visible before you build. */
.animal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.animal-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1 1 auto;
  font-weight: 400;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
}

.animal-check input { width: 1rem; height: 1rem; accent-color: var(--accent); }

.view-field { display: flex; align-items: center; gap: 0.2rem; flex: 0 0 auto; }

.view-min {
  width: 3.1rem;
  max-width: 3.1rem;
  padding: 0.15rem 0.3rem;
  font-size: 0.82rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.view-min:disabled { opacity: 0.45; }

.view-unit { color: var(--muted); font-size: 0.72rem; }

label input:disabled + span { opacity: 0.5; }

.hint { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.86rem; }

.status { margin: 0.5rem 0 0; color: var(--accent); font-weight: 600; }
.status.error { color: #b3261e; }

@media (prefers-color-scheme: dark) {
  .status.error { color: #ff8f85; }
}

.finish-line {
  margin: 0 0 0.85rem;
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--accent);
}

.summary { margin: 0 0 0.75rem; color: var(--muted); }

.route { list-style: none; margin: 0; padding: 0; }

.route li { padding: 0.45rem 0; border-top: 1px solid var(--line); display: flex; gap: 0.7rem; align-items: baseline; }
.route li:first-child { border-top: 0; }

.time { flex: 0 0 6.6rem; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); }

.stop-name { flex: 1 1 auto; }

.stop-meta { color: var(--muted); font-size: 0.86rem; }

.route li.zone-stop { border-top: 0; padding-bottom: 0.1rem; }
.route li.zone-stop .stop-name { font-weight: 700; letter-spacing: 0.01em; }
.route li.walk-stop { color: var(--muted); font-size: 0.9rem; padding: 0.3rem 0; }
.route li.walk-stop .time { color: var(--muted); font-weight: 500; }

.route li.talk-stop {
  border-top: 2px solid var(--accent);
  border-left: 3px solid var(--accent);
  background: var(--bg);
  padding-left: 0.5rem;
  border-radius: 4px;
}

.route li.talk-stop .stop-name { font-weight: 700; }

.checklist { list-style: none; margin: 0; padding: 0; }

.checklist li { padding: 0.4rem 0; border-top: 1px dashed var(--line); display: flex; gap: 0.6rem; }
.checklist li:first-child { border-top: 0; }

.box { flex: 0 0 auto; font-size: 1.05rem; line-height: 1.4; }

.export-field { margin-top: 0.9rem; }

.plan-text {
  width: 100%;
  min-height: 11rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre;
  overflow: auto;
  resize: vertical;
}

footer { text-align: center; color: var(--muted); font-size: 0.88rem; padding: 0 1rem 2rem; }
footer a { color: inherit; }

.hidden { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media (max-width: 30rem) {
  .time { flex-basis: 5.4rem; font-size: 0.95rem; }
}

@media print {
  :root { color-scheme: light; }
  body { background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  .panel { border: 0; padding: 0; margin: 0 0 0.6rem; }
  #setup, #status, #print, #copyPlan, .export-field, .presets-field, .zone-actions { display: none; }
  .lead, .hint, #about-h, .about-text, .walk-stop { display: none; }
  /* The setup instructions are hints and belong off the paper. The two notes under "Your route" are
     hints as well, but they warn a helper that a keeper talk was reached late or that a big group
     added minutes to every stop, so keep them on the sheet whenever the page is showing them. */
  #talkNote:not(.hidden), #groupNote:not(.hidden) { display: block; margin: 0.15rem 0 0.5rem; }
  /* Keep one route row or one checklist line in one piece instead of splitting it over two pages. */
  .route li, .checklist li { break-inside: avoid; }
  .time, .summary, .finish-line { color: #000; }
  .finish-line { font-size: 1.05rem; }
  .route li { border-top: 1px solid #999; }
  .route li.talk-stop { background: #fff; border-left: 3px solid #333; }
  footer { padding: 0.5rem 0 0; }
  a { text-decoration: none; color: #000; }
}
