/* ============================================================
   WALKABOUT 2026 — "Alpine Dusk"
   A cinematic dark expedition dashboard.
   Rigor (mono data, precise grid) + romance (Fraunces display,
   dusk atmosphere). High contrast, calm density, one confident
   accent. App-shell layout: the view is the only scroll owner,
   so nothing jumps on mobile or at any window size.
   ============================================================ */

:root {
  /* ---- Surfaces: pure white canvas, white cards on hairlines + soft shadow ---- */
  --bg:        #ffffff;
  --bg-2:      #f6f7f9;
  --surface:   #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e7ebf0;
  --border:    #e5e8ec;
  --border-2:  #d4d9e1;

  /* ---- Text: near-black ink for strong contrast on white ---- */
  --text:   #15181e;
  --text-2: #48505c;
  --muted:  #767f8c;
  --faint:  #a7aeb9;

  /* ---- Accent: summit orange, darkened to read on white ---- */
  --accent:      #e2520e;
  --accent-soft: #bf420a;
  --accent-ink:  #ffffff;                        /* text ON accent fills */
  --accent-dim:  rgba(226, 82, 14, 0.10);
  --accent-line: rgba(226, 82, 14, 0.42);

  /* ---- Secondary: alpine teal, deepened for white ---- */
  --teal:     #0e9a85;
  --teal-ink: #04211b;
  --teal-dim: rgba(14, 154, 133, 0.12);

  /* ---- MTB difficulty (darkened for white contrast) ---- */
  --grade-green:  #2f9e52;
  --grade-blue:   #2563eb;
  --grade-black:  #2b313b;
  --grade-double: #8b3fd4;

  /* ---- Day-planner block fills: soft tints over white, dark ink on top ---- */
  --blk-drive:   color-mix(in srgb, #8a92a1 15%, var(--surface));
  --blk-work:    color-mix(in srgb, #e0920c 16%, var(--surface));
  --blk-ride:    color-mix(in srgb, var(--accent) 15%, var(--surface));
  --blk-sleep:   color-mix(in srgb, #5b6bd6 16%, var(--surface));
  --blk-eat:     color-mix(in srgb, var(--teal) 15%, var(--surface));
  --blk-explore: color-mix(in srgb, var(--grade-double) 15%, var(--surface));
  --blk-other:   color-mix(in srgb, #8a92a1 10%, var(--surface));

  /* ---- Status ---- */
  --ok:    #2f9e52;
  --warn:  #b9770c;
  --bad:   #d63333;

  /* ---- Geometry ---- */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 18px;
  --sidebar-w: 240px;

  /* ---- Type ---- */
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans:    "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* ---- Elevation: soft neutral shadows on white ---- */
  --shadow:    0 1px 2px rgba(20,24,32,0.05), 0 16px 40px -22px rgba(20,24,32,0.20);
  --shadow-sm: 0 1px 2px rgba(20,24,32,0.04), 0 8px 22px -18px rgba(20,24,32,0.15);

  --app-h: 100vh;
  --app-h: 100dvh;

  /* Theme native controls (date/time pickers, calendar icons, dropdowns, scrollbars) */
  color-scheme: light;
}

* { box-sizing: border-box; }
input[type=checkbox], input[type=radio], input[type=range], progress { accent-color: var(--accent); }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  overflow: hidden;                 /* the .view is the single scroll owner */
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Pure white canvas — no tint, no texture. Clarity first. */

h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 540; letter-spacing: -0.012em; line-height: 1.15; }
h4 { margin: 0; font-weight: 600; }
a { color: var(--accent-soft); text-decoration: none; }
a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
button { font-family: inherit; cursor: pointer; color: inherit; }
input, select, textarea { font-family: inherit; }
::selection { background: var(--accent-dim); }

.mono { font-family: var(--mono); }

/* ============================================================ Layout (app shell) */
.app {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: var(--app-h);
}

/* ----- Sidebar ----- */
.sidebar {
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100%; min-height: 0;
  padding: 20px 14px 16px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 6px 20px; }
.brand-mark {
  width: 46px; height: 46px; flex: none;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-title { font-family: var(--mono); font-size: 14px; letter-spacing: 0.22em; font-weight: 600; }
.brand-year { font-family: var(--mono); font-size: 11px; color: var(--accent); letter-spacing: 0.42em; margin-top: 5px; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; overflow-y: auto; flex: 1; min-height: 0; }
.nav-btn {
  display: flex; align-items: center; gap: 12px;
  background: transparent; border: 0; color: var(--text-2);
  padding: 9px 11px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 500; text-align: left; width: 100%;
  position: relative;
  transition: background 0.14s, color 0.14s;
}
.nav-btn .ico { width: 18px; text-align: center; opacity: 0.7; font-size: 14px; }
.nav-btn .lbl { flex: 1; }
.nav-btn .badge {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 1px 7px; border-radius: 20px; font-weight: 500;
}
.nav-btn:hover { background: var(--surface); color: var(--text); }
.nav-btn:hover .ico { opacity: 1; }
.nav-btn.active { background: var(--accent-dim); color: var(--accent-soft); }
.nav-btn.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--accent); }
.nav-btn.active .ico { opacity: 1; }
.nav-btn.active .badge { color: var(--accent-soft); border-color: var(--accent-line); background: transparent; }

.sidebar-foot { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 14px; flex: none; }
.countdown {
  font-family: var(--mono); font-size: 12px; color: var(--text-2);
  text-align: center; margin-bottom: 12px; letter-spacing: 0.02em;
}
.countdown b { font-family: var(--display); color: var(--accent); font-size: 17px; font-weight: 500; }
.data-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ghost-btn {
  background: var(--surface); border: 1px solid var(--border-2); color: var(--text-2);
  padding: 6px 8px; border-radius: var(--r-sm); font-size: 12px; font-weight: 500;
  transition: border-color 0.14s, color 0.14s, background 0.14s;
}
.ghost-btn:hover { color: var(--text); border-color: var(--muted); background: var(--surface-2); }
.ghost-btn.danger:hover { color: var(--bad); border-color: var(--bad); }
.ghost-btn:nth-child(3) { grid-column: 1 / -1; }
.save-state {
  text-align: center; font-family: var(--mono); font-size: 10px;
  color: var(--faint); margin-top: 11px; letter-spacing: 0.12em; text-transform: uppercase;
}
.save-state.flash { color: var(--teal); }

/* ----- Main ----- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 16px 30px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(10px);
  flex: none; z-index: 20;
}
.menu-toggle { display: none; background: var(--surface); border: 1px solid var(--border-2); color: var(--text); border-radius: var(--r-sm); width: 40px; height: 40px; font-size: 18px; }
.topbar-trip { flex: 1; min-width: 0; }
.topbar-trip h1 { font-size: 25px; font-weight: 500; }
.topbar-sub { margin: 3px 0 0; color: var(--muted); font-size: 12px; font-family: var(--mono); letter-spacing: 0.02em; }
.topbar-meta { display: flex; gap: 22px; align-items: center; }
.tb-stat { text-align: right; background: transparent; border: 0; padding: 0; }
.tb-stat .k { font-family: var(--mono); font-size: 9.5px; color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase; }
.tb-stat .v { font-size: 15px; font-weight: 600; margin-top: 2px; }
.tb-stat .v.accent { color: var(--accent); }

/* no scroll-behavior:smooth here — render() restores scroll positions
   programmatically and smooth would animate every reactive repaint */
.view { padding: 30px; flex: 1; min-width: 0; min-height: 0; overflow-y: auto; overflow-x: hidden; outline: none; }
.view:focus-visible { outline: none; }
/* staggered settle on view change */
.view > * { animation: view-in 0.32s cubic-bezier(.2,.7,.2,1) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

/* ============================================================ Shared bits */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.section-head h2 { font-size: 19px; display: flex; align-items: center; gap: 10px; font-weight: 500; }
.section-head .sub { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card.pad-lg { padding: 22px 24px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: var(--accent-ink); border: 0;
  padding: 9px 15px; border-radius: var(--r-sm); font-size: 13px; font-weight: 600;
  transition: filter 0.14s, transform 0.06s, box-shadow 0.14s;
  box-shadow: 0 6px 18px -10px rgba(226,82,14,0.7);
}
.btn:hover { filter: brightness(1.06); box-shadow: 0 8px 22px -10px rgba(226,82,14,0.8); }
.btn:active { transform: translateY(1px); }
.btn.sm { padding: 6px 11px; font-size: 12px; box-shadow: none; }
.btn.outline { background: transparent; color: var(--text-2); border: 1px solid var(--border-2); box-shadow: none; }
.btn.outline:hover { color: var(--text); border-color: var(--muted); filter: none; background: var(--surface-2); }
.btn.teal { background: var(--teal); color: var(--teal-ink); box-shadow: 0 6px 18px -10px rgba(55,211,181,0.7); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  background: var(--surface-2); border: 1px solid transparent;
  color: var(--text-2); padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}
.chip.accent { color: var(--accent-soft); background: var(--accent-dim); }
.chip.teal { color: var(--teal); background: var(--teal-dim); }
.chip.ok   { color: var(--ok);   background: color-mix(in srgb, var(--ok) 14%, transparent); }
.chip.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.chip.bad  { color: var(--bad);  background: color-mix(in srgb, var(--bad) 14%, transparent); }

.pill-status { font-family: var(--mono); font-size: 10px; font-weight: 500; padding: 3px 9px; border-radius: 20px; letter-spacing: 0.06em; }
.pill-status.booked { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill-status.tbd    { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.pill-status.idea   { background: var(--surface-2); color: var(--muted); }

/* difficulty marker */
.diff { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; }
.diff .glyph { width: 11px; height: 11px; display: inline-block; }
.diff.green  { color: var(--grade-green); }
.diff.blue   { color: var(--grade-blue); }
.diff.black  { color: var(--grade-black); }
.diff.double { color: var(--grade-double); }
.diff.green .glyph  { border-radius: 50%; background: var(--grade-green); }
.diff.blue .glyph   { background: var(--grade-blue); }
.diff.black .glyph  { background: var(--grade-black); transform: rotate(45deg); }
.diff.double .glyph { background: var(--grade-double); transform: rotate(45deg); }

.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 12.5px; }
.tiny { font-size: 11px; }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.mt { margin-top: 16px; }
.mt-sm { margin-top: 8px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* forms */
input[type=text], input[type=number], input[type=date], input[type=time], select, textarea {
  background: var(--bg-2); border: 1px solid var(--border-2); color: var(--text);
  border-radius: var(--r-sm); padding: 9px 11px; font-size: 13px; width: 100%;
  transition: border-color 0.14s, box-shadow 0.14s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-dim); }
textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
label.field { display: block; }
label.field > span { display: block; font-family: var(--mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 6px; }
.inline-edit { background: transparent; border: 1px dashed transparent; border-radius: 5px; padding: 2px 4px; width: 100%; color: var(--text); }
.inline-edit:hover { border-color: var(--border-2); }
.inline-edit:focus { border-style: solid; border-color: var(--accent-line); background: var(--bg-2); }
select option { background: var(--surface); color: var(--text); }

/* ============================================================ Overview */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 18px 18px 16px; position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.stat::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: linear-gradient(90deg, var(--accent), transparent 70%); opacity: 0.5; }
.stat .k { font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; }
.stat .v { font-family: var(--display); font-size: 36px; font-weight: 500; margin-top: 8px; letter-spacing: -0.02em; line-height: 1; }
.stat .v small { font-size: 14px; color: var(--muted); font-weight: 500; }
.stat .foot { font-size: 11.5px; color: var(--text-2); margin-top: 8px; }

.leg-strip { display: flex; gap: 0; align-items: stretch; overflow-x: auto; padding-bottom: 8px; }
.leg-node { flex: 1; min-width: 150px; position: relative; padding: 0 4px; }
.leg-node .dot-line { display: flex; align-items: center; gap: 0; margin-bottom: 12px; }
.leg-node .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); flex: none; z-index: 1; box-shadow: 0 0 0 3px rgba(226,82,14,0.14); }
.leg-node .line { height: 2px; background: var(--border-2); flex: 1; }
.leg-node:last-child .line { background: transparent; }
.leg-node .lg-name { font-weight: 600; font-size: 14px; }
.leg-node .lg-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ============================================================ Legs */
.leg-card { display: flex; flex-direction: column; transition: border-color 0.14s, transform 0.1s; }
.leg-card:hover { border-color: var(--border-2); }
.leg-card .lc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.leg-card .lc-title { font-family: var(--display); font-size: 19px; font-weight: 500; }
.leg-card .lc-region { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 3px; }
.leg-card .lc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; margin-top: 16px; }
.kv { display: flex; flex-direction: column; gap: 3px; }
.kv .k { font-family: var(--mono); font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.kv .v { font-size: 13.5px; }
.work-meter { display: flex; gap: 3px; margin-top: 4px; }
.work-meter .seg { height: 6px; flex: 1; border-radius: 3px; background: var(--surface-3); }
.work-meter .seg.on.good { background: var(--ok); }
.work-meter .seg.on.ok { background: var(--warn); }
.work-meter .seg.on.bad { background: var(--bad); }
.ride-tag { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; padding: 4px 11px; font-size: 12px; margin: 3px 4px 0 0; color: var(--text-2); transition: border-color 0.14s, color 0.14s; }
.ride-tag:hover { border-color: var(--accent-line); color: var(--text); }

/* ============================================================ Map + Discover */
.map-wrap { display: grid; grid-template-columns: 340px 1fr; gap: 18px; height: calc(var(--app-h) - 168px); min-height: 480px; }
.map-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-sm); }
.map-panel .mp-head { padding: 16px 16px; border-bottom: 1px solid var(--border); }
.map-panel .mp-body { padding: 14px 16px; overflow-y: auto; flex: 1; }
#map, #map-discover { width: 100%; height: 100%; border-radius: var(--r); border: 1px solid var(--border); background: var(--bg-2); z-index: 1; }
.map-col { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.map-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-2); }
.map-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.map-legend .sw { width: 10px; height: 10px; border-radius: 50%; }

