:root {
  --bg: #ffffff;
  --ink: #17202a;
  --muted: #5d6874;
  --line: #e4e7eb;
  --hover: #f3f5f7;
  --accent: #16324f;
  --c0: #0b7a3b;
  --c1: #43a85b;
  --c2: #e8892b;
  --c3: #8f8f8f;
  --warn: #d7301f;
  --sheet-w: 360px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: #f4f2ec;
  overflow: hidden;
}
#map { position: absolute; inset: 0; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Sheet: bottom sheet on phones, side panel on wider screens. */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 42vh; display: flex; flex-direction: column;
  transition: height .2s ease;
  background: var(--bg); border-radius: 14px 14px 0 0;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, .18);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 2;
}
.sheet.dragging { transition: none; }
.sheet-head { padding: 4px 16px 8px; border-bottom: 1px solid var(--line); flex: none; }
.handle {
  display: block; width: 100%; height: 18px; border: 0; background: none; cursor: pointer;
  position: relative;
}
.handle::after {
  content: ""; position: absolute; left: 50%; top: 7px; width: 40px; height: 4px;
  margin-left: -20px; border-radius: 2px; background: #c9ced4;
}
.title-row { display: flex; align-items: center; gap: 8px; }
.titles { min-width: 0; }
h1 { font-size: 17px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#subtitle { margin: 0; font-size: 13px; }
.asof { margin: 1px 0 0; font-size: 12px; }
.asof:empty { display: none; }
.asof.stale { color: var(--warn); }
.back {
  flex: none; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg); font-size: 22px; line-height: 1; cursor: pointer;
}
.back:hover { background: var(--hover); }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 759px) {
  /* The header is the drag handle for the sheet. */
  .sheet-head { touch-action: none; cursor: grab; user-select: none; }
}

@media (min-width: 760px) {
  .sheet {
    top: 12px; left: 12px; bottom: 12px; right: auto; width: var(--sheet-w);
    height: auto !important; transition: none;
    border-radius: 12px; box-shadow: 0 2px 12px rgba(0, 0, 0, .2);
  }
  .sheet-head { padding-top: 12px; }
  .handle { display: none; }
}

/* Rows */
.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left;
  padding: 11px 16px; border: 0; border-bottom: 1px solid var(--line); background: none;
  cursor: pointer;
}
.row:hover, .row:focus-visible { background: var(--hover); outline: none; }
.row .dot { margin-top: 5px; }
.row-main { min-width: 0; flex: 1; }
.row-name { font-weight: 600; }
.row-sub { font-size: 13px; color: var(--muted); }
.row-flag { color: var(--warn); font-size: 13px; font-weight: 600; }
.section { padding: 10px 16px 4px; font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); }

.dot { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 50%; }
.dot.c0 { background: var(--c0); }
.dot.c1 { background: var(--c1); }
.dot.c2 { background: var(--c2); }
.dot.c3 { background: var(--c3); }
.dot.warn { background: #fff; border: 3px solid var(--warn); }

/* Trail card */
.card { padding: 14px 16px; }
.status { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; }
.status-time { margin: 2px 0 12px 20px; font-size: 13px; color: var(--muted); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.notice {
  border-left: 4px solid var(--warn); background: #fdf0ee; padding: 8px 10px; margin: 0 0 12px;
  border-radius: 4px;
}
.comments { background: var(--hover); padding: 8px 10px; border-radius: 4px; margin: 0 0 12px; white-space: pre-wrap; }
.empty { padding: 16px; color: var(--muted); }
.error { padding: 16px; color: var(--warn); }

.foot { padding: 12px 16px 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend .dot { width: 10px; height: 10px; }
.legend .dot.warn { border-width: 2px; }

/* Keep map controls clear of the sheet on phones. */
@media (max-width: 759px) {
  .maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { bottom: var(--sheet-h, 0px); }
}
