/* Trip Planner
   Layout: phone first. A top bar, one pane per tab, a bottom tab bar on phones;
   on wide screens the tabs move into the top bar and sheets become dialogs. */

:root {
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-2: #eaf0ee;
  --line: #d8e0de;
  --line-soft: #e7ecea;
  --ink: #132321;
  --ink-2: #485856;
  --ink-3: #75837f;
  --accent: #0f6b66;
  --accent-hover: #0b5753;
  --accent-ink: #ffffff;
  --accent-soft: #d6ebe8;
  --booked: #1f7a4a;
  --booked-bg: #d9f0e2;
  --booked-ink: #0f4b2c;
  --need: #c2410c;
  --need-bg: #fde6d8;
  --need-ink: #7f2a06;
  --none: #56677a;
  --none-bg: #e5ebf1;
  --none-ink: #2e3d4d;
  --danger: #b42318;
  --danger-bg: #fde4e1;
  --today: #fff7e0;
  --shadow: 0 1px 2px rgba(16, 35, 33, 0.06), 0 6px 18px rgba(16, 35, 33, 0.08);
  --shadow-up: 0 -8px 30px rgba(16, 35, 33, 0.16);
  --font-display: 'Bricolage Grotesque', 'Figtree', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'Figtree', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --gutter: 46px;
  --tap: 44px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0e1716;
    --surface: #152120;
    --surface-2: #1c2b29;
    --line: #2a3b39;
    --line-soft: #213230;
    --ink: #e6efed;
    --ink-2: #a9bab7;
    --ink-3: #7f918e;
    --accent: #3fb3a9;
    --accent-hover: #5cc4bb;
    --accent-ink: #062120;
    --accent-soft: #173b38;
    --booked: #4cc283;
    --booked-bg: #163a28;
    --booked-ink: #bdf0d3;
    --need: #ff8a50;
    --need-bg: #43230f;
    --need-ink: #ffd5bd;
    --none: #93a6ba;
    --none-bg: #233040;
    --none-ink: #d3dee9;
    --danger: #ff7b6e;
    --danger-bg: #43191a;
    --today: #2a2814;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.3);
    --shadow-up: 0 -8px 30px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
#app { height: 100%; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; text-wrap: balance; }
p { margin: 0; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--ink-3); }
.warn-text { color: var(--need); font-weight: 600; }
.loading { padding: 40px 16px; text-align: center; color: var(--ink-3); }
.ic { display: inline-flex; width: 20px; height: 20px; flex: none; }
.ic svg { width: 100%; height: 100%; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--ink-3); }
.btn .ic { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { color: var(--danger); border-color: transparent; background: transparent; }
.btn.danger-ghost:hover { background: var(--danger-bg); }
.btn-small { min-height: 34px; padding: 5px 12px; font-size: 13px; }
.btn-wide { width: 100%; }
.btn-need { color: var(--need-ink); background: var(--need-bg); border-color: transparent; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); flex: none;
  border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  min-height: 34px; padding: 5px 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink-2);
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip .ic { width: 16px; height: 16px; }
.chip[aria-pressed='true'] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .count { font-weight: 500; opacity: .7; font-variant-numeric: tabular-nums; }
.chip-add { border-style: dashed; color: var(--accent); }
.chip-st.st-booked[aria-pressed='true'] { background: var(--booked); border-color: var(--booked); color: #fff; }
.chip-st.st-need[aria-pressed='true'] { background: var(--need); border-color: var(--need); color: #fff; }
.chip-st.st-none[aria-pressed='true'] { background: var(--none); border-color: var(--none); color: #fff; }
.chip-st[aria-pressed='false'] { text-decoration: line-through; opacity: .75; }
.chip-row { display: flex; gap: 6px; overflow-x: auto; padding: 2px 16px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip-sep { width: 1px; flex: none; background: var(--line); margin: 4px 4px; }
.chip-group { display: flex; gap: 4px; }
.chip-static {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2);
  font-size: 12px; font-weight: 600;
}
.chip-static .ic { width: 14px; height: 14px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px 2px 6px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.badge .ic { width: 15px; height: 15px; }
.st-booked.badge { background: var(--booked-bg); color: var(--booked-ink); }
.st-need.badge { background: var(--need-bg); color: var(--need-ink); }
.st-none.badge { background: var(--none-bg); color: var(--none-ink); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 600; }
.tag-now { background: var(--accent); color: var(--accent-ink); }

/* ---------- home ---------- */
.home {
  height: 100%; overflow-y: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) 16px calc(env(safe-area-inset-bottom, 0px) + 32px);
  max-width: 980px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 24px;
}
.home-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.home-title { font-family: var(--font-display); font-size: clamp(34px, 8vw, 52px); font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.home-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.trip-sections { display: flex; flex-direction: column; gap: 24px; }
.section-title { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px; }
.trip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 12px; }
.trip-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  padding: 18px; min-height: 120px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  cursor: pointer; box-shadow: var(--shadow);
}
.trip-card:hover { border-color: var(--accent); }
.trip-card.is-now { border-color: var(--accent); }
.trip-name { font-family: var(--font-display); font-size: 24px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.1; }
.trip-dates { color: var(--ink-2); font-weight: 500; }
.trip-meta { margin-top: auto; display: flex; gap: 8px; align-items: center; color: var(--ink-3); font-size: 13px; }
.home-foot { color: var(--ink-3); font-size: 13px; padding-top: 8px; border-top: 1px solid var(--line); }
.empty-state { padding: 28px 20px; border: 1px dashed var(--line); border-radius: var(--radius); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; max-width: 560px; }
.empty-state h3 { font-family: var(--font-display); font-size: 20px; }
.empty-text { color: var(--ink-3); padding: 12px 0; }

/* ---------- join ---------- */
.join { height: 100%; overflow-y: auto; display: grid; place-items: center; padding: 24px 16px; }
.join-card {
  width: min(420px, 100%); display: flex; flex-direction: column; gap: 14px;
  padding: 24px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.join-title { font-family: var(--font-display); font-size: 30px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; }
.join-card .link-btn { align-self: center; }
.form-error { color: var(--danger); font-weight: 600; min-height: 0; }
.form-error:empty { display: none; }
.err-detail { white-space: pre-wrap; font-size: 12px; background: var(--surface-2); padding: 8px; border-radius: 6px; }

/* ---------- trip shell ---------- */
.shell { height: 100%; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; }
.demo-banner { background: var(--need-bg); color: var(--need-ink); font-size: 12px; font-weight: 600; text-align: center; padding: calc(env(safe-area-inset-top, 0px) + 4px) 16px 4px; }
[data-mode='firebase'] .topbar, .shell > .topbar:first-child { padding-top: calc(env(safe-area-inset-top, 0px) + 6px); }
.topbar {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 8px; background: var(--surface); border-bottom: 1px solid var(--line);
  min-width: 0;
}
.top-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; padding: 0 4px; }
.top-name { font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-dates { font-size: 12px; color: var(--ink-3); }
.tabs-top { display: none; }
.main { position: relative; min-height: 0; overflow: hidden; }
.pane { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }
.pane > * { flex: 1; min-height: 0; }
.tabbar {
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 56px; color: var(--ink-3); text-decoration: none; font-size: 12px; font-weight: 600;
}
.tab[aria-current='page'] { color: var(--accent); }
.tab .ic { width: 22px; height: 22px; }

@media (min-width: 900px) {
  .tabbar { display: none; }
  .shell { grid-template-rows: auto auto minmax(0, 1fr); }
  .tabs-top { display: flex; gap: 4px; margin: 0 12px; }
  .tabs-top .tab { flex-direction: row; min-height: 38px; padding: 0 14px; border-radius: 999px; font-size: 14px; gap: 6px; }
  .tabs-top .tab .ic { width: 18px; height: 18px; }
  .tabs-top .tab[aria-current='page'] { background: var(--accent-soft); }
  .topbar { padding: 8px 16px; }
}

/* ---------- calendar ---------- */
.cal { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.cal-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line-soft);
}
.cal-nav { display: flex; align-items: center; gap: 2px; min-width: 0; }
.cal-range { font-weight: 700; font-size: 15px; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cal-actions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
@media (max-width: 699px) {
  .cal-toolbar { gap: 4px 6px; padding: 4px 8px 8px; }
  .cal-nav { flex: 1 1 100%; justify-content: space-between; }
  .cal-nav .icon-btn { height: 36px; }
  .chip-group .chip { padding: 4px 10px; min-height: 34px; }
  .cal-actions { gap: 4px; }
  .cal-actions .btn { padding: 5px 10px; }
  .lbl-long { display: none; }
}
.cal-frame { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--surface); }
.cal-head, .cal-band, .cal-grid { display: grid; }
.cal-head { border-bottom: 1px solid var(--line-soft); }
.cal-day-head { display: flex; flex-direction: column; align-items: center; padding: 6px 2px; min-width: 0; border-left: 1px solid var(--line-soft); }
.cal-wd { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.cal-dn { font-size: 14px; font-weight: 700; white-space: nowrap; }
.cal-day-head.is-today .cal-dn { color: var(--accent); }
.cal-band { border-bottom: 1px solid var(--line); padding: 4px 0; row-gap: 3px; background: var(--surface-2); }
.cal-band-label { grid-column: 1; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); align-self: center; text-align: center; }
.stay-bar {
  display: flex; align-items: center; gap: 4px; min-width: 0;
  margin: 0 2px; padding: 3px 8px; border: 0; border-radius: 6px;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; cursor: pointer; text-align: left;
}
.stay-bar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stay-bar .ic { width: 15px; height: 15px; }
.stay-bar.cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: 0; }
.stay-bar.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0; }
.stay-empty { grid-row: 1; margin: 0 2px; padding: 3px 8px; border: 1px dashed var(--line); border-radius: 6px; background: transparent; color: var(--ink-3); font-size: 12px; font-weight: 600; cursor: pointer; text-align: left; }
.cal-empty { padding: 8px 16px; font-size: 13px; color: var(--ink-2); background: var(--accent-soft); }
.cal-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.cal-gutter { grid-column: 1; }
.cal-hour { position: relative; font-size: 11px; color: var(--ink-3); text-align: right; padding-right: 6px; font-variant-numeric: tabular-nums; }
.cal-hour:not(:empty) { transform: translateY(-7px); }
.cal-col {
  position: relative; border-left: 1px solid var(--line-soft); cursor: copy;
  background-image: linear-gradient(to bottom, var(--line-soft) 1px, transparent 1px);
  background-size: 100% var(--hour, 44px);
}
.cal-col.is-today { background-color: var(--today); }

