/* ==========================================================================
   방콕 3D 동선 — components
   Needs tokens.css first. Phone-first; the desktop layout switches on at an
   #app width of 861px (map3d.js treats innerWidth <= 860 as "mobile").

   Responsive rules use container queries on #app, not @media, so the same CSS
   works full-screen and inside the prototype's device frames. #app must be a
   size container (set below) and every height is a % of #app, never vh/dvh.

   Class index (★ = markup rendered by ui.js/map3d.js; keep these names)
   Shell      #app[data-sheet=peek|half|full][data-view=day|overview]
              .topbar .brand .brand-mark .plan-chip(-tag|-text|-name|-sub|-caret)
              .icon-btn .panel-reopen .scrim
   Sheet      #panel[data-seg=timeline|slots] .sheet-handle .panel-scroll
              .overview-note .block .sec-head .hint .text-btn .seg .seg-tab .seg-panel
              .panel-foot
   Day        ★.days ★.day-tab(.d .w .k .dot.warn|.error|.empty) .day-tab.is-today
              ★.day-head ★.day-title(.big .dow .kind) ★.stats
              .next-up .nu(-when|-label|-time|-pin|-main|-name|-leg|-go)
              ★.issues ★.issue.ok|.warn|.error|.info ★.ic
   Timeline   ★.timeline ★.tl-row(.first .last .tl-leg .tl-gap) ★.tl-time ★.tl-rail
              ★.tl-node(.landmark .lodging .air) ★.tl-num ★.tl-body ★.tl-stop ★.tl-name
              ★.tl-sub ★.tl-note ★.tl-badges ★.leg-line ★.mode-tag(.walk) ★.mono
              .tl-row.is-past .tl-row.is-next (shell.js, live trip day only)
   Blocks     ★.slot ★.slot-label(.t) ★.blk ★.blk-title ★.blk-sum ★.blk-meta ★.blk-actions
              ★.blk-empty ★.cand-list ★.cand(.ct .cs)[aria-current] ★.pill(.err .warn .info .gold)
   Plan       .plan-sheet .plan-head .plan-scroll ★.chips ★.chip(.tag .rank)[aria-pressed]
              ★.lodging-detail(.pc)
   Map UI     .map-controls ★.ctl(.primary .active) .ctl-label .ctl-seg .layers-pop
              ★.ctl-group ★.toggle .map-key .map-key-item ★.legend(.lg .sw .sw.walk)
   Details    live in explore.css (drawer, rail, filter bar); this file keeps the v1 parts
   Overlays   ★.modal ★.modal-box ★.modal-close ★.modal-row ★.toast
   Markers    ★.mk ★.mk-stop ★.mk-lodging ★.mk-air ★.mk.landmark ★.mk-label(.mk-hide)
              ★.mk-pin ★.no-labels  .mk[aria-current] (optional hook)
   Utilities  ★.sr-only ★.muted ★.small ★.th ★.mono
   ========================================================================== */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ko);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;          /* Korean: never split inside a word */
  overflow-wrap: break-word;     /* long Latin names / URLs still wrap */
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--muted); }
.small { font-size: var(--fs-xs); }
.th { font-family: var(--font-th); }
.mono { font-variant-numeric: tabular-nums; }
svg { flex: none; }

/* ---------- Shell ---------- */
#app { position: fixed; inset: 0; overflow: hidden; container: app / size; }
#globe { position: absolute; inset: 0; z-index: var(--z-map); background: var(--map-bg, oklch(0.935 0.012 85)); }

.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  inline-size: var(--tap); block-size: var(--tap);
  padding: 0;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  font-size: 17px; font-weight: var(--fw-semi); line-height: 1;
  transition: background var(--dur-fast) var(--ease-standard);
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn:active { background: var(--border); }

/* Top bar: floating on phones, the header card of the left column on desktop */
.topbar {
  position: absolute; z-index: var(--z-topbar);
  top: calc(var(--safe-top) + 8px); left: var(--edge); right: var(--edge);
  display: flex; align-items: center; gap: var(--sp-2);
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-standard);
}
.topbar > * { pointer-events: auto; }
.topbar .icon-btn { background: var(--surface-glass); box-shadow: var(--shadow-1); backdrop-filter: blur(8px); }
.topbar .icon-btn:hover { background: var(--surface-3); }
.brand { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.brand h1 { margin: 0; font-size: var(--fs-xl); font-weight: var(--fw-bold); letter-spacing: -0.01em; line-height: var(--lh-tight); }
.brand .sub { margin: 0; color: var(--fg-2); font-size: var(--fs-xs); line-height: var(--lh-snug); }
.brand-mark { color: var(--gold); }
#btn-collapse { display: none; }

.plan-chip {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: var(--sp-2);
  min-block-size: var(--tap);
  padding: 4px 12px 4px 6px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface-glass);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-1);
  text-align: left;
  transition: background var(--dur-fast) var(--ease-standard);
}
.plan-chip:hover { background: var(--surface-3); }
.plan-chip-tag {
  flex: none; display: grid; place-items: center;
  inline-size: 34px; block-size: 34px; border-radius: var(--r-pill);
  background: var(--inverse-bg); color: var(--inverse-fg);
  font-family: var(--font-num); font-weight: var(--fw-bold); font-size: var(--fs-lg);
}
.plan-chip-tag.is-mixed { font-family: var(--font-ko); font-size: var(--fs-2xs); font-weight: var(--fw-semi); }
.plan-chip-text { display: grid; min-width: 0; line-height: 1.25; }
.plan-chip-name, .plan-chip-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-chip-name { font-weight: var(--fw-semi); font-size: var(--fs-md); }
.plan-chip-sub { font-size: var(--fs-xs); color: var(--fg-2); }
.plan-chip-caret { margin-left: auto; color: var(--fg-2); }

