* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
}

html {
    background-color: #f1f5f9; /* ページ外側のベース背景色 */
}

body {
    background-color: #f9f4f1;
    color: #334155;
    line-height: 1.6;
    padding: 58px 0 0 0; /* 固定ヘッダー分（左右の余白はコンテナ側で制御） */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* =========================================================
   wxidx.com 共通固定ヘッダー（画面横幅いっぱい）
   ========================================================= */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 58px;
    z-index: 1000;
    background: #0f172a; /* ヘッダー：ダークネイビー */
    border-bottom: 1px solid #1e293b;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.site-header-inner {
    height: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
}

.menu-button {
    width: 42px;
    height: 42px;
    margin: 0 8px 0 0;
    padding: 9px 8px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
}

.menu-button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.menu-button:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.menu-button span {
    display: block;
    width: 24px;
    height: 2px;
    margin: 0 auto;
    border-radius: 999px;
    background: #f8fafc;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.site-brand {
    color: #ffffff;
    text-decoration: none;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 1090;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.site-menu {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 86vw);
    z-index: 1100;
    background: #1e293b;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.25);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
}

.site-menu-header {
    height: 58px;
    padding: 0 16px 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #334155;
}

.site-menu-title {
    font-size: 17px;
    font-weight: 700;
    color: #f8fafc;
}

.menu-close {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #94a3b8;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
}

.menu-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.site-menu-links {
    padding: 12px;
}

.site-menu-link {
    display: flex;
    align-items: center;
    min-height: 46px;
    padding: 10px 14px;
    margin-bottom: 4px;
    border-radius: 7px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
}

.site-menu-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.site-menu-link.active {
    background: #2563eb;
    color: #ffffff;
    font-weight: 700;
}

body.menu-open {
    overflow: hidden;
}

body.menu-open .menu-overlay {
    opacity: 1;
    visibility: visible;
}

body.menu-open .site-menu {
    transform: translateX(0);
}

/* =========================================================
   ページ共通部品（主要株価インデックスのページと同じ見た目）
   ========================================================= */

.container {
    max-width: 1200px;
    width: calc(100% - 40px);
    margin: 0 auto;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    padding: 32px 32px 0px;
    flex: 1;
}

.page-header {
    margin-bottom: 25px;
    min-height: 92px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.page-header h1 {
    font-size: 26px;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 15px;
    color: #64748b;
    margin-top: 6px;
}

.subtitle-updated {
    display: block;
    margin-top: 4px;
    margin-left: 0px;
    color: #2563eb;
    font-weight: 600;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    padding: 6px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    color: #334155;
    transition: all 0.2s ease;
}

.btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.btn.active {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

/* メインチャート表示エリア */
.chart-wrapper {
    width: 100%;
    margin-bottom: 35px;
    background: #f8fafc;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #c7ced7;
}

.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
}

footer {
    width: 100%;
    padding: 30px 20px 40px 20px;
    margin-bottom: 50px;
    border-top: 1px solid #e2e8f0;
    font-size: 14px;
    color: #64748b;
    text-align: center;
}

footer a {
    color: #475569;
    text-decoration: underline;
}

footer a:hover {
    color: #2563eb;
}

.db-error {
    margin-bottom: 20px;
    padding: 14px 18px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    border-radius: 8px;
    font-size: 14px;
}

/* =========================================================
   気象病予報ページ専用スタイル
   ========================================================= */

:root {
    --lv-0: #059669; /* 安心     */
    --lv-1: #d97706; /* 注意     */
    --lv-2: #ea580c; /* 警戒     */
    --lv-3: #dc2626; /* 厳重警戒 */

    /* 時系列の寸法（main.js が同じ値を設定する）。3時間 = 1列 */
    --col: 72px;     /* 3時間ぶんの幅   */
    --label: 84px;   /* 左のラベル列    */
    --n: 16;         /* 表示する列数    */
}

.lv-0 { background: var(--lv-0); }
.lv-1 { background: var(--lv-1); }
.lv-2 { background: var(--lv-2); }
.lv-3 { background: var(--lv-3); }

/* 地点の選択バー */
.loc-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.loc-bar input[type="search"],
.loc-bar button {
    height: 38px;
    padding: 0 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: #334155;
    font-size: 15px;
}

.loc-bar input[type="search"] {
    flex: 1 1 200px;
    min-width: 0;
}

.loc-bar button {
    cursor: pointer;
    transition: all 0.2s ease;
}

.loc-bar button:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.loc-bar input:focus-visible,
.loc-bar button:focus-visible,
.place-results button:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.place-results {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.place-results:empty {
    display: none;
}

.place-results button {
    padding: 6px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: #334155;
    font-size: 14px;
    cursor: pointer;
}

.place-results button:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.place-note {
    margin-bottom: 8px;
    font-size: 13px;
    color: #475569;
}

.place-note:empty {
    display: none;
}

.place-note.error {
    color: #dc2626;
}

/* 今日・明日の警戒レベル */
.hero-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-top: 16px;
}

.hero-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    align-items: center;
    padding: 16px;
    background: #f8fafc;
    border: 1px solid #c7ced7;
    border-radius: 12px;
}

