/* ==========================================================================
   Design tokens.

   Spacing scale: 4 / 8 / 12 / 16 / 20 / 24.
   Radius scale:  control 10 · card 12 · floating 16.
   Colour system: one meaning per colour, never decorative —
                  blue = route/itinerary · green = places · red = attention
                  purple = ideas · grey = reference · amber = needs action.
   ========================================================================== */
:root {
  --bg:        #f5f6f8;
  --panel:     #ffffff;
  --sunken:    #f2f4f7;
  --hover:     #edf0f4;
  --active:    #e9f0fd;
  --line:      #ebedf1;
  --line2:     #dfe3e9;
  --text:      #131820;
  --dim:       #59636f;
  --dim2:      #8d96a2;
  --accent:    #2f6df6;
  --accent-sc: #ffffff;
  --accent-bg: #eaf1ff;
  --route:     #2f6df6;
  --place:     #12855c;
  --attention: #d1495b;
  --idea:      #7c5cd6;
  --grey:      #98a2b3;
  --warn:      #a2660f;
  --warn-bg:   #fdf4e7;
  --ok:        #0b7a57;
  --ok-bg:     #eff9f5;
  --map-bg:    #eceff3;
  --casing:    #ffffff;
  --sh-sm:     0 1px 2px rgba(16,24,40,.06);
  --sh:        0 1px 2px rgba(16,24,40,.05), 0 6px 16px rgba(16,24,40,.08);
  --sh-lg:     0 2px 6px rgba(16,24,40,.06), 0 16px 40px rgba(16,24,40,.13);
  --tile-fx:   none;
  --r-ctl:     10px;
  --r-card:    12px;
  --r-float:   16px;
}

/* Dark: very dark blue-grey ground, elevated surfaces a step lighter, borders
   almost invisible. No pure black, no pure white. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #080b10; --panel: #10141b; --sunken: #171c25; --hover: #1c222c;
    --active: #182437; --line: #1b212b; --line2: #29313d;
    --text: #e9edf3; --dim: #98a3b1; --dim2: #69737f;
    --accent: #629bff; --accent-sc: #071021; --accent-bg: #16233a;
    --route: #629bff; --place: #35b489; --attention: #f0687d;
    --idea: #a58cf0; --grey: #78828f;
    --warn: #e0ac52; --warn-bg: #221a0d; --ok: #35b489; --ok-bg: #0e1f18;
    --map-bg: #12161d; --casing: #0a0d12;
    --sh-sm: 0 1px 2px rgba(0,0,0,.55);
    --sh: 0 1px 2px rgba(0,0,0,.5), 0 6px 16px rgba(0,0,0,.45);
    --sh-lg: 0 2px 6px rgba(0,0,0,.5), 0 16px 40px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --bg: #080b10; --panel: #10141b; --sunken: #171c25; --hover: #1c222c;
  --active: #182437; --line: #1b212b; --line2: #29313d;
  --text: #e9edf3; --dim: #98a3b1; --dim2: #69737f;
  --accent: #629bff; --accent-sc: #071021; --accent-bg: #16233a;
  --route: #629bff; --place: #35b489; --attention: #f0687d;
  --idea: #a58cf0; --grey: #78828f;
  --warn: #e0ac52; --warn-bg: #221a0d; --ok: #35b489; --ok-bg: #0e1f18;
  --map-bg: #12161d; --casing: #0a0d12;
  --sh-sm: 0 1px 2px rgba(0,0,0,.55);
  --sh: 0 1px 2px rgba(0,0,0,.5), 0 6px 16px rgba(0,0,0,.45);
  --sh-lg: 0 2px 6px rgba(0,0,0,.5), 0 16px 40px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
#sheetGrab { display: none; }
html, body { height: 100%; margin: 0; }
body {
  font-family: Inter, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.5;
  background: var(--bg); color: var(--text);
  overflow: hidden; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.85; stroke-linecap: round; stroke-linejoin: round; }
/* ic() emits a viewBox with no width/height. Inside a flex slot such an SVG
   collapses to 0x0 and disappears, so give every sizeless icon a default;
   the rules further down override it where a slot wants another size. */
svg:not([width]) { width: 15px; height: 15px; flex: 0 0 auto; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

#app { display: flex; height: 100dvh; }
#mapwrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--map-bg); }

/* ========================= sidebar ========================= */
#side {
  width: 380px; flex: 0 0 380px; height: 100%;
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 600;
}
#side.hidden { display: none; }

/* --- 1. trip identity --- */
#topbar { padding: 16px 20px 4px; }

/* The product signs the panel once, quietly, and then gets out of the way:
   the trip is the headline, not the app. */
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.brand-mark {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-sc);
}
.brand-mark svg { stroke-width: 2.1; }
.brand-name { font-size: 13px; font-weight: 600; letter-spacing: .01em; color: var(--text); }