.ev {
  position: absolute; z-index: 1; overflow: hidden;
  padding: 3px 6px 4px; border-radius: 7px;
  font-size: 12px; line-height: 1.25; cursor: grab;
  border: 1.5px solid transparent;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
  transition: box-shadow .12s, transform .05s;
}
.ev.st-booked { background: var(--booked-bg); color: var(--booked-ink); border-color: color-mix(in srgb, var(--booked) 45%, transparent); }
.ev.st-need { background: var(--need-bg); color: var(--need-ink); border: 1.5px dashed var(--need); }
.ev.st-none { background: var(--none-bg); color: var(--none-ink); border-color: color-mix(in srgb, var(--none) 30%, transparent); }
.ev.cont-top { border-top-left-radius: 0; border-top-right-radius: 0; border-top-style: dotted; }
.ev.cont-bottom { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom-style: dotted; }
.ev-title { display: flex; align-items: flex-start; gap: 3px; font-weight: 700; }
.ev-name { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.ev-short .ev-name { -webkit-line-clamp: 1; white-space: nowrap; display: block; }
.ev-mark .ic { width: 14px; height: 14px; margin-top: 1px; }
.ev-time, .ev-place { font-size: 11px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.ev-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 10px; cursor: ns-resize; }
.ev-resize::after { content: ''; position: absolute; left: 50%; bottom: 3px; width: 18px; height: 3px; margin-left: -9px; border-radius: 2px; background: currentColor; opacity: 0; transition: opacity .15s; }
.ev:hover .ev-resize::after, .ev.dragging .ev-resize::after { opacity: .45; }
.ev.pressing { transform: scale(.98); }
.ev.dragging { z-index: 5; box-shadow: 0 10px 24px rgba(0, 0, 0, .22); cursor: grabbing; opacity: .95; transition: none; }
.ev.dragging::before {
  content: attr(data-time); position: absolute; right: 4px; top: 2px;
  font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: var(--ink); color: var(--bg);
}
body.is-dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }
@media (prefers-reduced-motion: reduce) { .ev, .sheet, .toast { transition: none !important; } }