.badge {
    min-width: 140px;
    padding: 12px 16px;
    border-radius: 10px;
    color: #ffffff;
    text-align: center;
}

.badge-label {
    font-size: 13px;
}

.badge-level {
    font-size: 26px;
    font-weight: 800;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.hero-comment {
    font-size: 14px;
    color: #475569;
}

.alert-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 12px 0 20px;
    font-size: 13px;
    color: #475569;
}

.alert-legend i {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 6px;
    border-radius: 3px;
    vertical-align: -1px;
}

/* 時系列エリア（チャートと表が同じ幅・同じ時刻位置で横に並ぶ） */
.scroll-hint {
    margin-bottom: 10px;
    font-size: 13px;
    color: #64748b;
}

.timeline-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* 日付行・表・各チャートがそれぞれ横スクロールバーを持つ（スクロール位置は main.js で連動） */
.timeline-scroll.no-bar {
    scrollbar-width: none;
    /* 日付行を固定ヘッダー(58px)の直下に固定。overflow を持つ要素自身を sticky にする
       （親の overflow 内では sticky が効かないため）。下を通るグラフを隠すため背景色は .chart-wrapper と同じ */
    position: sticky;
    top: 58px;
    z-index: 5;
    background: #f8fafc;
    box-shadow: 0 1px 0 #c7ced7;
}

.timeline-scroll.no-bar::-webkit-scrollbar {
    display: none;
}

.day-row {
    display: grid;
    width: calc(var(--label) + var(--n) * var(--col));
    margin-bottom: 4px;
}

.day-cell {
    padding: 5px 0;
    background: #e2e8f0;
    border-left: 2px solid #93c5fd;
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
}

.day-cell span {
    position: sticky;
    left: calc(var(--label) + 10px);
    display: inline-block;
}

/* 日付行の2段目：時刻（表の列と同じ幅） */
.time-cell,
.time-label {
    padding: 3px 0;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-align: center;
}

.time-label {
    position: sticky;
    left: 0;
    z-index: 1;
    padding-left: 10px;
    text-align: left;
    background: #f8fafc;
}

.time-cell.day-start {
    border-left: 2px solid #93c5fd;
}

@media (max-width: 768px) {
    .time-label { padding-left: 6px; font-size: 11px; }
}

/* 見出しは横スクロールしても左端に残す */
.tl-title {
    position: sticky;
    left: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 14px;
    width: max-content;
    max-width: calc(100vw - 100px);
    margin: 16px 0 6px;
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}

.tl-title .lg {
    font-size: 12px;
    font-weight: 500;
    color: #475569;
}

.lg i {
    display: inline-block;
    margin-right: 5px;
    vertical-align: middle;
}

.lg-line { width: 14px; height: 3px; border-radius: 2px; }
.lg-bar  { width: 10px; height: 10px; border-radius: 2px; }