.trip-row { position: relative; display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.trip-pick {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px;
  background: none; border: none; padding: 0; cursor: pointer; text-align: left;
  font-size: 21px; font-weight: 600; letter-spacing: -.022em; color: var(--text);
  line-height: 1.25;
}
#tripName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trip-pick .chev { flex: 0 0 auto; color: var(--dim2); transition: color .14s; }
.trip-pick:hover .chev { color: var(--text); }
.headbtns { display: flex; gap: 2px; flex: 0 0 auto; }
#side .sub { margin: 6px 0 0; color: var(--dim); font-size: 14px; }
#side .stats { margin: 3px 0 0; color: var(--dim2); font-size: 12.5px; }

.icon-btn {
  background: transparent; color: var(--dim2); border: 1px solid transparent;
  border-radius: var(--r-ctl); width: 30px; height: 30px; cursor: pointer;
  flex: 0 0 auto; transition: color .14s, background .14s; display: inline-flex;
  align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--text); background: var(--hover); }
.icon-btn.float {
  position: absolute; top: 16px; left: 16px; z-index: 700; width: 36px; height: 36px;
  background: var(--panel); border-color: var(--line); box-shadow: var(--sh);
}

/* --- 2. search --- */
.controls { padding: 12px 20px 10px; position: relative; }
.searchwrap { position: relative; }
.search-ico {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--dim2); pointer-events: none; transition: color .14s;
}
.searchwrap:focus-within .search-ico { color: var(--accent); }
#search {
  width: 100%; padding: 10px 12px 10px 36px; border-radius: var(--r-ctl); font-size: 14px;
  border: 1px solid transparent; background: var(--sunken); color: var(--text);
  transition: background .14s, border-color .14s, box-shadow .14s;
}
#search::placeholder { color: var(--dim2); }
#search:hover { background: var(--hover); }
#search:focus {
  outline: none; background: var(--panel);
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg);
}
#search::-webkit-search-cancel-button { filter: grayscale(1) opacity(.5); }

#results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 1100;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: var(--sh-lg); max-height: 340px; overflow-y: auto; padding: 6px;
}
.rgroup {
  font-size: 11px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--dim2); padding: 8px 8px 4px; font-weight: 500;
}
.ritem {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px; cursor: pointer; border-radius: var(--r-ctl);
}
.ritem:hover { background: var(--hover); }
.ritem .rmark {
  flex: 0 0 auto; width: 20px; height: 20px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; color: #fff; margin-top: 1px;
}
.ritem .rmark.add { background: var(--accent); color: var(--accent-sc); }
.ritem .rbody { min-width: 0; flex: 1; }
.ritem .rname { font-size: 14px; }
.ritem .rdetail { font-size: 12px; color: var(--dim2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rnote { padding: 10px; font-size: 13px; color: var(--dim2); line-height: 1.5; }

/* --- 3. primary controls, one coordinated group --- */
.toolbar { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 32px;
  padding: 0 12px; border-radius: var(--r-ctl); cursor: pointer;
  font-size: 13px; font-weight: 450; white-space: nowrap;
  background: var(--sunken); color: var(--dim); border: 1px solid transparent;
  transition: background .14s, color .14s;
}
.pill:hover { background: var(--hover); color: var(--text); }
.pill.on { background: var(--accent-bg); color: var(--accent); }
/* Three pills, three weights: to-book shouts, filters speaks, routes hums. */
.pill.quiet.on { background: var(--sunken); color: var(--accent); }
.pill.quiet.on::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex: 0 0 auto;
}
.pill.attention .count { color: var(--warn); }
.pill.attention.on { background: var(--warn-bg); color: var(--warn); }
.pill.attention.on .count { color: inherit; }
.pill:disabled { opacity: .55; cursor: default; }
.pill .count { font-variant-numeric: tabular-nums; font-weight: 500; }
.pill .dotsep { color: var(--dim2); }

/* Floats over the itinerary. In flow it ate the panel on a short window and
   pushed the editing footer off-screen. */
.popover {
  position: absolute; left: 20px; right: 20px; top: calc(100% - 4px); z-index: 1200;
  padding: 4px 14px 14px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--sh-lg);
  max-height: 62dvh; overflow-y: auto;
}
.fgroup { margin-top: 14px; }
.flabel {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--dim2); margin-bottom: 8px; font-weight: 500;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; padding: 5px 10px; border-radius: 999px; cursor: pointer;
  background: var(--panel); color: var(--dim2);
  border: 1px solid transparent; transition: background .14s, color .14s;
}
.chip:hover { color: var(--text); }
.chip.on { color: var(--accent); background: var(--accent-bg); }
.sw { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.sw-am { background: var(--attention); }
.sw-ge { background: var(--route); }

.tgl { font-size: 13px; color: var(--dim); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.tgl:hover { color: var(--text); }
.tgl input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; margin: 0; }
.tgl.big { font-size: 14px; color: var(--text); font-weight: 500; }
.link-btn {
  background: none; border: none; color: var(--accent); font-size: 12.5px;
  cursor: pointer; padding: 0;
}
.link-btn:hover { text-decoration: underline; }

/* ========================= trip check =========================
   Secondary by design: a single quiet row when collapsed, and it gets out of
   the way on its own once you start reading the itinerary. */
#tripCheck { padding: 0 20px 10px; }
.check-card { background: var(--sunken); border-radius: var(--r-card); }
.check-title {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 10px 12px; background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 13px; color: var(--dim); text-align: left;
  border-radius: var(--r-card); transition: color .14s;
}
.check-title:hover { color: var(--text); }
.check-title .cwarn { flex: 0 0 auto; color: var(--warn); display: flex; }
.check-title .cwarn svg { width: 14px; height: 14px; }
.check-title .cwarn.clear { color: var(--ok); }
.check-title .ctxt { flex: 1; min-width: 0; }
.check-title .cnum { color: var(--dim2); font-variant-numeric: tabular-nums; }
.check-title .cnum.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--warn-bg); color: var(--warn); font-size: 11.5px; font-weight: 600;
}
/* The header goes uppercase when open; the count should stay plain. */
.check-card:not(.shut) .check-title .cnum { text-transform: none; letter-spacing: 0; }
.check-title .ccar { flex: 0 0 auto; color: var(--dim2); transition: transform .2s ease; }
.check-card:not(.shut) .check-title .ccar { transform: rotate(180deg); }
.check-card:not(.shut) .check-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  font-weight: 500; color: var(--dim2); padding-bottom: 6px;
}
.check-card:not(.shut) .check-title .cwarn { display: none; }

