:root {
  --bg: #10151c;
  --panel: #1a2230;
  --panel2: #212b3b;
  --text: #e8eef6;
  --dim: #8fa0b5;
  --accent: #4da3ff;
  --border: #2c3a4e;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- header ---------- */
#topbar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  flex-wrap: wrap;
}
#topbar h1 { font-size: 18px; margin: 0; font-weight: 600; }
#topbar .sub { font-size: 12px; color: var(--dim); font-weight: 400; margin-left: 6px; }
.btn-3d {
  margin-left: auto;
  background: #1b2534;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.btn-3d:hover { background: #243044; }
.btn-3d.on { background: var(--accent, #4aa3e0); color: #0b1017; border-color: transparent; font-weight: 600; }
#map3d { position: absolute; inset: 0; z-index: 400; }
#map3d[hidden] { display: none; }
#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #2a1f1f;
  color: #ffd7d7;
  border: 1px solid #7a4040;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  z-index: 3000;
  max-width: 80vw;
  text-align: center;
}
/* ---------- plan row (M6 inputs) — lives in the sidebar, below the search ---------- */
#plan-row {
  margin: 0 10px 8px; padding: 8px 10px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 8px;
  justify-content: flex-start; gap: 5px 12px;
  font-size: 12px; color: var(--dim);
}
.plan-title {
  font-weight: 700; font-size: 11.5px; color: var(--text);
  letter-spacing: .05em; text-transform: uppercase;
}
.plan-l { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.plan-l input[type="date"], .plan-l input[type="number"], .plan-l select {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px; padding: 4px 7px; font-size: 12.5px;
  color-scheme: dark;
}
.plan-l input[type="number"] { width: 76px; }

/* ---------- recommended block (M6) ---------- */
.rec-panel {
  margin: 0 10px 10px;
  border: 1px solid #22c55e55;
  background: #22c55e10;
  border-radius: 10px;
  padding: 8px 10px;
}
.rec-head { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.rec-sub { display: block; font-size: 11px; font-weight: 400; color: var(--dim); }
.rec-item {
  display: flex; align-items: baseline; gap: 7px;
  padding: 5px 6px; border-radius: 7px; cursor: pointer; font-size: 12.5px;
}
.rec-item:hover { background: var(--panel2); }
.rec-rank {
  background: #22c55e22; color: #4ade80; border-radius: 6px;
  min-width: 17px; text-align: center; font-size: 11px; font-weight: 700;
}
.rec-name { font-weight: 600; white-space: nowrap; }
.rec-score { color: #4ade80; font-size: 11px; font-weight: 700; }
.rec-why { flex: 1; font-size: 11px; color: var(--dim); }

/* ---------- compare + itinerary (M6) ---------- */
.cmp-panel {
  margin: 0 10px 10px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12.5px;
}
.cmp-head { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.cmp-head small { color: var(--dim); font-weight: 400; }
.cmp-head button {
  float: right; background: none; border: 1px solid var(--border); color: var(--dim);
  border-radius: 7px; padding: 1px 8px; font-size: 11px; cursor: pointer;
}
.cmp-head button:hover { color: var(--text); border-color: var(--accent); }
.cmp-scroll { overflow-x: auto; }
table.cmp-table { border-collapse: collapse; width: 100%; min-width: 280px; }
.cmp-table th, .cmp-table td { padding: 4px 7px; border-top: 1px solid var(--border); text-align: left; vertical-align: top; }
.cmp-table th { font-size: 12px; }
.cmp-table .cmp-label { color: var(--dim); font-size: 11px; white-space: nowrap; }
.cmp-btn {
  margin-top: 8px; width: 100%; padding: 7px 10px;
  background: var(--accent); color: #08111c; border: none; border-radius: 8px;
  font-size: 13px; font-weight: 700; cursor: pointer;
}
.cmp-btn:hover { filter: brightness(1.1); }
.itin { margin-top: 8px; }
.itin-day { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px; }
.itin-n { font-weight: 700; min-width: 42px; }
.itin-when { color: var(--dim); font-size: 11.5px; min-width: 86px; }
.itin-where { font-weight: 600; }
#resort-list .cmp { display: inline-flex; cursor: pointer; }
#resort-list .cmp-box { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* ---------- layout ---------- */
#app { flex: 1; display: flex; min-height: 0; }
#sidebar {
  width: 300px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#search {
  margin: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  font-size: 14px;
}
#mode-select,
#pass-select {
  display: block;
  width: calc(100% - 20px);
  margin: 0 10px 8px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
/* ---------- season passes ---------- */
.pass-panel {
  margin: 0 10px 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #facc15aa;
  background: #facc1514;
  font-size: 12.5px;
}
.pp-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.pp-name { font-weight: 700; font-size: 13.5px; }
.pp-type {
  font-size: 11px; color: #facc15;
  background: #facc1522; padding: 1px 7px; border-radius: 9px; white-space: nowrap;
}
.pp-how { margin: 0 0 6px; line-height: 1.4; }
.pp-tickets { display: flex; flex-wrap: wrap; gap: 5px 10px; margin-bottom: 7px; }
.pp-tk { font-size: 11.5px; }
.pp-covered { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 5px; }
.pp-chip {
  border: 1px solid var(--border); background: var(--panel2); color: var(--text);
  border-radius: 9px; padding: 2px 8px; font-size: 11.5px; cursor: pointer;
}
.pp-chip:hover { border-color: #facc15; }
.pp-more { margin: 4px 0 2px; font-size: 11.5px; opacity: .85; }
.pp-note { margin: 4px 0 0; font-size: 11.5px; opacity: .8; line-height: 1.4; }
.pass-chip {
  background: #facc1522; color: #facc15; border: 1px solid #facc1577;
  border-radius: 7px; padding: 0 6px; font-size: 10.5px; font-weight: 700;
}
.d-pass {
  border: 1px solid #facc1588; background: #facc1512;
  border-radius: 9px; padding: 8px 10px; margin: 6px 0;
}
.d-pass-name { font-weight: 700; font-size: 13px; }
.d-pass-type {
  display: inline-block; font-size: 10.5px; color: #facc15;
  background: #facc1522; padding: 0 7px; border-radius: 9px; margin-left: 8px; vertical-align: middle;
}
.d-pass-prices { margin: 4px 0 2px; font-size: 12px; }
.d-pass-note { margin: 3px 0 0; font-size: 11.5px; opacity: .85; line-height: 1.4; }

/* ---------- visitor ratings (data/resort_reviews.json) ---------- */
.rating-badge {
  font-size: 10.5px; color: #fbbf24; white-space: nowrap;
  background: #fbbf2418; border-radius: 7px; padding: 0 6px;
}
.rating-badge.dim { opacity: .55; }
.d-rating { color: #fbbf24; font-size: 14px; margin-left: 6px; vertical-align: middle; }
.review-summary { font-size: 13px; line-height: 1.5; margin: 4px 0 10px; }
.review-rating { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; margin-bottom: 8px; }
.review-rating .stars { color: #fbbf24; letter-spacing: 2px; font-size: 15px; }
.review-comment { border-left: 2px solid var(--border); padding: 2px 0 2px 10px; margin: 10px 0; }
.rc-head { font-size: 11.5px; color: var(--dim); margin-bottom: 3px; }
.rc-text { font-size: 12.5px; line-height: 1.45; white-space: pre-line; }
.rc-link { font-size: 11.5px; }
.review-attr { font-size: 10.5px; color: var(--dim); margin-top: 12px; opacity: .8; }

.legend-grad {
  display: inline-block;
  width: 90px;
  height: 9px;
  border-radius: 5px;
  vertical-align: middle;
  margin-right: 6px;
}
#region-legend {
  padding: 0 14px 8px;
  font-size: 11px;
  color: var(--dim);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: baseline;
}
.dot.big { width: 14px; height: 14px; margin-right: 8px; }

#resort-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#resort-list li {
  padding: 9px 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
#resort-list li:hover { background: var(--panel2); }
#resort-list li.selected {
  background: var(--panel2);
  border-left-color: var(--accent);
}
#resort-list .rname { flex: 1; }
#resort-list .rmeta { font-size: 11px; color: var(--dim); }
.badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 9px;
  white-space: nowrap;
}
.status-open { background: #123d2a; color: #4ade80; }
.status-soon { background: #2a2410; color: #fbbf24; }
.status-closed { background: #332020; color: #f87171; }

/* ---------- map ---------- */
#map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }
#map { background: #0e1218; }

/* ---------- detail panel ---------- */
#detail {
  position: absolute;
  left: 12px;
  bottom: 12px;
  width: min(560px, calc(100% - 24px));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
  z-index: 800;
  max-height: 75%;
  display: flex;
}
#detail.hidden { display: none; }
#detail-inner { flex: 1; padding: 14px 16px; overflow-y: auto; min-width: 0; }
#detail-close {
  position: absolute;
  top: 8px; right: 10px;
  background: none;
  border: none;
  color: var(--dim);
  font-size: 22px;
  cursor: pointer;
}
#detail-close:hover { color: var(--text); }

.d-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.d-head h2 { margin: 0; font-size: 19px; }
.d-sub { font-size: 12px; color: var(--dim); }

.stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.stat {
  background: var(--panel2);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 86px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat .v { font-size: 15px; font-weight: 600; }
.stat .v.small { font-size: 12px; }
.stat .v.dim { color: #5b6b80; }
.stat .k { font-size: 10.5px; color: var(--dim); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.tab {
  background: none;
  border: none;
  color: var(--dim);
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tabpane { font-size: 13px; }
.tabpane.hidden { display: none; }
.tabpane h3 { font-size: 13px; margin: 8px 0 6px; }
.tabpane small { color: var(--dim); font-weight: 400; }

table.tickets { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
table.tickets td { padding: 4px 6px; border-bottom: 1px solid var(--border); }
table.tickets .price { text-align: right; font-weight: 600; }

.links { margin-top: 8px; display: flex; gap: 14px; font-size: 13px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

iframe {
  width: 100%;
  height: 380px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #eee;
}
img.cam { max-width: 100%; border-radius: 8px; margin: 4px 0; }
.cam-fig { margin: 6px 0; }
.cam-fig figcaption, .cam-label { font-size: 0.75rem; color: var(--dim); margin: 2px 0 8px; }
.cam-frame iframe { width: 100%; aspect-ratio: 16/9; border: 0; border-radius: 8px; display: block; background: #000; }
.course-map img { max-width: 100%; border-radius: 8px; margin: 4px 0; display: block; }
ul.access { font-size: 0.78rem; color: var(--dim); margin: 4px 0 10px; padding-left: 18px; }
ul.access li { margin: 2px 0; }
.wx7-wrap { overflow-x: auto; margin: 4px 0 10px; }
table.wx7 { width: 100%; min-width: 430px; border-collapse: collapse; font-size: 0.72rem; text-align: center; }
.wx7 th { color: var(--dim); font-weight: 500; padding: 2px 1px; }
.wx7 td { padding: 3px 1px; border-top: 1px solid rgba(255,255,255,0.07); }
.wx7 .wx-snow td { color: #9cc4ff; font-weight: 600; }
.empty { color: var(--dim); }
.empty.small { font-size: 12px; }

/* piste legend on the map */
#piste-legend {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 800;
  background: rgba(20, 27, 38, .92);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11px;
  color: var(--dim);
}
#piste-legend.hidden { display: none; }
#piste-legend .row { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
#piste-legend .line { width: 22px; height: 0; border-top: 4px solid; border-radius: 2px; }
#piste-legend .line.dashed { border-top: 3px dashed; height: 0; }

/* ---------- footer ---------- */
#attrib {
  font-size: 11px;
  color: var(--dim);
  padding: 4px 12px;
  background: var(--panel);
  border-top: 1px solid var(--border);
}
.freshness { color: #6d7f95; margin-bottom: 2px; }

/* ---------- mobile tabs (visible only on small screens) ---------- */
#mobile-tabs { display: none; }
.mtab {
  flex: 1; padding: 10px 0; background: none; border: none;
  color: var(--dim); font-size: 13.5px; cursor: pointer;
  border-top: 2px solid transparent;
}
.mtab.active { color: var(--text); border-top-color: var(--accent); font-weight: 600; }

/* mobile: one thing at a time — compact chrome, tab between map and list,
   detail panel becomes a full-screen overlay */
@media (max-width: 760px) {
  #topbar { padding: 6px 10px; gap: 4px; }
  #topbar h1 { font-size: 14px; }
  #topbar .sub { font-size: 10.5px; }
  .btn-3d { padding: 4px 8px; font-size: 11px; margin-left: 0; }
  .plan-l { gap: 4px; font-size: 11.5px; }
  .plan-l input[type="date"], .plan-l input[type="number"], .plan-l select {
    padding: 4px 5px; font-size: 11.5px;
  }
  .plan-l input[type="number"] { width: 62px; }

  #app { flex-direction: column; }
  #app #sidebar {
    width: 100%; height: auto; flex: 1; order: 2;
    border-right: none; border-top: 1px solid var(--border);
    display: none;
  }
  #app.view-list #sidebar, #app.view-plan #sidebar { display: flex; }
  #app #map-wrap { order: 1; flex: 1; height: auto; }
  /* shrink to zero instead of display:none — the detail panel lives inside
     #map-wrap and must stay renderable as a fixed overlay */
  #app.view-list #map-wrap, #app.view-plan #map-wrap {
    flex: 0; height: 0; min-height: 0; overflow: hidden;
  }
  /* Plan tab: only the plan controls + recommendations
     Resorts tab: only the list controls */
  #app.view-plan #search, #app.view-plan #mode-select, #app.view-plan #depth-date-row,
  #app.view-plan #pass-select, #app.view-plan #pass-panel, #app.view-plan #region-legend,
  #app.view-plan #cmp-panel, #app.view-plan #resort-list { display: none; }
  #app.view-list #plan-row, #app.view-list #rec-panel { display: none; }

  /* detail: full-screen overlay instead of a floating corner card */
  #detail {
    position: fixed; inset: 0; width: 100%; max-height: none;
    border-radius: 0; border: none; z-index: 1200;
  }
  .rec-why { white-space: normal; }

  #mobile-tabs {
    display: flex;
    background: var(--panel);
    border-top: 1px solid var(--border);
  }
  #attrib { display: none; }
}

/* ---------- snow history (JMA climatology) ---------- */
.snh-head {
  display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline;
  font-size: 12.5px; margin-bottom: 6px;
}
.snh-period { opacity: .75; font-size: 11.5px; }
.snh-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 4px 0 8px; }
.snh-label { font-size: 13px; }
.snh-pick input[type="date"] {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; font-size: 13px;
  color-scheme: dark;
}
.snh-result { font-size: 13.5px; }
.snh-chart { margin: 2px 0 10px; }
.snh-svg { width: 100%; height: auto; display: block; }
.snh-fill { fill: rgba(96, 165, 250, 0.18); }
.snh-line { fill: none; stroke: #60a5fa; stroke-width: 2; }
.snh-ax { fill: #94a3b8; font-size: 11px; }
.snh-mark { stroke: #facc15; stroke-width: 1.5; stroke-dasharray: 4 3; }
.snh-dot { fill: #facc15; stroke: #1e293b; stroke-width: 1; }

/* ---------- depth-date mode control ---------- */
#depth-date-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; margin: 2px 0 4px;
}
#depth-date-row input[type="date"] {
  flex: 1;
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; font-size: 13px;
  color-scheme: dark;
}
#depth-date-row[hidden] { display: none; }
