:root {
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --bg: #fbf6ef;
  --card: #ffffff;
  --ink: #2b1d20;
  --muted: #7d6a66;
  --line: rgba(80, 40, 40, .12);
  --accent: #b8325a;
  --accent-2: #d4893a;
  --accent-ink: #ffffff;
  --soft: rgba(184, 50, 90, .08);
  --shadow: 0 10px 40px rgba(60, 20, 30, .18), 0 2px 8px rgba(60, 20, 30, .08);
  --sheet-h: 52vh;
  --tile-filter: none;
}
body[data-theme="night"] {
  --bg: #15162a; --card: #1e2038; --ink: #f6eedd; --muted: #a8a3b8; --line: rgba(255, 255, 255, .1);
  --accent: #f0c46a; --accent-2: #e48aa6; --accent-ink: #1c1a2c; --soft: rgba(240, 196, 106, .1);
  --shadow: 0 10px 40px rgba(0, 0, 0, .45);
  --tile-filter: none;
}
body[data-theme="golden"] {
  --bg: #fdf3e6; --accent: #c9551f; --accent-2: #b8325a; --soft: rgba(201, 85, 31, .09);
  --tile-filter: sepia(.1) saturate(1.12) hue-rotate(-4deg);
}
body[data-theme="rain"] {
  --bg: #f1f3f6; --accent: #3f6596; --accent-2: #b8325a; --soft: rgba(63, 101, 150, .09);
  --tile-filter: grayscale(.5) brightness(.99);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font-family: var(--sans); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; transition: background .6s; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#map { position: fixed; inset: 0; background: #e8dfd2; }
body[data-theme="night"] #map { background: #1a1b2c; }
.leaflet-tile-pane { filter: var(--tile-filter); transition: filter .8s; }
.leaflet-container { font-family: var(--sans); }
.leaflet-control-attribution { font-size: 9px; background: rgba(255, 255, 255, .6) !important; border-radius: 0 0 0 6px; }
body[data-theme="night"] .leaflet-control-attribution { background: rgba(20, 20, 40, .6) !important; color: #aaa; }
body[data-theme="night"] .leaflet-control-attribution a { color: #ccc; }

/* ---------- brand ---------- */
.heart { width: 30px; height: 30px; fill: #c23a5e; flex: none; filter: drop-shadow(0 2px 6px rgba(194, 58, 94, .4)); }
body[data-theme="night"] .heart { fill: #e9748f; }
.brand-float h1, .panel-brand h1 { font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 26px; line-height: 1; margin: 0; letter-spacing: .2px; }
.when { margin: 3px 0 0; font-size: 12px; color: var(--muted); letter-spacing: .2px; }
.brand-float {
  position: fixed; z-index: 500; top: max(12px, env(safe-area-inset-top)); left: 12px;
  display: flex; align-items: center; gap: 10px; padding: 10px 16px 10px 12px;
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: 18px; box-shadow: var(--shadow); color: var(--ink);
}
.panel-brand { display: none; }

/* ---------- tool buttons ---------- */
.tools { position: fixed; z-index: 500; right: 12px; top: max(34px, calc(env(safe-area-inset-top) + 22px)); display: flex; flex-direction: column; gap: 8px; }
.tool {
  width: 44px; height: 44px; border-radius: 14px; border: 0; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow); color: var(--ink);
}
.tool svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tool svg .fill { fill: #c23a5e; stroke: none; }
.tool.on { background: var(--accent); color: var(--accent-ink); }

/* ---------- hero ---------- */
.hero {
  position: fixed; z-index: 700; left: 12px; right: 12px; bottom: max(16px, env(safe-area-inset-bottom));
  max-width: 460px; margin: 0 auto; padding: 22px 22px 18px;
  color: #fff7ef; border-radius: 24px; overflow: hidden;
  background: linear-gradient(160deg, #3a1526 0%, #7a2a3d 45%, #c4612f 85%, #e8a04c 100%);
  box-shadow: 0 20px 60px rgba(60, 10, 30, .45);
  animation: rise .9s cubic-bezier(.2, .8, .2, 1) both;
}
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 214, 140, .55), rgba(255, 214, 140, 0) 70%); pointer-events: none; }
.hero .kicker { margin: 0; font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase; opacity: .85; }
.hero h2 { font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 44px; line-height: 1.02; margin: 6px 0 10px; }
.hero-text { margin: 0; font-size: 14.5px; line-height: 1.55; opacity: .95; }
.hero-index { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; }
.hero-index button { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; border: 0; border-radius: 14px; padding: 9px 12px;
  background: rgba(255, 255, 255, .12); color: #fff7ef; font-size: 14.5px; font-weight: 500; transition: background .2s; }
.hero-index button:hover { background: rgba(255, 255, 255, .22); }
.hero-index small { display: block; font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase; opacity: .75; font-weight: 500; }
.hero-index .n { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-family: var(--serif); font-style: italic; font-size: 17px; font-weight: 600; background: rgba(255, 244, 230, .9); color: #6a1f38; }
.hero-actions { display: flex; gap: 8px; margin-top: 16px; }
.hero .btn.primary { background: #fff4e6; color: #5a1a2e; }
.hero .btn.ghost { border-color: rgba(255, 255, 255, .45); color: #fff7ef; }
@keyframes rise { from { opacity: 0; transform: translateY(40px) scale(.98); } to { opacity: 1; transform: none; } }

.btn { border: 1px solid var(--line); background: var(--card); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; white-space: nowrap; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
a.btn { text-decoration: none; color: var(--ink); display: inline-block; }
.btn.small { padding: 7px 12px; font-size: 13px; }

/* ---------- sheet (mobile bottom sheet / desktop side panel) ---------- */
.sheet {
  position: fixed; z-index: 600; left: 0; right: 0; bottom: 0; height: var(--sheet-h);
  background: var(--bg); color: var(--ink); border-radius: 24px 24px 0 0; box-shadow: 0 -10px 40px rgba(40, 10, 20, .2);
  display: flex; flex-direction: column; transition: height .35s cubic-bezier(.2, .8, .2, 1), background .6s, transform .5s;
}
.sheet.dragging { transition: none; }
.sheet.away { transform: translateY(110%); }
.grab { padding: 10px 0 4px; display: grid; place-items: center; touch-action: none; cursor: grab; }
.grab span { width: 42px; height: 5px; border-radius: 3px; background: var(--line); background: color-mix(in srgb, var(--ink) 22%, transparent); }

.weather { display: flex; gap: 6px; padding: 2px 16px 8px; overflow-x: auto; scrollbar-width: none; }
.weather::-webkit-scrollbar, .chapters::-webkit-scrollbar { display: none; }
.wx { flex: none; display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 5px 10px 5px 7px; border-radius: 999px; background: var(--soft); color: var(--ink); }
.wx svg { width: 18px; height: 18px; }
.wx b { font-weight: 600; }
.wx .rain { color: #3f6596; font-weight: 600; }
body[data-theme="night"] .wx .rain { color: #9ec0ef; }
.wx.note { color: var(--muted); }

.chapters { display: flex; gap: 6px; padding: 2px 16px 10px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); touch-action: pan-x; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 8px 13px; font-size: 13px; font-weight: 500; position: relative; }
.chip[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chip .dot { position: absolute; top: 3px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: #3f6596; }

.sheet-body { flex: 1; overflow-y: auto; padding: 16px 16px 40px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.ch-kicker { margin: 0; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.ch-title { font-family: var(--serif); font-weight: 600; font-size: 30px; line-height: 1.05; margin: 4px 0 8px; }
.ch-intro { margin: 0 0 12px; font-size: 14.5px; line-height: 1.55; color: var(--muted); }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.meta { font-size: 12px; padding: 5px 10px; border-radius: 999px; background: var(--soft); }
.meta b { font-weight: 600; }
.banner { border-radius: 14px; padding: 12px 14px; margin: 0 0 14px; font-size: 13.5px; line-height: 1.5; background: rgba(63, 101, 150, .12); }
.banner.warm { background: var(--soft); }

/* dinner picker */
.picker-label { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.pick { text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 10px 12px; }
.pick b { display: block; font-size: 14px; font-weight: 600; }
.pick small { color: var(--muted); font-size: 11.5px; }
.pick[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--soft); }
.pick.unsure { grid-column: 1 / -1; text-align: center; padding: 8px; }

/* timeline */
.stops { list-style: none; margin: 0; padding: 0; }
.stop { position: relative; padding-left: 46px; }
.stop::before { content: ""; position: absolute; left: 17px; top: 36px; bottom: -6px; width: 2px; background: repeating-linear-gradient(to bottom, var(--accent) 0 4px, transparent 4px 9px); opacity: .45; }
.stop:last-child::before, .stops.loose .stop::before { display: none; }
.num {
  position: absolute; left: 2px; top: 12px; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 600; font-size: 14px;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 4px var(--bg);
}
.num svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 13px 14px; margin: 0 0 6px; transition: box-shadow .3s, border-color .3s; cursor: pointer; }
.stop.on .card { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 8px 24px rgba(60, 20, 30, .1); }
.card-top { display: flex; align-items: baseline; gap: 8px; justify-content: space-between; }
.card h3 { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.25; }
.time { flex: none; font-size: 12.5px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.sub { margin: 2px 0 6px; font-size: 12.5px; color: var(--muted); }
.card p.txt { margin: 0; font-size: 14px; line-height: 1.55; }
.tip { margin: 8px 0 0; font-size: 12.8px; line-height: 1.5; color: var(--muted); padding-left: 10px; border-left: 2px solid var(--accent-2); }
.note { margin: 8px 0 0; font-size: 13px; line-height: 1.5; padding: 7px 10px; border-radius: 10px; background: var(--soft); }
.actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.actions a, .actions button { font-size: 12.5px; text-decoration: none; color: var(--ink); border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 6px 11px; }
.leg { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); margin: 0 0 6px 46px; padding: 0 0 2px; }
.leg svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.home-line { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 10px 12px; margin: 6px 0 0 46px; border-radius: 14px; background: var(--soft); }
.home-line svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.foot { margin: 18px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.open-all { display: inline-block; margin: 0 0 14px; }

/* ---------- map markers ---------- */
.pin { width: 34px; height: 34px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg); display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 12px rgba(40, 10, 20, .35), 0 0 0 3px var(--bg); transition: transform .25s; }
.pin > * { transform: rotate(45deg); font: 600 14px var(--sans); }
.pin svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.pin.on { transform: rotate(-45deg) scale(1.22); }
.pin.k-dinner { background: #c23a5e; color: #fff; }
.pin.k-base { background: #2b1d20; color: #fff; width: 30px; height: 30px; border-radius: 9px; transform: none; }
.pin.k-base > * { transform: none; }
body[data-theme="night"] .pin.k-base { background: #f6eedd; color: #1c1a2c; }
.pin.k-hotel { background: #fff; color: #c23a5e; border-radius: 50%; transform: none; }
.pin.k-hotel > * { transform: none; }
.pin.faded { opacity: .55; }
.lbl { display: none; position: absolute; left: 40px; top: 6px; white-space: nowrap; font: 600 12px var(--sans); color: var(--ink); padding: 3px 8px; border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); box-shadow: 0 2px 8px rgba(0, 0, 0, .12); pointer-events: none; }

.show-labels .lbl, .mk.on .lbl, .mk:hover .lbl { display: block; }
.mk.on { z-index: 2000 !important; }
.hero-pin { position: relative; width: 46px; height: 46px; }
.hero-pin svg { position: absolute; inset: 6px; width: 34px; height: 34px; fill: #c23a5e; filter: drop-shadow(0 3px 8px rgba(120, 20, 50, .55)); animation: beat 2.4s ease-in-out infinite; }
.hero-pin::before, .hero-pin::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(232, 120, 80, .9); animation: ripple 2.4s ease-out infinite; }
.hero-pin::after { animation-delay: 1.2s; }
@keyframes beat { 0%, 100% { transform: scale(1); } 12% { transform: scale(1.14); } 24% { transform: scale(1); } 36% { transform: scale(1.1); } }
@keyframes ripple { from { transform: scale(.6); opacity: 1; } to { transform: scale(2.4); opacity: 0; } }

.route-ants { animation: ants 1.4s linear infinite; }
@keyframes ants { to { stroke-dashoffset: -18; } }
.me-dot { width: 16px; height: 16px; border-radius: 50%; background: #2f7cf6; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(47, 124, 246, .25); }

.leaflet-popup-content-wrapper { border-radius: 14px; background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.leaflet-popup-tip { background: var(--card); }
.leaflet-popup-content { margin: 10px 14px; font-size: 13px; line-height: 1.4; }
.leaflet-popup-content b { font-size: 14px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }

/* ---------- dialog / toast ---------- */
.dialog { position: fixed; inset: 0; z-index: 900; background: rgba(30, 10, 20, .45); display: grid; place-items: end center; padding: 12px; }
.dialog-card { width: 100%; max-width: 440px; background: var(--bg); color: var(--ink); border-radius: 22px; padding: 18px; box-shadow: var(--shadow); animation: rise .4s both; }
.dialog-card h3 { font-family: var(--serif); font-size: 26px; margin: 0 0 4px; font-weight: 600; }
.muted { color: var(--muted); font-size: 13px; margin: 0 0 12px; line-height: 1.5; }
#hotel-form { display: flex; gap: 8px; }
#hotel-form input { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
#hotel-results { list-style: none; margin: 10px 0 0; padding: 0; max-height: 40vh; overflow: auto; }
#hotel-results li button { width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 10px 4px; font-size: 13.5px; line-height: 1.4; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.toast { position: fixed; z-index: 950; left: 50%; top: 84px; transform: translateX(-50%); background: #2b1d20; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 13.5px; box-shadow: var(--shadow); max-width: calc(100% - 32px); text-align: center; }

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  .brand-float { display: none; }
  .sheet { left: 16px; top: 16px; bottom: 16px; right: auto; width: 420px; height: auto !important; border-radius: 26px; box-shadow: var(--shadow); }
  .sheet.away { transform: translateX(-120%); }
  .grab { display: none; }
  .panel-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 12px; }
  .panel-brand h1 { font-size: 32px; }
  .tools { top: 34px; }
  .hero { left: auto; right: 24px; bottom: 28px; margin: 0; }
  .dialog { place-items: center; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* stay zones */
.pin.k-zone { background: #fff; color: #b8325a; }
.pin.k-hotel svg { width: 18px; height: 18px; }
.actions button.here { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.actions button.here.chosen { background: var(--accent); color: var(--accent-ink); }
.banner a { color: inherit; font-weight: 600; }
.banner svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.home-line a { color: inherit; font-weight: 600; }
.k-hotel + .lbl { display: block; }

/* next chapter */
.next { display: flex; align-items: center; gap: 10px; width: 100%; margin: 22px 0 8px; padding: 14px 16px; border-radius: 18px; border: 0; text-align: left;
  background: var(--accent); color: var(--accent-ink); font-size: 14.5px; font-weight: 500; box-shadow: 0 6px 20px rgba(60, 20, 30, .15); }
.next small { font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase; opacity: .8; }
.next span { flex: 1; }
.next b { font-size: 20px; }
@media (max-height: 700px) { .hero { padding: 16px 18px 14px; } .hero h2 { font-size: 36px; margin: 4px 0 6px; } .hero-text { font-size: 13.5px; } .hero-index button { padding: 7px 10px; } }

/* "Dove dormire" is a separate screen: no weekend tabs, one way into the weekend */
body[data-mode="stay"] .chapters, body[data-mode="stay"] .weather { display: none; }
body[data-mode="stay"] .sheet-body { padding-bottom: 16px; }
.next.sticky { position: sticky; bottom: 0; margin-bottom: 0; font-size: 16px; font-weight: 600; }
.next .from { display: inline; text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 500; opacity: .85; margin-left: 4px; }
