:root {
  --bg: #060a14;
  --glass: rgba(12, 18, 34, 0.66);
  --glass-strong: rgba(12, 18, 34, 0.86);
  --line: rgba(160, 190, 255, 0.12);
  --line-strong: rgba(160, 190, 255, 0.22);
  --text: #e7ecff;
  --muted: #8f9bbd;
  --faint: #5d6888;
  --cyan: #6ee7ff;
  --violet: #a78bfa;
  --gold: #ffd36e;
  --green: #4ade80;
  --amber: #fbbf24;
  --red: #fb7185;
  --grad: linear-gradient(135deg, var(--cyan), var(--violet));
  --radius: 18px;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.7), 0 0 0 1px var(--line);
  --top: 76px;
  --panel-w: 400px;
  --drawer-w: 440px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text); overflow: hidden;
  font: 14px/1.45 Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .num, .brand { font-family: 'Space Grotesk', Inter, sans-serif; letter-spacing: -0.01em; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
kbd { font: 12px ui-monospace, monospace; background: rgba(255,255,255,.08); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

#map { position: fixed; inset: 0; }
.vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(3,6,14,.55) 100%); }

.glass {
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- buttons & inputs ---------- */
button { cursor: pointer; border: 0; background: none; }
.primary {
  background: var(--grad); color: #071021; font-weight: 600; padding: 10px 18px; border-radius: 12px;
  box-shadow: 0 6px 24px -6px rgba(110, 231, 255, .55); transition: transform .15s, box-shadow .2s, filter .2s; white-space: nowrap;
}
.primary:hover { transform: translateY(-1px); box-shadow: 0 10px 30px -6px rgba(167, 139, 250, .7); }
.primary:active { transform: translateY(0); }
.primary:disabled { filter: grayscale(.6) brightness(.7); cursor: progress; }
.ghost { padding: 9px 14px; border-radius: 11px; border: 1px solid var(--line-strong); color: var(--text); background: rgba(255,255,255,.03); transition: background .15s, border-color .15s; }
.ghost:hover { background: rgba(255,255,255,.08); border-color: rgba(160,190,255,.35); }
.ghost.sm { padding: 6px 10px; font-size: 12px; }
#pasteSrcBtn { font-family: ui-monospace, monospace; }
.danger { color: var(--red); border-color: rgba(251,113,133,.35); }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.03); }
.icon-btn:hover { background: rgba(255,255,255,.09); }
.icon-btn svg { width: 20px; height: 20px; }
input[type=text], input[type=url], input[type=search], input[type=number], select, textarea {
  background: rgba(4, 8, 18, .55); border: 1px solid var(--line-strong); border-radius: 11px; padding: 9px 12px; outline: none; transition: border-color .15s, box-shadow .15s; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: rgba(110,231,255,.6); box-shadow: 0 0 0 3px rgba(110,231,255,.12); }
select { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
select option { background: #0c1222; }
textarea { resize: vertical; min-height: 70px; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; top: 12px; left: 12px; right: 12px; height: 56px; z-index: 20;
  display: flex; align-items: center; gap: 16px; padding: 0 10px 0 16px;
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 19px; font-weight: 600; white-space: nowrap; }
.brand svg { width: 26px; height: 26px; filter: drop-shadow(0 0 10px rgba(110,231,255,.5)); }
.brand b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.add { flex: 1; display: flex; align-items: center; gap: 8px; max-width: 780px; margin: 0 auto; position: relative;
  background: rgba(4,8,18,.5); border: 1px solid var(--line-strong); border-radius: 14px; padding: 4px 4px 4px 12px; transition: border-color .2s, box-shadow .2s; }
.add:focus-within { border-color: rgba(110,231,255,.55); box-shadow: 0 0 0 4px rgba(110,231,255,.1), 0 0 40px -10px rgba(110,231,255,.5); }
.add .ico { width: 18px; height: 18px; color: var(--muted); flex: none; }
.add input { border: 0; background: transparent; box-shadow: none !important; padding: 8px 4px; }
.add .primary { padding: 8px 16px; }
.top-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.seg { display: flex; background: rgba(4,8,18,.5); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { padding: 6px 12px; border-radius: 9px; color: var(--muted); font-weight: 500; font-size: 13px; }
.seg button.on { background: rgba(110,231,255,.14); color: var(--text); box-shadow: inset 0 0 0 1px rgba(110,231,255,.3); }

/* ---------- list panel ---------- */
.panel {
  position: fixed; top: var(--top); left: 12px; bottom: 12px; width: var(--panel-w); z-index: 10;
  display: flex; flex-direction: column; overflow: hidden; transition: transform .45s cubic-bezier(.2,.8,.2,1), opacity .3s;
}
body[data-view=map] .panel, body[data-view=table] .panel { transform: translateX(calc(-100% - 24px)); opacity: 0; pointer-events: none; }
.panel-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.stats .chip b { color: var(--text); }
.controls { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.controls .toggle { grid-column: 1 / -1; }
.dest-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.dest-pick:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.05); border: 1px solid var(--line); font-size: 12px; white-space: nowrap; }
.chip.btn { cursor: pointer; }
.status-pick .chip b { color: var(--muted); font-weight: 600; }
.status-pick .chip.on b { color: var(--text); }
.chip.btn.on { background: rgba(110,231,255,.14); border-color: rgba(110,231,255,.4); color: var(--text); }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { display: none; }
.toggle span { width: 32px; height: 18px; border-radius: 99px; background: rgba(255,255,255,.12); position: relative; transition: background .2s; flex: none; }
.toggle span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle input:checked + span { background: var(--red); }
.toggle input:checked + span::after { transform: translateX(14px); }

.list { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; scrollbar-color: rgba(160,190,255,.2) transparent; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty .big { font-size: 46px; margin-bottom: 6px; filter: drop-shadow(0 0 20px rgba(110,231,255,.6)); }

.card {
  position: relative; display: grid; grid-template-columns: 96px 1fr; gap: 12px; padding: 10px; border-radius: 15px;
  background: rgba(255,255,255,.035); border: 1px solid var(--line); cursor: pointer;
  transition: transform .2s, background .2s, border-color .2s, box-shadow .2s, opacity .2s; animation: rise .5s both cubic-bezier(.2,.8,.2,1);
}
.card:hover { background: rgba(255,255,255,.06); border-color: var(--line-strong); transform: translateY(-1px); }
.card.sel { border-color: rgba(110,231,255,.6); box-shadow: 0 0 0 1px rgba(110,231,255,.4), 0 10px 40px -12px rgba(110,231,255,.45); background: rgba(110,231,255,.06); }
.card.ruled { opacity: .5; filter: saturate(.3); }
.card.ruled .thumb::after { content: 'RULED OUT'; position: absolute; inset: auto 0 8px 0; text-align: center; font: 700 10px/1 Inter; letter-spacing: .12em; color: #fff; background: rgba(251,113,133,.85); padding: 4px 0; transform: rotate(-8deg); }
.card.dragging { opacity: .35; }
.card.drop-before { box-shadow: 0 -3px 0 0 var(--cyan); }
.card.drop-after { box-shadow: 0 3px 0 0 var(--cyan); }
.thumb { position: relative; width: 96px; height: 96px; border-radius: 11px; overflow: hidden; background: linear-gradient(135deg, #1b2744, #0d1428); }
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s; }
.card:hover .thumb img { transform: scale(1.06); }
.rank { position: absolute; top: 6px; left: 6px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 8px; display: grid; place-items: center; font: 700 12px 'Space Grotesk'; background: rgba(6,10,20,.75); border: 1px solid var(--line-strong); backdrop-filter: blur(6px); }
.rank.r1 { background: linear-gradient(135deg, #ffe08a, #f5a524); color: #2a1a00; border: 0; box-shadow: 0 0 16px rgba(255,211,110,.7); }
.rank.r2 { background: linear-gradient(135deg, #f1f5ff, #9aa8c7); color: #101626; border: 0; }
.rank.r3 { background: linear-gradient(135deg, #f7c59f, #c0773e); color: #2a1300; border: 0; }
.card-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.price { font: 600 17px 'Space Grotesk'; }
.price small { font: 500 11px Inter; color: var(--muted); margin-right: 4px; }
.desc { font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.addr { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; background: rgba(255,255,255,.06); color: var(--muted); white-space: nowrap; }
.pill.c-good { background: rgba(74,222,128,.12); color: #8ff0b2; }
.pill.c-ok { background: rgba(251,191,36,.12); color: #fcd57a; }
.pill.c-bad { background: rgba(251,113,133,.13); color: #ffa3b2; }
.pill.status { background: rgba(167,139,250,.14); color: #cbbcff; }
.stars { color: var(--gold); letter-spacing: 1px; font-size: 12px; }
.stars .off { color: rgba(255,255,255,.15); }
.handle { position: absolute; right: 8px; bottom: 8px; color: var(--faint); cursor: grab; font-size: 14px; opacity: 0; transition: opacity .2s; }
.card:hover .handle { opacity: 1; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- drawer ---------- */
.drawer {
  position: fixed; top: var(--top); right: 12px; bottom: 12px; width: var(--drawer-w); z-index: 15; overflow-y: auto; overflow-x: hidden;
  transform: translateX(calc(100% + 24px)); transition: transform .5s cubic-bezier(.2,.8,.2,1); background: var(--glass-strong);
  scrollbar-width: thin; scrollbar-color: rgba(160,190,255,.2) transparent;
}
.drawer.open { transform: none; }
.hero { position: relative; height: 230px; overflow: hidden; border-radius: var(--radius) var(--radius) 0 0; background: radial-gradient(80% 120% at 20% 0%, rgba(110,231,255,.25), transparent 60%), radial-gradient(80% 120% at 100% 30%, rgba(167,139,250,.28), transparent 60%), #0d1428; }
.gallery { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.gallery img { flex: none; width: 100%; height: 100%; object-fit: cover; scroll-snap-align: start; }
.hero::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(6,10,20,.4), transparent 30%, transparent 55%, rgba(8,12,24,.95)); pointer-events: none; }
.hero .close { position: absolute; top: 10px; right: 10px; z-index: 2; width: 34px; height: 34px; border-radius: 50%; background: rgba(6,10,20,.6); backdrop-filter: blur(8px); font-size: 18px; }
.hero .count { position: absolute; top: 12px; left: 12px; z-index: 2; }
.hero .gnav { position: absolute; top: 50%; z-index: 2; width: 32px; height: 32px; border-radius: 50%; background: rgba(6,10,20,.55); transform: translateY(-50%); font-size: 16px; }
.hero .gnav.prev { left: 10px; } .hero .gnav.next { right: 10px; }
.hero-title { position: absolute; left: 18px; right: 18px; bottom: 12px; z-index: 2; }
.hero-title h2 { margin: 0; font-size: 22px; line-height: 1.15; text-shadow: 0 2px 16px rgba(0,0,0,.6); }
.hero-title .price { font-size: 26px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.dsec { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.dsec:last-child { border-bottom: 0; }
.dsec h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-family: Inter; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.facts .k { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; }
.facts .v { font-weight: 500; overflow-wrap: anywhere; }
.facts .full { grid-column: 1 / -1; }
.links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.links a { text-decoration: none; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.row.wrap { flex-wrap: wrap; }

.rate { display: flex; gap: 2px; font-size: 24px; }
.rate button { color: rgba(255,255,255,.15); transition: transform .15s, color .15s, text-shadow .2s; padding: 0 2px; }
.rate button.on { color: var(--gold); text-shadow: 0 0 14px rgba(255,211,110,.6); }
.rate button:hover { transform: scale(1.2); }
.rank-big { font: 700 34px 'Space Grotesk'; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1; }
.rank-ctl { display: flex; align-items: center; gap: 14px; justify-content: space-between; }
.rank-ctl .ghost { padding: 6px 10px; }
.ruled-box { margin-top: 14px; padding: 12px; border-radius: 12px; border: 1px dashed rgba(251,113,133,.35); background: rgba(251,113,133,.05); display: grid; gap: 8px; }

.commute { border-radius: 14px; padding: 14px; background: linear-gradient(135deg, rgba(110,231,255,.07), rgba(167,139,250,.07)); border: 1px solid var(--line); margin-bottom: 10px; position: relative; overflow: hidden; }
.commute.active { border-color: rgba(110,231,255,.55); box-shadow: 0 0 30px -12px rgba(110,231,255,.7); }
.commute .ch { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.commute .dname { font-weight: 600; }
.commute .when { font-size: 11.5px; color: var(--muted); }
.commute .mins { font: 700 30px/1 'Space Grotesk'; }
.commute .mins small { font-size: 13px; color: var(--muted); font-weight: 500; }
.walk { display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; padding: 10px 12px; border-radius: 11px; background: rgba(4,8,18,.45); }
.walk .wico { font-size: 20px; }
.walk b { font: 700 18px 'Space Grotesk'; }
.legs { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--muted); }
.legs li { display: flex; gap: 8px; }
.legs .lm { color: var(--text); font-weight: 500; flex: 0 0 34%; }
.commute .err { font-size: 12px; color: #fcd57a; margin-top: 8px; }
.commute .actions { display: flex; gap: 8px; margin-top: 10px; }

.stations { display: flex; flex-direction: column; gap: 6px; }
.stations div { display: flex; justify-content: space-between; font-size: 13px; }

.timeline { list-style: none; margin: 14px 0 0; padding: 0 0 0 16px; border-left: 2px solid rgba(160,190,255,.14); display: flex; flex-direction: column; gap: 14px; }
.timeline li { position: relative; }
.timeline li::before { content: ''; position: absolute; left: -22px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--violet); box-shadow: 0 0 10px var(--violet); }
.timeline li.sys::before { background: var(--faint); box-shadow: none; }
.timeline .when { font-size: 11.5px; color: var(--faint); display: flex; justify-content: space-between; }
.timeline .when button { color: var(--faint); font-size: 12px; opacity: 0; }
.timeline li:hover .when button { opacity: 1; }
.timeline .txt { white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline li.sys .txt { color: var(--muted); font-size: 13px; }
.comment-form { display: grid; gap: 8px; }
.comment-form .row select { width: auto; flex: 1; }

.edit-grid { display: grid; gap: 10px; }
.edit-grid label, .modal label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
.edit-grid .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.drag-note { font-size: 12px; color: var(--cyan); margin-top: 8px; }

/* ---------- table view ---------- */
#tableView { position: fixed; top: var(--top); left: 12px; right: 12px; bottom: 12px; z-index: 12; overflow: hidden; display: none; background: var(--glass-strong); }
body[data-view=table] #tableView { display: block; animation: fade .35s both; }
body[data-view=table] .map-tools { display: none; }
.table-wrap { height: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { position: sticky; top: 0; background: rgba(10,15,30,.97); text-align: left; padding: 12px 9px; font-weight: 600; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); cursor: pointer; white-space: nowrap; z-index: 1; }
th:hover { color: var(--text); }
th.sorted::after { content: ' ↓'; color: var(--cyan); }
th.sorted.asc::after { content: ' ↑'; }
td { padding: 10px 9px; border-top: 1px solid var(--line); vertical-align: middle; }
tr.trow { cursor: pointer; transition: background .15s; }
tr.trow:hover { background: rgba(110,231,255,.05); }
tr.trow.ruled { opacity: .45; }
tr.trow.ruled td:nth-child(3) { text-decoration: line-through; }
td .tthumb { width: 56px; height: 40px; border-radius: 7px; object-fit: cover; display: block; background: #1b2744; }
@keyframes fade { from { opacity: 0; } }

/* ---------- map tools & markers ---------- */
.map-tools { position: fixed; z-index: 9; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; padding: 4px; border-radius: 14px; }
body[data-view=split] .map-tools { left: calc(50% + var(--panel-w) / 2); }
body.has-sel .map-tools { left: calc(50% - var(--drawer-w) / 2); }
body.has-sel[data-view=split] .map-tools { left: calc(50% + (var(--panel-w) - var(--drawer-w)) / 2); }
.map-tools button { padding: 7px 12px; border-radius: 10px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.map-tools button.on, .map-tools button:hover { color: var(--text); background: rgba(255,255,255,.08); }
.map-tools .sep { width: 1px; background: var(--line); margin: 4px 4px; }
.maplibregl-ctrl-bottom-right { bottom: 10px; right: 10px; }
.maplibregl-ctrl-attrib { background: rgba(6,10,20,.6) !important; color: var(--faint) !important; }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
.maplibregl-ctrl-group { background: var(--glass) !important; backdrop-filter: blur(12px); border-radius: 12px !important; box-shadow: var(--shadow) !important; }
.maplibregl-ctrl-group button { filter: invert(1) hue-rotate(180deg); }
body.has-sel .maplibregl-ctrl-top-right { right: calc(var(--drawer-w) + 24px); }
.maplibregl-ctrl-top-right { top: calc(var(--top) - 4px); }

/* Home pins. The outer .pin is positioned by MapLibre (never give it a transform or transition);
   the visual parts live in .pin-body, centred exactly on the coordinate. */
.pin { width: 16px; height: 16px; cursor: pointer; }
.pin-body { --c: var(--cyan); position: relative; width: 16px; height: 16px; transition: transform .2s cubic-bezier(.2,.8,.2,1), opacity .2s, filter .2s; }
.pin:hover .pin-body { transform: scale(1.15); }
.pin-dot { position: absolute; inset: 2px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px rgba(6,10,20,.75), 0 0 0 5px color-mix(in srgb, var(--c) 30%, transparent), 0 0 16px var(--c); }
.pin-dot::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--c); animation: ping 2.4s infinite cubic-bezier(.2,.6,.3,1); opacity: 0; }
.pin-stem { position: absolute; left: 7px; bottom: 100%; width: 2px; height: 12px; background: linear-gradient(transparent, var(--c)); pointer-events: none; }
.pin-label { position: absolute; left: 50%; bottom: calc(100% + 12px); transform: translateX(-50%); padding: 4px 8px; border-radius: 9px; background: rgba(6,10,20,.85); border: 1px solid color-mix(in srgb, var(--c) 70%, transparent); color: #fff; font: 600 12px/1.2 'Space Grotesk'; white-space: nowrap; box-shadow: 0 0 16px -3px color-mix(in srgb, var(--c) 70%, transparent); backdrop-filter: blur(6px); display: flex; gap: 6px; align-items: center; }
.pin-label .r { background: var(--c); color: #061021; border-radius: 5px; padding: 0 5px; font-size: 11px; }
.pin-label .cm { color: color-mix(in srgb, var(--c) 75%, #fff); }
.pin-label .cm::before { content: '· '; color: var(--muted); }
.pin-body.top .pin-label { border-color: var(--gold); box-shadow: 0 0 20px -2px rgba(255,211,110,.6); }
.pin-body.ruled { --c: #6b7280 !important; filter: grayscale(1); opacity: .55; }
.pin-body.ruled .pin-label { text-decoration: line-through; }
.pin-body.ruled .pin-dot::after { display: none; }
.pin-body.sel { transform: scale(1.2); }
.pin-body.sel .pin-dot::after { animation-duration: 1.2s; }
.pin-body.dim { opacity: .35; }
/* zoom bands (set on the map container) */
#map[data-z=far] .pin-body:not(.sel) .pin-label, #map[data-z=far] .pin-body:not(.sel) .pin-stem { display: none; }
#map[data-z=far] .pin:hover .pin-label, #map[data-z=far] .pin:hover .pin-stem { display: flex; }
#map[data-z=far] .pin-body:not(.sel) { transform: scale(.8); }
#map[data-z=far] .pin-body:not(.sel) .pin-dot::after { display: none; }
#map[data-z=mid] .pin-body:not(.sel) .pin-label .cm { display: none; }
@keyframes ping { 0% { transform: scale(.6); opacity: .9; } 100% { transform: scale(3.2); opacity: 0; } }

/* Destination stars: the element is the star itself (centred on the point); the label hangs below. */
.dest { width: 30px; height: 30px; cursor: pointer; } /* no position here: MapLibre makes markers position:absolute */
.dest .star { position: absolute; inset: 0; border-radius: 10px; display: grid; place-items: center; background: var(--grad); color: #061021; font-size: 15px; box-shadow: 0 0 0 5px rgba(167,139,250,.18), 0 0 26px rgba(167,139,250,.9); transform: rotate(45deg); }
.dest .star span { transform: rotate(-45deg); }
.dest label { position: absolute; top: calc(100% + 10px); left: 50%; transform: translateX(-50%); padding: 3px 9px; border-radius: 8px; background: rgba(6,10,20,.85); font: 600 12px 'Space Grotesk'; white-space: nowrap; border: 1px solid rgba(167,139,250,.5); pointer-events: none; }
#map[data-z=far] .dest label { display: none; }

/* ---------- overlays, modals, toasts ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(3,6,14,.55); backdrop-filter: blur(6px); animation: fade .3s both; }
.progress-card { width: min(420px, calc(100vw - 32px)); padding: 30px 28px 24px; text-align: center; }
.progress-card h3 { margin: 18px 0 14px; font-size: 20px; }
.progress-card ol { list-style: none; padding: 0; margin: 0; text-align: left; display: grid; gap: 9px; }
.progress-card li { color: var(--faint); display: flex; align-items: center; gap: 10px; transition: color .3s; }
.progress-card li::before { content: ''; width: 9px; height: 9px; border-radius: 50%; border: 2px solid currentColor; flex: none; }
.progress-card li.active { color: var(--text); }
.progress-card li.active::before { background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 12px var(--cyan); animation: pulse 1s infinite alternate; }
.progress-card li.done { color: var(--muted); }
.progress-card li.done::before { background: var(--green); border-color: var(--green); }
@keyframes pulse { to { transform: scale(1.4); } }
.orb { position: relative; width: 84px; height: 84px; margin: 0 auto; }
.orb span { position: absolute; inset: 0; border-radius: 50%; border: 2px solid transparent; border-top-color: var(--cyan); animation: spin 1.4s linear infinite; }
.orb span:nth-child(2) { inset: 10px; border-top-color: var(--violet); animation-duration: 1.9s; animation-direction: reverse; }
.orb span:nth-child(3) { inset: 24px; background: var(--grad); border: 0; filter: blur(6px); animation: breathe 1.6s ease-in-out infinite alternate; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { from { transform: scale(.7); opacity: .6; } to { transform: scale(1.05); opacity: 1; } }

dialog.modal { border: 0; color: var(--text); padding: 24px; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow-y: auto; background: var(--glass-strong); }
dialog.modal::backdrop { background: rgba(3,6,14,.6); backdrop-filter: blur(5px); }
dialog.modal h2 { margin: 0 0 6px; font-size: 21px; }
dialog.modal h4 { margin: 22px 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
dialog.modal form { display: grid; gap: 12px; }
.dest-list { display: grid; gap: 8px; }
.dest-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.dest-item .grow { flex: 1; min-width: 0; }
.dest-item small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dest-add { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; }
.status-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; }
.dotc { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dotc.on { background: var(--green); box-shadow: 0 0 10px var(--green); }
.dotc.off { background: var(--faint); }
.bookmarklet { display: inline-block; padding: 9px 16px; border-radius: 11px; background: var(--grad); color: #061021 !important; font-weight: 600; text-decoration: none !important; cursor: grab; }
.banner { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: rgba(167,139,250,.1); border: 1px solid rgba(167,139,250,.3); font-size: 13px; }
.banner button { margin-left: auto; }

#toasts { position: fixed; z-index: 60; bottom: 76px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { pointer-events: auto; padding: 11px 16px; border-radius: 12px; background: var(--glass-strong); backdrop-filter: blur(14px); box-shadow: var(--shadow); max-width: min(560px, calc(100vw - 32px)); animation: toastIn .35s both cubic-bezier(.2,.8,.2,1); border-left: 3px solid var(--cyan); }
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.97); } }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  :root { --panel-w: 340px; --drawer-w: 380px; }
  .brand span { display: none; }
}
@media (max-width: 760px) {
  :root { --top: 124px; }
  .topbar { height: auto; flex-wrap: wrap; padding: 10px; gap: 8px; }
  .add { order: 3; flex-basis: 100%; }
  .top-right { margin-left: auto; }
  .panel { left: 8px; right: 8px; width: auto; top: auto; height: 46vh; bottom: 8px; }
  .drawer { left: 8px; right: 8px; width: auto; top: 70px; bottom: 8px; z-index: 30; }
  .map-tools, body[data-view=split] .map-tools { left: 50%; bottom: calc(46vh + 18px); }
  body[data-view=map] .map-tools { bottom: 18px; }
  .seg button { padding: 6px 9px; }
  #pasteSrcBtn { display: none; }
  .dest-add { grid-template-columns: 1fr; }
}
/* Phones (the Android app, a Galaxy S10e is 360px wide): one row of controls over the add box, rows of
   chips that scroll sideways instead of wrapping, and a list panel that scrolls as a whole, so the
   filters scroll away and the homes get the room. */
@media (max-width: 520px) {
  :root { --top: 112px; }
  .topbar { top: 8px; left: 8px; right: 8px; padding: 8px; gap: 8px; }
  .brand { display: none; }
  .top-right { order: 1; flex-basis: 100%; margin-left: 0; gap: 6px; }
  .add { order: 2; padding: 3px 3px 3px 10px; }
  .add input { padding: 6px 2px; font-size: 16px; } /* 16px stops the phone zooming in on focus */
  .add .primary { padding: 7px 12px; }
  .list-btn { flex: 1; min-width: 0; max-width: none; padding: 7px 8px 7px 10px; }
  .seg button { padding: 6px 8px; font-size: 12.5px; }
  .icon-btn { width: 36px; height: 36px; flex: none; }
  .panel { overflow-y: auto; overscroll-behavior: contain; }
  .panel-head { padding: 10px 10px 8px; gap: 8px; }
  .list { flex: none; overflow: visible; padding: 8px; }
  .stats, .dest-pick { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -10px; padding: 0 10px; }
  .stats::-webkit-scrollbar, .dest-pick::-webkit-scrollbar, .map-tools::-webkit-scrollbar { display: none; }
  .stats > *, .dest-pick > * { flex: none; }
  .controls input, .controls select { font-size: 16px; }
  .map-tools, body[data-view=split] .map-tools, body.has-sel .map-tools, body.has-sel[data-view=split] .map-tools {
    left: 8px; right: 8px; transform: none; overflow-x: auto; scrollbar-width: none; }
  .map-tools, body[data-view=split] .map-tools { bottom: calc(46vh + 14px); }
  .map-tools button { flex: none; padding: 7px 10px; }
  .drawer { top: 8px; }
  .card { grid-template-columns: 84px minmax(0, 1fr); gap: 10px; }
  .thumb { width: 84px; height: 84px; }
  .card-body .pill { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
}

.match { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.match figure { margin: 0; position: relative; border-radius: 11px; overflow: hidden; aspect-ratio: 16 / 10; background: #0d1428; }
.match img { width: 100%; height: 100%; object-fit: cover; display: block; }
.match figcaption { position: absolute; left: 6px; bottom: 6px; font-size: 11px; padding: 2px 7px; border-radius: 6px; background: rgba(6,10,20,.75); }

/* journey strip */
.jstrip { display: flex; gap: 3px; margin: 12px 0 12px; height: 24px; }
.js { min-width: 38px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font: 600 11px/1 Inter; overflow: hidden; white-space: nowrap; }
.js span { display: inline-flex; align-items: center; gap: 3px; line-height: 1; }
.js-walk { background: repeating-linear-gradient(90deg, rgba(255,255,255,.18) 0 4px, rgba(255,255,255,.06) 4px 8px); color: var(--text); }
.js-transit { background: var(--lc); color: #061021; box-shadow: 0 0 14px -4px var(--lc); }
.ldot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--lc); margin-right: 6px; box-shadow: 0 0 6px var(--lc); }
/* station markers on the map */
.stop { display: flex; align-items: center; gap: 6px; pointer-events: none; }
.stop i { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--lc); box-shadow: 0 0 10px var(--lc); flex: none; }
.stop span { padding: 2px 7px; border-radius: 6px; background: rgba(6,10,20,.82); border: 1px solid color-mix(in srgb, var(--lc) 60%, transparent); font: 600 11px Inter; color: #fff; white-space: nowrap; }
.stop b { color: var(--lc); font-weight: 700; }

/* collapsible commute cards */
.commute { padding: 0; }
.csum { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-align: left; border-radius: 14px; }
.csum:hover { background: rgba(255,255,255,.03); }
.cleft { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cwalk { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cwalk b { color: var(--text); font-family: 'Space Grotesk'; }
.csum .mins { font-size: 26px; }
.chev { font-size: 20px; color: var(--faint); transition: transform .2s; line-height: 1; }
.commute.open .chev { transform: rotate(90deg); color: var(--cyan); }
.cdetail { padding: 0 14px 14px; animation: fade .25s both; }
.commute .err { margin: 0 14px 12px; }
.cdetail .err { margin: 8px 0 0; }
.linkish { color: var(--cyan); font-size: 11.5px; letter-spacing: 0; text-transform: none; font-weight: 500; }
.linkish:hover { text-decoration: underline; }

/* refresh-all progress card */
#jobCard { position: fixed; z-index: 40; left: 24px; bottom: 24px; width: 340px; padding: 14px 16px; display: grid; gap: 8px; animation: toastIn .3s both; }
body[data-view=split] #jobCard { left: calc(var(--panel-w) + 36px); }
#jobCard .bar { height: 6px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
#jobCard .bar span { display: block; height: 100%; width: 0; background: var(--grad); box-shadow: 0 0 12px rgba(110,231,255,.6); transition: width .4s; }
#jobText { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.controls .linkish { font-size: 12.5px; }
@media (max-width: 760px) { #jobCard, body[data-view=split] #jobCard { left: 8px; right: 8px; width: auto; bottom: calc(46vh + 70px); } }

/* hover card on home pins */
.hh-pop { pointer-events: none; z-index: 30; }
.hh-pop .maplibregl-popup-content { padding: 0; background: var(--glass-strong); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-radius: 14px; box-shadow: 0 18px 50px -12px rgba(0,0,0,.8), 0 0 0 1px var(--line-strong); overflow: hidden; color: var(--text); font: inherit; }
.hh-pop .maplibregl-popup-tip { display: none; }
.hc { width: 280px; animation: hcIn .16s ease-out both; }
.hc-img { position: relative; height: 130px; background: #0d1428; }
.hc-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hc-img .rank { top: 8px; left: 8px; }
.hc-ruled { position: absolute; right: 8px; top: 8px; font: 700 10px Inter; letter-spacing: .1em; text-transform: uppercase; padding: 3px 7px; border-radius: 6px; background: rgba(251,113,133,.9); color: #fff; }
.hc.ruled .hc-img img { filter: grayscale(1) brightness(.7); }
.hc-body { padding: 10px 12px 11px; display: grid; gap: 3px; }
.hc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hc .price { font-size: 18px; }
.hc .desc { white-space: normal; }
.hc .addr { white-space: normal; }
.hc-commute { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; margin-top: 4px; font-size: 12.5px; }
.hc-commute b { font: 700 15px 'Space Grotesk'; }
.hc-commute b.c-good { color: #8ff0b2; } .hc-commute b.c-ok { color: #fcd57a; } .hc-commute b.c-bad { color: #ffa3b2; }
.hc .meta { margin-top: 5px; }
.hc-reason { font-size: 12px; color: #ffa3b2; margin-top: 3px; }
.hc-foot { font-size: 11px; color: var(--faint); margin-top: 6px; }
@keyframes hcIn { from { opacity: 0; transform: translateY(4px) scale(.98); } }

/* pin highlighted from the list */
.pin-body.hover { transform: scale(1.45); }
.pin-body.hover .pin-dot { box-shadow: 0 0 0 3px rgba(6,10,20,.75), 0 0 0 7px color-mix(in srgb, var(--c) 45%, transparent), 0 0 26px var(--c); }
#map[data-z=far] .pin-body.hover .pin-label, #map[data-z=far] .pin-body.hover .pin-stem { display: flex; }
#map[data-z=mid] .pin-body.hover .pin-label .cm { display: inline; }

/* table: last status update */
.tupd { min-width: 240px; max-width: 320px; display: grid; gap: 3px; justify-items: start; }
.tupd-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; line-height: 1.35; }
.tupd-when { font-size: 11.5px; }

/* address as the heading, short description as the subheading */
.card .desc { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; }
.hero-title h2 { font-size: 20px; }
.hero-sub { margin-top: 3px; font-size: 14px; color: #c9d3f0; text-shadow: 0 2px 12px rgba(0,0,0,.7); }
.thome { display: grid; gap: 2px; justify-items: start; min-width: 200px; max-width: 280px; }
.thome .muted { font-size: 12px; }

/* the details drawer belongs to the map views; table rows switch back to Split when clicked */
body[data-view=table] .drawer { transform: translateX(calc(100% + 24px)); }
body[data-view=table] .maplibregl-ctrl-top-right { display: none; }

/* table: rank badge on the thumbnail */
.tthumb-wrap { position: relative; width: 60px; height: 44px; border-radius: 8px; background: #1b2744; }
.tthumb-wrap .tthumb { width: 60px; height: 44px; border-radius: 8px; }
.tthumb-wrap .rank { top: -6px; left: -6px; min-width: 22px; height: 22px; font-size: 11px; }
th:first-child, td:first-child { padding-left: 16px; }
.tupd { min-width: 220px; }

.banner.dup { background: rgba(251,191,36,.1); border-color: rgba(251,191,36,.35); flex-wrap: wrap; }

/* homes waiting for details (site blocked the direct read) */
.card.pending { border-style: dashed; }
.card.pending .thumb { display: grid; place-items: center; }
.card.pending .thumb .wait { font-size: 30px; opacity: .7; animation: waitpulse 2.4s ease-in-out infinite; }
.card.pending .addr { white-space: normal; }
@keyframes waitpulse { 50% { opacity: .3; } }
.hero.pending-hero { height: 120px; }
.steps { margin: 8px 0 10px; padding-left: 20px; line-height: 1.8; }
.steps a { color: var(--cyan); }

/* EPC register */
.epc-pick { margin-top: 8px; width: 100%; font-size: 13px; }
.epc-band { display: inline-block; min-width: 2.2em; padding: 1px 7px; border-radius: 6px; font-weight: 700; font-size: 12px; color: #0a0f1c; text-align: center; }
.epc-band.b-A { background: #008054; color: #fff; }
.epc-band.b-B { background: #19b459; }
.epc-band.b-C { background: #8dce46; }
.epc-band.b-D { background: #ffd500; }
.epc-band.b-E { background: #fcaa65; }
.epc-band.b-F { background: #ef8023; }
.epc-band.b-G { background: #e9153b; color: #fff; }

/* ---------- accounts, lists and sharing ---------- */
input[type=email] { background: rgba(4, 8, 18, .55); border: 1px solid var(--line-strong); border-radius: 11px; padding: 9px 12px; outline: none; width: 100%; }
.small { font-size: 12px; }
.btn { display: inline-block; text-decoration: none; }
.list-btn { display: flex; align-items: center; gap: 6px; max-width: 220px; padding: 8px 10px 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.03); font-weight: 600; }
.list-btn:hover { background: rgba(255,255,255,.09); }
.list-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-btn svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.avatar span { font-weight: 700; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-size: 16px; }
.menu { position: fixed; z-index: 60; min-width: 260px; max-width: min(360px, calc(100vw - 24px)); padding: 6px; display: flex; flex-direction: column; background: var(--glass-strong); }
.menu-h { padding: 8px 10px 6px; font-weight: 600; }
.menu-h small { display: block; color: var(--muted); font-weight: 400; }
.menu-i { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; padding: 9px 10px; border-radius: 10px; }
.menu-i:hover { background: rgba(255,255,255,.07); }
.menu-i.on { background: rgba(110,231,255,.09); box-shadow: inset 2px 0 0 var(--cyan); }
.menu-i small { color: var(--muted); font-size: 11.5px; }
.auth { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at 50% 30%, rgba(110,231,255,.08), transparent 60%), rgba(6,10,20,.72); }
.auth-card { width: min(420px, 100%); padding: 28px 26px; display: flex; flex-direction: column; gap: 12px; background: var(--glass-strong); }
.auth-card h2 { margin: 6px 0 0; font-family: 'Space Grotesk', Inter, sans-serif; }
.auth-card p { margin: 0; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-family: 'Space Grotesk', Inter, sans-serif; font-size: 20px; }
.auth-brand svg { width: 30px; height: 30px; }
.brand.auth-brand span { display: inline; } /* the top bar hides its wordmark on phones; the sign-in card keeps it */
.auth-form { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.auth-card .banner { flex-wrap: wrap; }
body.signed-out .topbar, body.signed-out #listPanel, body.signed-out .map-tools { visibility: hidden; }
.others-rate { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.others-rate b { color: var(--gold); font-weight: 400; letter-spacing: 1px; }
textarea.note { min-height: 64px; border-style: dashed; }
.timeline .when .by { margin-left: auto; margin-right: 8px; color: var(--muted); }
.invite-link { display: flex; gap: 8px; margin-top: 10px; }
.invite-link input { font-family: ui-monospace, monospace; font-size: 12px; }
.dest-item select { width: auto; }
/* Viewers see everything but the controls that change shared details. */
body[data-role=viewer] :is(#addForm, #refreshAllBtn, .ruled-box, .dest-add, [data-del-dest], #recalcAll, [data-refresh-all], #commentForm select,
  [data-act=edit], [data-act=delete], [data-act=pin], [data-act=pinpoint], [data-act=refresh], [data-act=up], [data-act=down], [data-act=epcreject], [data-act=epcpick], [data-act=recommute], [data-act=unpin], [data-act=notdup]) { display: none !important; }
@media (max-width: 720px) { .list-btn { max-width: 130px; } #shareBtn { display: none; } }
