/* Porcelain and pine. The chrome is ink on a low-chroma stone ground; the one hue on the page
   is a deep pine ramp, kept for the location grade (S deepest, D palest). Names are set in
   Newsreader, everything else in Instrument Sans with tabular figures for times.
   Grid: one 1200px column, 32px outer margins, 16px gutter; three cards per row on desktop. */
:root {
  --bg: #f3f3f0;
  --surface: #fcfcfb;
  --sunk: #f0f0ec;          /* tone step inside a card */
  --line: #e2e1dc;
  --line-strong: #cfcec8;
  --ink: #23262a;
  --ink-2: #464a50;
  --muted: #676b72;
  --accent: #24493f;        /* pine */
  --urgent: #9b3a35;

  --g-s: #24493f; --g-s-ink: #f2f6f4;
  --g-a: #4c7a6d; --g-a-ink: #ffffff;
  --g-b: #a8c4ba; --g-b-ink: #17362f;
  --g-c: #d5e3dd; --g-c-ink: #2a4a42;
  --g-d: #e9e9e5; --g-d-ink: #5b5f65;

  --serif: "Newsreader", "Iowan Old Style", Georgia, "Songti SC", serif;
  --sans: "Instrument Sans", "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --radius: 14px;
  --radius-s: 8px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.page { max-width: 1296px; margin: 0 auto; padding: 48px 32px 56px; }

/* header */
.head { margin-bottom: 24px; }
.head h1 { margin: 0; font: 500 32px/1.15 var(--serif); letter-spacing: -0.015em; color: var(--ink); }
.intro { margin: 10px 0 0; max-width: 72ch; color: var(--ink-2); font-size: 16px; line-height: 1.55; }
.intro a { text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.intro a:hover { text-decoration-color: currentColor; }
.linkish { border: 0; background: none; padding: 0; cursor: pointer; color: var(--accent); font-weight: 500; text-decoration: underline; text-decoration-color: #a8c4ba; text-underline-offset: 3px; }
.linkish:hover { text-decoration-color: currentColor; }

/* categories */
.cats { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 14px; }
.cat { height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink-2); font-size: 14px; cursor: pointer; white-space: nowrap; }
.cat:hover { border-color: var(--line-strong); background: var(--surface); }
.cat[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #f6f6f3; }

/* toolbar: one quiet bar */
.toolbar { display: flex; align-items: center; gap: 8px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.search { position: relative; flex: 1 1 220px; min-width: 0; }
.search svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; margin-top: -8px; fill: none; stroke: var(--muted); stroke-width: 1.5; }
.search input { width: 100%; height: 38px; padding: 0 12px 0 36px; border: 0; border-radius: var(--radius-s); background: transparent; font-size: 14px; }
.search input:hover { background: var(--sunk); }
.search input:focus { background: var(--sunk); outline: none; }
.search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.search input::placeholder { color: var(--muted); }
.selects { display: flex; gap: 4px; flex: none; }
.ctl { position: relative; display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 28px 0 12px; border-radius: var(--radius-s); background: var(--sunk); cursor: pointer; white-space: nowrap; }
.ctl:hover { background: #e8e8e3; }
.ctl span { color: var(--muted); font-size: 13px; }
.ctl select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; padding: 0; font-size: 14px; font-weight: 500; color: var(--ink); cursor: pointer; }
.ctl select:focus { outline: none; }
.ctl:has(select:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.ctl::after { content: ""; position: absolute; right: 12px; top: 50%; width: 6px; height: 6px; margin-top: -5px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); pointer-events: none; }
.clock { flex: none; padding: 0 10px 0 6px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* legend + count */
.listhead { display: flex; justify-content: space-between; align-items: center; gap: 8px 24px; flex-wrap: wrap; margin: 18px 2px 14px; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin: 0; color: var(--muted); font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .legend-title { color: var(--ink-2); font-weight: 500; }
.legend .legend-hint { color: var(--muted); }
.legend i { font-style: normal; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; font-size: 12px; font-weight: 600; }
.count { margin: 0; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

/* grade colours, shared by the card block, the legend and the trail */
.g-S { background: var(--g-s); color: var(--g-s-ink); }
.g-A { background: var(--g-a); color: var(--g-a-ink); }
.g-B { background: var(--g-b); color: var(--g-b-ink); }
.g-C { background: var(--g-c); color: var(--g-c-ink); }
.g-D { background: var(--g-d); color: var(--g-d-ink); }
.g-none { background: var(--sunk); color: var(--muted); }

/* cards */
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 20px 18px; display: flex; flex-direction: column; min-width: 0; transition: border-color .15s ease; }
.card:hover { border-color: var(--line-strong); }
.card.past { background: transparent; }
.card.past > * { opacity: .58; }
.card-head { display: flex; align-items: flex-start; gap: 16px; }
.card-name { flex: 1; min-width: 0; padding-top: 2px; }
.conf-title { display: flex; align-items: baseline; gap: 6px; font: 500 22px/1.2 var(--serif); letter-spacing: -0.01em; color: var(--ink); }
.conf-title a { text-decoration: none; }
.conf-title a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.conf-title .ext { color: var(--muted); display: inline-flex; align-self: center; }
.conf-title .ext:hover { color: var(--ink); }
.conf-title .ext svg { width: 13px; height: 13px; }
.conf-desc { margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 18px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* the location grade: the strongest thing on the card */
.grade { flex: none; width: 60px; height: 64px; border-radius: 12px; display: grid; place-items: center; align-content: center; gap: 2px; cursor: help; }
.grade b { font: 500 30px/30px var(--serif); }
.grade span { font-size: 12px; line-height: 14px; font-variant-numeric: tabular-nums; opacity: .85; }
.grade.g-none b { font: 500 13px/16px var(--sans); }

.dlbox { margin-top: 16px; padding: 12px 14px; border-radius: 10px; background: var(--sunk); }
.dl { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.dl .kind { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl .cd { color: var(--ink); font-size: 17px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.dl .cd.soon { color: var(--urgent); }
.dl .cd.done { color: var(--muted); font-weight: 500; font-size: 15px; }
.when { margin-top: 2px; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }

.facts { margin-top: 14px; display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; }
.place { color: var(--ink); font-size: 15px; font-weight: 500; }
.meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.tags span { border: 1px solid var(--line); color: var(--ink-2); border-radius: 6px; padding: 0 8px; font-size: 12px; line-height: 22px; white-space: nowrap; }
.trail { margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 20px; }
.trail-item { white-space: nowrap; }
.trail b { display: inline-grid; place-items: center; min-width: 17px; height: 17px; padding: 0 3px; border-radius: 4px; font-size: 11px; font-weight: 600; line-height: 1; vertical-align: 1px; }
.state { grid-column: 1 / -1; padding: 48px 0; color: var(--muted); text-align: center; list-style: none; }

/* footer + pager */
.foot { display: flex; flex-direction: column; align-items: center; gap: 18px; margin-top: 32px; color: var(--muted); font-size: 13px; text-align: center; }
.foot p { margin: 0; }
.foot a { text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.pager { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px; }
.pager span { padding: 0 4px; }
.pager button { min-width: 36px; height: 36px; padding: 0 8px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); cursor: pointer; font-size: 14px; font-variant-numeric: tabular-nums; }
.pager button:hover:not(:disabled) { background: var(--surface); }
.pager button[aria-current="page"] { background: var(--ink); color: #f6f6f3; }
.pager button:disabled { opacity: .35; cursor: default; }

/* dialog */
dialog { width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 64px); padding: 0; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: var(--surface); box-shadow: 0 24px 48px rgba(20, 28, 26, .14); }
dialog::backdrop { background: rgba(24, 30, 28, .32); }
.dialog-head { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font: 500 22px/1.2 var(--serif); }
.btn { height: 34px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: 13px; }
.btn:hover { background: var(--sunk); }
.dialog-body { padding: 8px 24px 24px; font-size: 14px; line-height: 22px; color: var(--ink-2); }
.dialog-body h3 { font-size: 14px; font-weight: 600; margin: 20px 0 2px; color: var(--ink); }
.dialog-body p { margin: 6px 0; }
.dialog-body b { color: var(--ink); font-weight: 600; }
.dialog-body a { color: var(--accent); text-underline-offset: 3px; }
.weights { border-collapse: collapse; width: 100%; margin: 14px 0 4px; font-size: 13px; font-variant-numeric: tabular-nums; }
.weights th, .weights td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.weights th:first-child, .weights td:first-child { text-align: left; }
.weights th { color: var(--muted); font-weight: 500; }

@media (prefers-reduced-motion: no-preference) {
  .cat, .ctl, .pager button, .btn, .search input { transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
}

/* tablet */
@media (max-width: 1100px) {
  .toolbar { flex-wrap: wrap; }
  .search { flex: 1 1 100%; }
  .selects { flex: 1 1 auto; flex-wrap: wrap; }
  .clock { margin-left: auto; }
}

/* phone */
@media (max-width: 640px) {
  .page { padding: 28px 16px 40px; }
  .head { margin-bottom: 20px; }
  .head h1 { font-size: 26px; }
  .intro { font-size: 15px; }
  .cats { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px 4px; scrollbar-width: none; }
  .cats::-webkit-scrollbar { display: none; }
  .selects { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; width: 100%; }
  .ctl { height: 44px; justify-content: space-between; }
  .ctl select { text-align: right; }
  .ctl:last-child { grid-column: 1 / -1; }
  .search input { height: 44px; }
  .clock { margin: 2px 0 2px; padding: 0 6px 4px; }
  .listhead { margin-top: 14px; }
  .legend-hint { display: none !important; }
  .cards { grid-template-columns: 1fr; gap: 12px; }
  .card { padding: 18px 16px 16px; }
  .conf-title { font-size: 21px; }
}