.scrim { position: absolute; inset: 0; z-index: var(--z-scrim); background: var(--scrim); animation: fade-in var(--dur-base) var(--ease-standard); }

/* ---------- Sheet (#panel) ---------- */
#app { --sheet-h: var(--sheet-half); }
#app[data-sheet="peek"] { --sheet-h: var(--sheet-peek); }
#app[data-sheet="full"] { --sheet-h: var(--sheet-full); }

#panel {
  position: absolute; z-index: var(--z-panel);
  left: 0; right: 0; bottom: 0;
  block-size: var(--sheet-h);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-3);
  overflow: hidden;
  transition: block-size var(--dur-slow) var(--ease-sheet);
}
#panel.is-dragging { transition: none; }
#panel.collapsed { display: none; }

.sheet-handle {
  position: relative; z-index: 3; flex: none;
  display: block; inline-size: 100%; block-size: 30px;
  padding: 0; border: 0; background: transparent;
  touch-action: none; cursor: grab;
}
.sheet-handle::before {
  content: ''; position: absolute; left: 50%; top: 10px; translate: -50% 0;
  inline-size: 40px; block-size: 5px; border-radius: 3px;
  background: var(--border-strong);
  transition: background var(--dur-fast);
}
.sheet-handle::after { content: ''; position: absolute; inset: 0 0 -14px; } /* 44px hit area */
.sheet-handle:hover::before { background: var(--muted); }
.sheet-handle:focus-visible { outline-offset: -4px; border-radius: var(--r-md); }

.panel-scroll {
  flex: 1; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  padding-bottom: calc(var(--sp-6) + var(--safe-bottom));
  scroll-padding-top: 76px;
}

.block { padding: var(--sp-2) var(--sp-4) var(--sp-3); }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.sec-head h2, .sec-head h3 { margin: 0; font-size: var(--fs-xs); font-weight: var(--fw-semi); color: var(--fg-2); letter-spacing: 0.02em; }
.hint { margin: 0; color: var(--fg-2); font-size: var(--fs-sm); line-height: var(--lh-snug); text-wrap: pretty; }
.text-btn {
  display: inline-flex; align-items: center; gap: 4px;
  min-block-size: var(--tap); padding: 0 var(--sp-2);
  border: 0; border-radius: var(--r-sm); background: none;
  color: var(--accent-text); font-weight: var(--fw-semi); font-size: var(--fs-sm);
}
.text-btn:hover { background: var(--accent-soft); }

.overview-note {
  display: none;
  margin: 0 var(--sp-4) var(--sp-2);
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: var(--fs-sm); color: var(--fg-2);
  align-items: center; justify-content: space-between; gap: var(--sp-2);
}
#app[data-view="overview"] .overview-note { display: flex; }

/* Segmented control: timeline / blocks */
.seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  margin: var(--sp-3) var(--sp-4) var(--sp-2);
  padding: 3px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.seg-tab {
  min-block-size: var(--tap);
  border: 0; border-radius: 9px; background: transparent;
  color: var(--fg-2); font-weight: var(--fw-semi); font-size: var(--fs-sm);
  transition: background var(--dur-fast) var(--ease-standard);
}
.seg-tab:hover { background: var(--surface-3); color: var(--fg); }
.seg-tab[aria-selected="true"] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-1); }
#panel[data-seg="timeline"] .seg-panel[data-seg-panel="slots"],
#panel[data-seg="slots"] .seg-panel[data-seg-panel="timeline"] { display: none; }
.seg-panel > .hint { margin: 0 0 var(--sp-3); font-size: var(--fs-xs); color: var(--muted); }

.panel-foot {
  display: grid; gap: 6px;
  margin: var(--sp-4) var(--sp-4) 0; padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  font-size: var(--fs-2xs); line-height: var(--lh-snug); color: var(--muted);
}
.panel-foot a { color: var(--fg-2); }

.panel-reopen {
  position: absolute; z-index: var(--z-panel);
  left: var(--edge); bottom: calc(var(--safe-bottom) + var(--edge));
  min-block-size: var(--tap); padding: 0 var(--sp-4);
  border-radius: var(--r-pill); border: 1px solid var(--border);
  background: var(--surface); color: var(--fg); font-weight: var(--fw-semi);
  box-shadow: var(--shadow-2);
}
.panel-reopen:hover { background: var(--surface-3); }

