body:has(#theme-toggle:checked) {
    background-color: #0d1117;
}
:root {
    --bg-color: #f4f6f9;
    --card-bg: #ffffff;
    --border-color: #dce1e8;
    --text-main: #222831;
    --text-sub: #5c6672;
    --sun-color: #d93025;
    --sun-bg: #fff5f5;
    --sat-color: #1a73e8;
    --sat-bg: #f4f8ff;
    --today-border: #ff9800;
    --today-bg: #fffdf5;
    --accent: #2c3e50;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.4;
    padding: 12px;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
}

/* ヘッダー・ナビゲーション */
.header-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 14px 18px;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    margin-bottom: 14px;
    gap: 10px;
}

.title-area h1 {
    font-size: clamp(14px, 8.00px + 1.56vw, 22px);
    color: var(--accent);
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.location-badge {
    font-size: 0.78rem;
    font-weight: normal;
    background: #eef2f7;
    color: #4a5568;
    padding: 3px 8px;
    border-radius: 4px;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.btn {
    display: inline-block;
    text-decoration: none;
    background: #fff;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
    background: #eef2f7;
    border-color: #b8c2cc;
}

.btn-home {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-home:hover {
    background: #1a252f;
    color: #fff;
}

/* カレンダーグリッド（PC・タブレット標準） */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--border-color);
    gap: 1px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.weekday-header {
    background: #2c3e50;
    color: #fff;
    text-align: center;
    padding: 8px 4px;
    font-weight: bold;
    font-size: 0.9rem;
}

.weekday-header.sun {
    background: #b71c1c;
}

.weekday-header.sat {
    background: #1565c0;
}

.day-cell {
    background: var(--card-bg);
    min-height: 145px;
    padding: 7px 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.day-cell.empty {
    background: #f9fafb;
}

.day-cell.sun, .day-cell.holiday {
    background: var(--sun-bg);
}

.day-cell.sat {
    background: var(--sat-bg);
}

.day-cell.today {
    background: var(--today-bg);
    box-shadow: inset 0 0 0 2px var(--today-border);
}

/* セル上部（日付・六曜） */
.cell-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}

.day-num {
    font-size: 1.2rem;
    font-weight: 700;
}

.sun .day-num, .holiday .day-num {
    color: var(--sun-color);
}

.sat .day-num {
    color: var(--sat-color);
}

.rokuyo-tag {
    font-size: 0.75rem;
    padding: 1px 5px;
    border-radius: 3px;
    background: #edf2f7;
    color: #333;
    font-weight: 600;
}

.rokuyo-taian {
    background: #ffebee;
    color: #c62828;
}

.rokuyo-butsumetsu {
    background: #eceff1;
    color: #546e7a;
}

/* 祝日名・旧暦 */
.holiday-name {
    font-size: 0.74rem;
    color: var(--sun-color);
    font-weight: bold;
    min-height: 1.1em;
    margin-bottom: 3px;
}

.meta-row {
    font-size: 0.72rem;
    color: var(--text-sub);
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed #e2e8f0;
    padding-bottom: 3px;
    margin-bottom: 4px;
}

.moon-phase-badge {
    font-weight: bold;
    color: #b45309;
}

/* 天文・潮汐データリスト */
.astro-list {
    list-style: none;
    font-size: 0.72rem;
    color: #334155;
}

.astro-list li {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2px;
    gap: 4px;
}

.astro-label {
    color: #64748b;
    white-space: nowrap;
}

.astro-val {
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.tide-high {
    color: #0369a1;
}

.tide-low {
    color: #0f766e;
}

.mobile-week {
    display: none;
}

/* フッター注釈 */
.footer-note {
    margin-top: 12px;
    font-size: 0.78rem;
    color: var(--text-sub);
    background: var(--card-bg);
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

/* ▼ 追加: ダークモード切り替え用隠しチェックボックス */
#theme-toggle {
    display: none;
}

/* ▼ 追加: チェック時にCSS変数をブラックダーク風に上書き */
#theme-toggle:checked ~ .container {
    --bg-color: #0d1117;
    --card-bg: #161b22;
    --border-color: #30363d;
    --text-main: #e6edf3;
    --text-sub: #8b949e;
    --sun-color: #ff7b72;
    --sun-bg: #26171a;
    --sat-color: #79c0ff;
    --sat-bg: #131d2e;
    --today-border: #f0883e;
    --today-bg: #241e16;
    --accent: #388bfd;
}

/* ▼ 追加: ダークモード時の個別パーツ色調整 */
#theme-toggle:checked ~ .container .location-badge {
    background: #21262d;
    color: #c9d1d9;
}
#theme-toggle:checked ~ .container .btn {
    background: #21262d;
    color: #e6edf3;
    border-color: #30363d;
}
#theme-toggle:checked ~ .container .btn:hover {
    background: #30363d;
}
#theme-toggle:checked ~ .container .btn-home {
    background: #238636;
    border-color: #2ea043;
    color: #ffffff;
}
#theme-toggle:checked ~ .container .day-cell.empty {
    background: #0d1117;
}
#theme-toggle:checked ~ .container .rokuyo-tag {
    background: #21262d;
    color: #c9d1d9;
}
#theme-toggle:checked ~ .container .rokuyo-taian {
    background: #3d1c20;
    color: #ff7b72;
}
#theme-toggle:checked ~ .container .rokuyo-butsumetsu {
    background: #21262d;
    color: #8b949e;
}
#theme-toggle:checked ~ .container .meta-row,
#theme-toggle:checked ~ .container .astro-list li {
    border-color: #30363d;
}
#theme-toggle:checked ~ .container .astro-list {
    color: #c9d1d9;
}
#theme-toggle:checked ~ .container .astro-label {
    color: #8b949e;
}
#theme-toggle:checked ~ .container .tide-high {
    color: #58a6ff;
}
#theme-toggle:checked ~ .container .tide-low {
    color: #3fb950;
}
#theme-toggle:checked ~ .container .moon-phase-badge {
    color: #e3b341;
}