.cat-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.cat-tab { background: var(--surface-2); border: 1px solid var(--border-2); color: var(--text-2); padding: 6px 12px; border-radius: 20px; font-size: 12.5px; transition: border-color 0.14s, color 0.14s, background 0.14s; }
.cat-tab:hover { color: var(--text); border-color: var(--muted); }
.cat-tab.active { background: var(--accent-dim); border-color: var(--accent-line); color: var(--accent-soft); }

.result-item { display: flex; gap: 10px; padding: 11px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); margin-bottom: 8px; background: var(--bg-2); transition: border-color 0.14s; }
.result-item:hover { border-color: var(--border-2); }
.result-item .ri-main { flex: 1; min-width: 0; }
.result-item .ri-name { font-weight: 600; font-size: 13.5px; }
.result-item .ri-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 3px; }
.result-item .ri-dist { font-family: var(--mono); font-size: 11px; color: var(--teal); white-space: nowrap; }
.result-item .ri-actions { display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }

.search-center { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 9px 11px; }
.search-center .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); flex: none; box-shadow: 0 0 8px var(--teal); }
.loading-row { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12.5px; padding: 10px 2px; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================ Itinerary */
.day-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.day-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 14px; cursor: pointer; transition: border-color 0.14s, transform 0.1s; box-shadow: var(--shadow-sm); }
.day-card:hover { border-color: var(--border-2); transform: translateY(-2px); }
.day-card .dc-date { display: flex; align-items: baseline; justify-content: space-between; }
.day-card .dc-dow { font-family: var(--mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.day-card .dc-day { font-family: var(--display); font-size: 24px; font-weight: 500; }
.day-card .dc-loc { font-size: 13px; margin-top: 6px; color: var(--text); }
.day-card .dc-loc .leg-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.day-card .dc-blocks { display: flex; gap: 3px; margin-top: 10px; height: 7px; }
.day-card .dc-blocks .b { flex: 1; border-radius: 2px; opacity: 0.9; }
.day-card .dc-rides { margin-top: 9px; font-size: 11.5px; color: var(--accent-soft); }
.day-card.weekday { box-shadow: inset 3px 0 0 var(--warn), var(--shadow-sm); }
.day-card .work-flag { font-family: var(--mono); font-size: 10px; margin-top: 8px; }
.work-flag.ok { color: var(--ok); }
.work-flag.warn { color: var(--warn); }
.work-flag.bad { color: var(--bad); }

/* ============================================================ Day planner */
.planner-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 18px; }
.timeline { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 8px 8px 8px 56px; box-shadow: var(--shadow-sm); }
.tl-hour { position: relative; height: 46px; border-top: 1px dashed var(--border); }
.tl-hour:first-child { border-top: 0; }
.tl-hour .hr-label { position: absolute; left: -50px; top: -8px; font-family: var(--mono); font-size: 10px; color: var(--faint); width: 44px; text-align: right; }
.work-window-band { position: absolute; left: 56px; right: 8px; background: repeating-linear-gradient(45deg, rgba(240,181,61,0.08), rgba(240,181,61,0.08) 8px, transparent 8px, transparent 16px); border-top: 1px solid rgba(240,181,61,0.3); border-bottom: 1px solid rgba(240,181,61,0.3); pointer-events: none; z-index: 1; }
.work-window-band .wb-label { position: absolute; right: 6px; top: 3px; font-family: var(--mono); font-size: 9px; color: var(--warn); letter-spacing: 0.08em; }
.tl-block { position: absolute; left: 56px; right: 8px; border-radius: 7px; padding: 5px 9px; color: var(--text); font-size: 12px; overflow: hidden; z-index: 2; cursor: pointer; border: 1px solid rgba(20,24,32,0.07); }
.tl-block .bk-t { font-weight: 700; display: flex; justify-content: space-between; gap: 6px; }
.tl-block .bk-sub { font-size: 10.5px; opacity: 0.82; font-family: var(--mono); }
.tl-block .bk-warn { position: absolute; top: 4px; right: 6px; font-size: 12px; }
.blk-drive   { background: var(--blk-drive);   box-shadow: inset 3px 0 0 #8a92a1; }
.blk-work    { background: var(--blk-work);    box-shadow: inset 3px 0 0 var(--warn); }
.blk-ride    { background: var(--blk-ride);    box-shadow: inset 3px 0 0 var(--accent); }
.blk-sleep   { background: var(--blk-sleep);   box-shadow: inset 3px 0 0 #7683de; }
.blk-eat     { background: var(--blk-eat);     box-shadow: inset 3px 0 0 var(--teal); }
.blk-explore { background: var(--blk-explore); box-shadow: inset 3px 0 0 var(--grade-double); }
.blk-other   { background: var(--blk-other);   box-shadow: inset 3px 0 0 #8a92a1; }

.planner-side .ps-day { font-family: var(--display); font-size: 20px; font-weight: 500; }
.legend-blocks { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.legend-blocks .lb { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-2); }
.legend-blocks .lb .sw { width: 10px; height: 10px; border-radius: 3px; }

/* segmented view-mode switcher */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg-btn { background: transparent; border: 0; color: var(--text-2); padding: 5px 12px; border-radius: 6px; font-size: 12.5px; font-weight: 500; transition: background 0.14s, color 0.14s; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--accent-dim); color: var(--accent-soft); }

/* multi-day columns (3-day / 7-day) — the strip is its own scroll box so the
   day headers + stop bands stay pinned (Google Calendar-style) while the
   timeline scrolls under them. */
.planner-cols { display: grid; gap: 0 6px; align-items: start; overflow: auto; padding-bottom: 6px; max-height: calc(100dvh - 200px); }
.pc-gutter-head { position: sticky; left: 0; top: 0; z-index: 6; background: var(--bg); }
.pc-gutter-band { position: sticky; left: 0; top: 64px; z-index: 6; background: var(--bg); }
.pc-gutter { position: sticky; left: 0; z-index: 3; background: var(--bg); }
.pc-hr { position: absolute; right: 6px; font-family: var(--mono); font-size: 10px; color: var(--faint); }
.pc-head { position: sticky; top: 0; z-index: 4; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm) var(--r-sm) 0 0; padding: 8px 11px; cursor: pointer; transition: border-color 0.14s; height: 64px; overflow: hidden; box-shadow: 0 -14px 0 var(--bg); }
.pc-head:hover { border-color: var(--border-2); }
.pc-head.today { border-color: var(--accent-line); box-shadow: 0 -14px 0 var(--bg), 0 0 0 1px var(--accent-line); }
.pc-head.off { cursor: default; opacity: 0.55; background: var(--bg-2); }
.pc-head.off:hover { border-color: var(--border); }
.pc-dow { font-family: var(--mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.pc-date { font-family: var(--display); font-size: 18px; font-weight: 500; margin-top: 2px; }
/* stop band — one continuous bar per run of days at the same stop */
.pc-band { position: sticky; top: 64px; z-index: 4; background: var(--bg); padding: 4px 0 8px; }
.pc-band-bar { --bandc: var(--accent); height: 20px; display: flex; align-items: center; padding: 0 9px; font-size: 11px; font-weight: 600; color: var(--text); background: color-mix(in srgb, var(--bandc) 16%, var(--surface)); white-space: nowrap; overflow: hidden; }
.pc-band-bar.start { border-radius: 999px 0 0 999px; }
.pc-band-bar.end { border-radius: 0 999px 999px 0; }
.pc-band-bar.start.end { border-radius: 999px; }
.pc-band-bar:not(.start) { margin-left: -7px; padding-left: 12px; }
.pc-col { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); }
.pc-col.off { background: var(--bg-2); opacity: 0.5; }
.pc-col .tl-block { left: 3px; right: 3px; }
.tl-block.compact { padding: 2px 5px; border-radius: 5px; }
.tl-block.compact .bk-t { font-size: 10.5px; font-weight: 600; }
.tl-block.compact .bk-warn { font-size: 10px; top: 2px; right: 3px; }

/* month calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); text-align: center; padding-bottom: 4px; }
.cal-cell { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 9px; min-height: 96px; display: flex; flex-direction: column; gap: 5px; cursor: pointer; transition: border-color 0.14s, transform 0.08s; }
.cal-cell:hover { border-color: var(--border-2); transform: translateY(-1px); }
.cal-cell.today { border-color: var(--accent-line); box-shadow: 0 0 0 1px var(--accent-line); }
.cal-cell.blank { background: transparent; border-color: transparent; cursor: default; }
.cal-cell.off { background: var(--bg-2); opacity: 0.45; cursor: default; min-height: 96px; }
.cal-cell.off:hover { transform: none; border-color: var(--border); }
.cal-top { display: flex; align-items: center; justify-content: space-between; }
.cal-num { font-family: var(--display); font-size: 16px; font-weight: 500; }
.cal-loc { font-size: 11px; color: var(--text-2); line-height: 1.3; flex: 1; }
.cal-loc .leg-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.cal-strip { display: flex; gap: 2px; height: 6px; }
.cal-strip .b { border-radius: 2px; opacity: 0.9; }
.cal-foot { display: flex; align-items: center; justify-content: space-between; font-size: 10px; min-height: 13px; }
.cal-foot .work-flag { font-family: var(--mono); font-size: 9.5px; }

/* ============================================================ Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-sm); -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 540px; }
table.tbl th { text-align: left; font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--bg-2); position: sticky; top: 0; cursor: pointer; white-space: nowrap; z-index: 1; }
table.tbl th:hover { color: var(--text); }
table.tbl th.sorted { color: var(--accent); }
table.tbl th.sorted::after { content: " ▾"; }
table.tbl th.sorted.asc::after { content: " ▴"; }
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr { transition: background 0.12s; }
table.tbl tbody tr:hover { background: var(--surface-2); }
.status-select { background: var(--bg-2); border: 1px solid var(--border-2); color: var(--text-2); border-radius: 20px; padding: 4px 9px; font-size: 11.5px; font-family: var(--mono); }

/* ============================================================ Logistics / Packing */
.truck-card { display: flex; gap: 12px; align-items: flex-start; }
.truck-ico { font-size: 26px; }
.matrix { font-family: var(--mono); font-size: 12px; }
.matrix td, .matrix th { text-align: center; }
.matrix td.label, .matrix th.label { text-align: left; }

.pack-cat { margin-bottom: 20px; }
.pack-cat h3 { font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); margin-bottom: 10px; font-weight: 500; }
.pack-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--r-sm); }
.pack-item:hover { background: var(--surface-2); }
.pack-item input { width: auto; accent-color: var(--accent); }
.pack-item label { flex: 1; font-size: 13.5px; }
.pack-item.checked label { color: var(--muted); text-decoration: line-through; }
.pack-progress { font-family: var(--mono); font-size: 12px; color: var(--text-2); }