/* ---------- Day tabs ★ ---------- */
.days {
  position: sticky; top: 0; z-index: 2;
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px;
  padding: 0 var(--sp-2) var(--sp-2);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.day-tab {
  position: relative;
  display: grid; justify-items: center; align-content: center;
  min-block-size: 56px; padding: 6px 0 7px;
  border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--fg);
  transition: background var(--dur-fast) var(--ease-standard);
}
.day-tab .d { font-family: var(--font-num); font-weight: var(--fw-semi); font-size: var(--fs-lg); line-height: 1.15; font-variant-numeric: tabular-nums; }
.day-tab .w { font-size: var(--fs-2xs); line-height: 1.35; color: var(--fg-2); }
.day-tab .k { font-size: var(--fs-2xs); line-height: 1.35; color: var(--muted); white-space: nowrap; }
.day-tab:hover { background: var(--surface-3); }
.day-tab[aria-selected="true"] { background: var(--inverse-bg); color: var(--inverse-fg); }
.day-tab[aria-selected="true"] .w,
.day-tab[aria-selected="true"] .k { color: var(--inverse-fg); }
/* Status dot: quiet when the day is fine, loud only for warnings and closed-day conflicts */
.day-tab .dot { position: absolute; top: 5px; right: 5px; inline-size: 8px; block-size: 8px; border-radius: 50%; display: none; }
.day-tab .dot.warn  { display: block; background: var(--warn-dot); box-shadow: 0 0 0 2px var(--surface); }
.day-tab .dot.error { display: block; background: var(--err);      box-shadow: 0 0 0 2px var(--surface); }
.day-tab .dot.empty { display: block; box-shadow: inset 0 0 0 1.5px var(--muted); }
.day-tab[aria-selected="true"] .dot.warn,
.day-tab[aria-selected="true"] .dot.error { box-shadow: 0 0 0 2px var(--inverse-bg); }
.day-tab.is-today::after {
  content: ''; position: absolute; left: 50%; bottom: 3px; translate: -50% 0;
  inline-size: 14px; block-size: 3px; border-radius: 2px; background: var(--accent);
}
/* Overview: each tab carries its day colour, doubling as the map legend */
.day-tab:nth-child(1) { --day-c: var(--day-1); }  .day-tab:nth-child(2) { --day-c: var(--day-2); }
.day-tab:nth-child(3) { --day-c: var(--day-3); }  .day-tab:nth-child(4) { --day-c: var(--day-4); }
.day-tab:nth-child(5) { --day-c: var(--day-5); }  .day-tab:nth-child(6) { --day-c: var(--day-6); }
.day-tab:nth-child(7) { --day-c: var(--day-7); }
#app[data-view="overview"] .day-tab::before {
  content: ''; position: absolute; left: 9px; right: 9px; bottom: 2px;
  block-size: 4px; border-radius: 2px; background: var(--day-c);
}
#app[data-view="overview"] .day-tab[aria-selected="true"] { background: var(--surface-3); color: var(--fg); }
#app[data-view="overview"] .day-tab[aria-selected="true"] :is(.w, .k) { color: var(--fg-2); }

/* ---------- Day summary ★ ---------- */
.day-head { display: grid; gap: 6px; padding: var(--sp-3) var(--sp-4) var(--sp-2); }
.day-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px var(--sp-2); }
.day-title .big { font-family: var(--font-num); font-weight: var(--fw-bold); font-size: var(--fs-3xl); line-height: 1; font-variant-numeric: tabular-nums; }
.day-title .dow { font-size: var(--fs-lg); font-weight: var(--fw-semi); }
.day-title .kind {
  align-self: center;
  padding: 1px 8px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--fg-2);
}
.stats { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: var(--fs-sm); color: var(--fg-2); }
.stats span { white-space: nowrap; }
.stats b { font-weight: var(--fw-semi); font-size: var(--fs-lg); color: var(--fg); font-variant-numeric: tabular-nums; }
.day-head .hint { margin-top: 2px; }

/* Next stop (shell.js derives it from #timeline) */
.next-up { padding: 0 var(--sp-4) var(--sp-2); }
.nu {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--sp-3);
  inline-size: 100%; min-block-size: 58px;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--fg); text-align: left;
  transition: background var(--dur-fast) var(--ease-standard);
}
button.nu:hover { background: var(--surface-3); }
.nu-when { display: grid; justify-items: start; min-inline-size: 48px; line-height: 1.15; }
.nu-label { font-size: var(--fs-2xs); font-weight: var(--fw-semi); color: var(--accent-text); }
.nu-time { font-family: var(--font-num); font-weight: var(--fw-semi); font-size: 19px; font-variant-numeric: tabular-nums; }
.nu-main { display: grid; gap: 3px; min-width: 0; }
.nu-name { display: flex; align-items: center; gap: 6px; font-weight: var(--fw-semi); font-size: var(--fs-lg); line-height: var(--lh-snug); min-width: 0; }
.nu-name > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nu-leg { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; font-size: var(--fs-xs); color: var(--fg-2); }
.nu-leg b { font-weight: var(--fw-semi); color: var(--fg); font-variant-numeric: tabular-nums; }
.nu-pin {
  flex: none; display: inline-grid; place-items: center;
  inline-size: 20px; block-size: 20px; border-radius: 50%;
  background: var(--fg); color: var(--surface);
  font-family: var(--font-num); font-weight: var(--fw-bold); font-size: 11px; line-height: 1;
}
.nu-pin.landmark { background: var(--gold); color: var(--mk-on); }
.nu-pin.lodging, .nu-pin.air { border-radius: 6px; background: var(--mk-lodging); color: var(--mk-on); font-family: var(--font-ko); font-size: 10px; }
.nu-pin.air { background: var(--mk-air); }
.nu-go { color: var(--muted); }

/* ---------- Issues ★ ---------- */
.issues-block { padding: var(--sp-1) var(--sp-4) 0; }
.issues-block .sec-head { display: none; }
.issues-block:has(.issue:not(.ok)) .sec-head { display: flex; }
.issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.issue {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 10px 12px; border-radius: var(--r-md);
  font-size: var(--fs-sm); line-height: var(--lh-snug); color: var(--fg);
}
.issue .ic {
  display: grid; place-items: center;
  inline-size: 20px; block-size: 20px; border-radius: 50%;
  font-size: 12px; font-weight: var(--fw-bold); line-height: 1;
  color: var(--surface);
}
.issue.error { background: var(--err-soft); }   .issue.error .ic { background: var(--err); }
.issue.warn  { background: var(--warn-soft); }  .issue.warn .ic  { background: var(--warn); }
.issue.info  { background: var(--surface-2); }  .issue.info .ic  { background: var(--info); }
.issue.ok { grid-template-columns: 16px minmax(0, 1fr); gap: 8px; align-items: center; padding: 2px 0; font-size: var(--fs-xs); color: var(--fg-2); }
.issue.ok .ic { inline-size: 16px; block-size: 16px; font-size: 10px; background: var(--ok); }

