:root {
  --bg: #0b0c0e;
  --surface: #141619;
  --surface-2: #1b1e22;
  --line: #24272c;
  --text: #ecebe7;
  --muted: #8b9099;
  --faint: #5d626b;
  --accent: #ffd23f; /* the one accent: departure-board yellow */

  --ok: #3ccf7a;
  --ok-bg: rgba(60, 207, 122, 0.12);
  --warn: #ff9f1c;
  --warn-bg: rgba(255, 159, 28, 0.14);
  --done: #9aa0a8;
  --done-bg: rgba(154, 160, 168, 0.12);
  --bad: #ff5a5f;
  --bad-bg: rgba(255, 90, 95, 0.14);

  /* Ship categories: distinct hues kept clear of the status colours and the accent. */
  --ferry: #4fd8c8;  /* teal */
  --cruise: #c4a2ff; /* violet */
  --cargo: #6cb6ff;  /* blue */

  --radius: 10px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--muted); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------ header */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(11, 12, 14, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-weight: 650; letter-spacing: 0.01em; }
.brand-sub { color: var(--muted); font-size: 12px; letter-spacing: 0.06em; white-space: nowrap; }

.tabs { display: flex; gap: 2px; background: var(--surface); border-radius: 999px; padding: 3px; }
.tab {
  border: 0; background: transparent; padding: 6px 13px; border-radius: 999px;
  color: var(--muted); font-size: 14px; font-weight: 550;
}
.tab[aria-selected="true"] { background: var(--text); color: var(--bg); }

main { flex: 1; display: flex; flex-direction: column; width: 100%; max-width: 760px; margin: 0 auto; }

/* ------------------------------------------------------------ controls */
.intro { margin: 0; padding: 14px 16px 0; color: var(--muted); font-size: 14px; line-height: 1.45; text-wrap: balance; }
.controls { padding: 14px 16px 8px; display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.search {
  width: 100%; padding: 11px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  outline: none; font-size: 16px; /* 16px stops iOS zoom */
}
.search::placeholder { color: var(--faint); }
.search:focus { border-color: var(--faint); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  border: 1px solid var(--line); background: transparent; border-radius: 999px;
  padding: 4px 12px; font-size: 13px; color: var(--muted);
}
.chips button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.chips button[data-cat="ferry"] { --tc: var(--ferry); }
.chips button[data-cat="cruise"] { --tc: var(--cruise); }
.chips button[data-cat="cargo"] { --tc: var(--cargo); }
.chips button[data-cat]:not([data-cat="all"]) { color: var(--tc); }
.chips button[data-cat]:not([data-cat="all"])[aria-pressed="true"] {
  border-color: var(--tc); color: var(--bg); background: var(--tc); font-weight: 600;
}
.chip-count { font-variant-numeric: tabular-nums; opacity: 0.75; margin-left: 3px; }

.refresh-group { display: flex; align-items: center; gap: 2px; margin-left: auto; min-width: 0; }
.updated { margin: 0; color: var(--faint); font-size: 12px; text-align: right; }
.updated .stale { color: var(--warn); }

.note { margin: 0; color: var(--warn); font-size: 12px; line-height: 1.4; }

.refresh-btn {
  flex: none; display: grid; place-items: center;
  width: 44px; height: 44px; margin: -8px -10px -8px 0; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted);
}
.refresh-btn svg { width: 18px; height: 18px; }
.refresh-btn:hover { color: var(--text); background: var(--surface); }
.refresh-btn:disabled { cursor: progress; }
.refresh-btn.spinning { color: var(--accent); }
.refresh-btn.spinning svg { animation: spin 0.8s linear infinite; }
.refresh-btn.pulse { animation: refresh-pulse 1.2s ease-out 1; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes refresh-pulse {
  0% { color: var(--accent); box-shadow: 0 0 0 0 rgba(255, 210, 63, 0.35); }
  60% { color: var(--accent); box-shadow: 0 0 0 8px rgba(255, 210, 63, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 210, 63, 0); }
}

/* ------------------------------------------------------------ board */
.board { padding: 4px 0 8px; }
.empty { color: var(--muted); text-align: center; padding: 48px 16px; margin: 0; }
.empty.error { color: var(--bad); }

.more {
  display: block; width: calc(100% - 32px); margin: 4px 16px 8px; padding: 9px;
  border: 1px dashed var(--line); border-radius: var(--radius); background: transparent;
  color: var(--muted); font-size: 13px;
}

.ship { border-bottom: 1px solid var(--line); }
.ship:first-of-type { border-top: 1px solid var(--line); }
.s-row {
  width: 100%; text-align: left; cursor: pointer;
  display: grid; align-items: center; column-gap: 10px;
  grid-template-columns: 3.1em minmax(0, 1fr) auto;
  padding: 11px 16px; min-height: 56px;
}
.s-row:hover { background: var(--surface); }
.ship.open .s-row { background: var(--surface); }

.s-time { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 15px; color: var(--accent); line-height: 1.2; align-self: start; padding-top: 1px; }
.s-time.changed { color: var(--warn); }
.s-time small { display: block; color: var(--faint); font-family: var(--sans); font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase; }

.s-main { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.s-name { font-weight: 600; font-size: 14.5px; letter-spacing: 0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s-sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s-type { font-weight: 550; }
.cat-ferry { color: var(--ferry); }
.cat-cruise { color: var(--cruise); }
.cat-cargo { color: var(--cargo); }

/* Status column: the pill, with a delay tag stacked under it when 15+ min late/early. */
.s-status { justify-self: end; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.pill {
  padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 550; white-space: nowrap;
  color: var(--ok); background: var(--ok-bg);
}
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.done { color: var(--done); background: var(--done-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }
.delay-tag {
  padding: 0 6px; border-radius: 999px; border: 1px solid; font-size: 11px; font-weight: 600;
  line-height: 1.5; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.delay-tag.late { color: var(--warn); border-color: rgba(255, 159, 28, 0.45); }
.delay-tag.early { color: var(--muted); border-color: var(--line); }

.s-detail {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px 16px;
  margin: 0; padding: 4px 16px 16px calc(16px + 3.1em + 10px);
  background: var(--surface);
}
.kv { min-width: 0; }
.kv dt { color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; }
.kv dd { margin: 2px 0 0; font-size: 14px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kv dd small { color: var(--muted); font-size: 12px; }
.kv.wide { grid-column: 1 / -1; }
.s-detail .src { grid-column: 1 / -1; margin: 0; color: var(--faint); font-size: 12px; }

@media (max-width: 460px) {
  .s-row { column-gap: 9px; }
  .pill { font-size: 11px; padding: 2px 6px; }
  .s-detail { padding-left: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chips { gap: 5px; }
  .chips button { padding: 4px 10px; }
  .tab { padding: 6px 11px; }
}

.foot {
  margin-top: auto; padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
  color: var(--faint); font-size: 12px; line-height: 1.6; text-align: center;
}
.foot p { margin: 0 0 8px; }
.foot .about { color: var(--muted); text-align: left; }
.foot .about strong { color: var(--text); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .refresh-btn.spinning svg { animation-duration: 2.4s; }
  .refresh-btn.pulse { animation: none; color: var(--accent); }
}
