/* =============================================
   R8通学路安全点検 — スタイルシート
   ============================================= */

:root {
    color-scheme: light;
    --bg: #f5f7f8;
    --panel: #ffffff;
    --text: #182026;
    --muted: #63717d;
    --line: #d8e0e5;
    --accent: #186f65;
    --accent-strong: #0c4f48;
    --subtle: #edf4f2;
    --danger: #9c2f23;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
}

/* 一覧ページ PC表示：ページ全体を100vhに収める（PC専用） */
@media (min-width: 1100px) {
    body.page-list {
        height: 100vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
}

a {
    color: inherit;
}

/* =============================================
   サイトヘッダー
   ============================================= */

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px clamp(16px, 4vw, 40px);
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.site-header h1 {
    margin: 0;
    font-size: clamp(22px, 4vw, 34px);
    line-height: 1.2;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.text-link {
    flex: 0 0 auto;
    color: var(--accent-strong);
    font-weight: 700;
    text-decoration: none;
    font-size: 14px;
}

.text-link:hover {
    text-decoration: underline;
}

/* =============================================
   メインコンテンツ
   ============================================= */

.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px clamp(16px, 4vw, 40px);
}

/* 投稿フォームページは読みやすい幅に制限 */
.main-content.form-page {
    max-width: 720px;
}

/* =============================================
   フォームパネル
   ============================================= */

.form-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 28px 28px 32px;
    margin-bottom: 24px;
}

.form-panel + .form-panel {
    margin-top: 0;
}

.panel-title {
    margin: 0 0 20px;
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-strong);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

/* =============================================
   フォームフィールド
   ============================================= */

.field {
    margin-bottom: 20px;
}

.field:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

label .required {
    color: var(--danger);
    margin-left: 4px;
}

label .optional {
    color: var(--muted);
    font-weight: 400;
    font-size: 12px;
    margin-left: 6px;
}

input[type="text"],
input[type="password"],
select,
textarea {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.15s;
    appearance: none;
    -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2363717d' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.field-hint {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--muted);
}

/* =============================================
   チェックリスト
   ============================================= */

.checklist {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* 各チェック項目のラッパー */
.check-item {
    border-bottom: 1px solid var(--line);
}

.check-item:last-child {
    border-bottom: none;
}

/* チェックボックス＋ラベル行 */
.check-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 4px;
    cursor: pointer;
}

.check-row:hover {
    background: var(--subtle);
    border-radius: 6px;
}

.check-row input[type="checkbox"] {
    margin-top: 3px;
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.check-row label {
    margin: 0;
    font-size: 15px;
    font-weight: 400;
    cursor: pointer;
    line-height: 1.5;
}

/* チェック連動の展開エリア */
.check-detail {
    display: none;
    overflow: hidden;
}

.check-detail.open {
    display: block;
}

.check-detail-inner {
    background: var(--subtle);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    padding: 16px 16px 12px 16px;
    margin: 0 0 10px 28px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.check-detail-inner .field {
    margin-bottom: 0;
}

.check-detail-inner textarea {
    min-height: 64px;
    font-size: 14px;
}

/* 項目内写真エリア（小さめ） */
.item-photo-area {
    border: 2px dashed var(--line);
    border-radius: 8px;
    padding: 14px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: var(--panel);
}

.item-photo-area:hover,
.item-photo-area.dragover {
    border-color: var(--accent);
    background: #fff;
}

.item-photo-area input[type="file"] {
    display: none;
}

.item-photo-area .photo-upload-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.item-photo-area p {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
}

.item-photo-grid {
    margin-top: 10px;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
}

/* カテゴリグループ */
.check-group {
    margin-bottom: 24px;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
}

.check-group:last-child {
    margin-bottom: 0;
}

.check-group-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-strong);
    background: var(--subtle);
    border-bottom: 1px solid var(--line);
    margin: 0;
    padding: 10px 14px;
    letter-spacing: 0.01em;
}

.checklist {
    padding: 0 12px;
}

/* =============================================
   写真アップロード
   ============================================= */

.photo-upload-area {
    border: 2px dashed var(--line);
    border-radius: 10px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: var(--bg);
}

