/* 雲量予測の画面スタイル。index.html から切り離してある（編集しやすさのため） */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --font-body: "Zen Kaku Gothic New", -apple-system, BlinkMacSystemFont,
        "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
    --font-logo: "Zen Maru Gothic", "Zen Kaku Gothic New", sans-serif;
    /* 表の中だけ数字を Roboto Condensed に。日本語は本文と同じ */
    --font-table: "Roboto Condensed", "Zen Kaku Gothic New", -apple-system, BlinkMacSystemFont,
        "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;

    /* ヘッダーとフッターの帯。雲量レイヤーの色（#92a4ad）から取った薄い青みグレー */
    --band-bg: #e8edf0;
    --band-border: #c8d2d8;
    --content-bg: #ffffff;
}

body {
    background: var(--band-bg);
    font-family: var(--font-body);
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    min-width: 320px;
}

/* コンテンツだけ白。中身が少なくてもフッターが画面下まで下がる */
#content {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding-bottom: 20px;
    background: var(--content-bg);
}

/* 注意: iOS(WebKit)では、枠線のあるボタンで line-height が内容領域の高さを超えると
   文字が描画されなくなる。box-sizing が border-box なので、枠線1pxのボタンの内容領域は
   height から2px引いた値になる。ここで指定する line-height を超える高さにするか、
   .search-submit のように display: flex で中央寄せすること */
button, select, option, input {
    font-family: inherit;
    font-size: 14px;
    height: 30px;
    line-height: 30px;
    padding: 0;
}

/* ヘッダーとフッターは全幅の帯。幅を決めているのは雲量の地図だけ */
/* 圏外になったときに、表示中のデータがいつ取得したものかを知らせる */
.offline-banner {
    padding: 6px 10px;
    background: #fff4e0;
    border-bottom: 1px solid #e8c98a;
    color: #6b4a12;
    font-size: 12px;
    line-height: 1.5;
}

.site-header {
    width: 100%;
    padding: 10px;
    background: var(--band-bg);
    border-bottom: 1px solid var(--band-border);
}

.site-header-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-header h1 {
    margin: 0;
    font-family: var(--font-logo);
    font-size: 20px;
    line-height: 100%;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #333;
}

#title-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    text-decoration: none;
    color: #333;
}

/* ロゴは見出しの文字サイズに追従させる。見出しに文字があるので alt は空 */
#title-logo {
    height: 1.1em;
    width: auto;
}

#update-time {
    font-size: 12px;
    color: #666;
    margin: 0;
}

#update-time strong {
    color: #333;
}

/* 地図の下の操作帯。地図の枠と地続きにする（角丸なし・枠の続き） */
.time-panel {
    padding: 8px 10px;
    background: var(--content-bg);
    border: 1px solid #999;
    border-top: 1px solid #d5dbdf;
}

.time-select-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.time-select-container[hidden],
.nowcast-timeline[hidden] {
    display: none;
}

/* 気象庁の降水の配色は黒い地図の上に置く前提で作られていて、
   白い背景だと一番よくある弱い雨（#f2f2ff）がコントラスト比1.11で消える。
   棒の色は気象庁が塗ったものをそのまま使うので、こちらの地を黒に合わせる */
.nowcast-timeline {
    display: block;
    margin: -8px -10px;
    padding: 5px 10px 8px;
    background: #1c1f21;
}

/* 上段: 選択中の日時と、実況か予測か */
.nowcast-head {
    margin-bottom: 3px;
    font-size: 13px;
    color: #e8eaec;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.nowcast-head b {
    font-size: 15px;
    font-weight: 700;
}
.nowcast-head .kind {
    margin-left: 5px;
    font-size: 11px;
    color: #7fc08a;
}
.nowcast-head .kind[data-forecast="true"] {
    color: #d8a75a;
}

.nowcast-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* カーソルは中央に固定し、軸のほうを動かす。全期間は一度に見せない */
.nowcast-track {
    position: relative;
    flex: 1;
    min-width: 0;
}

.nowcast-viewport {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    cursor: grab;
    touch-action: pan-x;
    /* 表示用の目盛り・ラベルなので、ドラッグ中に文字選択状態になるのを防ぐ */
    -webkit-user-select: none;
    user-select: none;
}
.nowcast-viewport::-webkit-scrollbar {
    display: none;
}
.nowcast-viewport:active {
    cursor: grabbing;
}

.nowcast-strip {
    position: relative;
    height: 30px;
}

/* 目盛りをまとめて左右にずらすための層。
   絶対配置の子は親の padding box を基準にするので、
   .nowcast-strip に padding を入れても目盛りは動かない。この層の left で動かす */
.nowcast-ticks {
    position: absolute;
    top: 0;
    height: 100%;
}
/* 雨の棒グラフと時間軸。同じ基準で重ねるので位置は揃う */
.nowcast-layer {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
}

/* ピン地点の帯（降水強度・雷活動度）。強さは色だけで表し、太さや長さは変えない。
   目盛りの手前に重ねるので、目盛りは帯の上下に突き抜けて見える */