.check-body {
  max-height: min(420px, 34dvh); overflow: hidden; opacity: 1;
  transition: max-height .2s ease, opacity .18s ease;
}
.check-card.shut .check-body { max-height: 0; opacity: 0; }
.check-rows { padding: 0 12px 10px; }
.check-row {
  display: flex; gap: 9px; align-items: flex-start;
  font-size: 13px; padding: 4px 6px; margin: 0 -6px; border-radius: 8px;
  color: var(--dim); line-height: 1.45;
}
.check-row .ci { flex: 0 0 auto; margin-top: 2px; display: flex; }
.check-row .ci svg { width: 14px; height: 14px; }
.check-row.warn .ci { color: var(--warn); }
.check-row.ok { color: var(--dim2); }
.check-row.ok .ci { color: var(--ok); opacity: .8; }
.check-row.clickable { cursor: pointer; }
.check-row.clickable:hover { background: var(--hover); color: var(--text); }
.check-row span:not(.ci):not(.cgo) { flex: 1; min-width: 0; }
/* Says "this takes you there" without adding another button. */
.cgo { flex: 0 0 auto; color: var(--dim2); opacity: 0; transition: opacity .14s, transform .14s; }
.cgo svg { width: 13px; height: 13px; }
.check-row.clickable:hover .cgo { opacity: 1; transform: translateX(2px); }
.check-sub {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--dim2); font-weight: 500; margin: 10px 0 2px; opacity: .8;
}

/* ========================= day list ========================= */
.dayctl {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 20px 8px; border-top: 1px solid var(--line);
}
.muted { font-size: 12.5px; color: var(--dim2); font-variant-numeric: tabular-nums; }
/* A filter state, not a problem — keep it quiet and on one line. */
.ctx-note {
  padding: 0 20px 8px; font-size: 12.5px; color: var(--dim);
  display: flex; align-items: baseline; gap: 10px;
}
.ctx-note span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-note .link-btn { color: var(--dim2); margin-left: auto; flex: 0 0 auto; white-space: nowrap; }
.ctx-note .link-btn:hover { color: var(--accent); }

#list { flex: 1; min-height: 88px; overflow-y: auto; overscroll-behavior: contain; padding: 6px 10px 16px; }
#list::-webkit-scrollbar { width: 10px; }
#list::-webkit-scrollbar-thumb {
  background: var(--line2); border-radius: 5px; border: 3px solid var(--panel);
}
#list::-webkit-scrollbar-thumb:hover { background: var(--dim2); }

/* Days are separated by space and a selected-state background, not by boxes. */
.day { border-radius: var(--r-card); position: relative; transition: background .16s; }
.day + .day { margin-top: 2px; }
.day.sel { background: var(--active); }
.day.sel::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 2px; border-radius: 2px; background: var(--accent);
}
/* A day tick is a map control, so an unticked day stays fully present in the
   column - only its content steps back, and the tick box never dims, because
   it is the thing you came back to click. */
.day.off .dh-main, .day.off .stops { opacity: .5; transition: opacity .16s; }
.day.off .dayhead:hover .dh-main { opacity: .8; }

.dayhead {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px; cursor: pointer; user-select: none; border-radius: var(--r-card);
}
.day:not(.sel) .dayhead:hover { background: var(--hover); }
.dayhead input {
  accent-color: var(--accent); width: 15px; height: 15px;
  cursor: pointer; margin: 4px 0 0; flex: 0 0 auto;
}
.dh-main { flex: 1; min-width: 0; }
.dnum {
  font-size: 12px; font-weight: 500; letter-spacing: .07em;
  text-transform: uppercase; color: var(--dim2);
}
.dtitle {
  font-size: 16.5px; font-weight: 600; letter-spacing: -.015em;
  margin-top: 3px; line-height: 1.3;
}
.dmeta { font-size: 12.5px; color: var(--dim); margin-top: 3px; font-variant-numeric: tabular-nums; }
.dmeta .sep { color: var(--dim2); margin: 0 5px; }
.dmeta .walk { color: var(--place); }
.dbed { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; margin-top: 6px; }
.dbed .dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; }
.dbed.booked { color: var(--ok); }
.dbed.tobook { color: var(--warn); }
.dbed.neutral { color: var(--dim2); }
.caret { color: var(--dim2); flex: 0 0 auto; margin-top: 4px; display: flex;
         transition: transform .2s ease; }