/* ---------- map ---------- */
.mapview { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.map-filters { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; background: var(--surface); border-bottom: 1px solid var(--line-soft); }
.map-wrap { position: relative; flex: 1; min-height: 0; }
.map { position: absolute; inset: 0; background: var(--surface-2); }
.map-note {
  position: absolute; z-index: 500; left: 50%; bottom: 12px; transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 5px 12px; border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow); font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.map-fail { display: grid; place-items: center; height: 100%; padding: 24px; text-align: center; color: var(--ink-2); }
.pin-wrap { background: none; border: 0; }
.pin {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  border: 2.5px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  color: #fff; font-size: 13px; font-weight: 800; font-family: var(--font-body);
}
.pin svg { width: 16px; height: 16px; }
.pin.st-booked { background: var(--booked); }
.pin.st-need { background: var(--need); }
.pin.st-none { background: var(--none); }
.pin-unsched { background: var(--surface); border: 2.5px solid var(--ink-3); box-shadow: 0 1px 4px rgba(0, 0, 0, .25); width: 22px; height: 22px; margin: 3px; }
.pin-stay { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); }
.pin-stay svg { width: 20px; height: 20px; }
.route-line { stroke: var(--ink); }
.leaflet-container { font-family: var(--font-body); }
.leaflet-tooltip { font-weight: 600; }

