/* ---------- トークン ---------- */
:root {
  --bg: #f1f4f9;
  --surface: #ffffff;
  --text: #1b2733;
  --muted: #66788a;
  --line: #e1e8f0;
  --primary: #2b6fd6;
  --hero-top: #3a86e8;
  --hero-bot: #7bb4f5;
  --great: #1f8a4c; --great-bg: #e3f4ea;
  --good: #1f6fa8;  --good-bg: #e2f0fa;
  --mid: #8a6100;   --mid-bg: #fff2d1;
  --bad: #b3261e;   --bad-bg: #fde7e5;
  --nav-h: 58px;
  --head-h: 52px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg:#0f151c; --surface:#18212b; --text:#e8eef4; --muted:#94a5b5; --line:#263341; --primary:#6aa6ff;
    --great:#5fd08a; --great-bg:#17301f; --good:#7cc0f0; --good-bg:#15283a; --mid:#f0c25e; --mid-bg:#3a2e12; --bad:#ff8e86; --bad-bg:#3d1a18; }
}
:root[data-theme="dark"] { --bg:#0f151c; --surface:#18212b; --text:#e8eef4; --muted:#94a5b5; --line:#263341; --primary:#6aa6ff;
  --great:#5fd08a; --great-bg:#17301f; --good:#7cc0f0; --good-bg:#15283a; --mid:#f0c25e; --mid-bg:#3a2e12; --bad:#ff8e86; --bad-bg:#3d1a18; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
a { color: var(--primary); }
[hidden] { display: none !important; }
small { color: var(--muted); }

/* ---------- ヘッダー・ナビ ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  background: var(--bg);
}
.place-btn {
  display: flex; align-items: center; gap: 6px; border: none; background: transparent;
  font-size: 1.15rem; font-weight: 700; padding: 6px 4px; min-height: 40px; max-width: 70%;
}
.place-btn #place-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { color: var(--muted); font-size: 0.8rem; }
.ver { margin-left: auto; font-size: 0.7rem; color: var(--muted); }
.icon-btn { border: none; background: transparent; font-size: 1.3rem; width: 40px; height: 40px; border-radius: 50%; }
.icon-btn:active { background: var(--line); }

main { padding: 0 12px calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.view[hidden] { display: none; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  position: relative; flex: 1; height: var(--nav-h); border: none; background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 0.68rem; color: var(--muted);
}
.nav-btn .ni { font-size: 1.35rem; line-height: 1; }
.nav-btn.on { color: var(--primary); font-weight: 700; }
.badge {
  position: absolute; top: 5px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--bad); color: #fff; font-size: 0.68rem; line-height: 18px; text-align: center;
}

/* ---------- カード共通 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 14px 12px; margin: 0 0 12px;
}
.card.card-selected { border-color: var(--primary); }
.card h2 { margin: 0 0 10px; font-size: 0.95rem; color: var(--muted); font-weight: 700; letter-spacing: 0.02em; }
.note { color: var(--muted); font-size: 0.8rem; margin: 6px 0 0; }
.note.warn { color: var(--bad); }
.credit { color: var(--muted); font-size: 0.72rem; text-align: center; margin: 6px 8px 18px; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 14px; font-size: 0.95rem; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- ヒーロー ---------- */
.hero {
  position: relative; margin: 2px 0 12px; padding: 18px 18px 14px; border-radius: 22px; color: #fff; text-align: center;
  background: linear-gradient(170deg, var(--hero-top), var(--hero-bot));
  box-shadow: 0 6px 18px rgba(30, 60, 110, 0.18);
}
.theme-clear { --hero-top: #2f80ed; --hero-bot: #6ec1ff; }
.theme-partly { --hero-top: #4a8fe0; --hero-bot: #8fc3f0; }
.theme-cloud { --hero-top: #6b7d93; --hero-bot: #a2b2c4; }
.theme-rain { --hero-top: #46607d; --hero-bot: #7f98b3; }
.theme-storm { --hero-top: #2f3b52; --hero-bot: #5d6b86; }
.theme-snow { --hero-top: #7a95b5; --hero-bot: #c4d6ea; }
.theme-clear-night { --hero-top: #0f1f45; --hero-bot: #2d4a86; }
.theme-cloud-night, .theme-rain-night { --hero-top: #1a2538; --hero-bot: #38485f; }
.hero-place { font-size: 0.9rem; opacity: 0.9; }
.hero-main { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 2px; }
.hero-icon { font-size: 3.6rem; line-height: 1; filter: drop-shadow(0 3px 6px rgba(0,0,0,0.2)); }
.hero-temp { font-size: 4.6rem; font-weight: 300; line-height: 1; letter-spacing: -0.03em; }
.hero-label { font-size: 1.1rem; margin-top: 2px; }
.hero-sub { font-size: 0.95rem; opacity: 0.95; margin-top: 4px; }
.hero-sub .t-max { font-weight: 700; } .hero-sub .t-min { opacity: 0.85; }
.hero-meta { font-size: 0.7rem; opacity: 0.75; margin-top: 10px; }
.rain-soon {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 7px 14px;
  border-radius: 999px; background: rgba(255,255,255,0.22); font-size: 0.85rem; backdrop-filter: blur(4px);
}
.rain-soon.rain-soon, .rain-soon.rain-raining { background: rgba(255,255,255,0.32); font-weight: 700; }

/* ---------- 1時間ごと ---------- */
.hr-scroll { display: flex; gap: 2px; overflow-x: auto; margin: 0 -6px; padding: 0 6px 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.hr-scroll::-webkit-scrollbar { display: none; }
.hr-cell { position: relative; flex: 0 0 auto; width: 54px; text-align: center; padding-top: 18px; }
.hr-cell.hr-newday { border-left: 1px solid var(--line); margin-left: 4px; padding-left: 4px; }
.hr-day { position: absolute; top: 0; left: 4px; font-size: 0.66rem; color: var(--primary); font-weight: 700; white-space: nowrap; }
.hr-time { font-size: 0.78rem; color: var(--muted); }
.hr-icon { font-size: 1.5rem; margin: 2px 0; }
.hr-temp { font-weight: 700; font-size: 0.95rem; }
.hr-pop { font-size: 0.72rem; color: var(--muted); min-height: 1.1em; }
.hr-pop.hi, .wk-pop.hi { color: var(--primary); font-weight: 700; }

/* ---------- 週間 ---------- */
.wk-row { display: grid; grid-template-columns: 74px 28px 38px 38px 1fr 38px; align-items: center; gap: 4px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 0.9rem; }
.wk-row:first-of-type { border-top: none; }
.wk-day { font-weight: 600; line-height: 1.2; }
.wk-day small { display: block; font-weight: 400; font-size: 0.68rem; }
.wk-day.sun { color: #d33; } .wk-day.sat { color: #2b6fd6; }
.wk-icon { font-size: 1.3rem; text-align: center; }
.wk-pop { font-size: 0.75rem; color: var(--muted); text-align: right; }
.wk-min { text-align: right; color: var(--muted); }
.wk-max { text-align: left; font-weight: 700; }
.wk-bar { position: relative; height: 6px; background: var(--line); border-radius: 3px; }
.wk-bar span { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, #5aa7f0, #f2a23a); }

/* ---------- 詳細タイル・指数 ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 8px; }
.tile { background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.tile-title { font-size: 0.72rem; color: var(--muted); }
.tile-value { font-size: 1.2rem; font-weight: 700; margin-top: 2px; }
.tile-value small { font-size: 0.7rem; font-weight: 400; margin-left: 2px; }
.tile-sub { font-size: 0.72rem; color: var(--muted); margin-top: 1px; }
.lvl { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; vertical-align: middle; white-space: nowrap; }
.lvl-great { background: var(--great-bg); color: var(--great); }
.lvl-good { background: var(--good-bg); color: var(--good); }
.lvl-mid { background: var(--mid-bg); color: var(--mid); }
.lvl-bad { background: var(--bad-bg); color: var(--bad); }
.idx-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.idx-row:first-of-type { border-top: none; }
.idx-icon { font-size: 1.5rem; width: 34px; text-align: center; }
.idx-body { flex: 1; min-width: 0; }
.idx-title { font-weight: 700; font-size: 0.92rem; }
.idx-detail { font-size: 0.75rem; color: var(--muted); }
.idx-val { font-size: 0.8rem; text-align: right; max-width: 40%; flex-shrink: 0; }
.idx-val:not(.lvl) { color: var(--muted); }

/* ---------- 雨雲レーダー ---------- */
#view-radar { display: flex; flex-direction: column; margin: 0 -12px; height: calc(100dvh - var(--head-h) - var(--nav-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 12px); min-height: 380px; }
.rd-map { flex: 1; min-height: 240px; background: #dfe7ee; }
.rd-panel { background: var(--surface); padding: 8px 14px 4px; border-top: 1px solid var(--line); }
.rd-row { display: flex; align-items: center; gap: 10px; }
.rd-row input[type=range] { flex: 1; accent-color: var(--primary); }
.rd-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 1rem; }
.rd-info { font-size: 0.85rem; margin-top: 2px; }
.rd-kind { padding: 1px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; }
.rd-kind.obs { background: var(--good-bg); color: var(--good); }
.rd-kind.fc { background: var(--mid-bg); color: var(--mid); }
.rd-legend { margin-left: auto; display: flex; align-items: center; gap: 1px; }
.rd-legend i { width: 14px; height: 10px; display: block; }
.rd-legend small { margin-left: 4px; font-size: 0.66rem; }
.rd-pin { font-size: 1.4rem; text-align: center; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4)); }
#view-radar .credit { margin: 2px 8px 6px; background: var(--surface); }
.leaflet-container { font: inherit; }

/* ---------- 警報 ---------- */
.wn-area { font-size: 0.8rem; color: var(--muted); margin-bottom: 8px; }
.wn-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.wn { padding: 4px 10px; border-radius: 8px; font-size: 0.85rem; font-weight: 700; }
.wn-advisory { background: #fff0b8; color: #6b5200; }
.wn-warning { background: #ffd9d6; color: #a1150c; }
.wn-danger { background: #8e1a14; color: #fff; }
.wn-special { background: #4a1a6b; color: #fff; }
.wn-none { color: var(--great); font-size: 0.9rem; }
.wn-headline { font-size: 0.85rem; margin: 10px 0 0; white-space: pre-wrap; }

/* ---------- 設定 ---------- */
.st-place { display: flex; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.st-place:first-of-type { border-top: none; }
.st-name { flex: 1; }
.st-btns button { width: 38px; height: 36px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; margin-left: 4px; }
.st-btns button:disabled { opacity: 0.3; }
.st-line { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: none; background: var(--surface); padding: 7px 14px; font-size: 0.88rem; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--primary); color: #fff; }
.st-check { display: flex; align-items: center; gap: 10px; padding: 9px 0; font-size: 0.92rem; }
.st-check input { width: 20px; height: 20px; }

/* ---------- 地点シート ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0.4); display: flex; align-items: flex-end; justify-content: center; }
.sheet-box { width: 100%; max-width: 720px; max-height: 85dvh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.search-form { display: flex; gap: 8px; margin-bottom: 8px; }
.search-form input { flex: 1; font-size: 1rem; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); min-width: 0; }
.sheet-item { display: block; width: 100%; text-align: left; border: none; background: transparent; padding: 12px 6px; border-top: 1px solid var(--line); font-size: 1rem; }
.sheet-item small { margin-left: 8px; }
.sheet-item.on { color: var(--primary); font-weight: 700; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 60; background: #1f2a36; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 0.88rem; max-width: 90%; }

/* 花粉の1週間の目安 */
.pl-strip { display: flex; justify-content: space-between; gap: 4px; padding: 6px 2px 2px; }
.pl-day { flex: 1; text-align: center; font-size: 0.7rem; color: var(--muted); }
.pl-dot { display: block; width: 18px; height: 18px; margin: 4px auto 0; border-radius: 50%; background: var(--line); }
.pl-0 { background: var(--great); opacity: 0.55; }
.pl-1 { background: var(--good); }
.pl-2 { background: var(--mid); }
.pl-3 { background: var(--bad); opacity: 0.8; }
.pl-4 { background: var(--bad); }

/* 地点の削除ボタン・未登録の画面 */
.sheet-row { display: flex; align-items: center; border-top: 1px solid var(--line); }
.sheet-row .sheet-item { border-top: none; flex: 1; }
.sheet-del { border: none; background: transparent; font-size: 1.1rem; padding: 10px 12px; }
.card.empty .btn { display: block; width: 100%; margin-top: 10px; }
#st-add { display: block; width: 100%; margin-top: 10px; }

/* 防災タブ（警報・地震・台風） */
.bs-head { padding: 4px 0 10px; }
.bs-head .seg { display: flex; }
.bs-head .seg button { flex: 1; }
.q-row { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.q-row:first-of-type { border-top: none; }
.q-int { width: 48px; height: 48px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 1.15rem; font-weight: 800; flex-shrink: 0; line-height: 1.05; }
.q-int small { font-size: 0.55rem; font-weight: 600; }
.q-body { flex: 1; min-width: 0; }
.q-name { font-weight: 700; }
.q-detail { font-size: 0.78rem; color: var(--muted); }
.q-minewrap { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.8rem; }
.q-mine b { padding: 0 6px; border-radius: 6px; }
/* 震度の色（気象庁の配色に近い） */
.sd { background: #e8edf2; color: #234; }
.sd-1 { background: #f2f2f2; color: #333; }
.sd-2 { background: #cfe6ff; color: #134; }
.sd-3 { background: #bfe9c8; color: #124; }
.sd-4 { background: #ffe97a; color: #432; }
.sd-5m { background: #ffb347; color: #321; }
.sd-5p { background: #ff8a3d; color: #fff; }
.sd-6m { background: #e5472f; color: #fff; }
.sd-6p { background: #b3261e; color: #fff; }
.sd-7 { background: #7a1a8a; color: #fff; }
.ty-sub { font-size: 0.8rem; color: var(--muted); margin: -4px 0 8px; }
.ty-str { font-size: 0.72rem; font-weight: 600; color: var(--muted); }
.ty-map { height: 260px; border-radius: 12px; overflow: hidden; margin: 10px 0; background: var(--line); }
.ty-pin { font-size: 1.6rem; line-height: 28px; text-align: center; }
.ty-ap { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 0.9rem; }
.ty-ap:first-child { border-top: none; }
.ty-h { font-size: 0.95rem; margin: 14px 0 4px; }
.ty-fr { display: grid; grid-template-columns: 1.4fr 0.9fr 0.8fr 1.2fr; gap: 4px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 0.82rem; align-items: center; }
.ty-fr:first-child { border-top: none; }
.ty-fr small { display: block; color: var(--muted); font-size: 0.68rem; }
.ty-radius { color: var(--muted); text-align: right; }

/* v1.4.0 大雨の危険度（キキクル） */
.rk-seg { display: flex; margin: 4px 0 10px; }
.rk-seg button { flex: 1; }
.rk-map { height: 340px; border-radius: 12px; overflow: hidden; background: #e8eef4; }
.rk-info { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; font-size: 0.82rem; flex-wrap: wrap; }
.rk-time { font-weight: 600; }
.rk-legend { display: inline-flex; align-items: center; gap: 4px; color: var(--muted, #666); }
.rk-legend i { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.2); display: inline-block; margin-left: 6px; }
.rk-legend i:first-child { margin-left: 0; }
/* 米軍(JTWC)の予報 */
.jt { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.jt h3 { margin: 0 0 4px; font-size: 0.95rem; }
.jt .ty-fr span:first-child { min-width: 5.5em; }
.jt-note { font-size: 0.78rem; color: var(--muted, #666); margin: 4px 0 0; }
.jt-badge { display: inline-block; font-size: 0.7rem; background: #fff3e0; color: #b25b00; border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: middle; }
.jt-legend { font-size: 0.78rem; margin: 4px 0 0; display: flex; gap: 12px; }

/* v1.4.2 地震：タップで詳細 */
.q-item + .q-item { border-top: 1px solid var(--line); }
.q-item .q-row { border-top: none; }
.q-tap { width: 100%; background: none; border: none; text-align: left; font: inherit; color: inherit; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.q-chev { margin-left: auto; font-size: 1.4rem; color: var(--muted, #888); transition: transform .15s; }
.q-tap[aria-expanded="true"] .q-chev { transform: rotate(90deg); }
.q-more { padding: 4px 0 12px; }
.q-map { height: 220px; border-radius: 12px; overflow: hidden; background: #e8eef4; margin-bottom: 8px; }
.q-epi { color: #d33; font-size: 22px; font-weight: 700; text-align: center; line-height: 24px; text-shadow: 0 0 3px #fff; }
.q-facts { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.85rem; }
.q-lv { margin-top: 10px; }
.q-lvh { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.q-pref { font-size: 0.82rem; line-height: 1.5; }