/* ---------- Timeline ★ (transit-diagram rail) ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.tl-row { display: grid; grid-template-columns: 46px 26px minmax(0, 1fr); column-gap: 10px; }
.tl-time {
  padding-top: 11px; text-align: right;
  font-family: var(--font-num); font-weight: var(--fw-semi); font-size: var(--fs-md);
  line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--fg);
}
.tl-rail { position: relative; display: flex; justify-content: center; }
.tl-rail::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: 50%; translate: -50% 0;
  inline-size: 4px; border-radius: 2px;
  background: var(--rail, var(--line));
}
.tl-row.first .tl-rail::before { top: 20px; }
.tl-row.last .tl-rail::before { bottom: calc(100% - 20px); }
/* ui.js marks walking legs with --rail: var(--line); draw them dashed like the map */
.tl-leg[style*="var(--line)"] .tl-rail::before {
  inline-size: 3px;
  background: repeating-linear-gradient(to bottom, var(--mode-walk) 0 5px, transparent 5px 9px);
}
.tl-gap .tl-rail::before { background: repeating-linear-gradient(to bottom, var(--rail-neutral) 0 3px, transparent 3px 7px); }

.tl-node {
  position: relative; z-index: 1;
  display: grid; place-items: center;
  margin-top: 8px;
  inline-size: 24px; block-size: 24px; border-radius: 50%;
  background: var(--fg); color: var(--surface);
  box-shadow: 0 0 0 3px var(--surface);
}
.tl-num { font-family: var(--font-num); font-size: 12.5px; font-weight: var(--fw-bold); line-height: 1; }
.tl-node.landmark { background: var(--gold); color: var(--mk-on); box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--gold-halo); }
.tl-node.lodging, .tl-node.air { border-radius: 7px; background: var(--mk-lodging); color: var(--mk-on); }
.tl-node.air { background: var(--mk-air); }
.tl-node.lodging::after, .tl-node.air::after { font-size: 11px; font-weight: var(--fw-semi); line-height: 1; }
.tl-node.lodging::after { content: '숙'; }
.tl-node.air::after { content: '✈'; }

.tl-body { min-width: 0; padding: 5px 0 12px; }
.tl-stop {
  display: grid; gap: 2px;
  inline-size: calc(100% + 8px); min-block-size: var(--tap);
  margin: 0 -8px 0 -8px; padding: 4px 8px;
  border: 0; border-radius: var(--r-sm);
  background: transparent; color: inherit; text-align: left;
  transition: background var(--dur-fast) var(--ease-standard);
}
.tl-stop:hover { background: var(--surface-2); }
.tl-name { font-weight: var(--fw-semi); font-size: var(--fs-lg); line-height: var(--lh-snug); }
.tl-body > .tl-name { padding-top: 5px; }
.tl-sub { font-size: var(--fs-xs); line-height: 1.45; color: var(--muted); }
.tl-sub .th { font-size: var(--fs-xs); }
.tl-note { margin-top: 3px; font-size: var(--fs-sm); line-height: var(--lh-snug); color: var(--fg-2); text-wrap: pretty; }
.tl-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

.tl-leg .tl-body { padding: 8px 0 12px; }
.leg-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: var(--fs-xs); color: var(--fg-2); }
.leg-line .mono { margin-left: 2px; font-weight: var(--fw-semi); font-size: var(--fs-sm); color: var(--fg); }
.leg-line .muted { color: var(--muted); }
.tl-leg .tl-note { font-size: var(--fs-xs); }

.mode-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: var(--r-xs);
  font-size: var(--fs-2xs); font-weight: var(--fw-semi); line-height: 1.35;
  color: var(--mode-on); background: var(--mode, var(--muted));
  white-space: nowrap;
}
/* ui.js sets --mode inline; pick an ink that passes on each line colour */
.mode-tag[style*="--mode-bts"],
.mode-tag[style*="--mode-boat"],
.mode-tag[style*="--mode-ferry"] { color: var(--mode-on-light); }
.mode-tag[style*="--mode-car"] { background: var(--mode-car-tag); }
.mode-tag[style*="--ink-3"] { color: var(--surface); }
.mode-tag.walk { padding: 1px 6px; background: transparent; color: var(--fg-2); border: 1px dashed var(--mode-walk); }

.tl-gap .tl-body {
  justify-self: start;
  margin: 2px 0 10px; padding: 1px 9px;
  border-radius: var(--r-pill); background: var(--surface-2);
  font-size: var(--fs-xs); color: var(--fg-2);
}
/* Live trip day (shell.js): past stops recede, the next one is labelled */
.tl-row.is-past .tl-time { color: var(--muted); }
.tl-row.is-next .tl-time { color: var(--accent-text); }
.tl-row.is-next .tl-time::after { content: '다음'; display: block; margin-top: 3px; font-family: var(--font-ko); font-size: 10.5px; font-weight: var(--fw-semi); }