.caret svg { width: 16px; height: 16px; }
.day.collapsed .caret { transform: rotate(-90deg); }
.day.collapsed .stops { display: none; }

/* --- timeline --- */
.stops { padding: 0 12px 12px 14px; }
.tl { position: relative; padding-left: 20px; }
.tl::before {
  content: ""; position: absolute; left: 4px; top: 12px; bottom: 14px;
  width: 1.5px; background: var(--line2); border-radius: 1px;
}
.stop { position: relative; padding: 7px 8px 7px 2px; cursor: pointer; border-radius: 8px; }
.stop:hover { background: var(--hover); }
.stop.sel { background: var(--accent-bg); }
.stop::before {
  content: ""; position: absolute; left: -20px; top: 13px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--dot, var(--grey)); box-shadow: 0 0 0 3px var(--panel);
  transition: transform .14s;
}
.day.sel .stop::before { box-shadow: 0 0 0 3px var(--active); }
.stop.sel::before { transform: scale(1.3); box-shadow: 0 0 0 3px var(--accent-bg); }
.stop .sname { font-size: 14.5px; }
.stop.done .sname { text-decoration: line-through; color: var(--dim2); }
.stop .smeta { font-size: 12px; color: var(--dim2); margin-top: 2px; }
.stop .flag { color: var(--warn); }

.stayrow {
  display: flex; gap: 10px; align-items: flex-start;
  margin-top: 10px; padding: 10px 12px; border-radius: var(--r-ctl);
  background: var(--sunken); cursor: pointer; transition: background .14s;
}
.stayrow:hover { background: var(--hover); }
/* Only the unsolved case gets weight. A booked stay is settled business and
   was reading as the loudest thing in the sidebar. */
.stayrow.tobook { background: var(--warn-bg); }
.stayrow.booked { background: transparent; padding-left: 0; padding-right: 0; }
.stayrow.booked:hover { background: var(--hover); padding-left: 12px; padding-right: 12px; }
.stayrow .sicon { flex: 0 0 auto; margin-top: 1px; color: var(--dim2); display: flex; }
.stayrow.tobook .sicon { color: var(--warn); }
.stayrow.booked .sicon { color: var(--ok); }
.stayrow .sbody { flex: 1; min-width: 0; }
.stayrow .swhere { font-size: 13.5px; font-weight: 500; }
.stayrow .sstate { font-size: 12px; margin-top: 2px; color: var(--dim2); }
.stayrow.tobook .sstate { color: var(--warn); }
.stayrow.booked .sstate { color: var(--ok); }
.stayrow .snote { font-size: 12px; color: var(--dim); margin-top: 5px; line-height: 1.45; }
.stayrow .sbook {
  display: inline-block; margin-top: 6px; font-size: 12px;
  color: var(--accent); text-decoration: none;
}
.stayrow .sbook:hover { text-decoration: underline; }

/* The day's start point: quiet by default — it is derived, not a decision,
   until someone overrides it. */
.stayrow.startrow { background: transparent; padding-left: 0; padding-right: 0; }
.stayrow.startrow:hover { background: var(--hover); padding-left: 12px; padding-right: 12px; }
.stayrow.startrow .sicon { color: var(--route, var(--dim2)); }
.stayrow.startrow .swhere { font-weight: 400; color: var(--dim); }
.ed-hint { font-size: 12px; color: var(--dim2); margin: -4px 0 2px; line-height: 1.45; }

.dayact { margin-top: 10px; }
.gmaps {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--dim2); text-decoration: none; transition: color .14s;
}
.gmaps:hover { color: var(--accent); }
.gmaps svg { width: 13px; height: 13px; }

.empty { padding: 44px 24px; text-align: center; color: var(--dim2); }
.empty .etitle { font-size: 14.5px; color: var(--text); font-weight: 500; margin-bottom: 5px; }
.empty .esub { font-size: 13px; line-height: 1.55; }
.empty .link-btn { margin-top: 12px; }