.nowcast-pinbar-seg {
    position: absolute;
    top: 4px;
    height: 8px;
}

/* 目盛りをつなぐ横線。実況と予測の区別は上の文字でしているので、線では区別しない */
.nowcast-rail {
    position: absolute;
    left: 0;
    top: 7px;
    height: 1px;
    background: #454c50;
}

/* 目盛り。雨の帯（4〜12px）の上下に突き抜ける長さにして、帯に隠れないようにする */
.nowcast-tick {
    position: absolute;
    top: 2px;
    width: 1px;
    height: 12px;
    background: #4d555a;
}
.nowcast-tick.major {
    top: 0;
    height: 16px;
    background: #7b868c;
}
.nowcast-tick.now {
    top: 0;
    height: 16px;
    background: #7fc08a;
}

.nowcast-label {
    position: absolute;
    top: 17px;
    transform: translateX(-50%);
    font-size: 10px;
    color: #949da2;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.nowcast-label.now {
    color: #7fc08a;
    font-weight: 700;
}

/* 中央の固定カーソル */
/* 基準線。位置が固定されているので、太ければ長さは要らない。
   一番弱い雨の色（#f2f2ff）に重なっても消えないよう、縁を暗く落とす */
.nowcast-cursor {
    position: absolute;
    left: 50%;
    top: 0;
    width: 3px;
    height: 16px;
    margin-left: -1.5px;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
    pointer-events: none;
}

.nowcast-play {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 13px;
    color: #e8eaec;
    border: 1px solid #4d555a;
    border-radius: 4px;
    background: #2b3134;
    cursor: pointer;
}
.nowcast-play:hover {
    background: #3a4145;
}

/* 地図の左下に出す配色の凡例（風・降水・雷）。スマホでも邪魔にならないよう極小にしてある */
.map-legend {
    background: rgba(20, 22, 24, 0.82);
    color: #e8eaec;
    border-radius: 4px;
    padding: 3px 5px;
    font-size: 9px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}
.map-legend .legend-bar {
    display: flex;
    width: 88px;
    height: 8px;
}
.map-legend .legend-bar i {
    flex: 1;
    display: block;
}
/* 目盛りは帯の境目（隣り合う色の間）に置く。気象庁の凡例と同じ考え方 */
.map-legend .legend-ticks {
    position: relative;
    width: 88px;
    height: 9px;
    margin-top: 1px;
}
.map-legend .legend-ticks span {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
}
.map-legend .legend-caption {
    text-align: left;
    opacity: 0.75;
    margin-top: 1px;
}
/* 雷は連続量ではなく活動度1〜4の区分なので、帯ではなく個別のマスで表す */
.map-legend .legend-levels {
    display: flex;
    gap: 2px;
}
.map-legend .legend-levels i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 14px;
    color: #000;
    font-style: normal;
    font-weight: 700;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.6);
}

.time-select-btn {
    width: 30px;
    height: 30px;
    line-height: 30px;
    padding: 0;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.time-select-btn:hover {
    background: #f0f0f0;
}

.time-select-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.time-select {
    flex: 1;
    min-width: 0;
    width: 185px;
    height: 30px;
    padding: 0 8px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    cursor: pointer;
}

/* タブと地図をひとまとまりのパネルにする */
.maps-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 10px 10px 0;
}

.maps-container {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 10px;
    border: 1px solid #999;
    border-top: none;
    border-bottom: none;
}

.map-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    border-bottom: 1px solid #ddd;
}

.map-wrapper:last-child {
    border-bottom: none;
}

/* 雲量の地図の切り替えタブ（全雲量 / 上・中・下層）。
   選択中のタブだけ下線を切って、下の地図とつながって見えるようにする */
.layer-tabs {
    display: flex;
    align-items: flex-end;
    width: 100%;
    border-bottom: 1px solid #999;
}
.layer-tab {
    position: relative;
    margin-bottom: -1px;
    padding: 0 14px;
    height: 28px;
    line-height: 26px;
    font-size: 13px;
    color: #555;
    background: #f0f0f0;
    border: 1px solid #999;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
}
.layer-tab + .layer-tab {
    margin-left: 4px;
}
/* モデル系（雲・風）は角丸のまま。上辺に地味な青灰の太線を置く（ナウキャストのランプと高さを揃える）。
   ナウキャスト系（降水・雷）は実況・レーダー寄りの特殊機能なので、
   角丸をやめて左上を斜めに切り、上辺をタリーランプ風の赤にする。
   border にグラデは載せにくいのでランプは ::before。
   clip-path は斜辺の border を消すので、枠線は ::after で描き足す */