/* ---------- Slots & swap flow ★ ---------- */
.slot { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; padding: 12px 0; border-top: 1px solid var(--border); }
.slot:first-child { border-top: 0; padding-top: 2px; }
.slot-label { padding-top: 12px; font-size: var(--fs-sm); font-weight: var(--fw-semi); line-height: 1.2; color: var(--fg); }
.slot-label .t { display: block; margin-top: 3px; font-family: var(--font-num); font-weight: var(--fw-medium); font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.blk {
  display: grid; gap: 6px;
  padding: 12px 14px;
  border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--surface-2);
}
.blk-title { font-weight: var(--fw-semi); font-size: var(--fs-lg); line-height: var(--lh-snug); }
.blk-sum { font-size: var(--fs-sm); line-height: var(--lh-snug); color: var(--fg-2); text-wrap: pretty; }
.blk-meta { display: flex; flex-wrap: wrap; gap: 4px; }
.blk-actions { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.blk-actions [data-toggle-slot] {
  padding: 0 var(--sp-4); border: 1px solid var(--border-strong); border-radius: var(--r-pill);
  background: var(--surface); color: var(--fg);
}
.blk-actions [data-toggle-slot]:hover { background: var(--surface-3); }
.blk-actions [data-toggle-slot][aria-expanded="true"] { background: var(--inverse-bg); border-color: var(--inverse-bg); color: var(--inverse-fg); }
.blk-actions [data-clear-slot] { color: var(--fg-2); }
.blk-actions [data-clear-slot]:hover { background: var(--surface-3); color: var(--fg); }
.blk-empty {
  margin: 0; padding: 12px 14px;
  border-radius: var(--r-md); border: 1px dashed var(--border-strong);
  font-size: var(--fs-sm); line-height: var(--lh-snug); color: var(--fg-2);
}

.cand-list { display: grid; gap: 8px; margin-top: 10px; }
.cand {
  position: relative;
  display: grid; gap: 4px;
  padding: 12px 14px;
  border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--surface); color: inherit; text-align: left;
  transition: background var(--dur-fast) var(--ease-standard), border-color var(--dur-fast);
}
.cand:hover { background: var(--surface-2); border-color: var(--border-strong); }
.cand .ct { font-weight: var(--fw-semi); font-size: var(--fs-md); line-height: var(--lh-snug); }
.cand .cs { font-size: var(--fs-xs); line-height: 1.5; color: var(--fg-2); }
.cand .blk-meta { margin-top: 2px; }
.cand[aria-current="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.cand[aria-current="true"] .ct { padding-right: 64px; }
.cand[aria-current="true"]::after {
  content: '지금 선택'; position: absolute; top: 12px; right: 12px;
  font-size: var(--fs-2xs); font-weight: var(--fw-semi); color: var(--accent-text);
}

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--surface);
  font-size: var(--fs-2xs); font-weight: var(--fw-medium); line-height: 1.55; color: var(--fg-2);
  white-space: nowrap;
}
.pill.err  { background: var(--err-soft);  border-color: transparent; color: var(--err); }
.pill.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.pill.info { background: var(--info-soft); border-color: transparent; color: var(--info); }
.pill.gold { background: var(--gold-soft); border-color: transparent; color: var(--gold-text); }

/* ---------- Plan sheet (presets + lodging) ---------- */
.plan-sheet {
  position: absolute; z-index: var(--z-plan);
  left: 0; right: 0; bottom: 0;
  max-block-size: calc(100% - var(--safe-top) - 24px);
  display: flex; flex-direction: column;
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-3);
  animation: sheet-in var(--dur-slow) var(--ease-sheet);
}
.plan-head { display: flex; align-items: center; gap: var(--sp-1); padding: 12px 10px 10px var(--sp-4); border-bottom: 1px solid var(--border); }
.plan-head h2 { flex: 1; margin: 0; font-size: var(--fs-xl); font-weight: var(--fw-bold); }
.plan-scroll { overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-2) 0 var(--sp-4); }
.plan-sheet .block { padding: var(--sp-3) var(--sp-4) var(--sp-2); }
.plan-sheet .hint { margin-top: var(--sp-2); }