/* y軸の目盛を左端に固定表示するための重ね描きキャンバス（高さ0の固定枠の中に置き、レイアウトには影響しない） */
.y-pin-wrap {
    position: sticky;
    left: 0;
    z-index: 3;
    width: 0;
    height: 0;
    pointer-events: none;
}

.y-pin {
    position: absolute;
    left: 0;
    top: 0;
    display: block;
    background: #f8fafc; /* .chart-wrapper の背景色と同じ。下を通るグラフを隠す */
}

.chart-container.chart-wide {
    height: 240px;
    width: calc(var(--label) + var(--n) * var(--col));
}

/* 3時間ごとの予報（横方向が時間） */
.hourly-table {
    width: calc(var(--label) + var(--n) * var(--col));
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    font-size: 13px;
}

.hourly-table th,
.hourly-table td {
    padding: 6px 2px;
    text-align: center;
    border-bottom: 1px solid #f1f5f9;
    overflow: hidden;
}

.hourly-table thead th {
    background: #f8fafc;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
}

.hourly-table .rowlabel {
    position: sticky;
    left: 0;
    z-index: 2;
    padding-left: 10px;
    text-align: left;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
}

/* 項目名の2行表示用の改行（PCでは改行しない） */
.hourly-table .rowlabel .br {
    display: none;
}

.hourly-table .day-start {
    border-left: 2px solid #93c5fd;
}

.hourly-table tbody tr:last-child th,
.hourly-table tbody tr:last-child td {
    border-bottom: none;
}

.hourly-table .lv-cell {
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.wx-icon {
    display: block;
    font-size: 18px;
    line-height: 1.3;
}

.wx-text {
    display: block;
    font-size: 11px;
    color: #475569;
    white-space: nowrap;
}

.wind-arrow {
    display: block;
    color: #475569;
    line-height: 1.3;
}

.week-section {
    margin-bottom: 25px;
}

.week-title {
    margin-bottom: 10px;
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
}

.week-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.week-table {
    width: 100%;
    min-width: 480px;
    border-collapse: separate;
    border-spacing: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    font-size: 14px;
}

.week-table th,
.week-table td {
    padding: 8px 6px;
    text-align: center;
    border-bottom: 1px solid #f1f5f9;
}

.week-table thead th {
    background: #f8fafc;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
}

.week-table thead th small {
    display: block;
    font-size: 11px;
    font-weight: 500;
}

.week-table tbody tr:last-child th,
.week-table tbody tr:last-child td {
    border-bottom: none;
}

.week-table .wk-date {
    padding-left: 12px;
    text-align: left;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
}

.week-table tbody .wk-date small {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: #64748b;
}

.week-table .lv-cell {
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.wk-icon {
    margin-right: 4px;
    font-size: 18px;
    vertical-align: middle;
}

.week-table .wx-text {
    display: inline;
    vertical-align: middle;
}

.t-max { color: #dc2626; font-weight: 700; }
.t-min { color: #2563eb; font-weight: 700; }

.page-note {
    margin-bottom: 20px;
    font-size: 13px;
    line-height: 1.7;
    color: #64748b;
}

/* スマホ */
@media (max-width: 768px) {
    body { padding: 58px 0 0 0; }
    .container {
        width: 100%;
        padding: 16px;
        border-radius: 0;
        border: none;
    }
    .page-header h1 { font-size: 22px; text-align: center; }
    .page-header { min-height: auto; }
    .loc-bar input[type="search"] { font-size: 16px; flex: 1 1 100%; } /* iOSの自動ズーム防止・入力欄を1行幅に */
    .hero-grid { grid-template-columns: 1fr; }
    .hero-card { grid-template-columns: 1fr; gap: 10px; }
    .chart-container.chart-wide { height: 210px; }
    /* 表の項目名：2行にして横幅を狭くする（幅は main.js の LABEL_W と合わせる） */
    .hourly-table .rowlabel {
        padding-left: 6px;
        font-size: 11px;
        line-height: 1.3;
    }
    .hourly-table .rowlabel .br { display: block; }
    .week-table { font-size: 12px; }
    .week-table th, .week-table td { padding: 6px 4px; }
    .week-table .wk-date { padding-left: 8px; }
}