.photo-upload-area:hover,
.photo-upload-area.dragover {
    border-color: var(--accent);
    background: var(--subtle);
}

.photo-upload-area input[type="file"] {
    display: none;
}

.photo-upload-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.photo-upload-area p {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
}

.photo-upload-area p strong {
    color: var(--accent-strong);
}

.photo-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.photo-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--line);
}

.photo-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-count {
    font-size: 13px;
    color: var(--muted);
    margin-top: 8px;
}

/* =============================================
   送信ボタン
   ============================================= */

.submit-area {
    text-align: center;
    margin-top: 28px;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 14px 36px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.btn-primary:hover {
    background: var(--accent-strong);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    background: var(--muted);
    cursor: not-allowed;
    transform: none;
}

/* =============================================
   メッセージ・アラート
   ============================================= */

.alert {
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
}

.alert-success {
    background: var(--subtle);
    border: 1px solid var(--accent);
    color: var(--accent-strong);
}

.alert-error {
    background: #fdf2f1;
    border: 1px solid var(--danger);
    color: var(--danger);
}

.alert-info {
    background: #f0f4ff;
    border: 1px solid #5b7be9;
    color: #2d4fa8;
}

.public-info-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 20px;
    color: var(--text);
    font-size: 14px;
}

.public-info-panel p {
    margin: 0 0 8px;
}

.public-info-panel p:last-child {
    margin-bottom: 0;
}

.public-info-panel a {
    color: var(--accent-strong);
    font-weight: 700;
}

.year-switcher {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    margin: 0 0 16px;
}

.year-switcher:empty {
    display: none;
}

.year-switcher-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.year-switcher-main label,
.year-badge-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.year-switcher-main select {
    width: auto;
    min-width: 140px;
    padding: 7px 34px 7px 10px;
    font-size: 14px;
}

.year-status {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 800;
}

.year-status.is-active {
    background: var(--subtle);
    color: var(--accent-strong);
}

.year-status.is-archived {
    background: #f3f0e8;
    color: #7b5d20;
}

.year-switcher-note {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.prototype-public-list .prototype-hidden {
    display: none !important;
}

/* =============================================
   一覧ページ — フィルターバー
   ============================================= */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
    align-items: center;
}

.filter-bar-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    flex: 0 0 auto;
}

.filter-btn {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text);
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* =============================================
   一覧ページ — カードグリッド（最大4カラム）
   ============================================= */

.record-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

@media (max-width: 1100px) {
    .record-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 760px) {
    .record-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .record-grid { grid-template-columns: 1fr; }
}

/* =============================================
   一覧ページ — 投稿カード
   ============================================= */

.record-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

/* ピンクリック時のハイライトアニメーション */
.record-card.card-highlight {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(24, 111, 101, 0.3);
    animation: card-pulse 2s ease-out;
}

@keyframes card-pulse {
    0%   { box-shadow: 0 0 0 6px rgba(24, 111, 101, 0.4); }
    100% { box-shadow: 0 0 0 0px rgba(24, 111, 101, 0.0); }
}

.record-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.10);
    transform: translateY(-2px);
}

/* 画像エリア：3:2固定・object-fit: contain */
.record-card-photo {
    width: 100%;
    aspect-ratio: 3 / 2;
    background: #e8ecef;
    overflow: hidden;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: zoom-in;
}

.record-card-photo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.record-card-photo .no-photo {
    font-size: 36px;
    color: var(--line);
}

.photo-zoom-badge {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(12, 79, 72, 0.88);
    color: #fff;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.20);
    pointer-events: none;
}

.record-card-body {
    padding: 14px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.record-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    align-items: center;
}

.record-date {
    font-size: 12px;
    color: var(--muted);
}

.badge {
    display: inline-block;
    background: var(--subtle);
    color: var(--accent-strong);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 12px;
    letter-spacing: 0.02em;
}

.record-location {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 8px;
}

.record-comment {
    font-size: 14px;
    color: var(--text);
    white-space: pre-line;
    margin: 0 0 12px;
}