.chips { display: grid; gap: 8px; }
#presets.chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chip {
  display: flex; align-items: center; gap: 10px;
  min-block-size: 50px; padding: 8px 12px;
  border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--surface); color: var(--fg); text-align: left;
  font-size: var(--fs-md); font-weight: var(--fw-semi); line-height: 1.3;
  transition: background var(--dur-fast) var(--ease-standard);
}
.chip:hover { background: var(--surface-2); border-color: var(--border-strong); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.chip[aria-pressed="true"]:hover { background: var(--accent-soft-hover); }
.chip .tag, .chip .rank {
  flex: none; display: grid; place-items: center;
  font-family: var(--font-num); font-weight: var(--fw-bold); line-height: 1;
  background: var(--surface-3); color: var(--fg);
}
.chip .tag { inline-size: 30px; block-size: 30px; border-radius: var(--r-sm); font-size: var(--fs-lg); }
.chip .rank { inline-size: 24px; block-size: 24px; border-radius: 50%; font-size: var(--fs-xs); }
.chip[aria-pressed="true"] :is(.tag, .rank) { background: var(--accent); color: var(--accent-ink); }

.lodging-detail {
  display: grid; gap: 8px;
  margin-top: 10px; padding: 12px 14px;
  border-radius: var(--r-md); background: var(--surface-2);
  font-size: var(--fs-sm); line-height: var(--lh-snug); color: var(--fg-2);
}
.lodging-detail .pc { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 8px; }
.lodging-detail .pc b { font-weight: var(--fw-semi); color: var(--fg); }
/* Pros and cons: one bullet per item, so a wrapped item does not run into the next (QA3A-08) */
.lodging-detail .pc-list { display: grid; gap: 4px; margin: 0; padding: 0 0 0 1.1em; list-style: disc outside; }
.lodging-detail .pc-list li::marker { color: var(--muted); }
.lodging-detail summary.muted {
  display: flex; align-items: center; min-block-size: var(--tap);
  color: var(--accent-text); font-size: var(--fs-sm); font-weight: var(--fw-semi); cursor: pointer;
}
.lodging-detail details[open] { display: grid; gap: 10px; }

/* ---------- Map controls ---------- */
.map-controls {
  position: absolute; z-index: var(--z-map-ctl);
  left: var(--edge); right: var(--edge);
  bottom: calc(var(--sheet-h) + 10px);
  display: flex; align-items: center; gap: var(--sp-2);
  pointer-events: none;
  transition: bottom var(--dur-slow) var(--ease-sheet), opacity var(--dur-base);
}
.map-controls > * { pointer-events: auto; }
#app:has(#panel.collapsed) .map-controls { bottom: calc(var(--safe-bottom) + 68px); }
.ctl-seg { display: flex; gap: var(--sp-2); margin-left: auto; }
.ctl {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-block-size: var(--tap); min-inline-size: var(--tap); padding: 0 14px;
  border-radius: var(--r-pill); border: 1px solid var(--border);
  background: var(--surface-glass); color: var(--fg);
  font-size: var(--fs-sm); font-weight: var(--fw-semi); white-space: nowrap;
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(8px);
  transition: background var(--dur-fast) var(--ease-standard);
}
.ctl:hover { background: var(--surface-3); }
.ctl.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ctl.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.ctl.active,
.ctl[aria-pressed="true"],
.ctl[aria-expanded="true"] { background: var(--inverse-bg); border-color: var(--inverse-bg); color: var(--inverse-fg); }
.ctl.active:hover,
.ctl[aria-pressed="true"]:hover,
.ctl[aria-expanded="true"]:hover { background: var(--inverse-bg); }
/* Phones: fit / overview / layers are icon buttons with hidden labels */
.ctl-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ctl-icon { padding: 0; }

.layers-pop {
  position: absolute; right: 0; bottom: calc(100% + 8px);
  inline-size: min(320px, 100%);
  padding: 6px;
  border-radius: var(--r-lg); border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow-2);
  animation: pop-in var(--dur-base) var(--ease-standard);
}
.layers-pop h3 { margin: 6px 10px 2px; font-size: var(--fs-xs); font-weight: var(--fw-semi); color: var(--fg-2); }
.ctl-group { display: grid; }
.toggle {
  display: flex; flex-direction: row-reverse; align-items: center; justify-content: space-between; gap: 12px;
  min-block-size: var(--tap); padding: 0 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-md); cursor: pointer;
}
.toggle:hover { background: var(--surface-2); }
.toggle input {
  appearance: none; flex: none; position: relative; margin: 0; cursor: pointer;
  inline-size: 40px; block-size: 24px; border-radius: 12px;
  background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--muted);
  transition: background var(--dur-fast) var(--ease-standard);
}
.toggle input::before {
  content: ''; position: absolute; top: 3px; left: 3px;
  inline-size: 18px; block-size: 18px; border-radius: 50%;
  background: var(--fg-2);
  transition: translate var(--dur-fast) var(--ease-standard), background var(--dur-fast);
}
.toggle input:checked { background: var(--accent); box-shadow: none; }
.toggle input:checked::before { translate: 16px 0; background: var(--accent-ink); }
.map-key { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; margin-top: 6px; padding: 12px 10px 8px; border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--fg-2); }
.map-key-item { display: flex; align-items: center; gap: 8px; }
.map-key .mk { pointer-events: none; }
.map-key .mk-pin { margin: 0; scale: 0.82; }
.map-key .mk-pin::after { display: none; }

/* Legend ★ (ui.js fills it) — desktop strip; on phones only during the overview */
.legend {
  display: none; flex-wrap: wrap; gap: 6px 12px;
  padding: 8px 12px;
  border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--surface-glass); box-shadow: var(--shadow-1);
  backdrop-filter: blur(8px);
  font-size: var(--fs-xs); color: var(--fg-2);
}
.legend .lg { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend .lg.muted { color: var(--fg-2); flex-basis: 100%; }
.legend .sw { inline-size: 18px; block-size: 4px; border-radius: 2px; background: var(--mode); }
.legend .sw.walk { background: repeating-linear-gradient(90deg, var(--mode-walk) 0 4px, transparent 4px 7px); }
#app[data-view="overview"] .legend {
  display: flex; position: absolute; z-index: var(--z-legend);
  left: var(--edge); right: var(--edge); bottom: calc(var(--sheet-h) + 64px);
}

/* ---------- Modal ★ (help, combination code) ---------- */
.modal {
  position: absolute; inset: 0; z-index: var(--z-modal);
  display: flex; align-items: flex-end; justify-content: center;
  background: var(--scrim);
  animation: fade-in var(--dur-base) var(--ease-standard);
}
.modal-box {
  position: relative;
  inline-size: 100%; max-block-size: calc(100% - var(--safe-top) - 24px);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 22px 20px calc(20px + var(--safe-bottom));
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: var(--surface); box-shadow: var(--shadow-3);
  animation: sheet-in var(--dur-slow) var(--ease-sheet);
}
.modal-box h3 { margin: 0 52px 12px 0; font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: var(--lh-tight); }
.modal-box h4 { margin: 22px 0 6px; font-size: var(--fs-md); font-weight: var(--fw-semi); }
.modal-box p, .modal-box li { margin: 0; font-size: var(--fs-md); line-height: var(--lh-body); color: var(--fg-2); }
.modal-box p + p { margin-top: 8px; }
.modal-box b { color: var(--fg); font-weight: var(--fw-semi); }
.modal-box ol, .modal-box ul { margin: 0; padding-left: 20px; }
.modal-box li + li { margin-top: 6px; }
.modal-close { position: absolute; top: 10px; right: 10px; background: var(--surface-2); border-color: transparent; }
.modal-box textarea {
  display: block; inline-size: 100%; min-block-size: 88px; margin-top: 10px;
  padding: 10px 12px; resize: vertical;
  border-radius: var(--r-md); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--fg);
  font-family: var(--font-mono); font-size: var(--fs-xs); line-height: 1.5; word-break: break-all;
}
.modal-box textarea::placeholder { color: var(--muted); }
.modal-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: 10px; }
.modal-row .ctl { box-shadow: none; backdrop-filter: none; background: var(--surface-2); padding: 0 var(--sp-5); }
.modal-row .ctl:hover { background: var(--surface-3); }
.modal-row .ctl.primary { background: var(--accent); color: var(--accent-ink); }
.modal-row .ctl.primary:hover { background: var(--accent-hover); }