/* ========================= footer ========================= */
#side footer { border-top: 1px solid var(--line); padding: 12px 20px; }
.row { display: flex; gap: 8px; align-items: center; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 13px; border-radius: var(--r-ctl); cursor: pointer;
  font-size: 13px; font-weight: 500; border: 1px solid transparent;
  text-decoration: none; transition: background .14s, filter .14s; white-space: nowrap;
}
.btn.primary { background: var(--accent); color: var(--accent-sc); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--sunken); color: var(--text); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { background: transparent; color: var(--attention); border-color: var(--line2); }
.btn.danger:hover { background: var(--attention); color: #fff; border-color: var(--attention); }
.btn.danger.solid { background: var(--attention); color: #fff; border-color: var(--attention); }
.btn.danger.solid:hover { filter: brightness(1.08); }
.btn.icon-only { flex: 0 0 auto !important; width: 34px; padding: 0; }
.btn:disabled { opacity: .5; cursor: default; }

.locked-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px;
  border-radius: 999px; cursor: pointer; border: none;
  background: var(--sunken); color: var(--dim2); font-size: 12.5px;
  transition: background .14s, color .14s;
}
.locked-chip:hover { background: var(--hover); color: var(--text); }
.locked-chip svg { width: 13px; height: 13px; }

/* Editing state reads as a state, not as another button. */
.editing-chip {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px; border-radius: 999px; cursor: pointer;
  border: none; background: var(--accent-bg); color: var(--accent);
  font-size: 12px; font-weight: 500; transition: background .14s, color .14s;
}
.editing-chip:hover { background: var(--attention); color: #fff; }
.editing-chip svg { width: 13px; height: 13px; }

/* ========================= menus ========================= */
.menu-wrap { position: relative; }
.menu {
  position: absolute; z-index: 1300; min-width: 208px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-card); box-shadow: var(--sh-lg);
  top: calc(100% + 6px); left: 0;
}
.menu.up { top: auto; bottom: calc(100% + 6px); }
.menu.right { top: 0; right: calc(100% + 8px); left: auto; }
.mitem {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: var(--r-ctl); cursor: pointer;
  background: none; border: none; text-align: left; font-size: 13.5px; color: var(--text);
}
.mitem:hover { background: var(--hover); }
.mitem.on { color: var(--accent); }
.mitem .mi { flex: 0 0 auto; color: var(--dim2); display: flex; }
.mitem.on .mi { color: var(--accent); }
.mitem .msub { display: block; font-size: 12px; color: var(--dim2); margin-top: 1px; }
.mitem .mbody { min-width: 0; flex: 1; }
.mlabel {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--dim2); padding: 8px 10px 4px; font-weight: 500;
}
.msep { height: 1px; background: var(--line); margin: 5px 0; }

/* ========================= map controls ========================= */
.mapctl {
  position: absolute; top: 16px; right: 16px; z-index: 700;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.ctl-group {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-ctl); box-shadow: var(--sh); overflow: visible;
  display: flex; flex-direction: column;
}
.ctl {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; color: var(--dim);
  transition: background .14s, color .14s; border-radius: var(--r-ctl); position: relative;
}
.ctl:hover { background: var(--hover); color: var(--text); }
.ctl-group .ctl + .ctl { border-top: 1px solid var(--line); border-radius: 0 0 var(--r-ctl) var(--r-ctl); }
.ctl-group .ctl:first-child { border-radius: var(--r-ctl) var(--r-ctl) 0 0; }
.ctl-group .ctl:only-child { border-radius: var(--r-ctl); }

/* Own tooltip — the native one is slow and looks like a browser control. */
.ctl[data-tip]::after {
  content: attr(data-tip); position: absolute; right: calc(100% + 8px); top: 50%;
  transform: translateY(-50%); background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--sh);
  font-size: 12px; padding: 5px 9px; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .14s .25s; z-index: 5;
}
.ctl[data-tip]:hover::after { opacity: 1; }

/* selected place panel */
#placePanel {
  position: absolute; left: 16px; bottom: 16px; z-index: 750; width: 312px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-float); box-shadow: var(--sh-lg); padding: 16px;
  animation: pop .16s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.pp-head { display: flex; align-items: flex-start; gap: 10px; }
.pp-icon {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.pp-icon svg { width: 15px; height: 15px; }
.pp-t { font-size: 16px; font-weight: 600; letter-spacing: -.015em; }
.pp-m { font-size: 12px; color: var(--dim2); margin-top: 2px; }
.pp-close { margin-left: auto; }
.pp-n { font-size: 13px; color: var(--dim); line-height: 1.55; margin-top: 8px; white-space: pre-wrap; }
/* A warning you can act on is a button, not a sentence. */
.pp-warn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  margin-top: 8px; padding: 8px 10px; border-radius: var(--r-ctl);
  background: var(--warn-bg); color: var(--warn); border: none; cursor: pointer;
  font-size: 12.5px; text-align: left; transition: background .14s;
}
.pp-warn:hover { background: color-mix(in srgb, var(--warn) 16%, var(--warn-bg)); }
.pp-warn > span:not(.pw-go) { flex: 1; min-width: 0; }
.pp-warn .pw-go { flex: 0 0 auto; font-weight: 600; }

