:root {
  color-scheme: light;
  --ink: #17251f;
  --muted: #69716d;
  --paper: #f6f3ec;
  --panel: #fffdf8;
  --line: #d8d5cc;
  --signal: #e96b38;
  --signal-dark: #bc4720;
  --safe: #2f7357;
  --unknown: #8d928f;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
}

button { font: inherit; }

.shell {
  width: min(100%, 560px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom));
}

.topbar,
.run-status,
.section-heading,
.secondary-actions {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  padding-bottom: 22px;
  border-bottom: 2px solid var(--ink);
}

.app-name,
.clock,
.status-label,
.section-heading h2,
.section-heading p { margin: 0; }

.app-name { font-size: 15px; font-weight: 750; }

.clock {
  margin-top: 3px;
  font: 600 14px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.storage-status {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.status-light {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--safe);
}

.run-status {
  min-height: 142px;
  justify-content: space-between;
  gap: 20px;
}

.status-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

h1 {
  max-width: 350px;
  margin: 0;
  font-size: clamp(28px, 8vw, 42px);
  line-height: .98;
  letter-spacing: -.04em;
}

.station-counter {
  min-width: 78px;
  text-align: right;
}

.station-counter span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.station-counter strong {
  display: block;
  font-size: 42px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.controls { margin-bottom: 30px; }

.primary-action {
  width: 100%;
  min-height: 190px;
  padding: 24px;
  border: 0;
  border-radius: 12px;
  background: var(--signal);
  color: #171b18;
  box-shadow: inset 0 -4px 0 rgba(79, 24, 5, .22);
  cursor: pointer;
  touch-action: manipulation;
}

.primary-action:active {
  background: #dc5e2d;
  box-shadow: inset 0 2px 0 rgba(79, 24, 5, .2);
}

.primary-action:focus-visible,
button:focus-visible {
  outline: 4px solid #176dff;
  outline-offset: 3px;
}

.primary-action span {
  display: block;
  font-size: clamp(38px, 12vw, 60px);
  font-weight: 850;
  line-height: .95;
  letter-spacing: -.045em;
}

.primary-action small {
  display: block;
  margin-top: 15px;
  font-size: 14px;
  font-weight: 650;
}

.secondary-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.secondary-actions button,
.export-action {
  min-height: 49px;
  padding: 10px 14px;
  border: 1px solid var(--ink);
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}

.secondary-actions .end-action {
  grid-column: 1 / -1;
  background: var(--ink);
  color: white;
}

button:disabled {
  cursor: default;
  opacity: .38;
}

.event-log {
  padding-top: 22px;
  border-top: 2px solid var(--ink);
}

.section-heading {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 15px;
}

.section-heading h2 { font-size: 18px; }
.section-heading p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.export-action { min-height: 42px; white-space: nowrap; }

.events {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.event,
.empty-state {
  min-height: 62px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}

.event {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
}

.event-number {
  color: var(--muted);
  font: 650 12px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.event-name { font-size: 15px; font-weight: 750; }
.event-meta { margin-top: 3px; color: var(--muted); font-size: 12px; }
.event-time { font: 700 15px ui-monospace, SFMono-Regular, Menlo, monospace; }
.event.missed .event-name { color: var(--signal-dark); }

.empty-state {
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

.field-note {
  margin-top: 24px;
  padding: 17px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.field-note strong { display: block; color: var(--ink); }

.toast {
  position: fixed;
  z-index: 5;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 18px;
  max-width: 524px;
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: 7px;
  background: var(--ink);
  color: white;
  font-size: 14px;
  font-weight: 650;
  text-align: center;
}

@media (max-width: 380px) {
  .shell { padding-right: 14px; padding-left: 14px; }
  .storage-status { max-width: 120px; text-align: right; }
  .primary-action { min-height: 168px; }
}

@media (prefers-reduced-motion: no-preference) {
  .primary-action,
  .secondary-actions button,
  .export-action { transition: background-color 120ms ease, color 120ms ease; }
}