.record-checklist {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.record-checklist li {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 12px;
    padding: 2px 10px;
    color: var(--muted);
}

/* 詳細付きチェックリスト */
.record-checklist-detail {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.record-checklist-detail li {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.record-map-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin-top: 2px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--subtle);
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.record-map-link:hover {
    border-color: var(--accent);
    background: #fff;
}

.check-item-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.check-item-comment {
    font-size: 12px;
    color: var(--text);
    line-height: 1.55;
    white-space: pre-line;
}

/* =============================================
   空状態
   ============================================= */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state p {
    margin: 0;
    font-size: 15px;
}

/* =============================================
   ローディング
   ============================================= */

.loading {
    text-align: center;
    padding: 40px;
    color: var(--muted);
    font-size: 15px;
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =============================================
   ドラムロールピッカー
   ============================================= */

/* 外枠 */
.picker-wrap {
    position: relative;
    display: flex;
    height: 220px;       /* ITEM_HEIGHT × 5行分 */
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--bg);
    user-select: none;
    -webkit-user-select: none;
}

/* 選択中ハイライト帯（中央1行分）— 背景は透明にしてborderのみ表示 */
.picker-highlight {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 44px;          /* ITEM_HEIGHT */
    transform: translateY(-50%);
    background: transparent;   /* 背景は透明 → アイテムの背景色で表現 */
    border-top: 2px solid var(--accent);
    border-bottom: 2px solid var(--accent);
    pointer-events: none;
    z-index: 3;            /* フェードより前面に（border線を確実に表示） */
}

/* 上下フェードアウト */
.picker-wrap::before,
.picker-wrap::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 80px;
    z-index: 2;
    pointer-events: none;
}
.picker-wrap::before {
    top: 0;
    background: linear-gradient(to bottom, var(--bg) 0%, transparent 100%);
}
.picker-wrap::after {
    bottom: 0;
    background: linear-gradient(to top, var(--bg) 0%, transparent 100%);
}

/* 左右列 */
.picker-col {
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* 左列は少し狭く（大分類は短め） */
#picker-left {
    flex: 0 0 42%;
}
#picker-right {
    flex: 1;
}

/* 区切り線 */
.picker-divider {
    width: 1px;
    background: var(--line);
    flex: 0 0 1px;
    align-self: stretch;
    z-index: 2;
}

/* スクローラー本体 */
.picker-scroller {
    height: 100%;
    overflow-y: scroll;
    overflow-x: hidden;
    scroll-behavior: auto;
    scrollbar-width: none;      /* Firefox */
    -ms-overflow-style: none;   /* IE */
    cursor: grab;
}
.picker-scroller::-webkit-scrollbar { display: none; } /* Chrome/Safari */

/* パディング（先頭・末尾に2行分の空白） */
.picker-padding {
    height: 88px;   /* ITEM_HEIGHT × 2 */
    flex-shrink: 0;
}

/* 各項目 */
.picker-item {
    height: 44px;           /* ITEM_HEIGHT */
    display: flex;
    align-items: center;
    padding: 0 14px;
    font-size: 14px;
    color: var(--muted);
    transition: color 0.15s, font-weight 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* 選択中アイテム */
.picker-item.is-selected {
    color: var(--accent-strong);
    font-weight: 700;
    font-size: 15px;
    background: var(--subtle);  /* ハイライト背景をアイテム自身に持たせる */
}

/* 右列の項目は折り返し許可 */
#scroller-right .picker-item {
    white-space: normal;
    font-size: 13px;
    line-height: 1.3;
}
#scroller-right .picker-item.is-selected {
    font-size: 14px;
}

/* 選択中表示バー */
.picker-selected-display {
    margin-top: 14px;
    padding: 10px 14px;
    background: var(--subtle);
    border-radius: 8px;
    border-left: 3px solid var(--accent);
    min-height: 40px;
    display: flex;
    align-items: center;
}

#selected-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-strong);
    line-height: 1.4;
}

/* =============================================
   投稿フォーム — ミニ地図
   ============================================= */

.form-map {
    width: 100%;
    height: 280px;
    border-radius: 10px;
    border: 1px solid var(--line);
    overflow: hidden;
    z-index: 0;
}

.map-coords-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--subtle);
    border-radius: 8px;
    font-size: 12px;
    color: var(--accent-strong);
    font-weight: 600;
}

.map-clear-btn {
    background: none;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}