.pp-stay {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 12px; padding: 8px 10px; border-radius: var(--r-ctl);
  background: var(--sunken); font-size: 12.5px; color: var(--dim);
}
.pp-stay .ps-ico { display: flex; flex: 0 0 auto; color: var(--dim2); }
.pp-stay .ps-state { font-weight: 500; }
.pp-stay .ps-price { opacity: .85; }
.pp-stay .ps-link { margin-left: auto; color: var(--accent); text-decoration: none; }
.pp-stay .ps-link:hover { text-decoration: underline; }
.pp-stay.booked { background: var(--ok-bg); color: var(--ok); }
.pp-stay.booked .ps-ico { color: var(--ok); }
.pp-stay.tobook { background: var(--warn-bg); color: var(--warn); }
.pp-stay.tobook .ps-ico { color: var(--warn); }
.pp-day {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 12px;
  font-size: 12.5px; color: var(--accent); cursor: pointer; white-space: nowrap;
}
.pp-day svg { width: 15px; height: 15px; flex: 0 0 auto; }
.pp-day:hover { text-decoration: underline; }
.pp-b { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.pp-b .btn { height: 31px; font-size: 12.5px; padding: 0 11px; }

/* ========================= map surface ========================= */
/* Esri's dark canvas is built as a chart backdrop, so it reads too dim for a
   map you navigate. Lift the ground a little and the label/road overlay a lot:
   cities, borders and roads become legible while the map stays properly dark. */
.leaflet-tile-pane .base-dark { filter: brightness(1.1) contrast(1.06); }
.leaflet-tile-pane .ref-dark { filter: brightness(1.5) contrast(1.02) saturate(1.1); }
body[data-base="Satellite"] .leaflet-tile-pane { filter: brightness(1.05); }

/* ========================= markers =========================
   Weight follows meaning: route stops read first, places and ideas sit back,
   reference pins are nearly silent, and the selection always wins. */
.pin-wrap { display: flex; align-items: flex-end; justify-content: center; }
.pin {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg); border: 2px solid var(--casing);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
  transition: transform .14s ease, opacity .14s ease, box-shadow .14s ease;
}
.pin > * { transform: rotate(45deg); }
.pin .glyph { font-size: 11px; line-height: 1; color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; }
.pin svg { width: 13px; height: 13px; color: #fff; stroke-width: 2.3; }
/* secondary: places, ideas — present but not competing with the route */
.pin.soft { width: 21px; height: 21px; opacity: .92; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.pin.soft svg { width: 11px; height: 11px; }
/* reference: banned, cut, out of range */
.pin.quiet { width: 17px; height: 17px; opacity: .72; box-shadow: none; border-width: 1.5px; }
.pin.quiet svg { width: 9px; height: 9px; stroke-width: 2.6; }
.pin.dim { opacity: .26; }
.pin.needs { box-shadow: 0 0 0 2.5px var(--warn); }
.pin.done { opacity: .35; }
.pin:hover, .pin.hot { transform: rotate(-45deg) scale(1.14); z-index: 900; opacity: 1; }
.pin.hot { box-shadow: 0 0 0 3px var(--accent-bg), 0 2px 6px rgba(0,0,0,.35); }
.pin.sel {
  transform: rotate(-45deg) scale(1.28); opacity: 1;
  box-shadow: 0 0 0 4px var(--accent-bg), 0 0 0 2px var(--accent), 0 4px 10px rgba(0,0,0,.4);
  z-index: 1000;
}

.marker-cluster {
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  border: 1.5px solid var(--line2);
  border-radius: 50%; color: var(--dim); font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.3); transition: transform .14s, border-color .14s;
}
/* Route-stop clusters carry the itinerary, so they keep the route colour;
   everything else clusters quietly behind them. */
.marker-cluster.c-stop {
  border-color: color-mix(in srgb, var(--route) 60%, transparent);
  color: var(--route);
}
.marker-cluster.c-place {
  background: color-mix(in srgb, var(--panel) 78%, transparent);
  border-style: dashed; border-color: var(--line2);
  font-weight: 500; box-shadow: none;
}
.marker-cluster div { background: none; width: auto; height: auto; margin: 0; }
.marker-cluster span { font-size: 12px; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.marker-cluster.c-lg span { font-size: 13px; }
.marker-cluster:hover { transform: scale(1.06); border-color: var(--accent); color: var(--accent); }

.leaflet-container { font-family: inherit; background: var(--map-bg); }
.leaflet-control-attribution {
  background: color-mix(in srgb, var(--panel) 82%, transparent) !important;
  color: var(--dim2) !important; font-size: 10.5px; border-radius: 8px 0 0 0; padding: 2px 7px;
}
.leaflet-control-attribution a { color: var(--dim) !important; }
.route-tip {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--r-ctl); box-shadow: var(--sh); font-size: 12.5px;
  padding: 8px 11px; white-space: nowrap;
}
.route-tip::before { display: none; }

/* ========================= drawers ========================= */
.drawer {
  position: fixed; top: 0; right: 0; width: 380px; height: 100dvh;
  background: var(--panel); border-left: 1px solid var(--line);
  z-index: 1400; display: flex; flex-direction: column; box-shadow: var(--sh-lg);
  animation: slide .18s ease;
}
@keyframes slide { from { transform: translateX(14px); opacity: .6; } to { transform: none; opacity: 1; } }
#scrim { position: fixed; inset: 0; background: rgba(6,9,14,.4); z-index: 1350; }
.ed-head {
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
}
.ed-head strong { font-size: 15px; font-weight: 600; display: block; }
.ed-ident { min-width: 0; }
/* An editor should name what it is editing, not just that it is an editor. */
.ed-sub {
  display: block; font-size: 12.5px; color: var(--dim2); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ed-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.ed-body label {
  display: block; font-size: 11px; color: var(--dim2); margin-bottom: 14px;
  text-transform: uppercase; letter-spacing: .06em; font-weight: 500;
}
.ed-body label.inline {
  display: flex; gap: 8px; align-items: center; font-size: 13px;
  text-transform: none; letter-spacing: 0; color: var(--dim); font-weight: 400;
}
.ed-body input, .ed-body select, .ed-body textarea {
  width: 100%; margin-top: 6px; padding: 9px 11px; font-size: 14px;
  background: var(--panel); text-transform: none; letter-spacing: 0; font-weight: 400;
  border: 1px solid var(--line2); border-radius: var(--r-ctl); transition: .14s;
}
.ed-body input:focus, .ed-body select:focus, .ed-body textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg);
}
.ed-body textarea { resize: vertical; line-height: 1.5; }
/* The generic field rule above would stretch a checkbox to the full row and
   shove its label to the far edge. */