.layer-tab[data-genre="model"] {
    box-shadow: inset 0 4px 0 #6a7e9b;
}
.layer-tab[data-genre="nowcast"] {
    border-radius: 0;
    clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%, 0 10px);
}
.layer-tab[data-genre="nowcast"]::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    /* 左上→右下の直線グラデ（中央が明るい放射型は使わない） */
    background: linear-gradient(to bottom right, #ffc4b8, #d03030);
    pointer-events: none;
}
.layer-tab[data-genre="nowcast"]::after {
    content: "";
    position: absolute;
    /* 斜辺 (10,0)–(0,10)。線を内側に少し寄せて clip で消えないようにする */
    top: 0;
    left: 0;
    width: 14.14px;
    height: 1px;
    background: #999;
    transform-origin: 0 50%;
    transform: translate(8.5px, -0.5px) rotate(135deg);
    pointer-events: none;
}
.layer-tab:hover {
    background: #f8f8f8;
}
.layer-tab[aria-selected="true"] {
    color: #333;
    font-weight: bold;
    background: white;
    border-bottom-color: white;
}

/* Leaflet 左上のズーム（＋−）：透過＋白文字／黒ドロップシャドウ */
.leaflet-control-zoom.leaflet-bar {
    border: none;
    box-shadow: none;
    background: transparent;
}
.leaflet-control-zoom a {
    width: 36px;
    height: 36px;
    line-height: 36px;
    font-size: 24px;
    font-weight: 700;
    color: #fff !important;
    background: transparent !important;
    border: none !important;
    border-radius: 4px;
    text-decoration: none;
    filter: drop-shadow(0 0 1.2px #000) drop-shadow(0 0 1.2px #000) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}
.leaflet-control-zoom a:hover,
.leaflet-control-zoom a:focus {
    background: rgba(0, 0, 0, 0.4) !important;
    color: #fff !important;
}
.leaflet-control-zoom a.leaflet-disabled {
    opacity: 0.35;
    cursor: default;
    background: transparent !important;
}

/* Leaflet 右下の全画面ボタン（透明＋白アイコン／黒縁。ホバーで半透明黒） */
.leaflet-control-fullscreen {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    color: #fff;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: none;
    filter: drop-shadow(0 0 1.2px #000) drop-shadow(0 0 1.2px #000) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}
.leaflet-control-fullscreen:hover,
.leaflet-control-fullscreen:focus-visible {
    background: rgba(0, 0, 0, 0.4);
    outline: none;
}
.leaflet-control-fullscreen svg {
    display: block;
    width: 30px;
    height: 30px;
}

/* 地図上の上中下層切替（全画面スマホのみ）。左右中央・右上ラベルの下 */
.cloud-layer-float {
    position: absolute;
    top: 44px;
    left: 50%;
    z-index: 1100;
    display: flex;
    transform: translateX(-50%);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.25);
}
.cloud-layer-float[hidden] {
    display: none;
}
.cloud-layer-tab {
    height: 30px;
    padding: 0 14px;
    line-height: 28px;
    font-size: 13px;
    color: #555;
    background: transparent;
    border: none;
    border-right: 1px solid #e0e0e0;
    cursor: pointer;
}
.cloud-layer-tab:last-child {
    border-right: none;
}
.cloud-layer-tab[aria-selected="true"] {
    color: #222;
    font-weight: 700;
    background: #fff;
}
.cloud-layer-tab:hover {
    background: #f7f7f7;
}

.wind-grid-tile {
    image-rendering: pixelated;
}

/* 単票タブは shared 1枚、上中下層タブは layers 3枚 */
.maps-container[data-view="total"] .layers-only,
.maps-container[data-view="wind"] .layers-only,
.maps-container[data-view="rain"] .layers-only,
.maps-container[data-view="thunder"] .layers-only,
.maps-container[data-view="layers"] .shared-only {
    display: none;
}

.map-label {
    padding: 10px;
    background: #f5f5f5;
    text-align: center;
    font-weight: bold;
    font-size: 14px;
    border-bottom: 1px solid #ddd;
}

.map {
    width: 100%;
    height: 200px;
    /* 長押しでピンを置くので、OS の長押しメニューを出さない */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* 既定の #ddd だと白地図の白抜きの向こうが明るく見え、海・雲のコントラストが落ちる */
.map .leaflet-container {
    background: #000;
}

/* 地図の下に置く「地点」のまとまり（場所検索とピンの情報） */
.point-panel {
    /* 検索候補を Leaflet のコントロール（z-index 1000）より上に出す */
    position: relative;
    z-index: 1100;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 24px;
    width: 100%;
    padding: 10px 10px 0;
}

.search-form {
    display: flex;
    position: relative;
    flex: 0 1 360px;
    flex-wrap: wrap;
    gap: 5px;
}
.search-input {
    flex: 1;
    min-width: 0;
    height: 30px;
    padding: 0 8px;
    font-size: 16px; /* 16px 未満だと iOS が入力時に拡大する */
    border: 1px solid #ccc;
    border-radius: 4px;
}
.search-submit {
    /* flex の既定では縮むので、文字が入りきらなくなるのを防ぐ */
    flex: 0 0 auto;
    white-space: nowrap;
    /* iOS で文字が消えるのを避けるため、行の高さに頼らず flex で中央に置く
       （◀▶ や現在地のボタンと同じ作り） */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    color: #333;
    cursor: pointer;
}
.gps-btn {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 30px;
    padding: 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    color: #333;
    cursor: pointer;
}
.gps-btn:hover {
    background: #f0f0f0;
}
.gps-btn:disabled {
    opacity: 0.5;
    cursor: progress;
}

.search-status {
    width: 100%;
    font-size: 12px;
    color: #666;
}
.search-results {
    position: absolute;
    top: 35px;
    left: 0;
    right: 0;
    max-height: 50vh;
    overflow-y: auto;
    list-style: none;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.search-results button {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    height: auto;
    min-height: 36px;
    padding: 6px 10px;
    line-height: 1.4;
    text-align: left;
    border: none;
    border-bottom: 1px solid #eee;
    background: white;
    cursor: pointer;
}
.search-results li:last-child button {
    border-bottom: none;
}
.search-results button:hover {
    background: #f0f0f0;
}
.search-results small {
    flex-shrink: 0;
    color: #888;
}

/* ピンを置いた地点の情報（1行） */
.pin-info {
    display: flex;
    flex: 1 1 260px;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #333;
}
.pin-info[hidden] {
    display: none;
}
.pin-name {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}
.pin-name-balloon {
    flex-shrink: 0;
    display: inline-flex;
    line-height: 0;
}
.pin-name-balloon svg {
    display: block;
}
.pin-name-text {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
/* 値であることが分かるように、枠で囲った表示にする（角は落とさない） */
.pin-values {
    flex-shrink: 0;
    padding: 1px 8px;
    font-family: var(--font-table);
    font-variant-numeric: tabular-nums;
    background: #f4f7f8;
    border: 1px solid var(--band-border);
}
.pin-values b {
    font-weight: 700;
    color: #222;
}
.pin-values .unit,
.pin-values .layer {
    color: #777;
    font-size: 11px;
}
.pin-values:empty {
    display: none;
}
.pin-place-btn {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    height: 26px;
    padding: 0 10px;
    font-size: 12px;
    line-height: 1;
    color: #333;
    background: #fff;
    border: 1px solid #b0bcc4;
    border-radius: 4px;
    cursor: pointer;
}
.pin-place-btn:hover {
    background: #f3f5f7;
}
.pin-clear-btn,
.search-toggle-btn {
    flex-shrink: 0;
    height: 26px;
    line-height: 24px;
    padding: 0;
    font-size: 14px;
    color: #666;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    cursor: pointer;
}
.pin-clear-btn,
.search-toggle-btn {
    width: 26px;
}
.pin-clear-btn:hover,
.search-toggle-btn:hover {
    background: #f0f0f0;
}

/* 検索欄は、スマホでピンが決まっている間だけ虫眼鏡ボタンに畳む */
.search-toggle-btn {
    margin-left: auto;
}
.point-panel.search-collapsed .search-form {
    display: none;
}
.point-panel:not(.search-collapsed) .search-toggle-btn {
    display: none;
}

.balloon-marker {
    background: none !important;
    border: none !important;
    pointer-events: auto;
}
.balloon-marker svg {
    display: block;
    pointer-events: none;
}

/* 保存地点の丸（選択中バルーンより小さく・下に潜る。雲タイルに溶けないシアン） */
.place-marker {
    background: none;
    border: none;
}
.place-marker-dot {
    display: block;
    width: 12px;
    height: 12px;
    background: #00acc1;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
}

/* 地点メニュー（登録｜編集｜削除｜閉じる） */
.place-menu-popup .leaflet-popup-content-wrapper {
    padding: 0;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}
.place-menu-popup .leaflet-popup-content {
    margin: 0;
    line-height: 1;
}
.place-menu-popup .leaflet-popup-tip {
    display: none;
}
.place-menu {
    display: flex;
    overflow: hidden;
    border-radius: 4px;
}
.place-menu button {
    height: 32px;
    padding: 0 12px;
    font-size: 13px;
    color: #333;
    background: #fff;
    border: none;
    border-right: 1px solid #e0e0e0;
    cursor: pointer;
    white-space: nowrap;
}
.place-menu button:last-child {
    border-right: none;
}
.place-menu button:hover {
    background: #f3f3f3;
}

/* 地点名の登録・編集ダイアログ */
.place-name-dialog {
    width: min(360px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid #9aa7b0;
    border-radius: 6px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
}
.place-name-dialog::backdrop {
    background: rgba(0, 0, 0, 0.35);
}
.place-name-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 16px 14px;
}
.place-name-title {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 700;
    color: #333;
}
.place-name-label {
    font-size: 12px;
    color: #666;
}
.place-name-input {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    font-size: 15px;
    border: 1px solid #b0bcc4;
    border-radius: 4px;
    box-sizing: border-box;
}
.place-name-input:focus {
    outline: 2px solid #6a7e9b;
    outline-offset: 1px;
}
.place-name-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}
.place-name-cancel,
.place-name-ok {
    height: 34px;
    padding: 0 14px;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
}
.place-name-cancel {
    color: #444;
    background: #f0f2f4;
    border: 1px solid #c5ced4;
}
.place-name-ok {
    color: #fff;
    background: #5a6f88;
    border: 1px solid #4a5d73;
}
.place-name-cancel:hover {
    background: #e4e8eb;
}
.place-name-ok:hover {
    background: #4e6178;
}

/* 予測・予報の表（行＝項目、列＝時刻。左端の項目名を固定して横スクロール） */
/* 表は画面の横幅いっぱいに使う（幅を決めているのは雲量の地図だけ） */
.forecast {
    width: 100%;
    margin-top: 20px;
    padding: 0 10px;
}

/* 出所で色を変える。数値予報モデルの「予測」と、気象庁の「予報」を見分けやすくする */
.forecast-model {
    --accent: #6a7e9b;
    --badge-bg: #eef2f7;
    --badge-border: #b9c6d6;
    --badge-color: #45566e;
}
.forecast-official {
    --accent: #5c8a64;
    --badge-bg: #eef4ef;
    --badge-border: #bcd2bf;
    --badge-color: #3e6a47;
}
.forecast h2 {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-left: 8px;
    margin-bottom: 5px;
    border-left: 4px solid var(--accent);
    font-size: 16px;
    font-weight: bold;
    color: #333;
}
/* 出典はバッジにする */
.forecast h2 small {
    padding: 1px 6px;
    font-size: 11px;
    font-weight: normal;
    color: var(--badge-color);
    background: var(--badge-bg);
    border: 1px solid var(--badge-border);
    border-radius: 3px;
}
/* 出典や発表時刻など、注意書きではない情報 */
.forecast-meta {
    margin: 3px 0 6px;
    font-size: 10.5px;
    line-height: 1.5;
    color: #666;
}
#msm-tide-note {
    margin-top: 6px;
}
/* 潮位の脚注番号。干潮側のベージュにそろえる */
.tide-ref {
    color: #a8905c;
    font-weight: bold;
}

/* 説明は「i」を押したときだけ出す（繰り返し使うときに邪魔にならないように） */
.info-btn {
    width: 20px;
    height: 20px;
    line-height: 20px;
    padding: 0;
    font-size: 15px;
    color: #7a8791;
    background: none;
    border: none;
    cursor: pointer;
}
.info-btn:hover {
    color: #40505c;
}
/* 「i」ボタンの真下に出る吹き出し。位置は JS で合わせる */
.info-popover {
    display: none;
    position: fixed;
    inset: auto;
    max-width: 280px;
    margin: 4px 0 6px;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.6;
    color: #444;
    background: white;
    border: 1px solid #9aa7b0;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
.info-popover:popover-open,
.info-popover.open {
    display: block;
}
.info-popover:popover-open {
    margin: 0;
}
/* 吹き出しの三角（ボタンの位置に合わせて --arrow-x を動かす） */
.info-popover:popover-open::before,
.info-popover:popover-open::after {
    content: "";
    position: absolute;
    top: -7px;
    left: var(--arrow-x, 20px);
    border: 7px solid transparent;
    border-top: none;
    border-bottom-color: #9aa7b0;
}
.info-popover:popover-open::after {
    top: -6px;
    border-bottom-color: white;
}
/* popover に対応していないブラウザでは見出しの下に普通に開く */
.info-popover.open {
    position: static;
}
.forecast-hint {
    flex-basis: 100%;
    font-size: 12px;
    color: #666;
}
.forecast-hint strong {
    color: #333;
    font-weight: 700;
}
/* 長押し案内の一時トースト。maps-container 上にフロート。自動では消さず Esc / ✗ で閉じる */
.longpress-toast {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 1100;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    box-sizing: border-box;
    width: calc(100% - 24px);
    max-width: 420px;
    padding: 10px 10px 10px 14px;
    font-size: 13px;
    line-height: 1.35;
    color: #fff;
    background: rgba(28, 28, 28, 0.92);
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
    transform: translate(-50%, -50%);
}
.longpress-toast[hidden] {
    display: none;
}
.longpress-toast-text {
    margin: 0;
    flex: 1 1 auto;
    text-align: left;
}
.longpress-toast-close {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    margin: -4px -2px -4px 0;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    color: #fff;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.longpress-toast-close:hover {
    background: rgba(255, 255, 255, 0.15);
}
.table-container {
    width: 100%;
    overflow-x: auto;
    /* 幅の狭い Roboto Condensed を使うぶん、文字は少し大きめにする */
    font-family: var(--font-table);
    font-size: 12px;
}
/* 枠線は「セルの右と下」で引く。左端の固定列だけ自分の左線を持たせると、
   横スクロールしても線が流れず、太さも1pxのまま揃う */
.table-container table {
    border-collapse: separate;
    border-spacing: 0;
    border-top: 1px solid #ccc;
    background: white;
}
.table-container th {
    position: sticky;
    left: 0;
    z-index: 1;
    white-space: pre;
    text-align: left;
    font-size: 12px;
    background: #eee;
    border-left: 1px solid #ccc;
    border-right: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    padding: 2px 6px;
    /* 右に薄い影を落として、続きがあることを示す */
    box-shadow: 4px 0 5px -4px rgba(0, 0, 0, 0.2);
}
.table-container th small {
    display: block;
    font-weight: 400;
    font-size: 10px;
    line-height: 1.2;
    color: #666;
    white-space: nowrap;
}
.table-container td {
    font-variant-numeric: tabular-nums;
    min-width: 44px;
    padding: 2px 4px;
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
    white-space: nowrap;
    border-right: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
}
.table-container tr[data-key="日付"] td,
.table-container tr[data-key="時刻"] td {
    background: #eee;
    font-weight: bold;
}
/* 雲ブロック（上層〜下層）の上下だけ二重線 */
.table-container tr[data-key="降水量"] th,
.table-container tr[data-key="降水量"] td,
.table-container tr[data-key="下層雲"] th,
.table-container tr[data-key="下層雲"] td {
    border-bottom: 3px double #ccc;
}
/* 同じ日をまとめたセル（1時間予測・2週間予測）だけ左寄せにする */
.table-container td.date-cell {
    text-align: left;
    padding: 2px 0;
}
/* 日付は、その日の列が見えている間ずっと左端に貼り付く */
.table-container .date-label {
    position: sticky;
    left: var(--label-width, 50px);
    display: inline-block;
    padding: 0 6px;
}
/* 1時間降水量（気象庁の「雨の強さと降り方」の区切り）。
   30mm（激しい雨）以上は警戒色にする */
.table-container td.rain-1 { background: #eef6ff; }
.table-container td.rain-2 { background: #d3e8ff; }
.table-container td.rain-3 { background: #a8d2ff; }
.table-container td.rain-4 { background: #6fb0f5; }
.table-container td.rain-5 { background: #2f7fd6; color: white; }
.table-container td.rain-6 { background: #ff9900; }
.table-container td.rain-7 { background: #ff2800; color: white; }
.table-container td.rain-8 { background: #b40068; color: white; }

/* 気圧の変化（気圧痛の目安）。低下＝ピンクの3段階（急な下降・持続的な下降・平年値比の低さの
   一番強いもの）。上昇は根拠が下降ほど強くないので、警戒色にせず単色の青だけで示す
   （変動があったこと自体は分かるが、段階では煽らない） */
.table-container td.press-fall-1 { background: #fbe8f0; }
.table-container td.press-fall-2 { background: #f3b6d1; }
.table-container td.press-fall-3 { background: #e58ab5; }
.table-container td.press-rise { background: #e3edf6; }

/* 気温は背景を使わず文字色で。-5℃未満と猛暑日だけ太字にする */
.table-container td.temp-cold3 { color: #0d47a1; font-weight: 700; }
.table-container td.temp-cold2 { color: #1565c0; }
.table-container td.temp-cold1 { color: #4a86c5; }
.table-container td.temp-hot1 { color: #c77700; }
.table-container td.temp-hot2 { color: #d95926; }
.table-container td.temp-hot3 { color: #c62828; font-weight: 700; }

/* 湿度は両端だけ。30%以下は乾燥、80%以上は霧・雲海が出やすい側 */
.table-container td.humid-dry { background: #f6efe2; }
.table-container td.humid-1 { background: #e6ddf5; }
.table-container td.humid-2 { background: #c3b2e6; }
.table-container td.humid-3 { background: #9b86d6; color: white; }

/* 潮位（天文潮）。局所±6h窓の中立は無色。満＝ティール、干＝くすんだカーキを5段階。
   閾値は頂点付近を細かくし、中央の満／干が最濃色になるようにしてある */
.table-container td.tide-high-1 { background: #eaf6f4; }
.table-container td.tide-high-2 { background: #c5e8e3; }
.table-container td.tide-high-3 { background: #8dcdc4; }
.table-container td.tide-high-4 { background: #4faba0; color: white; }
.table-container td.tide-high-5 { background: #2f7f76; color: white; }
.table-container td.tide-low-1 { background: #f6f2e8; }
.table-container td.tide-low-2 { background: #e6dcc0; }
.table-container td.tide-low-3 { background: #d0bd8e; }
.table-container td.tide-low-4 { background: #b89a5e; color: white; }
.table-container td.tide-low-5 { background: #8f7340; color: white; }

/* 風の強さ（5/10/15/20/25 m/s） */
.table-container td.wind-1 { background: #eeffee; }
.table-container td.wind-2 { background: #ccffcc; }
.table-container td.wind-3 { background: #aaffaa; }
.table-container td.wind-4 { background: #99ff99; }
.table-container td.wind-5 { background: #77ff77; }

/* 雲量の多さ（20/40/60/80/100%） */
.table-container td.cloud-1 { background: #eeeeee; }
.table-container td.cloud-2 { background: #d8d8d8; }
.table-container td.cloud-3 { background: #c0c0c0; }
.table-container td.cloud-4 { background: #a8a8a8; }
.table-container td.cloud-5 { background: #909090; }
/* 過ぎた時刻のセルは全体を薄く（雲量の濃淡も付けない） */
.table-container tr[data-key] td.past {
    background: white;
    color: #ccc;
}
/* 日付・時刻の行は見出しなので背景を変えない */
.table-container tr[data-key="日付"] td.past,
.table-container tr[data-key="時刻"] td.past {
    background-color: #eee;
    color: inherit;
}
.table-container td.pin-time {
    border-left: 2px solid #e53935;
    border-right: 2px solid #e53935;
}
.table-container tr[data-key="時刻"] td.pin-time {
    border-top: 2px solid #e53935;
}
.table-container tr:last-child td.pin-time {
    border-bottom: 2px solid #e53935;
}
.table-container td img {
    width: 36px;
    height: 24px;
}
.table-container .telop {
    font-size: 10px;
    line-height: 1.2;
    color: #555;
}
.wind-arrow {
    display: inline-block;
    color: #1565c0;
}
.range {
    color: #888;
    font-size: 9px;
}
.forecast-loading {
    margin: 8px 0;
    font-size: 12px;
    color: #666;
}
.forecast-error {
    margin: 8px 0;
    font-size: 12px;
    color: #b00;
}

.site-footer {
    width: 100%;
    padding: 10px;
    background: var(--band-bg);
    border-top: 1px solid var(--band-border);
    font-size: 12px;
    line-height: 1.6;
    color: #666;
}

/* 週間予報の下・フッターの上。iOS / Android のブラウザ閲覧時だけ表示（PWA 単体起動時は出さない） */
.install-guide {
    width: 100%;
    margin-top: 20px;
    padding: 14px 10px 16px;
    border-top: 1px solid #c5daf0;
    background: linear-gradient(160deg, #eef6ff 0%, #b7d6f5 50%, #7eb4e8 100%);
    box-sizing: border-box;
}
.install-guide-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
    font-size: 16px;
    font-weight: bold;
    color: #444;
}
.install-guide-body {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
}
.install-guide-icon {
    flex: 0 0 auto;
    width: 88px;
    height: auto;
    border-radius: 10px;
    background: #111;
}
.install-guide-copy {
    flex: 1 1 220px;
    min-width: 0;
    font-size: 13px;
    line-height: 1.55;
    color: #333;
}
.install-guide-copy > p {
    margin: 0 0 8px;
}
.install-guide-steps {
    margin: 0 0 8px;
    padding-left: 1.3em;
}
.install-guide-steps li {
    margin: 2px 0;
}
.install-guide-note {
    margin: 0;
    font-size: 12px;
    color: #333;
}
.footer-heading {
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: bold;
    color: #555;
}
.site-credit {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--band-border);
    font-size: 11px;
    color: #777;
}
.site-credit a {
    margin-left: 8px;
}
.site-footer .notice {
    margin-top: 4px;
    font-size: 10.5px;
    line-height: 1.5;
}

/* 押すとその時刻の雲量地図に切り替わる列。
   色は変えず、下線だけで押せることを示す（地図にコマがある列にだけ付く） */
#forecast-msm tr[data-key="時刻"] td.time-link {
    text-decoration: underline;
    cursor: pointer;
}

/* 格子の境界をぼかさない */
.cloud-grid-tile {
    image-rendering: pixelated;
}

/* 下地レイヤー用のペイン。雲量レイヤーとは分けてあるので、フィルタが雲に掛からない。
   陰影の海域は透過。白地図の海は白塗りだが、下の blank-under の invert+lighten で黒く見える */
.base-dark-pane {
    background: #000;
}

/* 陰影起伏図を暗く落として下地にする。無彩色なので雲の色と競合しない */
.hillshade-dark-tile {
    filter: brightness(0.30) contrast(1.3);
}

/* 天気より下の白地図。陰影と同じペインなので invert+lighten が効き、白地が黒になる */
.blank-under-tile {
    filter: invert(1);
    mix-blend-mode: lighten;
}

/* 手前の白地図線は JS で白線＋右下1px黒を焼済。ここでの filter は付けない（パンが重くなる） */

/* 地図ラベル用のスタイル */
.leaflet-control-map-label {
    background: rgba(255, 255, 255, 0.8);
    padding: 3px 6px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 12px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    text-align: right;
    color: #666;
}
.leaflet-control-map-label small {
    font-size: 10px;
    margin: 0 0 0 5px;
}

/* PC: 3つの地図を横に並べ、画面幅に応じて 300×200 の最大2倍まで拡大する */
@media (min-width: 1000px) {
    :root {
        --map-gap: 12px;
        /* 画面幅から、スクロールバー・パネルの左右の余白・枠・枠内の余白・
           地図どうしの隙間（15 + 20 + 2 + 24 + 24 = 85px）を引いて3等分する */
        --map-width: min(600px, calc((100vw - 88px) / 3));
        --maps-width: calc(3 * var(--map-width) + 70px);
    }

    .time-select {
        width: 220px;
        flex: none;
    }

    /* PCは横に余裕があるぶん、トラックが伸びきってリセット/再生ボタンが
       画面の両端に離れて見える。ひとまとまりとして中央に収める */
    .nowcast-bar {
        max-width: 480px;
        margin: 0 auto;
    }

    /* PCは横に余裕があるので、検索欄は常に出しておく */
    .point-panel.search-collapsed .search-form {
        display: flex;
    }
    .search-toggle-btn {
        display: none;
    }

    .search-status {
        position: absolute;
        top: 35px;
        left: 0;
        right: 0;
        padding: 6px 10px;
        background: white;
        border: 1px solid #ccc;
        border-radius: 4px;
    }

    .site-header-title {
        gap: 16px;
    }

    .maps-panel {
        width: var(--maps-width);
    }

    .maps-container {
        flex-direction: row;
        gap: var(--map-gap);
        padding: var(--map-gap);
    }

    .map-wrapper {
        width: var(--map-width);
        border-bottom: none;
    }

    .map {
        width: var(--map-width);
        height: calc(var(--map-width) * 2 / 3);
    }

    /* 単票タブは1枚だけなので、パネルの横幅いっぱいに広げる */
    .maps-container[data-view="total"] .shared-only,
    .maps-container[data-view="total"] .shared-only .map,
    .maps-container[data-view="wind"] .shared-only,
    .maps-container[data-view="wind"] .shared-only .map,
    .maps-container[data-view="rain"] .shared-only,
    .maps-container[data-view="rain"] .shared-only .map,
    .maps-container[data-view="thunder"] .shared-only,
    .maps-container[data-view="thunder"] .shared-only .map {
        width: 100%;
    }
    .maps-container[data-view="total"] .shared-only .map,
    .maps-container[data-view="wind"] .shared-only .map,
    .maps-container[data-view="rain"] .shared-only .map,
    .maps-container[data-view="thunder"] .shared-only .map {
        height: calc(var(--map-width) * 2 / 3);
    }

    /* PCは幅に余裕があるので、出典2つは1行に並べる */
    .site-footer .credit {
        display: inline;
    }
    .site-footer .credit + .credit {
        margin-left: 1.5em;
    }
}

/* ---------- フルスクリーンモード ---------- */
/* タブ＋地図＋時刻＋地点を画面いっぱいに広げる。予測表は後ろに隠れてよい */
body.is-map-fullscreen {
    overflow: hidden;
}

.maps-panel.is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 2000;
    width: 100%;
    max-width: none;
    height: 100dvh;
    padding: 0;
    background: var(--content-bg);
}

.maps-panel.is-fullscreen .layer-tabs {
    flex-shrink: 0;
    padding: 0 8px;
    box-sizing: border-box;
}

.maps-panel.is-fullscreen .maps-container {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0;
    border-left: none;
    border-right: none;
}

.maps-panel.is-fullscreen .map-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    border-bottom: none;
}

.maps-panel.is-fullscreen .map {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.maps-panel.is-fullscreen .time-panel {
    flex-shrink: 0;
}

.maps-panel.is-fullscreen .point-panel {
    flex-shrink: 0;
    padding-bottom: 10px;
}

.maps-panel.is-fullscreen .forecast-hint {
    display: none;
}

/* スマホ全画面の「雲(上中下層)」：3枚縦並びをやめ、data-layer の1枚だけ出す */
@media (max-width: 999.98px) {
    .maps-panel.is-fullscreen .maps-container[data-view="layers"][data-layer="upper"] .layers-only:not([data-cloud-layer="upper"]),
    .maps-panel.is-fullscreen .maps-container[data-view="layers"][data-layer="middle"] .layers-only:not([data-cloud-layer="middle"]),
    .maps-panel.is-fullscreen .maps-container[data-view="layers"][data-layer="lower"] .layers-only:not([data-cloud-layer="lower"]) {
        display: none;
    }
}

/* PC全画面：上中下層は横三分割のまま、縦だけ画面いっぱいに */
@media (min-width: 1000px) {
    .maps-panel.is-fullscreen {
        width: 100%;
    }

    .maps-panel.is-fullscreen .maps-container {
        flex-direction: row;
        gap: var(--map-gap, 12px);
        padding: var(--map-gap, 12px);
        border: none;
    }

    .maps-panel.is-fullscreen .map-wrapper {
        width: auto;
        flex: 1 1 0;
    }

    .maps-panel.is-fullscreen .maps-container[data-view="total"] .shared-only,
    .maps-panel.is-fullscreen .maps-container[data-view="wind"] .shared-only,
    .maps-panel.is-fullscreen .maps-container[data-view="rain"] .shared-only,
    .maps-panel.is-fullscreen .maps-container[data-view="thunder"] .shared-only {
        width: 100%;
    }

    .maps-panel.is-fullscreen .layer-tabs {
        padding: 0 12px;
    }
}
