:root {
  --bg: #0b1220; --panel: #121c2e; --panel-2: #1a2742; --ink: #e8eef7;
  --muted: #93a4bf; --teal: #14b8a6; --teal-deep: #0f766e; --line: #24344f;
  --danger: #ef4444; --amber: #f59e0b; --pink: #ec4899;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; color: var(--ink); background: var(--bg); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .85rem; }
.warn { color: #fca5a5; font-size: .85rem; margin: .3rem 0; }

#app { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; top: 56px; background: #0b1220; }
#timeline { position: absolute; inset: 56px 0 0 0; overflow-y: auto; padding: 1rem; }

/* Top bar */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; height: 56px; z-index: 700;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 1rem; background: #0d1626; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; }
.brand h1 { font-size: 1.2rem; margin: 0; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 12px var(--teal); }
.viewtoggle { display: flex; background: var(--panel-2); border-radius: 9px; padding: 2px; margin-left: .4rem; }
.viewtoggle button { font: inherit; font-size: .85rem; border: 0; background: none; color: var(--muted); padding: .3rem .8rem; border-radius: 7px; cursor: pointer; }
.viewtoggle button.on { background: var(--teal-deep); color: #fff; }
.actions { display: flex; align-items: center; gap: .8rem; }
.stats { color: var(--muted); font-size: .85rem; }
#stat-count { color: var(--teal); font-weight: 700; font-size: 1.1rem; }
button.primary { font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 9px; background: var(--teal-deep); color: #fff; padding: .5rem .9rem; }
button.primary:hover { background: var(--teal); }
button.primary:disabled { opacity: .55; cursor: not-allowed; }

/* Legend */
#legend { position: absolute; bottom: .8rem; left: .8rem; z-index: 600; background: rgba(18,28,46,.9); border: 1px solid var(--line); border-radius: 10px; padding: .5rem .7rem; font-size: .8rem; color: var(--muted); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin: 0 .25rem 0 .7rem; }
.swatch:first-child { margin-left: 0; }
.swatch.visited { background: var(--teal); } .swatch.unvisited { background: #33415c; }
.swatch.park { background: #22c55e; } .swatch.pin { background: var(--pink); border-radius: 50%; }

/* Badges */
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: .1rem .45rem; border-radius: 6px; background: #334155; color: #cbd5e1; }
.badge.city { background: #1e3a5f; color: #93c5fd; }
.badge.national_park { background: #14532d; color: #86efac; }
.badge.county { background: #134e4a; color: #5eead4; }
.badge.country { background: #3b1d5f; color: #d8b4fe; }

/* Panel */
#panel { position: absolute; top: 56px; right: 0; z-index: 1100; width: min(380px, 94vw); height: calc(100% - 56px); background: var(--panel); border-left: 1px solid var(--line); box-shadow: -12px 0 40px rgba(0,0,0,.45); padding: 1.1rem; overflow-y: auto; transition: transform .2s ease; }
#panel.hidden { display: block !important; transform: translateX(105%); pointer-events: none; }
#panel h2 { margin: .2rem 0 .2rem; font-size: 1.3rem; }
.icon-btn { position: absolute; top: .6rem; right: .6rem; background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); width: 32px; height: 32px; border-radius: 8px; font-size: 1.2rem; cursor: pointer; }
.icon-btn:hover { background: var(--line); }

/* Visit cards */
#visit-list { margin: 1rem 0; display: flex; flex-direction: column; gap: .8rem; }
.visit { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.visit img { display: block; width: 100%; max-height: 220px; object-fit: cover; background: #0b1220; }
.visit .body { padding: .7rem .8rem; }
.visit .date { font-weight: 600; color: var(--teal); font-size: .9rem; }
.visit .reason { margin: .35rem 0 0; white-space: pre-wrap; }
.visit .del { float: right; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: .8rem; }
.visit .del:hover { color: var(--danger); }
.rating-row { margin: .35rem 0; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.rate-btn { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 7px; font-size: .72rem; padding: .12rem .45rem; cursor: pointer; }
.rate-btn:hover { color: var(--ink); border-color: var(--muted); }
.rate-save, .rate-cancel { font: inherit; font-size: .75rem; border: 0; border-radius: 7px; padding: .25rem .6rem; cursor: pointer; }
.rate-save { background: var(--teal-deep); color: #fff; }
.rate-cancel { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.empty { color: var(--muted); font-style: italic; }

/* Rating dots */
.rating-dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.rating-dots .dot { width: 11px; height: 11px; border-radius: 50%; background: #334155; }
.rating-dots .dot.on { background: var(--amber); }
.rating-num { font-size: .78rem; color: var(--muted); margin-left: .4rem; vertical-align: middle; }
.rating-pick { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.rating-pick .dot { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line); background: #334155; cursor: pointer; padding: 0; }
.rating-pick .dot.on { background: var(--amber); border-color: var(--amber); }

/* Comments */
.comments { margin-top: .6rem; border-top: 1px solid var(--line); padding-top: .5rem; }
.thread { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .4rem; }
.comment { font-size: .85rem; background: #0e1726; border: 1px solid var(--line); border-radius: 8px; padding: .35rem .55rem; }
.comment .who { font-weight: 700; font-size: .75rem; padding: 0 .35rem; border-radius: 5px; margin-right: .35rem; }
.comment.tara .who { background: #4c1d95; color: #ddd6fe; }
.comment.matt .who { background: #075985; color: #bae6fd; }
.comment-form { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.comment-form input[type=text] { flex: 1; min-width: 120px; font: inherit; font-size: .85rem; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: .4rem .5rem; }
.comment-form button { font: inherit; font-size: .82rem; border: 0; border-radius: 8px; background: var(--teal-deep); color: #fff; padding: .4rem .7rem; cursor: pointer; }
.author-toggle { display: inline-flex; background: var(--panel-2); border-radius: 8px; padding: 2px; }
.author-toggle button { font: inherit; font-size: .78rem; border: 0; background: none; color: var(--muted); padding: .25rem .55rem; border-radius: 6px; cursor: pointer; }
.author-toggle button.on { background: var(--teal-deep); color: #fff; }

/* Add form */
#add-section { margin-top: .5rem; border-top: 1px solid var(--line); padding-top: .5rem; }
#add-section summary { cursor: pointer; color: var(--teal); font-weight: 600; padding: .3rem 0; }
#add-form { display: flex; flex-direction: column; gap: .6rem; margin-top: .5rem; }
#add-form .add-place { font-size: .85rem; color: var(--muted); margin: 0; }
#add-form label { display: flex; flex-direction: column; gap: .25rem; font-size: .82rem; color: var(--muted); }
#add-form input, #add-form textarea { font: inherit; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: .5rem .6rem; }
#add-submit { font: inherit; font-weight: 600; cursor: pointer; padding: .6rem 1rem; border: 0; border-radius: 10px; background: var(--teal-deep); color: #fff; }
#add-submit:hover { background: var(--teal); }

/* Modal */
/* Modal sits above Leaflet's controls (z-index 1000). While it's open we also
   hide the map controls so the zoom/layer toggles can't overlap the close X. */
.modal { position: fixed; inset: 0; z-index: 3000; background: rgba(3,7,18,.7); display: flex; align-items: center; justify-content: center; padding: 1rem; }
body.modal-open .leaflet-control-container { display: none; }
.modal-card { position: relative; width: min(420px, 96vw); max-height: 90vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 1.2rem; }
.modal-card h2 { margin: 0 0 .3rem; font-size: 1.2rem; }
.filebtn { display: inline-block; margin: .8rem 0; background: var(--panel-2); border: 1px dashed var(--line); border-radius: 10px; padding: .7rem 1rem; cursor: pointer; }
.filebtn input { display: none; }
.modal-card label { display: block; font-size: .82rem; color: var(--muted); margin: .6rem 0 .25rem; }
#qa-comment { width: 100%; font: inherit; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: .5rem .6rem; }
#qa-save { margin-top: .9rem; width: 100%; }
.qa-thumb { width: 100%; max-height: 220px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); margin-bottom: .6rem; }
.qa-meta { font-size: .9rem; display: flex; flex-direction: column; gap: .35rem; }
.qa-meta .k { color: var(--muted); font-size: .78rem; margin-right: .4rem; }
.qa-place { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.qa-pick { display: flex; flex-direction: column; gap: .35rem; }
.qa-pick select { font: inherit; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: .5rem .6rem; }

/* Timeline */
.tl-head { display: flex; align-items: center; justify-content: space-between; max-width: 720px; margin: 0 auto .6rem; }
.tl-head h2 { margin: 0; }
#tl-order { font: inherit; font-size: .85rem; background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: .4rem .7rem; cursor: pointer; }
#timeline-list { max-width: 720px; margin: 0 auto; }
.tl-year { font-weight: 700; color: var(--teal); margin: 1rem 0 .5rem; font-size: 1.1rem; border-bottom: 1px solid var(--line); padding-bottom: .2rem; }
.tl-item { display: flex; gap: .8rem; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .7rem; margin-bottom: .7rem; cursor: pointer; transition: border-color .15s; }
.tl-item:hover { border-color: var(--teal); }
.tl-photo { width: 110px; height: 110px; flex: 0 0 110px; object-fit: cover; border-radius: 9px; background: #0b1220; }
.tl-photo.none { display: flex; align-items: center; justify-content: center; font-size: 1.6rem; color: var(--muted); }
.tl-body { flex: 1; min-width: 0; }
.tl-top { display: flex; align-items: center; gap: .5rem; }
.tl-body .reason { margin: .3rem 0 .2rem; }

/* Map bits */
.place-tip { background: rgba(18,28,46,.95); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; font-weight: 600; font-size: .8rem; padding: 2px 7px; }
.place-tip.park { border-color: #4ade80; }
.place-tip::before { display: none; }
.leaflet-container { background: #0b1220; outline: none; }
.pin-thumb { width: 100%; max-height: 130px; object-fit: cover; border-radius: 6px; margin-bottom: 5px; display: block; }
.photo-popup .leaflet-popup-content-wrapper, .photo-popup .leaflet-popup-tip { background: var(--panel); color: var(--ink); }
.leaflet-control-layers { background: rgba(18,28,46,.95) !important; color: var(--ink); border: 1px solid var(--line) !important; border-radius: 10px !important; }
.leaflet-control-layers label { font-size: .85rem; }

@media (max-width: 560px) {
  #panel { width: 100vw; }
  .brand h1 { display: none; }
  .tl-photo { width: 80px; height: 80px; flex-basis: 80px; }
}
