:root {
  --bg: #f5f4f0;
  --ink: #16181d;
  --ink-2: #6f737b;
  --ink-3: #a3a6ac;
  --rule: #dedcd5;
  --rule-strong: #16181d;
  --rain: #2f6fd0;
  --warn: #c9741f;
  --hover: rgba(22, 24, 29, 0.05);
  --dot: #f2a516;
  --font: "BIZ UDPGothic", "BIZ UDPゴシック", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
}

/* 天気ごとの差し色(ひとことの点) */
:root[data-theme="sunny"]        { --dot: #f2a516; }
:root[data-theme="cloudy"]       { --dot: #8a94a3; }
:root[data-theme="rainy"]        { --dot: #2f6fd0; }
:root[data-theme="snowy"]        { --dot: #5aa9cf; }
:root[data-theme="storm"]        { --dot: #7a5cd0; }
:root[data-theme="night"]        { --dot: #4a5a8c; }
:root[data-theme="night-cloudy"] { --dot: #5d6675; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; }
svg { display: block; }
svg path, svg circle { fill: currentColor; }
svg .line { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
a { color: inherit; }

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  transition: opacity 0.3s;
}
body.loading .app > :not(.top) { opacity: 0.45; }

/* ---------- 見出し ---------- */
.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.place-btn {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 4px 8px;
  margin: -4px 0 0 -8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.place-btn:hover { background: var(--hover); }
.place-name {
  max-width: 100%;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.place-name::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 0 5px 9px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg);
}
.place-sub {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-2);
  min-height: 1em;
}
.top-actions { display: flex; gap: 2px; flex-shrink: 0; margin-right: -8px; }
.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 21px; height: 21px; }
#favBtn svg path { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
#favBtn[aria-pressed="true"] svg path { fill: var(--ink); }
#refreshBtn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- いま ---------- */
/* アイコンは右の透明な余白ごと少しはみ出させているので、せまい幅で横スクロールが出ないよう切る */
.now { padding: 22px 0 22px; border-bottom: 1px solid var(--rule-strong); overflow-x: clip; }
.now-row { display: flex; align-items: flex-end; justify-content: space-between; }
.now-temp {
  display: flex;
  align-items: flex-start;
  font-size: clamp(96px, 33vw, 128px);
  font-weight: 400;
  line-height: 0.82;
  letter-spacing: -0.04em;
}
.now-temp .deg { font-size: 0.3em; margin: 0.04em 0 0 0.06em; letter-spacing: 0; }
.now-icon {
  width: clamp(100px, 32vw, 128px);
  height: clamp(100px, 32vw, 128px);
  margin: 0 -14px -14px 0;
  flex-shrink: 0;
}
.now-label { margin-top: 18px; font-size: 18px; font-weight: 700; }
.now-range { margin-top: 5px; font-size: 13px; color: var(--ink-2); }

/* ---------- 区切り ---------- */
.sec { padding: 18px 0 16px; border-bottom: 1px solid var(--rule); }
.sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.sec-note { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.sec-head h2 {
  margin: 0;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--ink-2);
}
.conf-chip {
  padding: 3px 9px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.conf-chip.low { border-color: var(--warn); color: var(--warn); }

/* ひとこと */
.advice { display: grid; gap: 12px; }
.tip { display: grid; grid-template-columns: 16px minmax(0, 1fr); align-items: start; }
.tip::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--dot);
}
.tip-title { font-size: 15.5px; font-weight: 700; line-height: 1.5; }
.tip-body { margin-top: 1px; font-size: 13px; color: var(--ink-2); line-height: 1.6; }

/* 地図 */
.map-link { font-size: 12px; font-weight: 700; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--ink); }
.map {
  height: 220px;
  border: 1px solid var(--rule);
  background: #f2f1ec;
  font-family: var(--font);
}
.map .leaflet-tile-pane { filter: grayscale(1) contrast(0.92) brightness(1.04); }
.map .leaflet-control-zoom { border: 1px solid var(--rule); box-shadow: none; border-radius: 0; }
.map .leaflet-control-zoom a { color: var(--ink); border-radius: 0 !important; }
.map .leaflet-control-attribution { font-size: 10px; background: rgba(245, 244, 240, 0.85); color: var(--ink-2); }
.map .leaflet-control-attribution a { color: var(--ink-2); }

/* 1時間ごと */
.hourly {
  margin: 0 -22px;
  padding: 14px 14px 6px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}
.hourly-chart { display: block; margin-bottom: 6px; overflow: visible; }
.hourly-chart polyline { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linejoin: round; }
.hourly-chart circle { fill: var(--ink); }
.hourly-chart .now-pt { fill: var(--bg); stroke: var(--ink); stroke-width: 1.6; }
.hours { display: flex; }
.hour {
  flex: 0 0 auto;
  width: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.hour-temp { font-size: 15.5px; font-weight: 700; }
.hour img { width: 36px; height: 36px; margin: 2px 0; }
.hour-time { font-size: 12px; color: var(--ink-2); }
.hour.now-hour .hour-time { color: var(--ink); font-weight: 700; }
.hour-pop { margin-top: 2px; font-size: 11.5px; color: var(--rain); }
.hour-pop.dim { color: var(--ink-3); }
.hour-snow { font-size: 11px; font-weight: 700; color: #3f8fbf; }
.hour.newday { box-shadow: inset 1px 0 0 var(--rule); }
.hour.newday::before {
  content: attr(data-day);
  position: absolute;
  top: -14px;
  left: 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-2);
  white-space: nowrap;
}

/* 1週間 */
.week { list-style: none; margin: 0; padding: 0; }
.day {
  display: grid;
  grid-template-columns: 3.4em 36px 3em minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  padding: 7px 0;
  border-top: 1px solid var(--rule);
}
.day:first-child { border-top: 0; padding-top: 0; }
.day-name { font-size: 15px; font-weight: 700; line-height: 1.25; }
.day-name small { display: block; font-size: 11px; font-weight: 400; color: var(--ink-3); }
.day img { width: 36px; height: 36px; }
.day-pop { font-size: 12.5px; color: var(--rain); text-align: center; }
.day-pop.dim { color: var(--ink-3); }
.day-pop small { display: block; font-size: 10.5px; font-weight: 700; color: #3f8fbf; }
.day-range {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 8px;
  font-size: 15px;
}
.day-max { min-width: 2.9em; text-align: right; font-size: 16px; font-weight: 700; }
.day-sep { color: var(--ink-3); }
.day-min { min-width: 2.9em; text-align: right; color: var(--ink-2); }

/* 自信度 */
.conf-list { list-style: none; margin: 0; padding: 0; }
.conf-row {
  display: grid;
  grid-template-columns: 3.4em 3.4em minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  border-top: 1px solid var(--rule);
}
.conf-row:first-child { border-top: 0; padding-top: 0; }
.conf-pct { font-size: 21px; font-weight: 700; line-height: 1; text-align: right; padding-right: 8px; }
.conf-pct small { font-size: 11.5px; margin-left: 1px; }
.conf-row.low .conf-pct { color: var(--warn); }
.conf-body { display: grid; gap: 6px; min-width: 0; }
.conf-bar { height: 3px; background: var(--rule); }
.conf-bar i { display: block; height: 100%; background: var(--ink); }
.conf-row.low .conf-bar i { background: var(--warn); }
.conf-detail { font-size: 12px; color: var(--ink-2); line-height: 1.5; }
.conf-detail span { white-space: nowrap; }
.conf-note { margin: 12px 0 0; font-size: 11.5px; color: var(--ink-3); line-height: 1.7; }

/* くわしい数値 */
.details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 18px;
}
.tile { padding: 10px 0 12px; border-top: 1px solid var(--rule); }
.tile:nth-child(-n+2) { border-top: 0; padding-top: 0; }
.tile-head { display: flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.tile-head img { width: 26px; height: 26px; margin: -4px 0 -4px -6px; }
.tile-value { margin-top: 6px; font-size: 24px; font-weight: 700; line-height: 1.2; }
.tile-value small { font-size: 13px; margin-left: 2px; }
.tile-note { margin-top: 3px; font-size: 12px; color: var(--ink-2); line-height: 1.5; }

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  padding-top: 18px;
  font-size: 11px;
  color: var(--ink-3);
}

/* ---------- 場所の検索 ---------- */
.sheet {
  width: min(480px, 100vw);
  max-width: 100vw;
  max-height: min(88vh, 720px);
  min-height: min(62vh, 520px);
  margin: auto auto 0;
  padding: 14px 0 max(16px, env(safe-area-inset-bottom));
  border: 0;
  border-radius: 18px 18px 0 0;
  background: #fff;
  color: var(--ink);
  font-family: var(--font);
  overflow-y: auto;
}
.sheet[open] { animation: rise 0.22s ease-out; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet::backdrop { background: rgba(22, 24, 29, 0.35); }
@media (min-width: 600px) {
  .sheet { margin: 10vh auto auto; border-radius: 18px; }
}
.sheet-head {
  display: flex;
  gap: 8px;
  position: sticky;
  top: -14px;
  z-index: 1;
  margin-top: -14px;
  padding: 14px 18px 10px;
  background: #fff;
}
.sheet-head input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  outline: none;
}
.sheet-head input:focus { border-color: var(--ink); }
.text-btn { border: 0; background: transparent; font-weight: 700; padding: 0 6px; cursor: pointer; }
.row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 18px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.row:hover { background: var(--hover); }
.gps-row { font-weight: 700; }
.gps-row svg { width: 21px; height: 21px; }
.row-main { flex: 1; min-width: 0; }
.row-name { font-size: 15.5px; font-weight: 700; line-height: 1.4; }
.row-sub { margin-top: 2px; font-size: 12.5px; line-height: 1.4; color: var(--ink-2); }
.row-del {
  width: 36px; height: 36px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-2);
  font-size: 18px; cursor: pointer;
}
.row-del:hover { background: var(--hover); }
.list-title { margin: 14px 18px 4px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.14em; color: var(--ink-2); }
.list-note { padding: 10px 18px; font-size: 13.5px; color: var(--ink-2); }

/* ---------- お知らせ ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 広い画面 ---------- */
@media (min-width: 900px) {
  .app {
    max-width: 960px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "top top"
      "now now"
      "advice map"
      "hourly week"
      "details week"
      "details conf"
      "foot foot";
    column-gap: 48px;
    align-items: start;
    padding-top: 32px;
  }
  .top { grid-area: top; }
  .now { grid-area: now; }
  .advice-sec { grid-area: advice; }
  .hourly-sec { grid-area: hourly; }
  .week-sec { grid-area: week; }
  .conf-sec { grid-area: conf; }
  .map-sec { grid-area: map; }
  .details-sec { grid-area: details; }
  .foot { grid-area: foot; }
  .hourly { margin: 0; padding-left: 0; padding-right: 0; }
}
