:root {
  --aegean: #1B4965;
  --aegean-light: #2A6F97;
  --sky: #A9D6E5;
  --sky-pale: #E8F4F8;
  --sand: #FAF8F5;
  --sand-dark: #F0EDE8;
  --terracotta: #C2702A;
  --terracotta-light: #E8A566;
  --olive: #5C6B4F;
  --olive-light: #8FA377;
  --white-blue: #F0F6FA;
  --ink: #1A2332;
  --ink-light: #3D4F5F;
  --ink-muted: #7A8B99;
  --santorini-red: #B83B3B;
  --santorini-red-light: #F2E0E0;
  --athens-blue: #2A6F97;
  --athens-blue-light: #D6EBF5;
  --daytrip-green: #4A7C59;
  --daytrip-green-light: #DFF0E3;
  --hotel-amber: #B8860B;
  --hotel-amber-light: #FBF0DB;
  --food-orange: #D35400;
  --food-orange-light: #FDEBD0;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(27,73,101,0.06);
  --shadow-md: 0 4px 16px rgba(27,73,101,0.08);
  --shadow-lg: 0 8px 32px rgba(27,73,101,0.12);
  --font-display: 'Playfair Display', 'Georgia', serif;
  --font-body: 'Noto Sans JP', 'Hiragino Sans', sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: var(--font-body); background: var(--sand); overflow: hidden;
  min-height: 100vh; min-height: 100svh; height: 100vh; height: 100dvh;
  color: var(--ink); font-weight: 400; -webkit-font-smoothing: antialiased;
}

/* ===== HEADER ===== */
#header {
  background: var(--aegean);
  color: white; z-index: 1000; position: relative;
  box-shadow: 0 2px 20px rgba(27,73,101,0.25);
  padding-top: env(safe-area-inset-top, 0);
}
.header-row1 {
  display: flex; align-items: center; gap: 20px; padding: 12px 24px 8px;
}
.header-row2 {
  display: flex; align-items: center; gap: 10px; padding: 2px 24px 10px;
}
#header h1 {
  font-family: var(--font-display); font-size: 20px; font-weight: 700;
  white-space: nowrap; letter-spacing: 0.5px;
}
#header h1 span {
  font-family: var(--font-body); font-size: 11px; opacity: 0.6;
  margin-left: 10px; font-weight: 300; letter-spacing: 2px;
}

.plan-btns { display: flex; gap: 6px; margin-left: auto; }
.plan-btn {
  padding: 6px 18px; border: 1.5px solid rgba(169,214,229,0.35); border-radius: 20px;
  background: transparent; color: var(--sky); cursor: pointer; font-size: 12px;
  font-family: var(--font-body); font-weight: 500; transition: all 0.3s; white-space: nowrap;
}
.plan-btn:hover { background: rgba(169,214,229,0.12); color: white; border-color: rgba(169,214,229,0.5); }
.plan-btn.active {
  background: white; color: var(--aegean); border-color: white;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15); font-weight: 600;
}
.plan-btn .plan-sub { font-size: 10px; opacity: 0.65; margin-left: 4px; font-weight: 300; }
.plan-btn.active .plan-sub { opacity: 0.5; }

.day-tabs { display: flex; gap: 4px; margin-left: auto; }
.day-tab {
  padding: 5px 14px; border: none; border-radius: 12px;
  background: rgba(255,255,255,0.08); color: rgba(169,214,229,0.8); cursor: pointer;
  font-size: 11px; font-weight: 500; transition: all 0.3s; min-width: 58px; text-align: center;
  font-family: var(--font-body);
}
.day-tab:hover { background: rgba(255,255,255,0.15); color: white; }
.day-tab.active {
  background: white; color: var(--aegean); font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.day-tab .day-date { display: block; font-size: 9px; opacity: 0.6; font-weight: 300; margin-top: 1px; }
.day-tab.active .day-date { opacity: 0.5; color: var(--ink-muted); }

/* ===== MAIN LAYOUT ===== */
#main { display: flex; height: calc(100vh - 86px); height: calc(100dvh - 86px); }

/* ===== SIDEBAR ===== */
#sidebar {
  width: 400px; min-width: 400px; background: var(--sand); overflow-y: auto;
  border-right: 1px solid rgba(27,73,101,0.08); z-index: 500;
}
#sidebar::-webkit-scrollbar { width: 5px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(27,73,101,0.15); border-radius: 3px; }
#sidebar::-webkit-scrollbar-thumb:hover { background: rgba(27,73,101,0.25); }

.day-header {
  padding: 18px 24px 14px; background: white;
  border-bottom: 1px solid rgba(27,73,101,0.06); position: sticky; top: 0; z-index: 10;
}
.day-header h2 {
  font-family: var(--font-display); font-size: 18px; color: var(--aegean);
  font-weight: 700; margin-bottom: 4px;
}
.day-header .day-location { font-size: 12px; color: var(--ink-muted); display: flex; align-items: center; gap: 6px; font-weight: 400; }
.day-header .day-summary { font-size: 11px; color: var(--ink-muted); margin-top: 4px; opacity: 0.7; }

.timeline { padding: 8px 20px 20px; position: relative; }
.timeline-item {
  display: flex; gap: 14px; padding: 12px 10px; margin-bottom: 2px;
  cursor: pointer; transition: all 0.25s; border-radius: var(--radius);
  position: relative;
}
.timeline-item:hover { background: white; box-shadow: var(--shadow-sm); }
.timeline-item::before {
  content: ''; position: absolute; left: 30px; top: 28px; bottom: -14px;
  width: 1.5px; background: rgba(27,73,101,0.08);
}
.timeline-item:last-child::before { display: none; }

.timeline-time {
  font-size: 11px; font-weight: 600; color: var(--terracotta);
  min-width: 42px; padding-top: 2px; letter-spacing: 0.5px;
  position: relative; z-index: 1;
}
.timeline-content { flex: 1; }
.timeline-title { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 2px; }
.timeline-desc { font-size: 11px; color: var(--ink-muted); line-height: 1.6; font-weight: 300; }
.timeline-transport {
  font-size: 10px; color: var(--aegean-light); margin-top: 4px;
  display: flex; align-items: center; gap: 4px; font-weight: 500;
  background: var(--sky-pale); padding: 3px 8px; border-radius: 6px; display: inline-flex;
}