/* ============================================================ Decisions */
.decision { border-left: 3px solid var(--warn); }
.decision.resolved { border-left-color: var(--ok); }
.decision .dec-q { font-weight: 600; font-size: 14px; }
.decision .dec-opts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.dec-opt { background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--r-sm); padding: 6px 12px; font-size: 12.5px; color: var(--text-2); transition: border-color 0.14s, color 0.14s; }
.dec-opt.chosen { background: var(--accent-dim); border-color: var(--accent-line); color: var(--accent-soft); }
.dec-opt:hover { border-color: var(--muted); color: var(--text); }

/* ============================================================ Modal + Toast */
.modal-host { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-host[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(6,8,11,0.72); backdrop-filter: blur(4px); }
.modal { position: relative; background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-lg); padding: 24px; width: min(560px, 100%); max-height: 88dvh; overflow-y: auto; box-shadow: var(--shadow); animation: modal-in 0.2s cubic-bezier(.2,.7,.2,1); }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.985); } }
.modal h3 { font-size: 20px; margin-bottom: 6px; font-weight: 500; }
.modal .modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.toast-host { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; max-width: 92vw; }
.toast { background: var(--surface-3); border: 1px solid var(--border-2); color: var(--text); padding: 11px 17px; border-radius: 24px; font-size: 13px; box-shadow: var(--shadow); animation: toast-in 0.22s ease; }
.toast.good { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.toast.bad { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.toast .em { color: var(--accent-soft); font-weight: 600; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.empty { text-align: center; color: var(--muted); padding: 44px 20px; font-size: 13.5px; }
.empty .big { font-size: 34px; margin-bottom: 10px; opacity: 0.4; }

/* ============================================================ Suggestions */
.sug-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 9px; transition: border-color 0.14s, transform 0.1s; box-shadow: var(--shadow-sm); }
.sug-card:hover { border-color: var(--border-2); transform: translateY(-2px); }
.sug-top { display: flex; align-items: center; gap: 8px; }
.sug-ico { font-size: 17px; }
.sug-tag { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: 0.06em; }
.sug-title { font-family: var(--display); font-weight: 500; font-size: 16px; line-height: 1.3; }
.sug-why { font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.sug-btns { display: flex; gap: 8px; margin-top: 4px; }
.sug-btns .btn { flex: 1; }

/* ============================================================ Chat */
#chat-launcher {
  position: fixed; right: 24px; bottom: 24px; z-index: 70;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink); border: 0;
  padding: 12px 18px; border-radius: 28px; font-size: 13.5px; font-weight: 650;
  box-shadow: 0 12px 30px -10px rgba(226,82,14,0.6); transition: filter 0.14s, transform 0.1s, opacity 0.16s;
}
#chat-launcher:hover { filter: brightness(1.06); transform: translateY(-2px); }
#chat-launcher .cl-ico { font-size: 15px; }
#chat-launcher.hidden { opacity: 0; pointer-events: none; transform: translateY(8px); }

#chat-backdrop { position: fixed; inset: 0; background: rgba(6,8,11,0.66); backdrop-filter: blur(4px); z-index: 88; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
#chat-backdrop.show { opacity: 1; pointer-events: auto; }

#chat-panel { position: fixed; background: var(--bg-2); border: 1px solid var(--border-2); display: flex; flex-direction: column; z-index: 90; box-shadow: var(--shadow); overflow: hidden; }
#chat-panel.mode-sidebar { top: 0; right: 0; bottom: 0; width: 400px; border-width: 0 0 0 1px; transform: translateX(100%); transition: transform 0.24s cubic-bezier(.2,.7,.2,1); }
#chat-panel.mode-sidebar.open { transform: translateX(0); }
#chat-panel.mode-modal { top: 50%; left: 50%; width: min(820px, 94vw); height: min(84dvh, 860px); transform: translate(-50%, -50%) scale(0.98); opacity: 0; pointer-events: none; border-radius: var(--r-lg); transition: opacity 0.2s, transform 0.2s; }
#chat-panel.mode-modal.open { opacity: 1; transform: translate(-50%, -50%) scale(1); pointer-events: auto; }
body.chat-docked { padding-right: 400px; }

.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 17px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, var(--surface), var(--bg-2)); flex: none; }
.chat-title { font-weight: 650; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.chat-title .ci { color: var(--accent); }
.chat-status { font-family: var(--mono); font-size: 10px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; font-weight: 400; }
.chat-status .dot { width: 7px; height: 7px; border-radius: 50%; }
.chat-status .dot.ok { background: var(--ok); box-shadow: 0 0 7px var(--ok); }
.chat-status .dot.off { background: var(--faint); }
.chat-head-btns { display: flex; gap: 4px; }
.chat-ibtn { background: transparent; border: 1px solid transparent; color: var(--muted); width: 32px; height: 32px; border-radius: var(--r-sm); font-size: 14px; transition: background 0.14s, color 0.14s; }
.chat-ibtn:hover { background: var(--surface-2); color: var(--text); }

.chat-messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; max-width: 100%; }
.msg.user { justify-content: flex-end; }
.msg.bot { flex-direction: column; align-items: flex-start; }
.msg-b { padding: 10px 14px; border-radius: 16px; font-size: 13.5px; line-height: 1.55; max-width: 86%; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.user .msg-b { background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 5px; font-weight: 500; }
.msg.bot .msg-b { background: var(--surface); border: 1px solid var(--border); color: var(--text); border-bottom-left-radius: 5px; max-width: 100%; }
.msg.bot.err .msg-b { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.msg-b p { margin: 0 0 8px; } .msg-b p:last-child { margin-bottom: 0; }
.msg-b ul { margin: 6px 0; padding-left: 18px; } .msg-b li { margin: 3px 0; }
.msg-b strong { color: var(--text); font-weight: 700; }
.msg-b code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-family: var(--mono); font-size: 11.5px; }
.msg-b pre { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 12px; overflow-x: auto; margin: 8px 0; }
.msg-b pre code { background: none; border: 0; padding: 0; font-size: 11.5px; }
/* chat tables — contained, scroll on overflow, never break the bubble */
.md-table { margin: 8px 0; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-sm); -webkit-overflow-scrolling: touch; max-width: 100%; }
.md-table table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.md-table th, .md-table td { padding: 7px 11px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.md-table th { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); background: var(--bg-2); }
.md-table tr:last-child td { border-bottom: 0; }
.md-table td.align-right, .md-table th.align-right { text-align: right; }
.md-table td.align-center, .md-table th.align-center { text-align: center; }
.msg-meta { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 5px; padding-left: 4px; }
.msg-b.pending { color: var(--text); min-width: 60px; }
.msg-b.pending:has(.pending-act:only-child), .msg-b.pending.empty { color: var(--muted); }
.pending-act { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); margin-top: 6px; }
.msg-b.pending > .pending-act:first-child { margin-top: 0; }
.pending-t { font-family: var(--mono); font-size: 11.5px; }
.typing { display: inline-flex; gap: 3px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: typing 1s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; } .typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.chat-empty { text-align: center; color: var(--muted); margin: auto; padding: 24px 12px; }
.chat-empty .ce-ico { font-size: 32px; color: var(--accent); opacity: 0.8; margin-bottom: 10px; }
.chat-empty p { margin: 5px 0; }
.chat-suggest { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.chat-suggest button { background: var(--surface); border: 1px solid var(--border-2); color: var(--text-2); padding: 9px 13px; border-radius: var(--r-sm); font-size: 12.5px; text-align: left; transition: border-color 0.14s, color 0.14s; }
.chat-suggest button:hover { border-color: var(--accent-line); color: var(--text); }

.chat-input-row { display: flex; gap: 8px; align-items: flex-end; padding: 13px 15px; border-top: 1px solid var(--border); flex: none; }
#chat-input { resize: none; max-height: 140px; line-height: 1.5; }
.chat-send { background: var(--accent); color: var(--accent-ink); border: 0; width: 40px; height: 40px; border-radius: 50%; font-size: 17px; font-weight: 700; flex: none; transition: filter 0.14s; }
.chat-send:hover { filter: brightness(1.06); } .chat-send:disabled { opacity: 0.55; cursor: default; }
.chat-foot { text-align: center; font-size: 10px; color: var(--faint); padding: 0 15px 11px; flex: none; }

#chat-reload-banner { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); z-index: 96; display: none; align-items: center; gap: 12px; background: var(--surface-3); border: 1px solid var(--accent-line); color: var(--text); padding: 11px 15px; border-radius: 28px; box-shadow: var(--shadow); font-size: 13px; }
#chat-reload-banner.show { display: flex; animation: toast-in 0.2s ease; }
#chat-reload-banner button { background: var(--accent); color: var(--accent-ink); border: 0; padding: 6px 13px; border-radius: 16px; font-size: 12px; font-weight: 600; }
#chat-reload-banner #chat-reload-x { background: transparent; color: var(--muted); padding: 4px 7px; }

/* ============================================================ Planner drag */
/* Touch model (Google Calendar): scrolling ALWAYS wins, even on blocks.
   A ~0.4s long-press "lifts" a block (views.js then owns the gesture via
   preventDefault): drag moves it; release-in-place shows resize handles.
   Mouse drags keep the original pointer-event behavior. */
.timeline { touch-action: pan-y; }
.pc-col { touch-action: pan-x pan-y; }
.tl-block { touch-action: pan-x pan-y; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.tl-block { cursor: grab; transition: transform 0.12s ease, opacity 0.12s ease; }
.tl-block.lifted { transform: scale(1.03); }
.tl-block.selected { overflow: visible; z-index: 7; box-shadow: 0 0 0 2px var(--accent), 0 10px 24px -12px rgba(20,24,32,0.35); }
.tl-handle {
  position: absolute; left: 50%; width: 32px; height: 32px; margin-left: -16px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--accent);
  display: grid; place-items: center; touch-action: none; z-index: 9;
  box-shadow: var(--shadow-sm);
}
.tl-handle.top { top: -18px; }
.tl-handle.bottom { bottom: -18px; }
.tl-handle i { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.tl-block.dragging { cursor: grabbing; opacity: 0.97; box-shadow: 0 10px 26px -6px rgba(20,24,32,0.28); z-index: 6; }
.tl-ghost { position: absolute; border: 1.5px dashed var(--accent); background: var(--accent-dim); border-radius: 7px; z-index: 5; pointer-events: none; color: var(--text); font-size: 11px; padding: 3px 8px; font-weight: 600; }
#pl-timeline .tl-ghost { left: 56px; right: 8px; }
.pc-col .tl-ghost { left: 3px; right: 3px; }
body.dragging-active { user-select: none; cursor: grabbing; }
.now-line { position: absolute; left: 56px; right: 8px; height: 0; border-top: 2px solid var(--accent); z-index: 3; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -5px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.pc-col .now-line { left: 0; right: 0; }

/* ============================================================ Keyboard help */
.tb-link { background: transparent; border: 0; cursor: pointer; padding: 0; }
.tb-link:hover .v { text-decoration: underline; }
.pending-elapsed { opacity: 0.5; font-variant-numeric: tabular-nums; margin-left: 4px; }
.help-overlay { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: 20px; }
.help-overlay .help-backdrop { position: absolute; inset: 0; background: rgba(6,8,11,0.66); backdrop-filter: blur(4px); }
.help-card { position: relative; background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-lg); padding: 24px 26px; width: min(720px, 100%); max-height: 86dvh; overflow-y: auto; box-shadow: var(--shadow); animation: modal-in 0.2s cubic-bezier(.2,.7,.2,1); }
.help-card h3 { font-size: 20px; margin-bottom: 4px; font-weight: 500; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 30px; margin-top: 16px; }
.help-sec h4 { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); margin-bottom: 9px; font-weight: 500; }
.help-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 13px; }
.help-row .desc { color: var(--text-2); }
kbd { font-family: var(--mono); font-size: 11px; background: var(--surface-2); border: 1px solid var(--border-2); border-bottom-width: 2px; border-radius: 5px; padding: 2px 7px; color: var(--text); white-space: nowrap; }
.help-keys { display: flex; gap: 4px; align-items: center; }
.help-keys .sep { color: var(--faint); font-size: 11px; }

