body {
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    font-family: sans-serif;
    background: #f4f4f4;
}

/* ヘッダー全体をFlexbox化 */
header {
    background-color: #2c3e50;
    color: white;
    padding: 15px 20px;

    /* 横並び・折り返しの設定 */
    display: flex;
    flex-wrap: wrap;
    /* スペースが足りない時は自動で下へ折り返す */
    align-items: center;
    /* 縦方向の中央で高さを揃える */
    gap: 2vh;
    /* H1とPの間の隙間（折り返した時は上下の隙間） */
}

/* タイトルの余白をリセット */
header h1 {
    margin: 0;
    font-size: 1.5rem;
    white-space: nowrap;
    /* タイトル自体は途中で改行させない */
}

/* 注意書き（小文字化）の設定 */
header .attention {
    margin: 0;
    font-size: 0.8rem;
    /* 文字を小さくする */
    color: #bdc3c7;
    /* 少し薄いグレーにしてH1を目立たせる */
    line-height: 1.4;
    /* 複数行になった時の行間を見やすく */
}

/* 小さなグレーの観測点マーカー */
.station-dot-marker {
    background-color: #747d8c;
    border: 1.5px solid #ffffff;
    border-radius: 50%;
    width: 10px;
    height: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* 2つのトグルを並べるためのコンテナ */
.map-toggle-container {
    display: flex;
    gap: 15px;
    /* トグル同士の隙間 */
    flex-wrap: wrap;
    /* スマホなどで狭い場合は折り返す */
    justify-content: flex-end;
    align-items: center;

    padding: 6px 12px;
    background-color: #399ec2;
}

.station-toggle-label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: bold;
    color: #2f3542;
    gap: 8px;
    white-space: nowrap;
}

/* スイッチの四角い枠 */
.station-toggle-label input {
    display: none;
    /* デフォルトのチェックボックスを隠す */
}

.station-toggle-slider {
    width: 36px;
    height: 20px;
    background-color: #ced6e0;
    border-radius: 20px;
    position: relative;
    transition: 0.3s;
}

/* スイッチの丸いポッチ */
.station-toggle-slider::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: white;
    top: 2px;
    left: 2px;
    transition: 0.3s;
}

/* チェックされた時の状態 */
.station-toggle-label input:checked+.station-toggle-slider {
    background-color: #2f333e;
    /* 緑色に */
}

.station-toggle-label input:checked+.station-toggle-slider::before {
    transform: translateX(16px);
}

#toggle-earthquake-btn:checked+.earthquake-slider {
    background-color: #2f333e;
}

/* 検索バーのスタイル */
#search-bar {
    background: white;
    padding: 10px 20px;
    display: flex;
    flex-wrap: wrap;
    /* 画面が狭い時に折り返す */
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #ddd;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

input,
select {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

button {
    background: #3498db;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
}

button:hover {
    background: #399ec2;
}

.sub-buttons {
    display: flex;
    gap: 10px;
    /* ボタン同士の隙間 */
    margin-left: auto;
    /* 右寄せ */
}

/* サブボタン（リセット・更新）のデザイン */
.btn-secondary {
    background-color: #f1f2f6;
    border: 1px solid #ced6e0;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background-color: #dfe4ea;
    border-color: #a4b0be;
}

#btn-zoom-reset {
    background-color: #ce4a4a;
}

#btn-reset {
    background-color: #72d278;
    color: black;
}

#btn-update {
    background-color: #7f8c8d;
}

/* 更新中のボタン（無効化状態） */
.btn-secondary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#result-count {
    font-size: 0.9em;
    color: #666;
}

main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#map {
    flex: 2;
    z-index: 1;
}

#info-panel {
    flex: 1;
    padding: 20px;
    background: #fff;
    overflow-y: auto;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

/* 1つの地震の枠組み */
.eq-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    /* 角丸をはみ出させない */
}

