:root {
  --bg: #f6f7f5;
  --card: #ffffff;
  --text: #1d2420;
  --muted: #5f6b64;
  --line: #d9dfdb;
  --accent: #1f7a4d;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --warn-bg: #fff3cd;
  --warn-text: #6b4e00;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --card: #1c221f;
    --text: #e6ebe8;
    --muted: #9aa8a0;
    --line: #34403a;
    --accent: #3fb47a;
    --accent-text: #08130d;
    --danger: #ff8a80;
    --warn-bg: #4a3b00;
    --warn-text: #ffe08a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 16px;
  display: flex;
  flex-direction: column;
}
button, input, select { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 700; }
button.big { width: 100%; font-size: 18px; padding: 14px; }
button.ghost { background: transparent; }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; }
input, select {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: 9px 10px;
  min-height: 44px;
  width: 100%;
}
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; vertical-align: middle; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px; padding-top: max(6px, env(safe-area-inset-top));
  background: var(--accent); color: var(--accent-text);
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar button { color: var(--accent-text); border-color: currentColor; min-height: 36px; padding: 6px 10px; }

#map { height: 42vh; min-height: 220px; flex: 0 0 auto; }

.topbar, .tabs { flex: 0 0 auto; }
.tabs {
  display: flex; background: var(--card); border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tab {
  flex: 1 0 auto; border: 0; border-radius: 0; background: transparent;
  border-bottom: 3px solid transparent; color: var(--muted); font-weight: 600;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.panel { flex: 1 1 auto; overflow-y: auto; padding: 12px 16px 40px; }
.tabpane { display: none; }
.tabpane.active { display: block; }
h2 { font-size: 16px; margin: 20px 0 8px; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0; }
.credit { color: var(--muted); font-size: 12px; margin-top: 16px; }
.msg { min-height: 1.2em; color: var(--danger); font-size: 14px; }
.hidden { display: none !important; }

.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; }
.results { list-style: none; padding: 0; margin: 6px 0; }
.results li {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; margin-bottom: 6px;
}
.results .name { font-weight: 600; }
.results .sub { color: var(--muted); font-size: 13px; }
.results .acts { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.results .acts button { padding: 6px 10px; min-height: 36px; font-size: 14px; }

.points { list-style: none; padding: 0; margin: 10px 0; }
.points li {
  display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; margin-bottom: 6px;
}
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; border-radius: 17px; font-weight: 700; font-size: 14px;
  color: #fff; padding: 0 6px;
}
.badge.start { background: #1f7a4d; }
.badge.via { background: #2f6fb5; }
.badge.goal { background: #c0392b; }
.badge.rest { background: #8d5a2b; }
.badge.lunch { background: #e67e22; }
.points .stay select { width: auto; min-height: 34px; padding: 4px 6px; font-size: 13px; }
.points .stay { flex-wrap: wrap; }

.stat.em { border-color: var(--accent); border-width: 2px; }
.stat.wide { grid-column: 1 / -1; }
.sched-date { font-weight: 700; margin: 4px 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chips label {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; min-height: 40px;
  border: 1px solid var(--line); border-radius: 20px; background: var(--card); font-size: 15px;
}
.spots { margin-top: 10px; }
.spot {
  display: grid; grid-template-columns: 40px 1fr; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px;
}
.spot .icon { font-size: 28px; text-align: center; }
.spot .name { font-weight: 700; }
.spot .sub { color: var(--muted); font-size: 13px; margin: 2px 0 6px; }
.spot .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.spot .acts button, .spot .acts a {
  padding: 6px 10px; min-height: 36px; font-size: 14px; border-radius: 10px; border: 1px solid var(--line);
  text-decoration: none; color: inherit; display: inline-flex; align-items: center; background: var(--card);
}
.famous { font-size: 12px; color: #b7791f; font-weight: 700; white-space: nowrap; }
.points .pname { font-weight: 600; word-break: break-all; }
.points .stay { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); margin-top: 4px; }
.points .stay input { width: 70px; min-height: 34px; padding: 4px 6px; }
.points .ops { display: flex; gap: 4px; }
.points .ops button { min-height: 36px; min-width: 36px; padding: 4px 8px; }
.points .empty { display: block; color: var(--muted); text-align: center; }

.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 10px 0; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.unit { display: flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--text); }
.unit input { width: 90px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 14px; }

.summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin: 12px 0;
}
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.stat .k { display: block; font-size: 12px; color: var(--muted); }
.stat .v { display: block; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

.elev { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.elev-head { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
#elevCanvas { width: 100%; height: 140px; display: block; touch-action: none; }

.rests { list-style: none; padding: 0; margin: 6px 0; }
.rests li {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; margin-bottom: 6px;
}
.add-rest { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.add-rest .unit input { width: 80px; }

.schedule table { width: 100%; border-collapse: collapse; font-size: 14px; }
.schedule th, .schedule td { border-bottom: 1px solid var(--line); padding: 8px 4px; text-align: left; vertical-align: top; }
.schedule td.t { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 700; }
.schedule td.km { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); }
.schedule tr.stop td { background: color-mix(in srgb, var(--accent) 8%, transparent); }

.weather { margin-top: 10px; }
.wrow {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 8px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px;
}
.wrow .icon { font-size: 30px; text-align: center; }
.wrow .where { font-weight: 600; }
.wrow .when { color: var(--muted); font-size: 13px; }
.wrow .nums { text-align: right; font-size: 14px; font-variant-numeric: tabular-nums; }
.wrow .rain { color: #2f6fb5; font-weight: 700; }

.shops { padding-left: 0; list-style: none; }
.shops li {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px;
}
.shops .name { font-weight: 700; font-size: 17px; }
.shops .sub { color: var(--muted); font-size: 13px; margin: 2px 0 6px; }
.shops .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.shops .acts button, .shops .acts a {
  padding: 6px 10px; min-height: 36px; font-size: 14px; border-radius: 10px; border: 1px solid var(--line);
  text-decoration: none; color: inherit; display: inline-flex; align-items: center; background: var(--card);
}

.nav-big { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.nav-big .v { font-size: 26px; }
.warn { background: var(--warn-bg); color: var(--warn-text); padding: 10px; border-radius: 10px; font-weight: 700; }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(92vw, 480px); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.dlg { padding: 16px; }
.dlg h2 { margin-top: 0; }
.saved { list-style: none; padding: 0; max-height: 50vh; overflow-y: auto; }
.saved li { display: flex; gap: 6px; align-items: center; border-bottom: 1px solid var(--line); padding: 6px 0; }
.saved li .nm { flex: 1; word-break: break-all; }
.saved li button { min-height: 36px; padding: 4px 10px; font-size: 14px; }

/* 雨のお知らせ */
.rain-banner { border-radius: 10px; padding: 10px 12px; margin: 0 0 10px; font-size: 14px; line-height: 1.6; border: 1px solid var(--line); }
.rain-banner.warn { background: #e8f0fb; border-color: #2f6fb5; color: #123a66; }
.rain-banner.info { background: var(--card); border-color: #8fb3d9; }
.rain-banner.ok { background: var(--card); color: var(--muted); font-size: 13px; padding: 6px 10px; }
.rain-suggest { margin-top: 8px; padding-top: 8px; border-top: 1px dashed #8fb3d9; }
.rain-suggest button { display: block; margin-top: 6px; background: #2f6fb5; color: #fff; border-color: #2f6fb5; font-weight: 700; }
@media (prefers-color-scheme: dark) {
  .rain-banner.warn { background: #13263d; color: #cfe2ff; }
}
.wrow.rainy { border-color: #2f6fb5; border-width: 2px; }

/* 日没・暑さ・寒さの注意 */
.tip-banner { border-radius: 10px; padding: 10px 12px; margin: 0 0 10px; font-size: 14px; line-height: 1.6; border: 1px solid #e0b44c; background: #fff8e5; color: #5a4200; }
.tip-banner.info { background: var(--card); color: var(--text); }
.tip-banner .tip + .tip { margin-top: 6px; padding-top: 6px; border-top: 1px dashed #e0b44c; }
@media (prefers-color-scheme: dark) { .tip-banner { background: #3a2f10; color: #ffe7a8; } }

/* 往復・共有 */
.round-box { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 8px 0; }
.round-opts { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 2px 28px; }
.round-opts input[type=number] { min-height: 36px; padding: 4px 6px; }
.share-btn { background: var(--card); color: var(--accent); border: 2px solid var(--accent); font-weight: 700; }
.small-v { font-size: 15px !important; line-height: 1.5; }

/* 節電画面 */
.eco-btn { background: #111; color: #eee; border-color: #111; }
.eco {
  position: fixed; inset: 0; z-index: 3000; background: #000; color: #bdbdbd;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: 24px 16px; text-align: center; cursor: pointer; user-select: none;
}
.eco-arrow { font-size: 120px; line-height: 1; color: #6fcf97; }
.eco-turn { font-size: 34px; font-weight: 700; color: #e0e0e0; }
.eco-sub { display: flex; gap: 24px; font-size: 24px; font-variant-numeric: tabular-nums; flex-wrap: wrap; justify-content: center; }
.eco-warn { font-size: 18px; color: #ffcc66; min-height: 1.4em; max-width: 90vw; }
.eco-hint { position: absolute; bottom: 24px; font-size: 13px; color: #666; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #222; color: #fff; padding: 10px 16px; border-radius: 20px; z-index: 2000;
  max-width: 90vw; font-size: 14px;
}

.pin {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 13px;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.pin.start { background: #1f7a4d; }
.pin.via { background: #2f6fb5; }
.pin.goal { background: #c0392b; }
.pin.shop { background: #e67e22; width: 26px; height: 26px; font-size: 12px; }
.pin.rest { background: #8d5a2b; font-size: 15px; }
.pin.lunch { background: #e67e22; font-size: 15px; }
.pin.spot { background: #fff; width: 28px; height: 28px; font-size: 16px; border-color: #b7791f; }
.pin.wx { background: transparent; border: 0; box-shadow: none; font-size: 22px; }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(26,115,232,.25); }
.popup-acts { display: flex; flex-direction: column; gap: 6px; min-width: 150px; }
.popup-acts button { min-height: 38px; padding: 6px 10px; }

@media (min-width: 900px) {
  body { display: grid; grid-template-columns: 1fr 440px; grid-template-rows: auto auto 1fr; height: 100vh; }
  .topbar { grid-column: 1 / -1; }
  #map { grid-column: 1; grid-row: 2 / 4; height: auto; }
  .tabs { grid-column: 2; grid-row: 2; }
  .panel { grid-column: 2; grid-row: 3; }
}