.map-clear-btn:hover {
    background: #fdf2f1;
    border-color: var(--danger);
    color: var(--danger);
}

/* GPS取得ステータス */
.geo-status {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
}
.geo-status--loading {
    background: #f0f4ff;
    color: #2d4fa8;
    border: 1px solid #5b7be9;
}
.geo-status--success {
    background: var(--subtle);
    color: var(--accent-strong);
    border: 1px solid var(--accent);
}
.geo-status--warn {
    background: #fffbf0;
    color: #7a5a00;
    border: 1px solid #e6c85a;
}

/* =============================================
   一覧ページ — ビュー切り替えタブ（スマホのみ表示）
   ============================================= */

.view-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 4px;
    width: fit-content;
}

.view-tab {
    background: none;
    border: none;
    border-radius: 7px;
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.view-tab:hover {
    background: var(--subtle);
    color: var(--text);
}

.view-tab.active {
    background: var(--panel);
    color: var(--accent-strong);
    box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}

/* =============================================
   一覧ページ — サイドバイサイドラッパー
   ============================================= */

/* スマホ：タブ切り替え（縦積み） */
.list-map-wrapper {
    display: block;
}

.list-pane,
.map-pane {
    width: 100%;
}

/* PC（1100px以上）：左右並列表示 */
@media (min-width: 1100px) {

    /* タブは不要なので非表示 */
    .view-tabs {
        display: none;
    }

    /* 両ペインを常に表示 */
    .list-pane,
    .map-pane {
        display: block !important;
    }

    /* main-content：残り高さをすべて使う・幅制限を解除 */
    body.page-list .main-content {
        flex: 1 1 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        padding-bottom: 0;
        max-width: 100%;
        margin: 0;
    }

    /* list-map-wrapper：main-content の残り高さを埋める */
    body.page-list .list-map-wrapper {
        flex: 1 1 0;
        overflow: hidden;
        display: grid;
        grid-template-columns: minmax(420px, 600px) minmax(0, 1fr);
        gap: 24px;
        align-items: stretch;
        min-height: 0;
    }

    /* 一覧ペイン：内部スクロール */
    body.page-list .list-pane {
        overflow-y: auto;
        padding-right: 8px;
        min-height: 0;
        max-width: 600px;
    }

    /* 地図ペイン：高さ全体を使う */
    body.page-list .map-pane {
        overflow: hidden;
        min-height: 0;
        display: flex;
        flex-direction: column;
        padding-bottom: 24px;
    }

    /* PC時は4カラム → 2カラムに変更（左ペインが狭くなるため） */
    .list-pane .record-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* =============================================
   一覧ページ — 地図ビュー
   ============================================= */

.list-map {
    width: 100%;
    height: 560px;
    border-radius: 12px;
    border: 1px solid var(--line);
    overflow: hidden;
    z-index: 0;
}

.list-map .leaflet-popup-pane,
.list-map .leaflet-popup {
    z-index: 3000 !important;
}

.list-map .leaflet-top,
.list-map .leaflet-bottom,
.list-map .leaflet-control-container,
.list-map .leaflet-control-zoom {
    z-index: 700 !important;
}

/* =============================================
   通学路ルート表示
   ============================================= */

.route-controls-panel {
    margin: 0 0 16px;
}

.route-controls-panel:empty {
    display: none;
}

.route-legend {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
}

.route-legend-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--accent-strong);
    font: inherit;
    cursor: pointer;
    text-align: left;
}

.route-legend-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13px;
    font-weight: 800;
}

.route-legend-meta {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.route-legend-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.route-legend-action i {
    transition: transform 0.18s ease;
}

.route-legend-toggle[aria-expanded="true"] .route-legend-action i {
    transform: rotate(180deg);
}

.route-legend-empty {
    color: var(--muted);
    font-size: 12px;
}

.route-legend-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.route-legend-list[hidden] {
    display: none;
}

.route-legend-item {
    display: grid;
    grid-template-columns: auto 18px 1fr;
    align-items: start;
    gap: 10px;
    margin: 0;
    cursor: pointer;
}

.toggle-switch {
    position: relative;
    display: inline-flex;
    width: 42px;
    height: 24px;
    flex: 0 0 auto;
    align-items: center;
}

.toggle-switch-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.toggle-switch-track {
    position: relative;
    display: block;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: #c8d1d8;
    transition: background 0.18s ease;
}

.toggle-switch-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.24);
    transition: transform 0.18s ease;
}