/* カードの上部 */
.eq-card-header {
    background: #399ec2;
    color: white;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.eq-intensity {
    font-size: 1.2rem;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.2);
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

.eq-location {
    font-size: 1.1rem;
    font-weight: bold;
}

/* カードの下部（ボディ）: 詳細を並べる */
.eq-card-body {
    padding: 12px 15px;
    background: #f5f5f5;
}

.eq-info {
    font-size: 1rem;
    color: #2c3e50;
    display: flex;
    justify-content: space-between;
    /* 項目名を左、数値を右に配置 */
    padding: 6px 0;
    border-bottom: 1px dashed #ecf0f1;
}

/* 最後の線は消す */
.eq-info:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.eq-info span {
    color: #7f8c8d;
    font-weight: bold;
}

/* 複数表示用のタイトル */
.panel-title {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-top: 0;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 2px solid #ecf0f1;
}

/* 震度別の背景色定義 */
.bg-shindo-1 {
    background-color: #8bafd6 !important;
    color: #333 !important;
}

.bg-shindo-2 {
    background-color: #72d278 !important;
    color: #333 !important;
}

.bg-shindo-3 {
    background-color: #fae600 !important;
    color: #333 !important;
}

.bg-shindo-4 {
    background-color: #ffb100 !important;
    color: #333 !important;
}

.bg-shindo-5-low {
    background-color: #ff3300 !important;
}

.bg-shindo-5-high {
    background-color: #a50021 !important;
}

.bg-shindo-6-low {
    background-color: #b40671 !important;
}

.bg-shindo-6-high {
    background-color: #8a0557 !important;
}

.bg-shindo-7 {
    background-color: #600239 !important;
}

.intensity-marker {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid #333;
    font-weight: bold;
    font-size: 14px;
    color: #333;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* 震度ごとの背景色（気象庁の配色に準拠） */
.scale-7 {
    background-color: #600239;
    color: white;
}

.scale-6p {
    background-color: #8a0557;
    color: white;
}

.scale-6m {
    background-color: #b40671;
    color: white;
}

.scale-5p {
    background-color: #a50021;
    color: white;
}

.scale-5m {
    background-color: #ff3300;
    color: white;
}

.scale-4 {
    background-color: #ffb100;
}

.scale-3 {
    background-color: #fae600;
}

.scale-2 {
    background-color: #72d278;
}

.scale-1 {
    background-color: #8bafd6;
}

.intensity-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 6px;
    background-color: #f1f2f6;
    color: #333;
    border: 1px solid #dfe4ea;
    border-radius: 4px;
    text-align: center;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.intensity-btn:hover {
    background-color: #eccc68;
    /* 少し目立つ色に */
}

.intensity-btn:disabled {
    background-color: #f1f2f6;
    color: #a4b0be;
    border-color: #dfe4ea;
    cursor: not-allowed;
    opacity: 0.7;
}

.intensity-btn:disabled:hover {
    background-color: #f1f2f6;
    /* ホバーしても色を変えない */
}

.intensity-details-container {
    margin-top: 10px;
    font-size: 0.85rem;
    border-top: 1px dashed #ced6e0;
    padding-top: 10px;
    display: none;
    /* 最初は隠しておく */
}

/* 震度ごとのグループ */
.intensity-group {
    margin-bottom: 8px;
}

.intensity-group-title {
    font-weight: bold;
    color: #2f3542;
    margin-bottom: 4px;
    border-left: 3px solid #ff4757;
    padding-left: 5px;
}

.intensity-group-areas {
    color: #57606f;
    line-height: 1.4;
    padding-left: 8px;
}

/* ローディング表示 */
.loading-text {
    text-align: center;
    color: #747d8c;
    font-style: italic;
    animation: blink 1s infinite alternate;
}

@keyframes blink {
    from {
        opacity: 1;
    }

    to {
        opacity: 0.4;
    }
}

/* リアルタイムポップアップ */
.realtime-notification-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    /* 地図や他の要素より常に最前面 */
    display: block;
    pointer-events: none;
    /* 背景の地図操作の邪魔をしない */
    width: 90%;
    max-width: 400px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.realtime-popup {
    background-color: rgba(47, 53, 66, 0.95);
    color: #ffffff;
    padding: 15px;
    border-radius: 8px;
    border-left: 6px solid #2ed573;
    /* デフォルト（震度低）は緑 */
    pointer-events: auto;
    /* ここだけはクリック可能にする */
    animation: slideDown 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    /* ふわっと降りてくる */
    position: relative;
    backdrop-filter: blur(4px);
    max-height: 50vh;
    overflow-y: auto;
    height: auto;
    box-sizing: border-box;
    margin-bottom: 12px;
}

/* スクロールバーのデザイン */
.realtime-notification-container::-webkit-scrollbar {
    display: none; /* 見た目を消す */
}
/* 一部のブラウザ向け */
.realtime-notification-container {
    scrollbar-width: none; 
}

.realtime-popup::-webkit-scrollbar, 
#info-panel::-webkit-scrollbar {
    width: 6px;
}

.realtime-popup::-webkit-scrollbar-track, 
#info-panel::-webkit-scrollbar-track {
    background: transparent;
}