/* Spot Card */
.spot-card {
  margin: 6px 20px 10px; border-radius: var(--radius); overflow: hidden;
  background: white; cursor: pointer; transition: all 0.35s;
  box-shadow: var(--shadow-sm); border: 1px solid rgba(27,73,101,0.04);
}
.spot-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.spot-card-img {
  width: 100%; height: 130px; object-fit: cover; display: block;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.spot-card-img.athens { background: linear-gradient(145deg, var(--aegean) 0%, var(--aegean-light) 100%); }
.spot-card-img.santorini { background: linear-gradient(145deg, var(--santorini-red) 0%, var(--terracotta) 100%); }
.spot-card-img.daytrip { background: linear-gradient(145deg, var(--olive) 0%, var(--olive-light) 100%); }
.spot-card-img.hotel { background: linear-gradient(145deg, var(--hotel-amber) 0%, #D4A84B 100%); }
.spot-card-img.food { background: linear-gradient(145deg, var(--food-orange) 0%, #E67E22 100%); }

.spot-card-body { padding: 12px 16px; }
.spot-card-name { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 5px; }
.spot-card-meta { font-size: 11px; color: var(--ink-muted); margin-bottom: 4px; font-weight: 300; }
.spot-card-desc { font-size: 12px; color: var(--ink-light); line-height: 1.6; font-weight: 300; }
.spot-card-note {
  font-size: 11px; color: var(--terracotta); margin-top: 6px; padding: 6px 10px;
  background: #FEF7ED; border-radius: 6px; border-left: 3px solid var(--terracotta-light);
  font-weight: 400;
}

.category-badge {
  display: inline-block; padding: 2px 8px; border-radius: 8px;
  font-size: 9px; font-weight: 600; margin-right: 4px; letter-spacing: 0.5px; text-transform: uppercase;
}
.badge-athens { background: var(--athens-blue-light); color: var(--athens-blue); }
.badge-santorini { background: var(--santorini-red-light); color: var(--santorini-red); }
.badge-daytrip { background: var(--daytrip-green-light); color: var(--daytrip-green); }
.badge-hotel { background: var(--hotel-amber-light); color: var(--hotel-amber); }
.badge-food { background: var(--food-orange-light); color: var(--food-orange); }

.spot-stars { color: #D4922F; font-size: 12px; letter-spacing: 1px; margin: 2px 0; }
.spot-stars .star-empty { color: #D4D4D4; }

.plan-info-hotel {
  font-size: 11px; color: var(--hotel-amber); margin-top: 6px; padding: 8px 10px;
  background: var(--hotel-amber-light); border-radius: 6px;
  border-left: 3px solid var(--hotel-amber); line-height: 1.7; font-weight: 400;
}

/* ===== MAP ===== */
#map { flex: 1; z-index: 1; }

/* ===== POPUP ===== */
.leaflet-popup-content { min-width: 250px; max-width: 310px; padding: 0 !important; margin: 0 !important; }
.leaflet-popup-content-wrapper { padding: 0; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-lg); }
.popup-img-wrap { position: relative; overflow: hidden; }
.popup-img-wrap.collapsed { height: 0; }
.popup-img-wrap.small .popup-img { height: 100px; }
.popup-img-wrap.large .popup-img { height: 220px; }
.popup-img {
  width: 100%; height: 150px; object-fit: cover; display: block; cursor: pointer;
  transition: height 0.3s ease;
}
.popup-img-controls {
  position: absolute; bottom: 8px; right: 8px; display: flex; gap: 4px;
}
.popup-img-btn {
  width: 28px; height: 28px; border: none; border-radius: 8px;
  background: rgba(26,35,50,0.6); color: white; cursor: pointer;
  font-size: 14px; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; backdrop-filter: blur(8px);
}
.popup-img-btn:hover { background: rgba(26,35,50,0.85); transform: scale(1.05); }
.popup-toggle {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 5px 0; background: var(--sand); border-bottom: 1px solid rgba(27,73,101,0.06);
  cursor: pointer; font-size: 10px; color: var(--ink-muted); transition: all 0.2s;
  user-select: none; font-weight: 500;
}
.popup-toggle:hover { background: var(--sand-dark); color: var(--ink-light); }
.popup-body { padding: 14px 16px; background: white; }
.popup-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.popup-desc { font-size: 12px; color: var(--ink-light); line-height: 1.7; margin-bottom: 8px; font-weight: 300; }
.popup-info { font-size: 11px; color: var(--ink-muted); display: flex; flex-direction: column; gap: 4px; }
.popup-info span { display: flex; align-items: center; gap: 5px; font-weight: 400; }
.popup-note {
  font-size: 11px; color: var(--terracotta); background: #FEF7ED; padding: 8px 10px;
  border-radius: 6px; margin-top: 10px; border-left: 3px solid var(--terracotta-light); font-weight: 400;
}
/* Fullscreen overlay */
.popup-fullscreen-overlay {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(26,35,50,0.92); z-index: 9999; display: flex;
  align-items: center; justify-content: center; cursor: zoom-out;
  backdrop-filter: blur(8px); animation: fadeIn 0.25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.popup-fullscreen-overlay img {
  max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: var(--radius);
  box-shadow: 0 12px 48px rgba(0,0,0,0.4);
}
.popup-fullscreen-close {
  position: absolute; top: 20px; right: 20px; width: 44px; height: 44px;
  border: 1.5px solid rgba(255,255,255,0.2); border-radius: 50%; background: rgba(255,255,255,0.08);
  color: white; font-size: 18px; cursor: pointer; display: flex;
  align-items: center; justify-content: center; backdrop-filter: blur(8px);
  transition: all 0.2s;
}
.popup-fullscreen-close:hover { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.4); }

/* ===== LEGEND ===== */
.legend {
  background: white; padding: 12px 16px; border-radius: var(--radius);
  box-shadow: var(--shadow-md); font-size: 11px; line-height: 2.2;
  border: 1px solid rgba(27,73,101,0.06);
}
.legend-title { font-family: var(--font-display); font-weight: 700; font-size: 13px; margin-bottom: 4px; color: var(--ink); }
.legend i { width: 12px; height: 12px; display: inline-block; border-radius: 50%; margin-right: 8px; vertical-align: middle; }

/* ===== PLAN INFO BAR ===== */
.plan-info {
  padding: 10px 24px; background: white;
  border-bottom: 1px solid rgba(27,73,101,0.06); font-size: 12px; color: var(--ink-light);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.plan-info-name {
  font-family: var(--font-display); font-weight: 700; font-size: 13px;
  color: var(--aegean); white-space: nowrap;
}
.plan-info-summary { color: var(--ink-muted); flex: 1; min-width: 200px; font-weight: 300; font-size: 11px; }
.plan-info-tags { display: flex; gap: 6px; margin-left: auto; white-space: nowrap; }
.plan-info-tag {
  font-size: 10px; padding: 3px 10px; border-radius: 8px; font-weight: 500;
}
.plan-info-tag.merit { background: var(--daytrip-green-light); color: var(--daytrip-green); }
.plan-info-tag.demerit { background: var(--santorini-red-light); color: var(--santorini-red); }

/* ===== VIEW MODE TABS ===== */
.view-modes {
  display: flex; gap: 2px; background: rgba(169,214,229,0.12);
  border-radius: 10px; padding: 3px;
}
.view-btn {
  padding: 5px 14px; border: none; border-radius: 8px;
  background: transparent; color: rgba(169,214,229,0.7); cursor: pointer; font-size: 10px;
  font-weight: 500; transition: all 0.3s; white-space: nowrap;
  font-family: var(--font-body); letter-spacing: 0.3px;
}
.view-btn:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.9); }
.view-btn.active {
  background: white; color: var(--aegean); font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* === MODE: map-only === */
body.mode-map #sidebar { display: none; }
body.mode-map #map { flex: 1; }

/* === MODE: schedule === */
body.mode-schedule #map { display: none; }
body.mode-schedule #sidebar { width: 100%; min-width: auto; max-width: 100%; }
body.mode-schedule .timeline { max-width: 720px; margin: 0 auto; }
body.mode-schedule .spot-card { max-width: 720px; margin-left: auto; margin-right: auto; }

/* === MODE: guide (spot gallery) === */
body.mode-guide #sidebar { display: none; }
body.mode-guide #map { display: none; }
body.mode-guide #guidePanel { display: block; }
#guidePanel {
  display: none; flex: 1; overflow-y: auto; padding: 28px; background: var(--sand);
}
.guide-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px; max-width: 1400px; margin: 0 auto;
}
.guide-card {
  background: white; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm); transition: all 0.35s;
  border: 1px solid rgba(27,73,101,0.04);
}
.guide-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.guide-card-img {
  width: 100%; height: 180px; object-fit: cover; display: block;
  background: linear-gradient(135deg, #667eea, #764ba2);
}
.guide-card-img.athens { background: linear-gradient(145deg, var(--aegean), var(--aegean-light)); }
.guide-card-img.santorini { background: linear-gradient(145deg, var(--santorini-red), var(--terracotta)); }
.guide-card-img.daytrip { background: linear-gradient(145deg, var(--olive), var(--olive-light)); }
.guide-card-img.hotel { background: linear-gradient(145deg, var(--hotel-amber), #D4A84B); }
.guide-card-img.food { background: linear-gradient(145deg, var(--food-orange), #E67E22); }
.guide-card-body { padding: 16px 18px; }
.guide-card-name {
  font-family: var(--font-display); font-size: 16px; font-weight: 700;
  color: var(--ink); margin-bottom: 6px;
}
.guide-card-desc { font-size: 12px; color: var(--ink-light); line-height: 1.7; margin-bottom: 10px; font-weight: 300; }
.guide-card-info { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.guide-card-info span {
  font-size: 10px; padding: 4px 10px; border-radius: 6px; background: var(--sky-pale); color: var(--ink-light); font-weight: 500;
}
.guide-card-cost {
  font-size: 12px; color: var(--aegean); font-weight: 600; padding: 8px 0 0;
  border-top: 1px solid rgba(27,73,101,0.06); margin-top: 8px;
}
.guide-card-note {
  font-size: 11px; color: var(--terracotta); background: #FEF7ED; padding: 6px 10px;
  border-radius: 6px; margin-top: 8px; border-left: 3px solid var(--terracotta-light);
}
.guide-filter {
  display: flex; gap: 8px; margin-bottom: 24px; justify-content: center; flex-wrap: wrap;
}
.guide-filter-btn {
  padding: 7px 18px; border: 1.5px solid rgba(27,73,101,0.12); border-radius: 20px;
  background: white; cursor: pointer; font-size: 12px; font-weight: 500;
  color: var(--ink-muted); transition: all 0.3s; font-family: var(--font-body);
}
.guide-filter-btn:hover { border-color: var(--aegean-light); color: var(--aegean); }
.guide-filter-btn.active { border-color: var(--aegean); color: var(--aegean); background: var(--athens-blue-light); }
.guide-filter-btn.active-red { border-color: var(--santorini-red); color: var(--santorini-red); background: var(--santorini-red-light); }
.guide-filter-btn.active-green { border-color: var(--daytrip-green); color: var(--daytrip-green); background: var(--daytrip-green-light); }

/* === MODE: timeline (Gantt) === */
body.mode-timeline #sidebar { display: none; }
body.mode-timeline #map { display: none; }
body.mode-timeline #guidePanel { display: none; }
body.mode-timeline #ganttPanel { display: flex; flex-direction: column; }
#ganttPanel {
  display: none; flex: 1; overflow: hidden; padding: 16px 20px 12px;
  background: var(--sand); height: calc(100vh - 86px); height: calc(100dvh - 86px);
}
.gantt-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap;
}
.gantt-title {
  font-family: var(--font-display); font-size: 16px; font-weight: 700; color: var(--aegean);
}
.gantt-plan-tabs { display: flex; gap: 4px; }
.gantt-plan-tab {
  padding: 4px 14px; border: 1.5px solid rgba(27,73,101,0.15); border-radius: 16px;
  background: white; cursor: pointer; font-size: 11px; font-weight: 500;
  color: var(--ink-muted); transition: all 0.2s; font-family: var(--font-body);
}
.gantt-plan-tab:hover { border-color: var(--aegean); color: var(--aegean); }
.gantt-plan-tab.active { background: var(--aegean); color: white; border-color: var(--aegean); }
.gantt-legend {
  display: flex; gap: 10px; margin-left: auto; font-size: 10px; color: var(--ink-muted);
}
.gantt-legend-item { display: flex; align-items: center; gap: 4px; }
.gantt-legend-color {
  width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0;
}
.gantt-container {
  flex: 1; display: flex; flex-direction: column; background: white;
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
  border: 1px solid rgba(27,73,101,0.06);
}
.gantt-time-header {
  display: flex; border-bottom: 2px solid rgba(27,73,101,0.1);
  background: var(--white-blue); min-height: 28px; flex-shrink: 0;
}
.gantt-time-label-area {
  min-width: 120px; max-width: 120px; padding: 4px 10px;
  font-size: 10px; font-weight: 600; color: var(--ink-muted);
  display: flex; align-items: center; border-right: 1px solid rgba(27,73,101,0.08);
}
.gantt-time-labels {
  flex: 1; display: flex; position: relative;
}
.gantt-hour-label {
  font-size: 9px; color: var(--ink-muted); text-align: center;
  border-left: 1px solid rgba(27,73,101,0.06); font-weight: 500;
  display: flex; align-items: center; justify-content: center;
}
.gantt-rows { flex: 1; display: flex; flex-direction: column; }
.gantt-row {
  display: flex; flex: 1; border-bottom: 1px solid rgba(27,73,101,0.04);
  min-height: 0;
}
.gantt-row:last-child { border-bottom: none; }
.gantt-row-label {
  min-width: 120px; max-width: 120px; padding: 4px 10px;
  display: flex; flex-direction: column; justify-content: center;
  border-right: 1px solid rgba(27,73,101,0.08); background: var(--white-blue);
}
.gantt-row-day {
  font-family: var(--font-display); font-size: 12px; font-weight: 700; color: var(--aegean);
}
.gantt-row-date { font-size: 9px; color: var(--ink-muted); font-weight: 400; }
.gantt-row-loc { font-size: 9px; color: var(--terracotta); font-weight: 500; margin-top: 1px; }
.gantt-bar-area {
  flex: 1; position: relative; overflow: hidden;
}
.gantt-grid-line {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: rgba(27,73,101,0.04);
}
.gantt-block {
  position: absolute; top: 3px; bottom: 3px; border-radius: 4px;
  padding: 0 4px; overflow: hidden;
  cursor: pointer; transition: filter 0.15s, transform 0.15s;
  font-size: 9px; font-weight: 500; color: white; white-space: nowrap;
  text-overflow: ellipsis; text-shadow: 0 1px 2px rgba(0,0,0,0.2); min-width: 2px;
  line-height: 1; display: flex; align-items: center;
}
.gantt-block > span {
  overflow: hidden; text-overflow: ellipsis; display: block; min-width: 0;
}
.gantt-block:hover { filter: brightness(1.15); transform: scaleY(1.1); z-index: 10; }
.gantt-block.type-sightseeing { background: var(--aegean-light); }
.gantt-block.type-meal { background: #E67E22; }
.gantt-block.type-transport { background: #8B5CF6; }
.gantt-block.type-sleep { background: #6B7280; }
.gantt-block.type-free { background: #F59E0B; }
.gantt-block.type-hotel { background: #64748B; }

.gantt-tooltip {
  position: fixed; z-index: 9999; padding: 10px 14px;
  background: var(--ink); color: white; border-radius: 8px;
  font-size: 11px; line-height: 1.6; pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25); max-width: 280px;
  font-family: var(--font-body);
}
.gantt-tooltip .tt-time { color: var(--sky); font-weight: 600; font-size: 12px; }
.gantt-tooltip .tt-title { font-weight: 600; margin-top: 2px; }
.gantt-tooltip .tt-desc { color: rgba(255,255,255,0.7); font-weight: 300; font-size: 10px; }

/* === MODE: budget === */
body.mode-budget .plan-info { display: none; }
body.mode-budget .day-header { display: none; }
body.mode-budget .timeline { display: none; }
body.mode-budget #comparePanel { display: none; }
body.mode-budget #budgetPanel { display: block; }
#budgetPanel { display: none; overflow-y: auto; padding: 20px; }
.budget-title {
  font-family: var(--font-display); font-size: 18px; font-weight: 700;
  color: var(--aegean); margin-bottom: 16px; padding-bottom: 10px;
  border-bottom: 2px solid var(--aegean);
}
.budget-section {
  background: white; border-radius: var(--radius); padding: 16px;
  margin-bottom: 12px; box-shadow: var(--shadow-sm);
  border: 1px solid rgba(27,73,101,0.04);
}
.budget-section-title {
  font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
.budget-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0; font-size: 12px; color: var(--ink-light);
  border-bottom: 1px solid rgba(27,73,101,0.03);
}
.budget-row:last-child { border-bottom: none; }
.budget-row .budget-item { flex: 1; font-weight: 300; }
.budget-row .budget-amount { text-align: right; font-weight: 600; color: var(--ink); white-space: nowrap; }
.budget-total {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; margin-top: 16px;
  background: var(--aegean); color: white; border-radius: var(--radius);
  font-size: 16px; font-weight: 700; font-family: var(--font-display);
}
.budget-total .budget-total-label { font-size: 14px; }
.budget-note {
  font-size: 10px; color: var(--ink-muted); margin-top: 8px; padding: 6px 10px;
  background: var(--sky-pale); border-radius: 6px; line-height: 1.6;
}
.budget-plan-tabs {
  display: flex; gap: 6px; margin-bottom: 16px;
}
.budget-plan-tab {
  padding: 6px 16px; border: 1.5px solid rgba(27,73,101,0.15); border-radius: 20px;
  background: white; cursor: pointer; font-size: 12px; font-weight: 500;
  color: var(--ink-muted); transition: all 0.3s; font-family: var(--font-body);
}
.budget-plan-tab:hover { border-color: var(--aegean); color: var(--aegean); }
.budget-plan-tab.active { background: var(--aegean); color: white; border-color: var(--aegean); }

/* === MODE: compare === */
body.mode-compare .plan-info { display: none; }
body.mode-compare .day-header { display: none; }
body.mode-compare .timeline { display: none; }
body.mode-compare #comparePanel { display: block; }
#comparePanel { display: none; overflow-y: auto; }
.compare-header {
  padding: 14px 20px; background: white;
  border-bottom: 1px solid rgba(27,73,101,0.06); position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
}
.compare-header h3 {
  font-family: var(--font-display); font-size: 15px; color: var(--aegean); flex: 1; font-weight: 700;
}
.compare-count {
  font-size: 10px; background: var(--aegean); color: white; padding: 2px 10px;
  border-radius: 10px; font-weight: 600;
}
.compare-clear-btn {
  padding: 5px 12px; border: 1px solid rgba(27,73,101,0.12); border-radius: 8px;
  background: white; color: var(--ink-muted); cursor: pointer; font-size: 10px;
  font-weight: 500; transition: all 0.2s; font-family: var(--font-body);
}
.compare-clear-btn:hover { background: var(--santorini-red-light); color: var(--santorini-red); border-color: var(--santorini-red); }
.compare-empty {
  padding: 48px 24px; text-align: center; color: var(--ink-muted); font-size: 13px; line-height: 2;
  font-weight: 300;
}
.compare-item {
  padding: 14px 20px; border-bottom: 1px solid rgba(27,73,101,0.04);
  display: flex; gap: 12px; transition: all 0.25s; position: relative; cursor: pointer;
}
.compare-item:hover { background: white; }
.compare-num {
  width: 28px; height: 28px; border-radius: 50%; background: var(--aegean); color: white;
  font-size: 12px; font-weight: 700; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; margin-top: 2px;
}
.compare-num.santorini { background: var(--santorini-red); }
.compare-num.daytrip { background: var(--daytrip-green); }
.compare-num.hotel { background: var(--hotel-amber); }
.compare-num.food { background: var(--food-orange); }
.compare-item-img {
  width: 80px; height: 60px; border-radius: 8px; object-fit: cover; flex-shrink: 0;
  cursor: pointer;
}
.compare-item-body { flex: 1; min-width: 0; }
.compare-item-name { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.compare-item-desc { font-size: 11px; color: var(--ink-muted); line-height: 1.5; margin-bottom: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: 300; }
.compare-item-meta { font-size: 10px; color: var(--ink-muted); font-weight: 300; }
.compare-item-cost { font-size: 11px; color: var(--aegean); font-weight: 600; margin-top: 2px; }
.compare-item-note { font-size: 10px; color: var(--terracotta); margin-top: 2px; }
.compare-remove {
  position: absolute; top: 10px; right: 12px; width: 22px; height: 22px;
  border: none; border-radius: 50%; background: var(--sand-dark); color: var(--ink-muted);
  cursor: pointer; font-size: 11px; display: flex; align-items: center;
  justify-content: center; transition: all 0.2s; opacity: 0;
}
.compare-item:hover .compare-remove { opacity: 1; }
.compare-remove:hover { background: var(--santorini-red-light); color: var(--santorini-red); }
.marker-compare-badge {
  position: absolute; top: -8px; right: -8px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--terracotta); color: white; font-size: 10px;
  font-weight: 700; display: flex; align-items: center; justify-content: center;
  border: 2px solid white; box-shadow: 0 1px 4px rgba(0,0,0,0.2); z-index: 10;
}
.compare-hint {
  padding: 8px 20px; background: #FEF7ED; border-bottom: 1px solid rgba(194,112,42,0.12);
  font-size: 10px; color: var(--terracotta); text-align: center; font-weight: 500;
}

/* ===== MOBILE BOTTOM NAV ===== */
#mobileNav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 2000;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(27,73,101,0.08);
  box-shadow: 0 -2px 16px rgba(27,73,101,0.08);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
/* PWA standalone: 画面最下端まで背景を確実にカバー */
#mobileNav::after {
  content: ''; display: block; position: absolute;
  bottom: 0; left: 0; right: 0; height: 50px;
  transform: translateY(100%);
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.mobile-nav-inner {
  display: flex; justify-content: space-around;
  padding: 4px 2px 2px;
}
.mobile-nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 1px; padding: 6px 0 4px; border: none; background: none;
  cursor: pointer; font-family: var(--font-body); transition: all 0.2s;
  position: relative; min-width: 0;
}
.mobile-nav-btn .nav-icon { font-size: 17px; line-height: 1; transition: transform 0.2s; }
.mobile-nav-btn.active .nav-icon { transform: scale(1.15); }
.mobile-nav-btn .nav-label {
  font-size: 8.5px; color: var(--ink-muted); font-weight: 500;
  letter-spacing: 0.2px; white-space: nowrap;
}
.mobile-nav-btn.active .nav-label { color: var(--aegean); font-weight: 700; }
.mobile-nav-btn.active::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 20px; height: 2px; background: var(--aegean); border-radius: 0 0 2px 2px;
}

/* ===== RESPONSIVE: TABLET ===== */
@media (max-width: 900px) {
  #main { flex-direction: column; height: calc(100vh - 100px); height: calc(100dvh - 100px); }
  #sidebar { width: 100%; min-width: auto; max-height: 45vh; }
  #map { min-height: 40vh; }
  .day-tabs { flex-wrap: wrap; }
  .header-row1 { flex-wrap: wrap; gap: 8px; }
  .header-row2 { flex-wrap: wrap; gap: 6px; }
  #header h1 span { display: none; }
  .plan-info-tags { margin-left: 0; }
  .plan-btn .plan-sub { display: none; }
  .guide-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
  #guidePanel { padding: 20px 16px; }
  .gantt-row-label, .gantt-time-label-area { min-width: 90px; max-width: 90px; }
}

/* ===== RESPONSIVE: MOBILE ===== */
@media (max-width: 600px) {
  :root {
    --radius: 12px;
    --shadow-sm: 0 1px 4px rgba(27,73,101,0.07);
    --shadow-md: 0 4px 20px rgba(27,73,101,0.10);
    --mobile-header-height: 68px;
    --mobile-nav-height: 56px;
    --mobile-safe-top: env(safe-area-inset-top, 0px);
    --mobile-safe-right: env(safe-area-inset-right, 0px);
    --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
    --mobile-safe-left: env(safe-area-inset-left, 0px);
    --mobile-bottom-clearance: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom) + 22px);
  }

  /* --- Global mobile resets --- */
  * { -webkit-tap-highlight-color: transparent; }
  button, a { touch-action: manipulation; }
  html { -webkit-text-size-adjust: 100%; }
  body {
    overflow-x: hidden;
    overscroll-behavior-y: none;
    padding-left: var(--mobile-safe-left);
    padding-right: var(--mobile-safe-right);
  }

  button,
  .day-tab,
  .plan-btn,
  .guide-filter-btn,
  .budget-plan-tab,
  .gantt-plan-tab,
  .compare-clear-btn,
  .compare-remove,
  .popup-img-btn,
  .popup-fullscreen-close,
  .mobile-nav-btn,
  .leaflet-control-zoom a,
  .leaflet-control-layers-toggle {
    min-width: 44px;
    min-height: 44px;
  }

  button:active,
  a:active,
  .timeline-item:active,
  .spot-card:active,
  .guide-card:active,
  .compare-item:active,
  .popup-toggle:active,
  .day-tab:active,
  .plan-btn:active,
  .guide-filter-btn:active,
  .budget-plan-tab:active,
  .gantt-plan-tab:active,
  .mobile-nav-btn:active {
    filter: brightness(0.97);
  }

  /* --- Show bottom nav, hide header view modes --- */
  #mobileNav { display: block; }
  .view-modes { display: none !important; }

  /* --- Header compact --- */
  #header {
    box-shadow: 0 1px 10px rgba(27,73,101,0.15);
    padding-left: var(--mobile-safe-left);
    padding-right: var(--mobile-safe-right);
  }
  .header-row1 {
    padding: 8px 12px 4px; gap: 8px; flex-wrap: nowrap;
    justify-content: space-between; align-items: center;
  }
  #header h1 {
    font-size: 15px; flex-shrink: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  #header h1 span { display: none; }

  /* Plan buttons: pill row */
  .plan-btns {
    display: flex; gap: 3px; margin-left: 0; flex-shrink: 0;
  }
  .plan-btn {
    padding: 4px 12px; font-size: 12px; border-radius: 14px;
    flex-shrink: 0; min-height: 44px; border-width: 1px;
  }
  .plan-btn .plan-sub { display: none; }

  /* Day tabs: horizontal scroll with fade hint */
  .header-row2 {
    padding: 2px 12px 6px; gap: 0; flex-wrap: nowrap;
    position: relative;
  }
  .day-tabs {
    display: flex; gap: 3px; flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; margin-left: 0;
    flex: 1; padding-right: 8px;
  }
  .day-tabs::-webkit-scrollbar { display: none; }
  .day-tab {
    padding: 4px 12px; font-size: 10px; min-width: 48px; min-height: 44px;
    flex-shrink: 0; border-radius: 10px;
  }
  .day-tab .day-date { font-size: 10px; }

  /* --- Main layout (account for header ~68px + safe-area-top + bottom nav ~52px + safe-area-bottom) --- */
  #main {
    flex-direction: column;
    height: calc(100vh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
    height: calc(100dvh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
    height: calc(100svh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
    overflow: hidden;
    overscroll-behavior: none;
  }

  /* --- Default mode: map top, sidebar bottom --- */
  #sidebar {
    width: 100%; min-width: auto; max-height: 50vh;
    border-right: none; border-top: 1px solid rgba(27,73,101,0.06);
    order: 2;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    scrollbar-gutter: stable;
    padding-bottom: var(--mobile-bottom-clearance);
  }
  #map {
    flex: 1; order: 1; min-height: 0;
    touch-action: pan-x pan-y pinch-zoom;
  }
  #guidePanel,
  #budgetPanel,
  #comparePanel,
  #ganttPanel {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding-left: calc(10px + var(--mobile-safe-left));
    padding-right: calc(10px + var(--mobile-safe-right));
  }
  #map,
  .leaflet-container,
  .leaflet-pane,
  .leaflet-top,
  .leaflet-bottom {
    -webkit-overflow-scrolling: touch;
  }

  /* Plan info bar */
  .plan-info {
    padding: 8px 12px; gap: 6px; font-size: 11px;
    flex-direction: column; align-items: stretch;
  }
  .plan-info-name { font-size: 12px; }
  .plan-info-summary { min-width: 0; font-size: 10px; line-height: 1.5; }
  .plan-info-tags { margin-left: 0; flex-wrap: wrap; gap: 4px; }
  .plan-info-tag { font-size: 10px; padding: 2px 8px; }
  .plan-info-hotel {
    font-size: 10px; padding: 6px 8px; line-height: 1.5;
    word-break: break-word; overflow-wrap: anywhere;
  }

  /* Day header */
  .day-header { padding: 10px 12px 8px; }
  .day-header h2 { font-size: 14px; }
  .day-header .day-location { font-size: 11px; }
  .day-header .day-summary { font-size: 10px; }

  /* --- Timeline items --- */
  .timeline { padding: 4px 8px var(--mobile-bottom-clearance); }
  .timeline-item {
    padding: 12px 10px; gap: 8px; border-radius: 10px;
    margin-bottom: 1px;
  }
  .timeline-item::before { left: 22px; }
  .timeline-time { font-size: 10px; min-width: 36px; }
  .timeline-title { font-size: 12px; line-height: 1.4; }
  .timeline-desc { font-size: 10px; line-height: 1.5; }
  .timeline-transport { font-size: 10px; padding: 4px 8px; }

  /* --- Spot cards: full-bleed within sidebar --- */
  .spot-card {
    margin: 4px 8px 8px; border-radius: 12px;
    box-shadow: 0 2px 8px rgba(27,73,101,0.08);
    min-height: 44px;
  }
  .spot-card-img { height: 140px; }
  .spot-card-body { padding: 12px 14px; }
  .spot-card-name {
    font-size: 13px; line-height: 1.4;
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  }
  .spot-card-meta {
    font-size: 10px; line-height: 1.5;
    word-break: break-word; overflow-wrap: break-word;
  }
  .spot-card-desc {
    font-size: 11px; line-height: 1.6;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
    overflow: hidden; word-break: break-word; overflow-wrap: anywhere;
  }
  .spot-card-note { font-size: 10px; padding: 5px 8px; }
  .category-badge { font-size: 10px; padding: 3px 8px; }

  /* --- Map popups: fit viewport --- */
  .leaflet-popup-content { min-width: 180px; max-width: calc(100vw - 60px); }
  .leaflet-popup-content-wrapper { border-radius: 12px; }
  .popup-img { height: 120px !important; }
  .popup-body { padding: 10px 12px; }
  .popup-title { font-size: 14px; margin-bottom: 4px; }
  .popup-desc { font-size: 11px; line-height: 1.6; margin-bottom: 6px; }
  .popup-info span { font-size: 10px; word-break: break-word; }
  .popup-note { font-size: 10px; padding: 6px 8px; }
  .popup-img-btn { width: 44px; height: 44px; font-size: 16px; }
  .popup-fullscreen-overlay img {
    max-width: 96vw; max-height: 80vh; border-radius: 8px;
  }
  .popup-fullscreen-close {
    top: env(safe-area-inset-top, 12px); right: 12px;
    width: 44px; height: 44px; font-size: 18px;
  }

  /* --- Schedule mode --- */
  body.mode-schedule #main {
    height: calc(100vh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
    height: calc(100dvh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
    height: calc(100svh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
  }
  body.mode-schedule #sidebar {
    max-height: none; order: 1; flex: 1;
    overflow-y: auto;
  }
  body.mode-schedule .timeline {
    max-width: 100%; padding: 4px 8px calc(var(--mobile-bottom-clearance) + 24px);
  }
  body.mode-schedule .spot-card { max-width: 100%; }
  body.mode-schedule .day-header { position: sticky; top: 0; z-index: 10; }
  body.mode-schedule #sidebar,
  body.mode-schedule .timeline { scroll-padding-bottom: var(--mobile-bottom-clearance); }

  /* --- Map-only mode --- */
  body.mode-map #main {
    height: calc(100vh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
    height: calc(100dvh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
    height: calc(100svh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
  }
  body.mode-map #map { flex: 1; }

  /* --- Guide mode: single-column card gallery --- */
  body.mode-guide #main {
    height: calc(100vh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
    height: calc(100dvh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
    height: calc(100svh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
  }
  #guidePanel { padding: 12px 10px var(--mobile-bottom-clearance); }
  .guide-filter {
    gap: 4px; margin-bottom: 14px; padding: 0 2px;
    justify-content: flex-start;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap; scrollbar-width: none;
  }
  .guide-filter::-webkit-scrollbar { display: none; }
  .guide-filter-btn {
    padding: 8px 14px; font-size: 10px; border-radius: 14px; min-height: 44px;
    flex-shrink: 0; white-space: nowrap;
  }
  .guide-grid {
    grid-template-columns: 1fr; gap: 12px;
    max-width: 100%;
  }
  .guide-card { border-radius: 12px; min-height: 44px; }
  .guide-card-img { height: 180px; }
  .guide-card-body { padding: 14px 16px; }
  .guide-card-name { font-size: 14px; line-height: 1.4; }
  .guide-card-desc { font-size: 11px; line-height: 1.6; word-break: break-word; overflow-wrap: anywhere; }
  .guide-card-info span { font-size: 10px; padding: 4px 8px; }
  .guide-card-cost {
    font-size: 11px; word-break: break-word; overflow-wrap: break-word;
    line-height: 1.5;
  }
  .guide-card-note { font-size: 10px; padding: 5px 8px; line-height: 1.5; }

  /* --- Compare mode --- */
  body.mode-compare #main {
    height: calc(100vh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
    height: calc(100dvh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
    height: calc(100svh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
  }
  body.mode-compare #map { display: none; }
  body.mode-compare #sidebar {
    max-height: none; flex: 1; order: 1;
    padding-bottom: var(--mobile-bottom-clearance);
  }
  #comparePanel { padding-bottom: var(--mobile-bottom-clearance); }
  .compare-header { padding: 10px 12px; }
  .compare-header h3 { font-size: 13px; }
  .compare-item { padding: 12px 12px; gap: 8px; flex-wrap: nowrap; min-height: 72px; }
  .compare-item-img { width: 56px; height: 42px; border-radius: 6px; }
  .compare-item-body { min-width: 0; }
  .compare-item-name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .compare-item-desc { font-size: 10px; -webkit-line-clamp: 2; }
  .compare-item-cost { font-size: 10px; word-break: break-word; }
  .compare-remove { opacity: 1; width: 44px; height: 44px; top: 8px; right: 8px; }
  .compare-hint { font-size: 10px; padding: 8px 12px; }
  .compare-empty { padding: 32px 16px; font-size: 12px; }
  .compare-clear-btn { padding: 8px 12px; font-size: 10px; }

  /* --- Budget mode --- */
  body.mode-budget #main {
    height: calc(100vh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
    height: calc(100dvh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
    height: calc(100svh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
  }
  body.mode-budget #sidebar { max-height: none; flex: 1; overflow-y: auto; }
  #budgetPanel { padding: 12px 10px var(--mobile-bottom-clearance); }
  .budget-title { font-size: 15px; margin-bottom: 10px; padding-bottom: 8px; }
  .budget-section { padding: 10px; margin-bottom: 8px; border-radius: 10px; }
  .budget-section-title {
    font-size: 12px; margin-bottom: 8px;
    align-items: flex-start; flex-wrap: wrap;
  }
  .budget-section-title span {
    margin-left: 0 !important;
    font-size: 10px !important;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }
  .budget-row {
    font-size: 11px; padding: 8px 0; gap: 8px;
    align-items: flex-start;
  }
  .budget-row .budget-item {
    word-break: break-word; overflow-wrap: anywhere;
    line-height: 1.4; min-width: 0;
  }
  .budget-row .budget-item span {
    display: inline;
    font-size: 10px !important;
    margin-left: 0 !important;
    overflow-wrap: anywhere;
  }
  .budget-row .budget-amount {
    font-size: 11px; flex-shrink: 1; white-space: normal;
    word-break: break-word; overflow-wrap: anywhere; text-align: right;
  }
  .budget-total { padding: 10px 12px; font-size: 14px; border-radius: 10px; }
  .budget-total .budget-total-label { font-size: 12px; }
  .budget-note { font-size: 10px; padding: 6px 8px; }
  .budget-plan-tabs { gap: 3px; flex-wrap: wrap; }
  .budget-plan-tab { padding: 8px 12px; font-size: 10px; border-radius: 14px; }

  /* --- Timeline/Gantt mode --- */
  body.mode-timeline #main {
    height: calc(100vh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
    height: calc(100dvh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
    height: calc(100svh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
  }
  #ganttPanel { padding: 8px 6px var(--mobile-bottom-clearance); }
  .gantt-header {
    gap: 6px; margin-bottom: 6px;
    flex-direction: column; align-items: flex-start;
  }
  .gantt-title { font-size: 13px; }
  .gantt-plan-tabs { gap: 3px; }
  .gantt-plan-tab { padding: 8px 12px; font-size: 10px; border-radius: 12px; }
  .gantt-legend {
    gap: 4px 8px; font-size: 10px; margin-left: 0;
    flex-wrap: wrap; width: 100%;
  }
  .gantt-legend-color { width: 10px; height: 10px; border-radius: 2px; }
  /* Horizontal scroll with sticky labels */
  .gantt-container {
    border-radius: 10px;
    overflow: auto; -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-padding-left: 64px;
  }
  .gantt-time-header { min-width: 560px; }
  .gantt-rows { min-width: 560px; }
  .gantt-row-label, .gantt-time-label-area {
    min-width: 64px; max-width: 64px; padding: 2px 4px;
    position: sticky; left: 0; z-index: 5;
    background: var(--white-blue);
    box-shadow: 2px 0 4px rgba(27,73,101,0.06);
  }
  .gantt-row-day { font-size: 10px; }
  .gantt-row-date { font-size: 10px; }
  .gantt-row-loc { font-size: 10px; }
  .gantt-hour-label { font-size: 10px; }
  .gantt-block { font-size: 10px; top: 2px; bottom: 2px; border-radius: 3px; padding: 0 4px; }
  .gantt-tooltip { font-size: 10px; max-width: 220px; padding: 8px 10px; }

  /* --- Legend on map: compact and out of the way --- */
  .leaflet-top .leaflet-control {
    margin-top: calc(12px + var(--mobile-safe-top));
  }
  .leaflet-right .leaflet-control {
    margin-right: calc(10px + var(--mobile-safe-right));
  }
  .leaflet-left .leaflet-control {
    margin-left: calc(10px + var(--mobile-safe-left));
  }
  .leaflet-bottom .leaflet-control {
    margin-bottom: calc(var(--mobile-bottom-clearance) + 4px);
  }
  .legend {
    font-size: 10px; padding: 8px 10px; max-width: min(140px, 38vw);
    line-height: 1.7; border-radius: 8px;
    opacity: 0.96;
  }
  .legend-title { font-size: 10px; }
  .legend i { width: 10px; height: 10px; margin-right: 5px; }

  /* --- Leaflet controls --- */
  .leaflet-control-zoom { transform: none; transform-origin: top left; }
  .leaflet-control-zoom a {
    width: 44px; height: 44px; line-height: 42px;
    font-size: 20px;
  }
  .leaflet-control-layers {
    font-size: 10px; max-width: min(210px, calc(100vw - 32px));
    border-radius: 10px; overflow: hidden;
  }
  .leaflet-control-layers-toggle {
    width: 44px; height: 44px; background-size: 22px 22px;
  }
  .leaflet-control-layers-expanded {
    padding: 10px 12px;
  }
  .leaflet-control-layers-list label {
    display: flex; align-items: center; gap: 8px;
    min-height: 36px; line-height: 1.4;
  }
  .leaflet-control-layers-selector {
    width: 18px; height: 18px; flex-shrink: 0;
  }
  .leaflet-control-attribution {
    max-width: calc(100vw - 24px);
    font-size: 10px;
  }
  .mobile-nav-inner { min-height: var(--mobile-nav-height); }
  #mobileNav {
    padding-left: var(--mobile-safe-left);
    padding-right: var(--mobile-safe-right);
    padding-bottom: var(--mobile-safe-bottom);
  }
  .mobile-nav-btn .nav-label { font-size: 10px; }
}

@media (max-width: 600px) and (display-mode: standalone) {
  body {
    min-height: 100svh;
    background: var(--aegean);
  }

  #header {
    padding-top: max(env(safe-area-inset-top, 0px), 8px);
  }

  #main {
    height: calc(100svh - var(--mobile-header-height) - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom));
  }

  #mobileNav {
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(18px);
  }
}

/* ===== Extra small phones (SE, mini) ===== */
@media (max-width: 380px) {
  #header h1 { font-size: 13px; }
  .plan-btn { padding: 4px 10px; font-size: 10px; }
  .day-tab { padding: 4px 8px; font-size: 10px; min-width: 42px; }
  .spot-card-img { height: 120px; }
  .guide-card-img { height: 150px; }
  .popup-img { height: 100px !important; }
  .mobile-nav-btn .nav-icon { font-size: 15px; }
  .mobile-nav-btn .nav-label { font-size: 10px; }
  .gantt-row-label, .gantt-time-label-area { min-width: 56px; max-width: 56px; }
}