.toggle-switch-input:checked + .toggle-switch-track {
    background: var(--accent);
}

.toggle-switch-input:checked + .toggle-switch-track::after {
    transform: translateX(18px);
}

.toggle-switch-input:focus-visible + .toggle-switch-track {
    outline: 2px solid rgba(24, 111, 101, 0.35);
    outline-offset: 2px;
}

.route-toggle-switch {
    margin-top: 1px;
}

.route-swatch {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.12);
    flex: 0 0 auto;
}

.route-name {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.35;
}

.route-description {
    display: block;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.45;
    margin-top: 2px;
}

.route-popup p {
    margin: 4px 0 0;
    color: var(--muted);
}

/* PC時は親ペインの高さに追従 */
@media (min-width: 1100px) {
    body.page-list .list-map {
        flex: none;
        height: calc(100% - 50px);
        min-height: 0;
    }
}

@media (max-width: 600px) {
    .list-map {
        height: clamp(480px, calc(100dvh - 140px), 560px);
    }
    .form-map {
        height: 240px;
    }
}

@media (max-width: 760px) {
    body.page-list.mobile-map-active {
        overflow: hidden;
        background: var(--bg);
    }

    body.page-list.mobile-map-active .site-header {
        flex-direction: row;
        padding: 12px 16px;
        align-items: center;
        justify-content: space-between;
        gap: 6px;
    }

    body.page-list.mobile-map-active .site-header > div {
        min-width: 0;
    }

    body.page-list.mobile-map-active .site-header h1 {
        overflow: hidden;
        font-size: 22px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body.page-list.mobile-map-active .eyebrow,
    body.page-list.mobile-map-active .admin-organization {
        margin-bottom: 0;
        font-size: 11px;
    }

    body.page-list.mobile-map-active .text-link,
    body.page-list.mobile-map-active .admin-header-actions a {
        font-size: 13px;
    }

    body.page-list.mobile-map-active .admin-notice,
    body.page-list.mobile-map-active .admin-year-switcher,
    body.page-list.mobile-map-active .admin-header-actions,
    body.page-list.mobile-map-active .field-hint,
    body.page-list.mobile-map-active .site-footer {
        display: none;
    }

    body.page-list.mobile-map-active .main-content {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
    }

    body.page-list.mobile-map-active .list-map-wrapper,
    body.page-list.mobile-map-active .map-pane {
        width: 100%;
    }

    body.page-list.mobile-map-active .map-pane {
        position: relative;
        height: var(--mobile-map-height, calc(100dvh - var(--mobile-map-top, 0px)));
        overflow: hidden;
    }

    body.page-list.mobile-map-active .list-map {
        height: var(--mobile-map-height, clamp(480px, calc(100dvh - 120px), 620px));
        border: 0;
        border-radius: 0;
    }

    body.page-list.mobile-map-active .view-tabs {
        position: fixed;
        top: calc(var(--mobile-map-top, 0px) + 12px);
        right: 12px;
        z-index: 2400;
        margin: 0;
        border-radius: 999px;
        background: rgba(255,255,255,0.94);
        box-shadow: 0 4px 14px rgba(0,0,0,0.16);
        backdrop-filter: blur(10px);
    }

    body.page-list.mobile-map-active .view-tab {
        padding: 7px 12px;
        font-size: 13px;
        white-space: nowrap;
    }

    body.page-list.mobile-map-active #map-pin-count {
        position: fixed;
        top: calc(var(--mobile-map-top, 0px) + 12px);
        left: 62px;
        z-index: 2200;
        max-width: calc(100vw - 210px);
        margin: 0 !important;
        padding: 6px 9px;
        overflow: hidden;
        border: 1px solid rgba(216,224,229,0.9);
        border-radius: 999px;
        background: rgba(255,255,255,0.94);
        box-shadow: 0 4px 14px rgba(0,0,0,0.12);
        color: var(--muted) !important;
        text-overflow: ellipsis;
        white-space: nowrap;
        backdrop-filter: blur(10px);
    }
}