/* ---------- research ---------- */
.research { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.list-chips { padding-top: 10px; padding-bottom: 6px; background: var(--surface); }
.research-bar { padding: 4px 16px 10px; background: var(--surface); border-bottom: 1px solid var(--line-soft); }
.search-wrap { position: relative; display: flex; align-items: center; max-width: 520px; }
.search-wrap .ic { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--ink-3); pointer-events: none; }
.search-wrap input.search { width: 100%; min-height: 40px; padding: 8px 12px 8px 40px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); }
.research-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 16px 24px; display: flex; flex-direction: column; gap: 22px; }
.list-section { display: flex; flex-direction: column; gap: 10px; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 8px; }
.list-head h2 { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.list-head-actions { display: flex; align-items: center; gap: 2px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 10px; }
.place-card { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; min-width: 0; }
.place-main { display: flex; gap: 12px; padding: 12px; border: 0; background: none; text-align: left; cursor: pointer; min-width: 0; align-items: flex-start; }
.place-main:hover .place-name { color: var(--accent); }
.place-img { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); }
.place-img-empty { display: grid; place-items: center; font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--accent); background: var(--accent-soft); }
.img-broken { display: grid; place-items: center; font-size: 10px; color: var(--ink-3); text-align: center; padding: 4px; }
.place-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.place-name { font-size: 16px; font-weight: 700; line-height: 1.2; }
.place-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: 13px; color: var(--ink-2); }
.place-vibe { font-size: 13px; color: var(--ink-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sched { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.sched-none { color: var(--ink-3); font-weight: 500; }
.place-actions { display: flex; justify-content: flex-end; align-items: center; gap: 4px; padding: 0 10px 10px; margin-top: auto; }

/* ---------- sheets ---------- */
.sheet-layer { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(8, 18, 17, .45); opacity: 0; transition: opacity .2s; }
.sheet {
  position: relative; width: 100%; max-height: 90%; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: var(--shadow-up);
  transform: translateY(100%); transition: transform .22s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sheet-layer.open .sheet-backdrop { opacity: 1; }
.sheet-layer.open .sheet { transform: none; }
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 18px; flex: none; }
.sheet-title { flex: 1; min-width: 0; font-family: var(--font-display); font-size: 21px; font-weight: 700; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 18px 18px; overscroll-behavior: contain; }
.sheet-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 10px 18px 14px; border-top: 1px solid var(--line-soft); flex: none; }
.sheet-foot .danger-ghost { margin-right: auto; }
@media (min-width: 700px) {
  .sheet-layer { align-items: center; padding: 24px; }
  .sheet { width: min(560px, 100%); max-height: min(86vh, 860px); border-radius: 18px; transform: translateY(16px) scale(.98); opacity: 0; transition: transform .18s, opacity .18s; padding-bottom: 0; }
  .sheet-layer.open .sheet { opacity: 1; }
  .sheet.sheet-small { width: min(440px, 100%); }
  .sheet-grip { display: none; }
  .sheet-head { padding-top: 12px; }
}
.confirm-text { color: var(--ink-2); }

/* details */
.detail { display: flex; flex-direction: column; gap: 16px; }
.detail-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.detail-block { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.big { font-size: 16px; font-weight: 600; }
.vibe { font-size: 15px; color: var(--ink-2); }
.notes { white-space: pre-wrap; color: var(--ink-2); }
.meta { font-size: 12px; color: var(--ink-3); }
.hero-img { width: 100%; max-height: 220px; object-fit: cover; border-radius: var(--radius); background: var(--surface-2); }
.hero-img.img-broken { height: 60px; font-size: 12px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.row-btn, .row {
  width: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-align: left; cursor: pointer;
}
.row { cursor: default; }
.row-btn:hover { border-color: var(--accent); }
.row-main { font-weight: 600; min-width: 0; }
.row-sub { font-size: 13px; color: var(--ink-3); }
.results .row-btn { flex-direction: column; align-items: flex-start; }

/* segmented status control */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg {
  display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 42px; padding: 6px 8px;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink-2);
  font-size: 13px; font-weight: 700; cursor: pointer; text-align: center; line-height: 1.15;
}
.seg .ic { width: 17px; height: 17px; flex: none; }
.seg-booked[aria-checked='true'] { background: var(--booked-bg); color: var(--booked-ink); border-color: var(--booked); }
.seg-need[aria-checked='true'] { background: var(--need-bg); color: var(--need-ink); border-color: var(--need); border-style: dashed; }
.seg-none[aria-checked='true'] { background: var(--none-bg); color: var(--none-ink); border-color: var(--none); }

/* forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field > label, .field > legend { font-size: 13px; font-weight: 700; color: var(--ink-2); padding: 0; }
.field-hint { font-size: 12px; color: var(--ink-3); }
.field-hint:empty { display: none; }
input[type='text'], input[type='email'], input[type='password'], input[type='url'], input[type='search'], input[type='date'], input[type='time'], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  font-size: 16px; /* stops iOS zooming in */
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.grid-2, .grid-3 { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: 1.3fr 1fr 1fr; }
@media (max-width: 420px) { .grid-3 { grid-template-columns: 1fr 1fr; } .grid-3 > :first-child { grid-column: 1 / -1; } }
.inline-field { display: flex; gap: 8px; align-items: center; }
.inline-field input { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.pin-line { font-size: 13px; }
.picker-map { height: 260px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.tpl-list { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.tpl-row { display: flex; gap: 6px; width: 100%; }
.settings { display: flex; flex-direction: column; gap: 22px; }
.settings-sec { display: flex; flex-direction: column; gap: 10px; }
.settings-sec h3 { font-size: 15px; font-weight: 700; }
.settings-sec .row { flex-wrap: nowrap; }
.settings-sec .row .row-sub { margin-left: auto; }

/* toasts */
.toasts {
  position: fixed; z-index: 3000; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 72px);
  display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 460px); pointer-events: none;
}
@media (min-width: 900px) { .toasts { bottom: 24px; } }
/* with a sheet open on a phone, show messages at the top so they don't cover its buttons */
@media (max-width: 699px) {
  body:has(.sheet-layer) .toasts { bottom: auto; top: calc(env(safe-area-inset-top, 0px) + 12px); }
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 12px; background: var(--ink); color: var(--bg);
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow); transition: opacity .3s, transform .3s;
}
.toast.out { opacity: 0; transform: translateY(8px); }
.toast-error { background: var(--danger); color: #fff; }
.toast-action { border: 0; background: none; color: inherit; font-weight: 800; text-decoration: underline; cursor: pointer; padding: 0; }
