/* FroggyEarth — dark travel map theme */
:root {
  --bg: #0b1220;
  --panel: #131c2e;
  --panel2: #1a2740;
  --border: #24334f;
  --text: #e6edf7;
  --muted: #8ba1c2;
  --accent: #4cc2ff;
  --accent2: #ffd166;
  --danger: #ff6b6b;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none;
}
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea, select {
  font-family: inherit; font-size: 16px; color: var(--text);
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; width: 100%; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
input[type="date"] { min-height: 42px; }
[hidden] { display: none !important; }

/* ---------- login ---------- */
#login-view {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 800px at 30% 20%, #14233f 0%, var(--bg) 60%);
  padding: 24px;
}
.login-card { width: 100%; max-width: 340px; text-align: center; }
.login-logo { font-size: 56px; }
.login-card h1 { font-size: 24px; margin: 10px 0 4px; letter-spacing: 2px; }
.login-sub { color: var(--muted); margin-bottom: 26px; }
#login-form { display: flex; flex-direction: column; gap: 12px; }

/* ---------- buttons ---------- */
.btn-primary {
  background: var(--accent); color: #062033; font-weight: 700;
  border-radius: 12px; padding: 12px 18px; font-size: 16px;
}
.btn-primary:active { opacity: .8; }
.btn-ghost {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 9px 14px; font-size: 14px;
}
.btn-danger { color: var(--danger); border: 1px solid var(--danger); border-radius: 12px; padding: 12px 18px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 14px; }
.sheet-actions .btn-primary { flex: 1; }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1200;
  display: flex; justify-content: space-around;
  background: rgba(15, 23, 42, .92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 6px 0 calc(6px + var(--safe-bottom));
}
.nav-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11px; padding: 4px 18px; }
.nav-btn .nav-ico { font-size: 21px; }
.nav-btn.active { color: var(--accent); }

/* ---------- FAB ---------- */
#fab {
  position: fixed; right: calc(18px + var(--safe-right)); bottom: calc(76px + var(--safe-bottom));
  width: 56px; height: 56px; border-radius: 50%; z-index: 1100;
  background: var(--accent); color: #062033; font-size: 30px; font-weight: 700;
  box-shadow: 0 6px 20px rgba(76, 194, 255, .4);
  display: flex; align-items: center; justify-content: center;
}

/* ---------- map view (full-bleed) ---------- */
#map-view { position: fixed; inset: 0; z-index: 1; }
#map { position: absolute; inset: 0; background: #0b1220; }
#map-top {
  position: fixed; top: var(--safe-top); left: 0; right: 0; z-index: 1000;
  display: flex; align-items: flex-start; gap: 8px;
  padding: calc(10px + var(--safe-top)) 12px 0;
  pointer-events: none;
}
#trip-chips {
  flex: 1; display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px;
  scrollbar-width: none; pointer-events: auto;
}
#trip-chips::-webkit-scrollbar { display: none; }
.trip-chip {
  flex-shrink: 0; background: rgba(19, 28, 46, .88); border: 1px solid var(--border);
  color: var(--text); border-radius: 20px; padding: 7px 14px; font-size: 13px;
  backdrop-filter: blur(8px); white-space: nowrap;
}
.trip-chip.active { background: var(--accent); color: #062033; border-color: var(--accent); font-weight: 600; }
.trip-chip.add-chip { color: var(--accent); border-style: dashed; }
#fog-toggle {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; z-index: 1001;
  background: rgba(19, 28, 46, .88); border: 1px solid var(--border);
  font-size: 16px; backdrop-filter: blur(8px); pointer-events: auto;
}
#fog-toggle.off { opacity: .45; }
#map-badge {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 1000;
  bottom: calc(86px + var(--safe-bottom));
  background: rgba(19, 28, 46, .92); border: 1px solid var(--border);
  border-radius: 20px; padding: 8px 16px; font-size: 13px; color: var(--muted);
  backdrop-filter: blur(8px); white-space: nowrap;
}
#map-badge.pending { color: var(--accent2); }
#map-badge:empty { display: none; }

/* leaflet dark-ify: filter ONLY the tile pane */
.leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.9) saturate(0.65); }
.leaflet-container { background: #0b1220; font: inherit; }
.leaflet-control-attribution {
  background: rgba(11, 18, 32, .7) !important; color: #5a6f92 !important; font-size: 9px !important;
}
.leaflet-bottom { bottom: calc(58px + var(--safe-bottom)); }
.leaflet-popup-content-wrapper {
  background: var(--panel); color: var(--text); border-radius: 12px; border: 1px solid var(--border);
}
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 10px 14px; font-size: 14px; }
.leaflet-tooltip {
  background: rgba(11, 18, 32, .92); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; font-size: 12px;
}
.leaflet-tooltip-top:before, .leaflet-tooltip-bottom:before,
.leaflet-tooltip-left:before, .leaflet-tooltip-right:before { border: none; }