/* マップポップアップ */
.map-popup {
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.map-popup-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.map-popup-badge {
    display: inline-flex;
    flex: 0 1 auto;
    max-width: 58%;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 12px;
    line-height: 1.4;
}

.map-popup-date {
    flex: 0 0 auto;
    color: #63717d;
    font-size: 11px;
    line-height: 1.4;
    padding-top: 2px;
    white-space: nowrap;
}

.map-popup-item {
    font-weight: 700;
    color: #182026;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.map-popup-location {
    color: #186f65;
    font-size: 12px;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.map-popup-meta {
    color: #63717d;
    font-size: 11px;
}

.map-popup-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    color: #0c4f48;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.map-popup-link:hover {
    text-decoration: underline;
}

.map-popup-photo {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 3 / 2;
    margin-top: 8px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #f7f9fa;
    padding: 0;
}

.map-popup-photo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.map-popup-detail-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin-top: 9px;
    padding: 8px 10px;
    border: 0;
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.map-popup-detail-btn:hover {
    background: var(--accent-strong);
}

/* GPS バッジ */
.badge-gps {
    background: #edf4ff;
    color: #2d5fa8;
    font-size: 10px;
}

/* =============================================
   マーカークラスター
   ============================================= */

.cluster-icon {
    background: var(--accent, #186f65);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    font-family: system-ui, -apple-system, sans-serif;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.30);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
}

.cluster-icon:hover {
    transform: scale(1.1);
}

/* 件数が多いほど濃い色に */
.cluster-large .cluster-icon  { background: #c0392b; }   /* 10件以上 */
.cluster-medium .cluster-icon { background: #e67e22; }   /* 5〜9件 */

/* =============================================
   フッター
   ============================================= */

.site-footer {
    text-align: center;
    padding: 24px;
    font-size: 12px;
    color: var(--muted);
    border-top: 1px solid var(--line);
    margin-top: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 16px;
}

.site-footer a {
    color: var(--accent-strong);
    font-weight: 700;
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

@media (min-width: 1100px) {
    body.page-list .site-footer {
        display: none;
    }
}

/* =============================================
   モーダル（写真拡大表示）
   ============================================= */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    display: grid;
    grid-template-columns: minmax(0, auto);
    gap: 16px;
    max-width: min(960px, 100%);
    max-height: 92vh;
    align-items: center;
}

.modal-overlay.has-detail .modal-content {
    width: min(960px, 100%);
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
    align-items: stretch;
}

.modal-img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
    object-fit: contain;
}

.modal-overlay.has-detail .modal-img {
    width: 100%;
    max-height: 92vh;
    background: rgba(255,255,255,0.08);
}

.modal-detail {
    max-height: 92vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff;
    border-radius: 8px;
    padding: 16px;
    color: var(--text);
}

.modal-detail-badge {
    display: inline-flex;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 10px;
    border-radius: 999px;
}

.modal-detail-title {
    margin: 10px 0 8px;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.5;
}

.modal-detail-comment {
    margin: 0 0 12px;
    color: var(--text);
    font-size: 13px;
    line-height: 1.65;
    white-space: pre-wrap;
}

.modal-detail-meta {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 12px;
}

.modal-detail-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
}

.modal-detail-link:hover {
    text-decoration: underline;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    font-size: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =============================================
   レスポンシブ（スマートフォン対応）
   ============================================= */

@media (max-width: 480px) {
    .form-panel {
        padding: 20px 16px 24px;
    }

    .btn-primary {
        width: 100%;
        justify-content: center;
    }

    .record-card-photos img {
        height: 160px;
    }

    .site-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

@media (max-width: 760px) {
    .modal-overlay {
        align-items: stretch;
        padding: 14px;
    }

    .modal-content,
    .modal-overlay.has-detail .modal-content {
        grid-template-columns: 1fr;
        align-content: center;
        width: 100%;
        max-height: 94vh;
        overflow-y: auto;
    }

    .modal-img,
    .modal-overlay.has-detail .modal-img {
        max-height: 48vh;
    }

    .modal-detail {
        max-height: none;
    }
}