/* ▼ 追加: 切替ボタン（label）のスタイル */
.btn-theme {
    cursor: pointer;
    user-select: none;
}

/* 初期状態（ダークモード）では「ダークにする」を隠す */
.btn-theme .label-dark {
    display: none;
}

/* クリック後（ライトモード）で「ライトにする」を隠し、「ダークにする」を出す */
#theme-toggle:checked ~ .container .btn-theme .label-light {
    display: none;
}
#theme-toggle:checked ~ .container .btn-theme .label-dark {
    display: inline;
}

/* ▼ 追加: ダークモード時の平日（月〜金）の日付数字を真っ白にして濃くする */
#theme-toggle:checked ~ .container .day-num {
    color: #ffffff; /* 平日：純白 */
}
#theme-toggle:checked ~ .container .sun .day-num,
#theme-toggle:checked ~ .container .holiday .day-num {
    color: #ff9492; /* 日曜・祝日：より明るい赤 */
}
#theme-toggle:checked ~ .container .sat .day-num {
    color: #9ecbff; /* 土曜：より明るい青 */
}

/* タブレット対応 (〜960px) */
@media (max-width: 960px) {
    .day-cell {
        padding: 5px;
        min-height: 135px;
    }
    .astro-list li {
        flex-direction: column;
        gap: 0;
        margin-bottom: 3px;
    }
    .astro-val {
        text-align: left;
        font-size: 0.7rem;
    }
}

/* スマートフォン対応 (〜640px): 見やすい1列リスト形式へ自動変形 */
@media (max-width: 640px) {
    body {
        padding: 8px;
    }
    .header-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .nav-controls {
        justify-content: space-between;
    }
    .calendar-grid {
        display: flex;
        flex-direction: column;
        gap: 8px;
        background: transparent;
        border: none;
        box-shadow: none;
    }
    .weekday-header, .day-cell.empty {
        display: none;
    }
    .day-cell {
        min-height: auto;
        border-radius: 8px;
        border: 1px solid var(--border-color);
        padding: 10px 12px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    }
    .mobile-week {
        display: inline;
        font-size: 0.9rem;
        margin-left: 4px;
    }
    .astro-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px 12px;
        margin-top: 4px;
    }
    .astro-list li {
        flex-direction: row;
        justify-content: space-between;
        border-bottom: 1px dotted #e2e8f0;
        padding-bottom: 2px;
    }
}