/* ---------- Toast ★ ---------- */
.toast {
  position: absolute; z-index: var(--z-toast);
  left: 50%; translate: -50% 0;
  bottom: calc(var(--sheet-h) + 66px);
  max-inline-size: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: var(--r-md);
  background: var(--inverse-bg); color: var(--inverse-fg);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); line-height: var(--lh-snug); text-align: center;
  box-shadow: var(--shadow-2);
  animation: toast-in var(--dur-base) var(--ease-standard);
}

/* ---------- Map markers ★ (fixed colours; the basemap is light in both themes) ---------- */
.mk { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0; border: 0; background: none; cursor: pointer; font-family: var(--font-ko); }
.mk-label {
  max-inline-size: 170px; padding: 3px 8px;
  border-radius: var(--r-sm);
  background: var(--mk-label-bg); color: var(--mk-label-fg);
  font-size: 12px; font-weight: var(--fw-semi); line-height: 1.35;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: var(--mk-shadow);
}
.mk-pin {
  position: relative; display: grid; place-items: center;
  inline-size: 28px; block-size: 28px; margin-bottom: 7px;
  border-radius: 50%;
  background: var(--mk, var(--mk-stop)); color: var(--mk-on);
  font-family: var(--font-num); font-weight: var(--fw-bold); font-size: 14px; line-height: 1;
  box-shadow: 0 0 0 2px var(--mk-ring), 0 0 0 3px var(--mk-edge), var(--mk-shadow);
}
.mk-pin::after {
  content: ''; position: absolute; left: 50%; bottom: -8px; translate: -50% 0;
  border: 5px solid transparent; border-top: 6px solid var(--mk-ring); border-bottom: 0;
}
/* Gold landmark: white ring + gold halo + dark hairline keeps it apart from orange arterials */
.mk.landmark .mk-pin { background: var(--mk-landmark); box-shadow: 0 0 0 2px var(--mk-ring), 0 0 0 5px var(--mk-landmark-halo), 0 0 0 6px var(--mk-edge), var(--mk-shadow); }
.mk-lodging .mk-pin, .mk-air .mk-pin { border-radius: 8px; font-family: var(--font-ko); font-size: 13px; font-weight: var(--fw-semi); }
.mk-lodging .mk-pin { background: var(--mk-lodging); }
.mk-air .mk-pin { background: var(--mk-air); }
.mk:focus-visible { outline: none; }
.mk:hover .mk-label, .mk:focus-visible .mk-label { box-shadow: 0 0 0 2px var(--mk-focus), var(--mk-shadow); }
.mk:focus-visible .mk-pin { outline: 2px solid var(--mk-focus); outline-offset: 4px; }
.mk-label.mk-hide { visibility: hidden; }
.mk:hover .mk-label.mk-hide, .mk:focus-visible .mk-label.mk-hide { visibility: visible; }
.no-labels .mk-label { display: none; }
.mk[aria-current="true"] { z-index: 1; }
.mk[aria-current="true"] .mk-pin { scale: 1.18; }
.mk[aria-current="true"] .mk-label { background: var(--mk-label-fg); color: var(--mk-on); }
/* Only the head and a shown label take taps. The button's own box spans the label's slot above the
   head, and a label moved aside or hidden (map3d.js placeLabels) left that empty box over a neighbour's
   head, so tapping one head picked the next pin (QA3A-01). */
.mk { pointer-events: none; }
.mk-pin, .mk-label { pointer-events: auto; }
.mk-label.mk-hide, .no-labels .mk-label, .map-key .mk * { pointer-events: none; }

/* ---------- MapLibre chrome (positions only; maplibre-gl.css draws the rest) ---------- */
.maplibregl-ctrl-top-right { top: calc(var(--safe-top) + 58px); }
.maplibregl-ctrl.maplibregl-ctrl-group { border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-1); }
.maplibregl-ctrl-group button { width: var(--tap); height: var(--tap); }
.maplibregl-ctrl-bottom-left { bottom: calc(var(--sheet-h) + 60px); transition: bottom var(--dur-slow) var(--ease-sheet); }
.maplibregl-ctrl-bottom-right { bottom: calc(var(--sheet-h) + 60px); transition: bottom var(--dur-slow) var(--ease-sheet); }
.maplibregl-ctrl-attrib { font-size: 10.5px; }

/* ---------- Motion ---------- */
@keyframes fade-in  { from { opacity: 0; } }
@keyframes sheet-in { from { translate: 0 24px; opacity: 0; } }
@keyframes pop-in   { from { translate: 0 6px; opacity: 0; } }
@keyframes toast-in { from { translate: -50% 8px; opacity: 0; } }

/* ---------- Sheet states: phones only (a rotated phone past 860px ignores them) ---------- */
@container app (max-width: 860px) {
  /* Peek: a glance at today — date, totals, next stop. Everything else waits for a drag. */
  #app[data-sheet="peek"] .panel-scroll { overflow: hidden; }
  #app[data-sheet="peek"] #days,
  #app[data-sheet="peek"] .overview-note,
  #app[data-sheet="peek"] .day-head .hint { display: none; }
  #app[data-sheet="peek"] .day-head { padding-top: 0; cursor: pointer; }
  /* Half: drop the two hint lines so the first timeline row fits above the fold */
  #app[data-sheet="half"] .day-head .hint,
  #app[data-sheet="half"] .seg-panel > .hint { display: none; }
  #app[data-sheet="full"] .map-controls { opacity: 0; visibility: hidden; }
  #app[data-sheet="full"] .toast { bottom: auto; top: calc(var(--safe-top) + 64px); }
  #app[data-sheet="full"] :is(.maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right) { visibility: hidden; }
}