/* ============================================================ Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
* { scrollbar-color: var(--border-2) transparent; }

/* ============================================================ Responsive */
.sidebar-scrim { position: fixed; inset: 0; background: rgba(6,8,11,0.6); z-index: 40; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.sidebar-scrim.show { opacity: 1; pointer-events: auto; }
@media (min-width: 921px) { .sidebar-scrim { display: none; } }

@media (max-width: 1180px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .map-wrap { grid-template-columns: 300px 1fr; }
}
@media (max-width: 1080px) {
  .map-wrap { grid-template-columns: 1fr; height: auto; }
  #map, #map-discover { height: 62dvh; min-height: 420px; }
  .planner-wrap { grid-template-columns: 1fr; }
  /* Route Map view: show the actual map first on small screens
     (Discover keeps its search panel first — you set up the search there) */
  .map-wrap:has(#map) .map-col { order: -1; }
}

@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; height: var(--app-h); z-index: 50; transform: translateX(-100%); transition: transform 0.22s cubic-bezier(.2,.7,.2,1); box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .menu-toggle { display: grid; place-items: center; }
  .topbar { padding: 14px 18px; gap: 12px; }
  .topbar-trip h1 { font-size: 21px; }
  .topbar-meta { display: none; }
  .view { padding: 20px 18px; }
  .grid-2, .grid-3, .leg-card .lc-grid { grid-template-columns: 1fr; }
  .help-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  body.chat-docked { padding-right: 0; }
  #chat-panel.mode-sidebar { width: 100vw; height: var(--app-h); }
}

@media (max-width: 560px) {
  .stat-row { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat .v { font-size: 30px; }
  .section-head { align-items: stretch; }
  .section-head h2 { font-size: 17px; }
  .view { padding: 18px 14px; }
  .toast-host { bottom: 16px; }
  #chat-launcher { right: 16px; bottom: 16px; }
  /* planner controls: fill the row and wrap instead of clipping off-screen */
  .section-head .row.wrap { width: 100%; justify-content: flex-start; }
  .seg { flex: 1; }
  .seg .seg-btn { flex: 1; text-align: center; padding: 6px 4px; }
  /* ← / picker / Today / → as a grid so the picker shrinks instead of
     shoving the arrows off-screen */
  .section-head .row.wrap > .row { flex: 1 1 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; }
  #pl-day { min-width: 0 !important; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ============================================================
   Mobile layer — phone-first fixes for the hosted site.
   Bottom tab bar, safe areas, iOS keyboard/zoom behavior,
   44px touch targets, touch affordances.
   ============================================================ */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { overscroll-behavior-y: none; } /* no accidental pull-to-refresh mid-gesture */
.view, .planner-cols { overscroll-behavior: contain; }
button, a, .day-card, .cal-cell, .sug-card, .tl-block, .result-item { -webkit-tap-highlight-color: transparent; }

/* one finger scrolls the page over maps; two fingers move the map */
.map-touch-hint {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(13,15,18,0.78); color: #fff; padding: 10px 16px;
  border-radius: 22px; font-size: 13px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.25s; z-index: 1000;
}
.map-touch-hint.show { opacity: 1; }
.toast-host { pointer-events: none; bottom: calc(24px + env(safe-area-inset-bottom)); }
.leg-strip { scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.leg-node { scroll-snap-align: start; }
.leaflet-popup-content a { display: inline-block; padding: 6px 4px; }

/* the 1-day "+ Add time block" shortcut above the timeline (phones only) */
.pl-mobile-tools { display: none; }

/* ---- bottom tab bar ---- */
.tabbar { display: none; }

@media (max-width: 920px) {
  /* tab bar replaces the hamburger drawer entirely */
  .menu-toggle { display: none; }
  .sidebar { display: none; }
  .tabbar {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: rgba(255,255,255,0.92);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
  }
  .tab-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: transparent; border: 0; color: var(--muted);
    padding: 6px 2px; border-radius: 10px; min-height: 52px;
    font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em;
  }
  .tab-btn .ico { font-size: 20px; line-height: 1; }
  .tab-btn.active { color: var(--accent-soft); background: var(--accent-dim); }

  /* content must clear the fixed bar (+ home indicator) */
  .view { padding-bottom: calc(24px + 66px + env(safe-area-inset-bottom)); }
  .toast-host { bottom: calc(80px + env(safe-area-inset-bottom)); }
  #chat-launcher { right: 14px; bottom: calc(82px + env(safe-area-inset-bottom)); }
  #chat-reload-banner { bottom: calc(82px + env(safe-area-inset-bottom)); }
  .topbar { padding-top: max(14px, env(safe-area-inset-top)); }
  .planner-cols { max-height: calc(100dvh - 264px); }

  /* iOS zooms the page when a focused control is under 16px — never zoom */
  input[type=text], input[type=number], input[type=date], input[type=time],
  select, textarea, .status-select, .inline-edit { font-size: 16px; }

  #btn-help { display: none; }
}

/* ---- "More" sheet ---- */
.more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.more-btn {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--r-sm);
  padding: 12px; min-height: 52px; font-size: 14px; font-weight: 600; color: var(--text); text-align: left;
}
.more-btn .ico { font-size: 17px; opacity: 0.85; width: 22px; text-align: center; }
.more-btn:active { background: var(--surface-2); }

/* ---- touch targets & affordances ---- */
@media (pointer: coarse) {
  .btn.sm { min-height: 44px; }
  .seg-btn { min-height: 40px; }
  .cat-tab { min-height: 40px; padding: 9px 14px; }
  .ghost-btn { min-height: 40px; padding: 8px 12px; }
  .status-select { min-height: 40px; padding: 8px 10px; }
  .dec-opt { min-height: 44px; }
  .ride-tag { padding: 8px 13px; }
  .nav-btn { padding: 12px 11px; }
  #pl-prev, #pl-next, #pl-today { min-height: 44px; min-width: 44px; }
  .modal-foot .btn { min-height: 44px; }
  .chat-ibtn { width: 40px; height: 40px; }
  .pack-item { min-height: 44px; }
  .pack-item input { width: 22px; height: 22px; }
  /* inline-editable fields need a visible affordance without hover */
  .inline-edit { border-color: var(--border-2); background: var(--bg-2); }
}

/* hover-only feedback must not stick after taps */
@media (hover: none) {
  .day-card:hover, .sug-card:hover { transform: none; border-color: var(--border); }
  .cal-cell:hover { transform: none; border-color: var(--border); }
  .cal-cell.today:hover { border-color: var(--accent-line); }
  table.tbl tbody tr:hover { background: transparent; }
  .btn:hover { filter: none; }
  .day-card:active, .cal-cell:active, .sug-card:active, .result-item:active { background: var(--surface-2); }
}

/* ---- small screens ---- */
@media (max-width: 560px) {
  /* modals hug the top so the iOS keyboard never hides fields or buttons */
  .modal-host { place-items: start center; padding: max(12px, env(safe-area-inset-top)) 12px 12px; }
  .modal { max-height: calc(100dvh - 110px); padding: 18px; }

  /* month calendar: just the shape of each day — details live in 1-day view */
  .cal-cell, .cal-cell.off { min-height: 56px; padding: 5px 6px; gap: 3px; }
  .cal-loc { display: none; }
  .cal-foot { display: none; }
  .cal-num { font-size: 13px; }

  /* maps: leave grabbable page around them so they're not a scroll trap */
  #map, #map-discover { height: 52dvh; min-height: 320px; }
  #trails-map { height: 260px !important; }

  /* trails table: drop low-value columns so Status + actions stay reachable */
  #trail-tbl { min-width: 470px; }
  #trail-tbl th:nth-child(2), #trail-tbl td:nth-child(2),
  #trail-tbl th:nth-child(4), #trail-tbl td:nth-child(4),
  #trail-tbl th:nth-child(6), #trail-tbl td:nth-child(6) { display: none; }

  .grid-4 { grid-template-columns: 1fr; }

  .pl-mobile-tools { display: flex; justify-content: flex-end; margin-bottom: 10px; }

  .topbar { padding-left: 14px; padding-right: 14px; }
  .topbar-trip h1 { font-size: 19px; }
}