.ed-body input[type="checkbox"] {
  width: 15px; height: 15px; flex: 0 0 auto; margin: 0; accent-color: var(--accent);
}
.two { display: flex; gap: 10px; }
.two label { flex: 1; }

/* Progressive disclosure inside the editors: quiet section headings, and the
   fields nobody should need day to day tucked behind Advanced. */
.ed-sect.first { margin-top: 0; padding-top: 0; border-top: none; }
.ed-sect {
  margin: 4px 0 12px; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--dim2); font-weight: 500;
}
.ed-body .btn.wide { width: 100%; margin-bottom: 14px; }
.ed-body .tgl.gap { margin-bottom: 14px; }
.ed-adv { margin-top: 4px; }
.ed-adv > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--dim2); padding: 4px 0; user-select: none;
}
.ed-adv > summary::-webkit-details-marker { display: none; }
.ed-adv > summary::before {
  content: ""; width: 6px; height: 6px; flex: 0 0 auto;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); transition: transform .18s;
}
.ed-adv[open] > summary::before { transform: rotate(45deg); }
.ed-adv > summary:hover { color: var(--text); }
.ed-adv .two { margin-top: 12px; }

.st-state {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
  padding: 10px 12px; border-radius: var(--r-ctl);
  font-size: 13px; font-weight: 500; background: var(--sunken); color: var(--dim);
}
.st-state .sti { display: flex; flex: 0 0 auto; }
.st-state .sti svg { width: 15px; height: 15px; }
.st-state.booked { background: var(--ok-bg); color: var(--ok); }
.st-state.tobook { background: var(--warn-bg); color: var(--warn); }
.ed-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 9px; }
.ed-foot .btn { flex: 1; }

/* ========================= confirm dialog ========================= */
.dialog {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 1500; width: min(380px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-float); box-shadow: var(--sh-lg); padding: 20px;
  animation: pop .16s ease;
}
.dialog strong { display: block; font-size: 16px; font-weight: 600; letter-spacing: -.015em; }
.dialog p { margin: 8px 0 0; font-size: 13.5px; color: var(--dim); line-height: 1.55; }
.cf-b { display: flex; gap: 9px; margin-top: 20px; }
.cf-b .btn { flex: 1; }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; max-width: min(460px, calc(100vw - 32px));
  background: var(--text); color: var(--panel); padding: 11px 18px;
  border-radius: var(--r-ctl); z-index: 2000; font-size: 13px; box-shadow: var(--sh-lg);
}
#toast.err { background: var(--attention); color: #fff; }
.toast-act {
  flex: 0 0 auto; background: none; border: none; cursor: pointer; padding: 0;
  font-size: 13px; font-weight: 600; color: inherit; text-decoration: underline;
  text-underline-offset: 3px; opacity: .85;
}
.toast-act:hover { opacity: 1; }
body.adding #map { cursor: crosshair; }

/* Leave the Leaflet panes alone — their zoom/pan animations are driven by
   transitionend, and overriding the duration there breaks the map. */
@media (prefers-reduced-motion: reduce) {
  #app *:not(.leaflet-pane):not(.leaflet-pane *), .drawer, .drawer *, #toast {
    animation-duration: .01ms !important; transition-duration: .01ms !important;
  }
}


/* ========================= editor tabs =========================
   Place and Stay are two faces of the same night. Only one is ever mounted;
   the tabs say the other one exists. */
.ed-tabs { display: flex; gap: 2px; padding: 8px 20px 0; border-bottom: 1px solid var(--line); }
.ed-tab {
  position: relative; background: none; border: none; cursor: pointer;
  padding: 7px 12px 10px; font-size: 13px; color: var(--dim2);
  border-radius: var(--r-ctl) var(--r-ctl) 0 0; transition: color .14s;
}
.ed-tab:hover { color: var(--text); }
.ed-tab.on { color: var(--text); font-weight: 500; }
.ed-tab.on::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px;
  height: 2px; border-radius: 2px 2px 0 0; background: var(--accent);
}

/* ========================= position editing =========================
   Moving a pin is a mode with a way in and a way out, not a pair of number
   fields. The map keeps working; everything except the live pin steps back. */
.adjust-bar {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 20px;
  z-index: 800; display: flex; align-items: center; gap: 14px;
  padding: 10px 12px 10px 14px; max-width: calc(100% - 32px);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-float); box-shadow: var(--sh-lg); animation: pop .16s ease;
}
.adjust-bar .ab-ico { flex: 0 0 auto; display: flex; color: var(--accent); }
.adjust-bar .ab-body { display: flex; flex-direction: column; min-width: 0; }
.adjust-bar .ab-body strong {
  font-size: 13.5px; font-weight: 600; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.adjust-bar .ab-sub { font-size: 12px; color: var(--dim2); }
.adjust-bar .btn { flex: 0 0 auto; height: 32px; font-size: 12.5px; }

body.adjusting #map { cursor: grab; }
body.adjusting .pin:not(.adjust) { opacity: .3; }
.pin.adjust {
  transform: rotate(-45deg) scale(1.3); opacity: 1; z-index: 1200;
  animation: adjustPulse 1.9s ease-in-out infinite;
}
/* One pin, one shadow animation - cheap enough not to cost the map anything. */
@keyframes adjustPulse {
  0%, 100% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 34%, transparent),
                         0 4px 12px rgba(0,0,0,.45); }
  50%      { box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 10%, transparent),
                         0 4px 12px rgba(0,0,0,.45); }
}