/* ==========================================================================
   Desktop — #app wider than 860px
   ========================================================================== */
@container app (min-width: 861px) {
  .icon-btn { inline-size: 36px; block-size: 36px; border-radius: var(--r-sm); font-size: 16px; }
  .text-btn, .blk-actions .text-btn { min-block-size: 32px; }
  .seg-tab { min-block-size: 34px; }
  .day-tab { min-block-size: 52px; }

  /* Header card of the left column */
  .topbar {
    top: var(--edge); left: var(--edge); right: auto;
    inline-size: var(--panel-w);
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto;
    grid-template-areas: "mark title help collapse" "sub sub sub sub" "plan plan plan plan";
    align-items: center; gap: 2px 10px;
    padding: 14px 14px 14px 16px;
    border-radius: var(--r-lg); border: 1px solid var(--border);
    background: var(--surface); box-shadow: var(--shadow-2);
    pointer-events: auto;
  }
  .topbar .icon-btn { background: var(--surface-2); border-color: transparent; box-shadow: none; backdrop-filter: none; }
  .topbar .icon-btn:hover { background: var(--surface-3); }
  .brand { display: contents; white-space: normal; }
  .brand-mark { grid-area: mark; }
  .brand h1 { grid-area: title; font-size: var(--fs-2xl); }
  .brand .sub { grid-area: sub; margin: 2px 0 10px; }
  #btn-help { grid-area: help; }
  #btn-collapse { grid-area: collapse; display: inline-grid; }
  .plan-chip {
    grid-area: plan;
    border-radius: var(--r-md); background: var(--surface-2); border-color: var(--border);
    box-shadow: none; backdrop-filter: none;
  }
  .plan-chip:hover { background: var(--surface-3); }
  .plan-chip-tag { border-radius: var(--r-sm); }

  /* Left column */
  #panel {
    top: calc(var(--edge) + var(--topbar-h) + 8px); left: var(--edge); right: auto; bottom: var(--edge);
    inline-size: var(--panel-w); block-size: auto;
    border-radius: var(--r-lg); border: 1px solid var(--border);
    box-shadow: var(--shadow-2);
    transition: none;
  }
  .sheet-handle { display: none; }
  .panel-scroll { overflow-y: auto; padding-bottom: var(--sp-5); }
  .days { padding-top: var(--sp-2); }
  .panel-reopen { top: calc(var(--edge) + var(--topbar-h) + 8px); bottom: auto; }

  .scrim.for-plan { background: transparent; animation: none; }
  .plan-sheet {
    top: calc(var(--edge) + var(--topbar-h) + 8px); left: var(--edge); right: auto; bottom: auto;
    inline-size: var(--panel-w);
    max-block-size: calc(100% - var(--topbar-h) - 2 * var(--edge) - 8px);
    padding-bottom: 0;
    border-radius: var(--r-lg); border: 1px solid var(--border);
    box-shadow: var(--shadow-2);
    animation: pop-in var(--dur-base) var(--ease-standard);
  }

  /* Map controls: one bar bottom-right; the legend sits bottom-left of the map */
  .map-controls { left: auto; right: var(--edge); bottom: 34px; transition: none; }
  #app:has(#panel.collapsed) .map-controls { bottom: 34px; }
  .ctl-seg { margin-left: 0; gap: 0; border-radius: var(--r-pill); box-shadow: var(--shadow-1); }
  .ctl-seg .ctl { box-shadow: none; border-radius: 0; }
  .ctl-seg .ctl:first-child { border-radius: var(--r-pill) 0 0 var(--r-pill); }
  .ctl-seg .ctl:last-child { border-radius: 0 var(--r-pill) var(--r-pill) 0; border-left: 0; }
  .ctl { min-block-size: 40px; }
  .ctl-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .ctl-icon { padding: 0 14px; }
  .layers-pop { inline-size: 300px; }
  .toggle { min-block-size: 38px; font-size: var(--fs-sm); }

  .legend, #app[data-view="overview"] .legend {
    display: flex; position: absolute; z-index: var(--z-legend);
    left: calc(var(--edge) + var(--panel-w) + 12px); right: auto; bottom: 34px;
    max-inline-size: calc(100% - var(--panel-w) - 520px);
  }
  #app:has(#panel.collapsed) .legend { left: var(--edge); }

  .toast { bottom: 96px; left: calc(50% + var(--panel-w) / 2 + var(--edge) / 2); }
  #app:has(#panel.collapsed) .toast { left: 50%; }

  .modal { align-items: center; padding: 24px; }
  .modal-box { inline-size: min(580px, 100%); max-block-size: 86%; padding: 26px 26px 24px; border-radius: var(--r-xl); }

  .maplibregl-ctrl-top-right { top: 0; }
  .maplibregl-ctrl-group button { width: 32px; height: 32px; }
  .maplibregl-ctrl-bottom-left { left: calc(var(--edge) + var(--panel-w) + 12px); bottom: 84px; }
  .maplibregl-ctrl-bottom-right { bottom: 0; }
  #app:has(#panel.collapsed) .maplibregl-ctrl-bottom-left { left: 0; }
}

/* Narrow desktops and tablets: the legend moves above the control bar */
@container app (min-width: 861px) and (max-width: 1240px) {
  .legend, #app[data-view="overview"] .legend {
    left: auto; right: var(--edge); bottom: 84px;
    max-inline-size: min(440px, calc(100% - var(--panel-w) - 3 * var(--edge)));
  }
  .maplibregl-ctrl-bottom-left { bottom: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