/* lit town marker glow */
.glow {
  border-radius: 50%;
  background: radial-gradient(circle, rgba(120, 220, 255, 0.95) 0%, rgba(76, 194, 255, 0.55) 35%, rgba(76, 194, 255, 0) 72%);
  box-shadow: 0 0 18px rgba(76, 194, 255, .55);
  animation: pulse 2.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: .9; }
  50% { transform: scale(1.12); opacity: 1; }
}

/* ---------- calendar ---------- */
#calendar-view {
  position: fixed; inset: 0; z-index: 2; overflow-y: auto;
  padding: calc(14px + var(--safe-top)) 12px calc(90px + var(--safe-bottom));
}
#calendar { background: var(--panel); border-radius: 16px; border: 1px solid var(--border); padding: 10px; }
#calendar .fc { font-size: 13px; }
#calendar .fc-toolbar-title { font-size: 17px; }
#calendar .fc .fc-button {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  text-transform: none; font-size: 13px; padding: 4px 10px;
}
#calendar .fc .fc-button-primary:not(:disabled).fc-button-active { background: var(--accent); color: #062033; }
#calendar .fc-daygrid-day-number, #calendar .fc-col-header-cell-cushion { color: var(--muted); }
#calendar .fc-day-today { background: rgba(76, 194, 255, .08) !important; }
#calendar .fc-event { border: none; font-size: 11px; padding: 1px 4px; border-radius: 4px; cursor: pointer; }
.cal-trip-bg { background: rgba(76, 194, 255, .07); border-left: 3px solid var(--accent); }
.cal-stay { background: rgba(255, 209, 102, .2); color: #ffd166; }
.cal-sight { background: rgba(76, 194, 255, .18); color: #4cc2ff; }
.cal-fun { background: rgba(185, 129, 255, .2); color: #b981ff; }
.cal-transit-p { background: rgba(139, 161, 194, .18); color: #8ba1c2; }
.cal-leg { background: transparent; color: var(--text); font-weight: 600; }

/* ---------- stats ---------- */
#stats-view {
  position: fixed; inset: 0; z-index: 2; overflow-y: auto;
  padding: calc(14px + var(--safe-top)) 14px calc(90px + var(--safe-bottom));
}
.stat-hero { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 6px; text-align: center;
}
.stat-card .num { font-size: 24px; font-weight: 800; color: var(--accent); }
.stat-card .lbl { font-size: 11px; color: var(--muted); margin-top: 2px; }
.stat-section {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; margin-bottom: 12px;
}
.stat-section h3 { font-size: 14px; color: var(--muted); margin-bottom: 10px; font-weight: 600; }
.dist-row { display: flex; flex-direction: column; gap: 6px; }
.dist-line { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.dist-line .name { width: 58px; color: var(--muted); }
.dist-line .track { flex: 1; height: 14px; background: var(--panel2); border-radius: 7px; overflow: hidden; }
.dist-line .fill { height: 100%; border-radius: 7px; }
.dist-line .val { width: 70px; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.heat-strip { display: flex; gap: 3px; flex-wrap: wrap; }
.heat-cell { width: 16px; height: 16px; border-radius: 4px; background: var(--panel2); }
.heat-cell[data-l="1"] { background: rgba(76, 194, 255, .25); }
.heat-cell[data-l="2"] { background: rgba(76, 194, 255, .5); }
.heat-cell[data-l="3"] { background: rgba(76, 194, 255, .8); }
.heat-cell[data-l="4"] { background: var(--accent); }
.heat-months { display: flex; gap: 3px; font-size: 9px; color: var(--muted); margin-top: 4px; }
.heat-months span { width: 16px; text-align: center; overflow: visible; }
.mode-line { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; border-bottom: 1px dashed var(--border); }
.mode-line:last-child { border: none; }
.mode-line .km { color: var(--accent); font-variant-numeric: tabular-nums; }
.trip-summary { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.trip-summary:last-child { border: none; }
.trip-summary .meta { color: var(--muted); font-size: 12px; }

/* ---------- sheets ---------- */
#sheet-backdrop {
  position: fixed; inset: 0; z-index: 1300; background: rgba(4, 8, 18, .6);
  backdrop-filter: blur(2px);
}
.modal-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1400;
  background: var(--panel); border-radius: 20px 20px 0 0;
  border: 1px solid var(--border); border-bottom: none;
  max-height: 92dvh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(16px + var(--safe-bottom));
  animation: slideUp .25s ease-out;
}
.modal-sheet.tall { max-height: 88dvh; }
@keyframes slideUp { from { transform: translateY(60%); opacity: .5; } to { transform: translateY(0); opacity: 1; } }
.modal-sheet h3 { font-size: 16px; margin-bottom: 12px; }
.sheet-form { display: flex; flex-direction: column; gap: 10px; }
.form-row { display: flex; gap: 8px; align-items: center; }
.form-row > * { flex: 1; }
.mini-label { flex: 0 0 auto; color: var(--muted); font-size: 13px; }

.seg-toggle { display: flex; background: var(--panel2); border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.seg-toggle button { flex: 1; padding: 9px; border-radius: 9px; font-size: 15px; color: var(--muted); }
.seg-toggle button.active { background: var(--accent); color: #062033; font-weight: 700; }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip input { display: none; }
.chip span {
  display: inline-block; padding: 8px 13px; border-radius: 18px; font-size: 13px;
  background: var(--panel2); border: 1px solid var(--border); color: var(--muted);
}
.chip input:checked + span { background: rgba(76, 194, 255, .18); border-color: var(--accent); color: var(--accent); }

.leg-endpoint { display: flex; gap: 8px; align-items: center; }
.ep-label { flex: 0 0 32px; color: var(--muted); font-size: 13px; }
.btn-pick { flex: 0 0 auto; }
.line-hint { text-align: center; color: var(--muted); font-size: 11px; margin-top: 8px; }

/* media */
.media-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.media-thumb {
  position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden;
  background: var(--panel2); border: 1px solid var(--border);
}
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-thumb .rm {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0, 0, 0, .65); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}
.media-thumb.pending-upload { display: flex; align-items: center; justify-content: center; color: var(--accent2); font-size: 18px; }
.upload-progress { height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; }
.upload-progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.media-count { color: var(--muted); font-size: 12px; }

/* timeline + place detail */
#timeline-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
#timeline-head h3 { margin: 0; }
.tl-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--border); cursor: pointer; }
.tl-item:last-child { border: none; }
.tl-date { flex: 0 0 74px; color: var(--muted); font-size: 12px; padding-top: 3px; font-variant-numeric: tabular-nums; }
.tl-main { flex: 1; }
.tl-main .t { font-size: 15px; }
.tl-main .t .cat-ico { margin-right: 6px; }
.tl-main .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tl-leg .t { color: var(--accent); }
#timeline-body .add-hint { text-align: center; color: var(--muted); font-size: 12px; padding: 14px 0 4px; }

.detail-media { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0; }
.detail-media img, .detail-media video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.detail-row { margin-bottom: 10px; font-size: 14px; }
.detail-row .lbl { color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.detail-actions { display: flex; gap: 10px; margin-top: 14px; }
.detail-actions > * { flex: 1; }
.coord-fix { display: flex; gap: 8px; margin-top: 8px; }
.coord-fix input { font-size: 13px; padding: 7px 10px; }
.detail-note { color: var(--muted); white-space: pre-wrap; }

/* lightbox */
#lightbox {
  position: fixed; inset: 0; z-index: 2000; background: rgba(0, 0, 0, .93);
  display: flex; align-items: center; justify-content: center;
}
#lightbox img, #lightbox video { max-width: 100%; max-height: 100%; }

/* toast */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 3000;
  bottom: calc(96px + var(--safe-bottom));
  background: rgba(19, 28, 46, .96); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 18px; font-size: 14px; max-width: 86vw;
  animation: slideUp .2s ease-out;
}
#toast.err { border-color: var(--danger); color: var(--danger); }

/* place picker sheet reuses modal-sheet */
.picker-item { padding: 12px 4px; border-bottom: 1px dashed var(--border); cursor: pointer; font-size: 15px; }
.picker-item:last-child { border: none; }
.picker-item .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

@media (min-width: 700px) {
  .modal-sheet, .modal-sheet.tall { left: 50%; right: auto; transform: translateX(-50%); width: 480px; border-radius: 20px; margin-bottom: 20px; animation: fadeUp .25s ease-out; }
  @keyframes fadeUp { from { transform: translate(-50%, 40px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
  .stat-hero { max-width: 720px; }
}