/* ========================= unlock ========================= */
#unlockBox { width: min(360px, calc(100vw - 32px)); }
.ul-mark {
  width: 34px; height: 34px; border-radius: 11px; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-bg); color: var(--accent);
}
.ul-field {
  display: block; margin-top: 16px; font-size: 11px; color: var(--dim2);
  text-transform: uppercase; letter-spacing: .06em; font-weight: 500;
}
.ul-field input {
  width: 100%; margin-top: 6px; padding: 9px 11px; font-size: 14px;
  background: var(--panel); color: var(--text);
  text-transform: none; letter-spacing: 0; font-weight: 400;
  border: 1px solid var(--line2); border-radius: var(--r-ctl); transition: .14s;
}
.ul-field input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg);
}

/* ========================= responsive ========================= */
/* Narrow desktop: the sidebar gives up width, the itinerary keeps its size. */
@media (max-width: 1080px) and (min-width: 781px) {
  #side { width: 340px; flex: 0 0 340px; }
  #topbar { padding: 18px 16px 4px; }
  .controls { padding: 14px 16px 12px; }
  #tripCheck { padding: 0 16px 12px; }
  .dayctl, .ctx-note { padding-left: 16px; padding-right: 16px; }
  .popover { left: 16px; right: 16px; }
  #side footer { padding: 12px 16px; }
  #list { padding: 6px 8px 16px; }
}

/* Short windows: the header keeps every line the spec asks for, but gives the
   itinerary back the room it was spending on air. */
@media (min-width: 781px) and (max-height: 740px) {
  #topbar { padding-top: 12px; }
  .trip-row { margin-top: 8px; }
  #side .sub { margin-top: 4px; }
  .controls { padding-top: 8px; padding-bottom: 8px; }
  .toolbar { margin-top: 8px; }
  #tripCheck { padding-bottom: 8px; }
  .check-title { padding-top: 8px; padding-bottom: 8px; }
  .dayctl { padding-top: 5px; padding-bottom: 6px; }
  #list { padding-top: 2px; }
}

/* Mobile: map first, sidebar becomes a bottom sheet with snap points. */
@media (max-width: 780px) {
  #app { flex-direction: column-reverse; }
  #mapwrap { flex: 1 1 auto; min-height: 0; }
  #side {
    width: 100%; flex: 0 0 54dvh; height: 54dvh; overflow: hidden;
    border-right: none; border-top: 1px solid var(--line);
    border-radius: var(--r-float) var(--r-float) 0 0;
    box-shadow: 0 -6px 24px rgba(0,0,0,.25); position: relative;
  }
  #sheetGrab {
    display: block; position: absolute; top: 0; left: 0; right: 0; height: 18px;
    background: none; border: none; cursor: pointer; z-index: 2;
  }
  #sheetGrab::after {
    content: ""; position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 4px; border-radius: 2px; background: var(--line2);
  }
  #side.sheet-peek { flex-basis: 136px; height: 136px; }
  #side.sheet-tall { flex-basis: 86dvh; height: 86dvh; }
  #topbar { padding: 18px 16px 2px; }
  .trip-pick { font-size: 19px; }
  #side .sub { font-size: 13px; }
  .controls { padding: 12px 16px 10px; }
  #tripCheck { padding: 0 16px 10px; }
  .dayctl, .ctx-note { padding-left: 16px; padding-right: 16px; }
  #list { padding: 4px 8px 12px; }
  #side footer { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
  .popover { left: 16px; right: 16px; max-height: 46dvh; }
  .drawer { width: 100%; }
  .icon-btn.float { top: auto; bottom: 16px; left: 16px; }
  /* The map area is short on a phone; a vertical stack spills onto the sheet. */
  .mapctl { top: 12px; right: 12px; flex-direction: row; align-items: flex-start; }
  .ctl-group { flex-direction: row; }
  .ctl-group .ctl + .ctl {
    border-top: none; border-left: 1px solid var(--line);
    border-radius: 0 var(--r-ctl) var(--r-ctl) 0;
  }
  .ctl-group .ctl:first-child { border-radius: var(--r-ctl) 0 0 var(--r-ctl); }
  .ctl[data-tip]::after { display: none; }
  .menu.right { top: calc(100% + 6px); right: 0; left: auto; }
  #placePanel { left: 12px; right: 12px; bottom: 12px; width: auto; }
  .adjust-bar { left: 12px; right: 12px; bottom: 12px; transform: none; max-width: none; }
  .ed-tabs { padding-left: 16px; padding-right: 16px; }
  .btn { height: 36px; }
  .pill { height: 34px; }
}