.realtime-popup::-webkit-scrollbar-thumb, 
#info-panel::-webkit-scrollbar-thumb {
    background: rgba(120, 120, 120, 0.3);
    border-radius: 4px;
}

/* 震度に応じた枠線の色変化 */
.realtime-popup.intensity-high {
    border-left-color: #ff4757;
}

/* 震度5弱以上は赤 */
.realtime-popup.intensity-mid {
    border-left-color: #ffa502;
}

/* 震度3〜4はオレンジ */
.realtime-popup.eew-alert {
    border-left-color: #ff3838;
    background-color: rgba(194, 54, 22, 0.95);
}

/* 津波・緊急用ポップアップ */
.realtime-popup.tsunami-alert {
    border-left-color: #0abde3;
    background-color: rgba(10, 61, 98, 0.95);
}

.tsunami-warning-text {
    color: #ff4757;
    font-weight: bold;
    display: inline-block;
    margin-top: 5px;
    background-color: rgba(255, 71, 87, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

/* 緊急地震速報 */

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.popup-close-btn {
    position: absolute;
    top: 8px;
    right: 12px;
    cursor: pointer;
    color: #a4b0be;
    font-size: 14px;
}

.popup-close-btn:hover {
    color: #ffffff;
}

.realtime-popup-title {
    font-size: 12px;
    font-weight: bold;
    color: #ced6e0;
    margin-bottom: 8px;
}

.realtime-popup-content {
    font-size: 14px;
    line-height: 1.5;
}

.realtime-popup-content strong {
    font-size: 16px;
    color: #ffda79;
}

/* フッター全体のコンテナ設定 */
footer {
    background-color: #2c3e50;
    padding: 6px 10px;
    /* 上下の幅を極限まで小さく */
    font-size: 11px;
    color: #999;

    display: flex;
    flex-wrap: wrap;
    /* 幅が足りなくなったら自動で折り返す */
    justify-content: center;
    /* 全体を中央に寄せる */
    align-items: center;
    /* 縦方向のズレを揃える */
    gap: 15px;
    /* 並べた要素と要素の間の隙間 */
}

/* pタグの不要な余白を消去 */
footer p {
    margin: 0;
}

/* サイトバージョンの文字色 */
footer #site-version {
    color: #aaa;
}

/* リンク要素のデザイン */
footer .footer-link {
    color: #aaa;
    text-decoration: none;
    /* リンクの下線を消す */
}

/* リンクにマウスを乗せた際の動き */
footer .footer-link:hover {
    color: #fff;
    text-decoration: underline;
    /* マウスホバー時だけ下線を出す */
}

@media (max-width: 768px) {

    html,
    body {
        height: 100dvh;
        /* 表示領域に高さを一致させる */
        margin: 0;
        overflow: hidden;
        /* スクロール禁止 */
    }
}