:root {
    --color-primary: #1a5276;
    --color-primary-dark: #123c58;
    --color-primary-light: #eaf2f8;
    --color-primary-lighter: #d4e6f1;
    --color-bg: #f2f5f8;
    --color-surface: #ffffff;
    --color-border: #dde4ea;
    --color-text: #1c2733;
    /* WCAG AA(4.5:1)を満たすよう#71808fから調整(白背景で4.05:1、カード外の背景で3.70:1しか
       なくAA未達だったため)。#606d7aは白背景で5.3:1、背景色で4.84:1。 */
    --color-text-muted: #606d7a;
    --color-danger: #c0392b;
    --color-danger-bg: #fdecea;
    --color-danger-dark: #a3291b;
    --color-warning: #b9770e;
    --color-success: #1a7a3c;
    --color-success-bg: #eaf7ee;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-card: 0 0 0 1px rgba(16, 42, 67, 0.04), 0 6px 20px rgba(16, 42, 67, 0.05);
    --shadow-card-hover: 0 0 0 1px rgba(16, 42, 67, 0.05), 0 10px 28px rgba(16, 42, 67, 0.09);
}

/* ダークモード。以前一度削除された経緯があり、原因は現象コードのチップ・セルが
   背景色を直接指定する一方、文字色をこのCSS変数任せにしていたため、暗い背景色
   （#1a5276や#2c3e50など）の上で文字が読めなくなっていたこと。今回は
   _phenom_label_color()（webapp.py）が背景の輝度から文字色(濃紺/白)を計算して
   返すようにし、テンプレート側は必ずその文字色を明示するよう修正済み。
   また警告/成功/危険を示す各所のハードコードされた文字色も
   var(--color-danger)/var(--color-warning)/var(--color-success)に置き換え、
   カード背景等のハードコードされたごく薄い色もvar(--color-bg)等に統一した。
   グラフ画像(matplotlib生成のPNG)は背景が常に白のままなので、ダークモードでは
   白いカードで囲って浮いて見えないようにしている（画像自体の配色は変更しない）。 */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-primary: #5b9bd0;
        --color-primary-dark: #7fb3dc;
        --color-primary-light: #1c3a4d;
        --color-primary-lighter: #234a63;
        --color-bg: #12191f;
        --color-surface: #1b242c;
        --color-border: #2c3944;
        --color-text: #e6edf3;
        --color-text-muted: #94a4b3;
        --color-danger: #e5776a;
        --color-danger-bg: #3a2323;
        --color-danger-dark: #f0968b;
        --color-warning: #e0a751;
        --color-success: #4caf6f;
        --color-success-bg: #1f3327;
        --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.25);
        --shadow-card-hover: 0 2px 4px rgba(0, 0, 0, 0.35), 0 8px 20px rgba(0, 0, 0, 0.3);
    }
}
:root[data-theme="dark"] {
    --color-primary: #5b9bd0;
    --color-primary-dark: #7fb3dc;
    --color-primary-light: #1c3a4d;
    --color-primary-lighter: #234a63;
    --color-bg: #12191f;
    --color-surface: #1b242c;
    --color-border: #2c3944;
    --color-text: #e6edf3;
    --color-text-muted: #94a4b3;
    --color-danger: #e5776a;
    --color-danger-bg: #3a2323;
    --color-danger-dark: #f0968b;
    --color-warning: #e0a751;
    --color-success: #4caf6f;
    --color-success-bg: #1f3327;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-card-hover: 0 2px 4px rgba(0, 0, 0, 0.35), 0 8px 20px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) img.full-graph,
    :root:not([data-theme="light"]) .chart-wrap img {
        background: #fff;
        border-radius: var(--radius-sm);
        padding: 0.4rem;
    }
}
:root[data-theme="dark"] img.full-graph,
:root[data-theme="dark"] .chart-wrap img {
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 0.4rem;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans CJK JP", sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    transition: background 0.15s ease, color 0.15s ease;
}

.theme-toggle {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.7rem;
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease;
}
.theme-toggle:hover { background: rgba(255, 255, 255, 0.24); }

/* 通知ベル(base.html)。既読管理はサーバー側に持たず、ブラウザのlocalStorageで行う。 */
.notif-bell-wrap { position: relative; }
.notif-bell {
    position: relative;
    background: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.55rem;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    transition: background 0.15s ease;
}
.notif-bell:hover { background: rgba(255, 255, 255, 0.24); }
.notif-badge {
    position: absolute;
    top: 0.3rem;
    right: 0.3rem;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--color-danger);
    box-shadow: 0 0 0 2px var(--color-primary-dark);
    animation: badgePop 0.3s ease;
}
@keyframes badgePop {
    0% { transform: scale(0); }
    70% { transform: scale(1.25); }
    100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
    .notif-badge { animation: none; }
}
.nav-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.1rem;
    height: 1.1rem;
    padding: 0 0.3rem;
    margin-left: 0.35rem;
    border-radius: 999px;
    background: var(--color-danger);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    vertical-align: middle;
}

/* メンバー間メッセージ(LINE風の吹き出しチャット)。 */
.dm-thread-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.dm-thread-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.7rem;
    border-radius: var(--radius-md);
    background: var(--color-bg);
    text-decoration: none;
    color: var(--color-text);
}
.dm-thread-item:hover { box-shadow: var(--shadow-card-hover); }
.dm-thread-info { flex: 1 1 auto; min-width: 0; }
.dm-thread-name { font-weight: 600; }
.dm-thread-snippet { font-size: 0.8rem; color: var(--color-text-muted); }
.dm-bubbles {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 60vh;
    overflow-y: auto;
    padding: 0.5rem;
}
.dm-bubble-row { display: flex; }
.dm-bubble-row.mine { justify-content: flex-end; }
.dm-bubble {
    max-width: 70%;
    padding: 0.55rem 0.8rem;
    border-radius: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    word-break: break-word;
}
/* white-space:pre-wrapは本文だけに絞る(.dm-bubble本体に付けると、テンプレートの
   インデント用の改行までそのまま高さとして表示され、吹き出しが不自然に縦長になっていた)。 */
.dm-bubble-text { display: block; white-space: pre-wrap; }
.dm-bubble-row.mine .dm-bubble {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.dm-bubble-time {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.68rem;
    opacity: 0.7;
}
.dm-attachment { margin-top: 0.3rem; }
.dm-attachment a { color: inherit; text-decoration: underline; word-break: break-all; display: inline-flex; align-items: center; gap: 0.25rem; }

/* 共有ファイルページの右クリックメニュー(フォルダの作成・削除)。 */
.context-menu {
    position: absolute;
    z-index: 200;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-card-hover);
    padding: 0.3rem;
    min-width: 160px;
}
.context-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.7rem;
    border: none;
    background: none;
    font-size: 0.85rem;
    color: var(--color-text);
    cursor: pointer;
    border-radius: var(--radius-sm);
}
.context-menu button:hover { background: var(--color-bg); }
.folder-row td:first-child a { font-weight: 600; }
.dm-compose { display: flex; gap: 0.5rem; margin-top: 0.8rem; }
.dm-compose textarea {
    flex: 1 1 auto;
    resize: vertical;
    min-height: 2.4rem;
    padding: 0.5rem 0.7rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    font-family: inherit;
    font-size: 0.9rem;
}
.notif-panel {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: 320px;
    max-width: calc(100vw - 2rem);
    max-height: 420px;
    overflow-y: auto;
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card-hover);
    z-index: 20;
}
.notif-panel-header {
    padding: 0.7rem 1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    background: var(--color-surface);
}
.notif-item {
    display: block;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.86rem;
    line-height: 1.5;
    border-left: 3px solid transparent;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--color-primary-light); }
.notif-item.notif-level-danger { border-left-color: var(--color-danger); }
.notif-item.notif-level-warning { border-left-color: #b9770e; }
.notif-item.notif-level-info { border-left-color: var(--color-primary); }
.notif-empty { padding: 1rem; margin: 0; }
.notif-footnote {
    margin: 0;
    padding: 0.5rem 1rem;
    font-size: 0.74rem;
    border-top: 1px solid var(--color-border);
    position: sticky;
    bottom: 0;
    background: var(--color-surface);
}

/* AIチャットページ(/chat)。他のナビ項目(地点別・メンバー等)と同じく専用ページとして
   表示する(通知ベルのようなオーバーレイパネルにはしない)。 */
.chat-card {
    display: flex;
    flex-direction: column;
    height: 70vh;
    min-height: 420px;
    padding: 0;
    overflow: hidden;
}
.chat-card-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.9rem 1.2rem;
    border-bottom: 1px solid var(--color-border);
}
.chat-card-header h2 { margin: 0; font-size: 1.1rem; }
.chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0.9rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
}
.chat-message {
    padding: 0.5rem 0.7rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    white-space: pre-wrap;
    max-width: 90%;
}
.chat-message-user {
    align-self: flex-end;
    background: var(--color-primary);
    color: #fff;
}
.chat-message-ai {
    align-self: flex-start;
    background: var(--color-primary-light);
    color: var(--color-text);
}
.chat-message-error {
    align-self: flex-start;
    background: var(--color-danger);
    color: #fff;
}
.chat-message-thinking {
    align-self: flex-start;
    background: var(--color-primary-light);
    color: var(--color-text-muted);
    font-style: italic;
    animation: chatThinkingPulse 1.4s ease-in-out infinite;
}
@keyframes chatThinkingPulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .chat-message-thinking { animation: none; }
}
.chat-form {
    display: flex;
    gap: 0.4rem;
    padding: 0.7rem 1.2rem;
    border-top: 1px solid var(--color-border);
}
.chat-footnote {
    margin: 0;
    padding: 0.5rem 1.2rem;
    font-size: 0.74rem;
    border-top: 1px solid var(--color-border);
}
.chat-form textarea {
    flex: 1 1 auto;
    resize: none;
    padding: 0.4rem 0.5rem;
    font-family: inherit;
    font-size: 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text);
}
.chat-form button {
    align-self: flex-end;
    margin: 0;
}

/* フラッシュメッセージ。flash()のカテゴリ(success/error/未指定)で見た目を分ける
   (以前はどのカテゴリも同じ青系の見た目で、成功と失敗の区別がつかなかった)。 */
.flash-message, .flash-success, .flash-error {
    border-left: 4px solid var(--color-primary);
    background: var(--color-primary-light);
}
.flash-success { border-left-color: var(--color-success); background: var(--color-success-bg); }
.flash-error { border-left-color: var(--color-danger); background: var(--color-danger-bg); }

a { color: var(--color-primary); }

:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

header {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #fff;
    padding: 0.7rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    letter-spacing: 0.01em;
}
header nav {
    display: flex;
    /* flex-basisを0にする: flex-wrap:wrapの折り返し判定はshrink後ではなく本来サイズ
       (flex-basis)で行われるため、auto(=リンク全部を並べた本来の幅)のままだと
       navの中身が多いだけでheader自体が2段に折り返されてしまう。0にすることで
       navは常に1行に収まる扱いになり、はみ出た分はoverflow-xで横スクロールする。 */
    flex: 1 1 0;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 0.2rem;
    overflow-x: auto;
    /* トラックパッドの横スワイプが無い環境(マウス+キーボードのみ)でも、はみ出た項目に
       アクセスできるよう、スクロールバーは隠さず細く表示する(base.htmlのJSでマウス
       ホイールでの横スクロールにも対応)。 */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
}
header nav::-webkit-scrollbar { height: 6px; }
header nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.35); border-radius: 3px; }
header nav::-webkit-scrollbar-track { background: transparent; }
header nav a {
    color: rgba(255, 255, 255, 0.82);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem 0.7rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}
header nav a:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
header nav a.active { background: rgba(255, 255, 255, 0.22); color: #fff; font-weight: 600; }
header nav a .icon { vertical-align: -3px; margin-right: 0.3rem; }

.nav-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.14);
    border: none;
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 0.4rem;
    cursor: pointer;
    margin-left: auto;
}
@media (max-width: 900px) {
    .nav-toggle { display: inline-flex; order: 1; }
    header h1 { flex: 1 1 auto; }
    header nav {
        display: none;
        flex-direction: column;
        width: 100%;
        order: 3;
        overflow-x: visible;
    }
    header nav.open { display: flex; }
    header .theme-toggle, header .header-user, header .notif-bell-wrap { order: 4; }
}

main {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.6rem 1.5rem 3rem;
}

@media (max-width: 640px) {
    header { padding: 0.6rem 1rem; gap: 0.6rem; }
    header nav { gap: 0; }
    header nav a { padding: 0.45rem 0.55rem; font-size: 0.85rem; }
    main { padding: 1.1rem 1rem 2.5rem; }
}

.layout {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
}
.sidebar {
    flex: 0 0 240px;
    position: sticky;
    top: var(--header-h, 4.6rem);
}
.sidebar:empty { display: none; }
.layout-content { flex: 1 1 0%; min-width: 0; }

/* ページ読み込み時に本文がふわっと浮かび上がる、控えめな演出。 */
.layout-content { animation: contentFadeUp 0.35s ease; }
@keyframes contentFadeUp {
    0% { opacity: 0; transform: translateY(6px); }
    100% { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    .layout-content { animation: none; }
}

@media (max-width: 860px) {
    .layout { flex-direction: column; }
    .sidebar { position: static; flex-basis: auto; width: 100%; }
}

.sidebar-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 0.7rem;
    box-shadow: var(--shadow-card);
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
}
.sidebar-search {
    width: 100%;
    padding: 0.5rem 0.8rem;
    font-size: 0.86rem;
    font-family: inherit;
    border: none;
    border-radius: 999px;
    background: var(--color-bg);
    color: var(--color-text);
    margin-bottom: 0.5rem;
    box-sizing: border-box;
}
.sidebar-search:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--color-primary-lighter);
}
.sidebar-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    max-height: 600px;
    overflow: hidden;
    opacity: 1;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}
/* チャットの会話一覧は折りたたみグループが無く、会話数だけ際限なく増えるため、
   600pxで打ち切られると古い会話にアクセスできなくなってしまう。上限を外し、
   親の.sidebar-panel自体のスクロールに任せる。 */
.chat-sidebar-list { max-height: none; overflow: visible; }
.chat-sidebar-list li { display: flex; align-items: center; gap: 0.1rem; }
.chat-sidebar-list li a { flex: 1 1 auto; min-width: 0; }
.chat-delete-btn {
    flex: 0 0 auto;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.chat-delete-btn:hover { background: var(--color-danger); color: #fff; }
.sidebar-list a {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.12s ease;
}
.sidebar-list a:hover { background: var(--color-bg); }
.sidebar-list a.active { background: var(--color-primary); color: #fff; font-weight: 600; }
.sidebar-dot {
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.3);
}
.sidebar-label { overflow: hidden; text-overflow: ellipsis; }
.sidebar-empty { padding: 0.5rem 0.6rem; }

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.3rem 1.5rem;
    margin-bottom: 1.4rem;
    box-shadow: var(--shadow-card);
}
.card h2 {
    margin-top: 0;
    margin-bottom: 0.9rem;
    font-size: 1.05rem;
    font-weight: 600;
    border-left: 4px solid var(--color-primary);
    padding-left: 0.65rem;
}
.card h3 { font-size: 0.95rem; font-weight: 600; }

.muted { color: var(--color-text-muted); font-size: 0.9rem; }

a.button, button.button {
    display: inline-block;
    background: var(--color-primary);
    color: #fff;
    text-decoration: none;
    padding: 0.55rem 1.05rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    margin: 0.2rem 0.4rem 0.2rem 0;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    box-shadow: 0 1px 2px rgba(16, 42, 67, 0.15);
}
a.button:hover, button.button:hover { background: var(--color-primary-dark); box-shadow: 0 2px 6px rgba(16, 42, 67, 0.22); }
a.button:active, button.button:active { transform: scale(0.97); }

/* 削除・拒否・再起動など取り消しにくい/影響の大きい操作用の共通ボタン色。
   以前はページごとにstyle="background:#c0392b;"等を直書きしていて、ダークモード用の
   var(--color-danger)と食い違う箇所があった。 */
a.button.button-danger, button.button.button-danger {
    background: var(--color-danger);
}
a.button.button-danger:hover, button.button.button-danger:hover {
    background: var(--color-danger-dark);
}
button.button:disabled {
    opacity: 0.6;
    cursor: default;
    transform: none;
}

/* ログ・crontab等の等幅テキスト表示。以前はadmin_log/admin_status/admin_models.htmlに
   それぞれ同じインラインstyleが個別に書かれていた。 */
.log-viewer {
    background: #1c2733;
    color: #e8edf1;
    padding: 1rem;
    border-radius: 6px;
    font-size: 0.78rem;
    line-height: 1.4;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    white-space: pre-wrap;
    word-break: break-word;
}
.log-viewer.scrollable { max-height: 70vh; overflow-y: auto; }

/* admin_terminal.htmlのターミナル埋め込み。以前は高さ固定600pxで、スマホ縦画面だと
   画面の大半を占めて他の要素が見切れる/操作しづらかったため、ビューポート高さに応じて
   可変にする(狭い画面ほど低く、広い画面では600pxを上限にする)。 */
.terminal-frame {
    height: min(600px, 70vh);
    min-height: 320px;
}
@media (max-width: 640px) {
    .terminal-frame { height: 60vh; min-height: 280px; }
}

/* admin_cockpit.htmlのCockpit埋め込み。項目一覧・グラフ等が多く縦に長いため、
   ターミナルより高さに余裕を持たせる。 */
.cockpit-frame {
    height: min(900px, 82vh);
    min-height: 420px;
}
@media (max-width: 640px) {
    .cockpit-frame { height: 70vh; min-height: 320px; }
}

.badge {
    display: inline-block;
    background: var(--color-danger);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    padding: 0.2rem 0.4rem;
    border-radius: 999px;
    margin-left: 0.35rem;
    vertical-align: middle;
}

.breadcrumb {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
    padding: 0;
    margin: 0 0 1rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}
.breadcrumb li:not(:last-child)::after { content: "›"; margin-left: 0.3rem; color: var(--color-text-muted); }
.breadcrumb a { color: var(--color-primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb li:last-child { color: var(--color-text); font-weight: 500; }

/* トップナビの項目を統合したページ内での切り替えタブ(地点/観測アーカイブ/分析/
   コミュニティ等、1つのナビ項目に複数ページをまとめた場所で使う)。 */
.page-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    margin-bottom: 1.2rem;
    border-bottom: 1px solid var(--color-border);
}
.page-tabs a {
    padding: 0.55rem 0.9rem;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
}
.page-tabs a:hover { color: var(--color-text); }
.page-tabs a.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

.toast-container {
    position: fixed;
    bottom: 1.2rem;
    right: 1.2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast {
    background: #1c2733;
    color: #fff;
    padding: 0.7rem 1.1rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    font-size: 0.88rem;
    max-width: 320px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.toast-error { background: var(--color-danger); }
.toast-message { flex: 1 1 auto; }
.toast-close {
    flex: 0 0 auto;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
}
.toast-close:hover { opacity: 1; }

/* 確認ダイアログ(confirm()の代替)。base.htmlのconfirmModal()が生成する。 */
.modal-overlay[hidden] { display: none; }
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 32, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: 1rem;
}
.modal-dialog {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card-hover);
    padding: 1.4rem 1.5rem;
    max-width: 420px;
    width: 100%;
}
.modal-dialog p { margin: 0 0 1.2rem; white-space: pre-wrap; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }
.button.cancel { background: var(--color-text-muted); }

/* トップに戻るボタン(base.html)。 */
.back-to-top {
    position: fixed;
    bottom: 1.2rem;
    left: 1.2rem;
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 0.5rem 0.9rem;
    font-size: 0.8rem;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 900;
}
.back-to-top.show { opacity: 1; pointer-events: auto; }
.back-to-top:hover { background: var(--color-bg); }

/* コピー用ボタン(値の右に添える小さいアイコンボタン)。 */
.copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    margin-left: 0.3rem;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    vertical-align: middle;
}
.copy-btn:hover { background: var(--color-bg); color: var(--color-text); }
.copy-btn svg { width: 0.85rem; height: 0.85rem; }

/* station_detail.htmlでコメントをAjax投稿した直後、新しい要素だけふわっと表示する。 */
.comment-item-new { animation: contentFadeUp 0.35s ease; }
@media (prefers-reduced-motion: reduce) {
    .comment-item-new { animation: none; }
}

/* 空状態の統一表現(アイコン+説明文)。 */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.6rem 1rem;
    color: var(--color-text-muted);
    text-align: center;
}
.empty-state svg { width: 2rem; height: 2rem; opacity: 0.5; }

.spinner {
    display: inline-block;
    width: 1.6rem;
    height: 1.6rem;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.chart-wrap { position: relative; min-height: 2.4rem; }
.chart-wrap .spinner { position: absolute; top: 0.6rem; left: 0.6rem; display: none; }
.chart-wrap.is-loading .spinner { display: inline-block; }
.chart-wrap img { display: block; }
.chart-wrap img.loading { visibility: hidden; height: 0; }

.strength-meter {
    height: 6px;
    border-radius: 3px;
    background: var(--color-border);
    overflow: hidden;
    margin-top: 0.4rem;
    max-width: 100%;
}
.strength-meter-bar { height: 100%; width: 0; transition: width 0.15s ease, background 0.15s ease; }
.strength-label { font-size: 0.76rem; color: var(--color-text-muted); margin-top: 0.2rem; }

.search-box {
    width: 100%;
    max-width: 320px;
    padding: 0.6rem 0.9rem;
    font-size: 0.95rem;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    background: var(--color-surface);
    color: var(--color-text);
}
.search-box:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26, 82, 118, 0.15);
}
.list-count { margin-bottom: 0.6rem; }

ul.tile-list, ul.date-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.6rem;
}
ul.date-list { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.5rem; }
ul.tile-list li a, ul.date-list li a {
    display: block;
    padding: 0.8rem 0.9rem;
    background: var(--color-primary-light);
    border: 1px solid var(--color-primary-lighter);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--color-primary-dark);
    font-size: 0.95rem;
    font-weight: 500;
    text-align: center;
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
ul.date-list li a { padding: 0.55rem 0.7rem; font-size: 0.9rem; }
ul.tile-list li a:hover, ul.date-list li a:hover {
    background: var(--color-primary-lighter);
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-1px);
}
ul.tile-list li a:active, ul.date-list li a:active { transform: translateY(0); }
ul.tile-list.compact { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
ul.date-list.compact { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 0.4rem; }

details.date-month-group {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.6rem;
    overflow: hidden;
}
details.date-month-group summary {
    cursor: pointer;
    list-style: none;
    padding: 0.6rem 0.9rem;
    font-weight: 600;
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}
details.date-month-group summary::-webkit-details-marker { display: none; }
details.date-month-group summary::before {
    content: "▶";
    font-size: 0.7em;
    transition: transform 0.15s ease;
}
details.date-month-group[open] summary::before { transform: rotate(90deg); }
details.date-month-group summary .muted { font-weight: 400; }
details.date-month-group .date-list { padding: 0.8rem 0.9rem; margin: 0; }
ul.tile-list.compact li a { padding: 0.5rem 0.6rem; font-size: 0.9rem; }

.station-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 0.5rem;
}
.station-chip {
    padding: 0.5rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    text-align: center;
    line-height: 1.35;
    word-break: break-all;
    /* 文字色は現象コードごとにサーバー側で背景輝度から計算して渡す（暗い現象色の上では白文字になる）。
       境界線は明暗どちらの背景でも見えるよう、黒/白ではなく中間グレーで固定する。 */
    box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.4);
}
/* stations_list.html(比較地点選択)・member_detail.html(お気に入り地点選択)で共通の
   チェックボックス付き地点チップ。以前は両ファイルに同じインラインstyleが重複していた。 */
.station-chip-checkbox {
    background: var(--color-primary-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}
.station-chip-checkbox input[type="checkbox"] { margin: 0; }

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.9rem;
}
.image-grid figure {
    margin: 0;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--color-border);
    transition: box-shadow 0.15s ease;
}
.image-grid figure:hover { box-shadow: var(--shadow-card-hover); }
.image-grid img { width: 100%; display: block; aspect-ratio: 4 / 3; object-fit: cover; background: var(--color-border); }
.image-grid figcaption {
    font-size: 0.78rem;
    padding: 0.35rem 0.4rem;
    color: var(--color-text-muted);
    text-align: center;
    border-top: 1px solid var(--color-border);
}
.image-grid figure.unavailable img { opacity: 0.35; }

img.full-graph {
    max-width: 100%;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

/* station_detail.htmlのタイムラプス画像。カメラごとに元画像の解像度がまちまちで、
   幅・高さの上限だけ(max-width/max-height)しか指定していないと、解像度が低い
   カメラ(伊南川合流地点・三島大橋等)の画像だけ他より小さく表示されてしまっていた。
   幅いっぱい・固定の高さで表示し、object-fit:containで比率を保ったまま
   レターボックス表示することで、どのカメラでも同じ大きさで見えるようにする。 */
.timelapse-img {
    display: block;
    margin: 0 auto;
    width: 100%;
    max-width: 720px;
    height: 480px;
    object-fit: contain;
    background: var(--color-bg);
}
@media (max-width: 640px) {
    .timelapse-img { height: 320px; }
}

table.obs-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.82rem;
}
table.obs-table th, table.obs-table td {
    border: 1px solid var(--color-border);
    padding: 0.4rem 0.5rem;
    text-align: center;
    white-space: nowrap;
}
table.obs-table th {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    font-weight: 600;
    /* 以前はposition:stickyで見出し行をスクロール中も表示していたが、ヘッダー高さの
       測定値とずれると見出しがテーブル途中に浮いて表示される不具合が繰り返し発生したため、
       信頼性を優先し通常のテーブル見出し(スクロールで流れる)に戻した。 */
}
table.obs-table tbody tr:nth-child(even) { background: var(--color-bg); }
table.obs-table tbody tr:hover { background: var(--color-primary-light); }
.table-scroll { overflow-x: auto; }

/* 地点数だけ横に伸びる表(observations_date.html等)で、左端の時刻列を横スクロールしても
   見失わないよう固定する。右にスクロールした状態でも常に時刻が見えるようにするため。 */
table.obs-table .sticky-col {
    position: sticky;
    left: 0;
    background: var(--color-surface);
    z-index: 1;
}
table.obs-table th.sticky-col { z-index: 3; }

/* 狭い画面ではtable.obs-tableを表ではなくカード(1行=1カード、th見出しをdata-labelとして
   各セルの左側に出す)に切り替える。data-labelはbase.htmlのJSがth文字列から自動で
   セットするため、個々のテンプレート側での対応は不要。 */
@media (max-width: 640px) {
    table.obs-table { border: none; }
    table.obs-table thead { display: none; }
    table.obs-table, table.obs-table tbody,
    table.obs-table tr, table.obs-table td {
        display: block;
        width: 100% !important; /* 一部テーブルのstyle="width:auto"インライン指定に勝つため */
    }
    table.obs-table tr {
        margin-bottom: 0.7rem;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-sm);
        overflow: hidden;
    }
    table.obs-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.6rem;
        border: none;
        border-bottom: 1px solid var(--color-border);
        text-align: right;
        white-space: normal;
    }
    table.obs-table td:last-child { border-bottom: none; }
    table.obs-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--color-text-muted);
        text-align: left;
        margin-right: 0.6rem;
        flex: 0 0 auto;
    }
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.8rem;
}

.content-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.4rem;
    align-items: start;
}
.content-grid-2 > .card { margin-bottom: 0; }
@media (max-width: 1000px) {
    .content-grid-2 { grid-template-columns: 1fr; }
}

/* 地点マップ(map.html)の霧アラート地点マーカー点滅。 */
.map-marker-alert {
    animation: mapMarkerPulse 1.2s ease-in-out infinite;
}
@keyframes mapMarkerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}
.stat-card {
    background: var(--color-primary-light);
    border-radius: var(--radius-sm);
    padding: 0.8rem 0.9rem;
}
.stat-card .stat-label { font-size: 0.78rem; color: var(--color-text-muted); margin-bottom: 0.2rem; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; color: var(--color-primary-dark); line-height: 1.2; }
.stat-card .stat-unit { font-size: 0.85rem; font-weight: 400; color: var(--color-text-muted); margin-left: 0.15rem; }
.stat-card .stat-sub { font-size: 0.76rem; color: var(--color-text-muted); margin-top: 0.15rem; }

/* admin_status.htmlのサーバーリソースを数秒おきに自動更新している表示。 */
.live-indicator { color: var(--color-text-muted); display: inline-flex; align-items: center; gap: 0.3rem; }
.live-dot {
    width: 0.5rem; height: 0.5rem; border-radius: 50%;
    background: var(--color-success); display: inline-block;
    animation: liveDotPulse 1.6s ease-in-out infinite;
}
@keyframes liveDotPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.stat-bar {
    margin-top: 0.4rem; height: 0.35rem; border-radius: 999px;
    background: var(--color-primary-lighter, rgba(0,0,0,0.08)); overflow: hidden;
}
.stat-bar-fill {
    height: 100%; background: var(--color-primary); border-radius: 999px;
    transition: width 0.4s ease;
}

/* 旧クラス名（互換用）。stat-gridと同じ見た目にする。 */
.stat-row { display: flex; flex-wrap: wrap; gap: 1.6rem; }
.stat-row div { font-size: 0.92rem; }
.stat-row strong { font-size: 1.3rem; color: var(--color-primary); }

/* メンバー一覧・メンバー詳細（アバター・ロールタグ・ログイン頻度ヒートマップ） */
.avatar-circle, .avatar-circle-fallback {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}
.avatar-circle-fallback {
    background: var(--color-primary-lighter);
    color: var(--color-primary-dark);
    font-weight: 700;
    font-size: 1.3rem;
}
.avatar-lg { width: 88px; height: 88px; font-size: 2rem; margin: 0; }

/* 実績ポイントで交換できるアバターフレーム。段階(bronze/silver/gold/platinum)クラスで
   リング太さ・発光・アニメーションを、テーマ(kiri/hare/yuuyake/yuki/hoshizora)クラスで
   配色を指定し、両方を掛け合わせて4x5=20通りの見た目を出す(webapp.pyのFRAME_DEFINITIONS参照)。
   段階・テーマのクラスはCSS変数を設定するだけにして、実際の描画は用途ごとの
   ルール(.avatar-frame=アバター周りの丸いリング、.profile-card-frame=プロフィール
   カード全体の縁取り)に分けている。同じ2クラスを両方の要素に付ければ、アバターの
   輪と背景のプロフィールカードが同じグレード・テーマで連動して装飾される。 */
.frame-bronze { --frame-ring: 3px; --frame-glow: none; }
.frame-silver { --frame-ring: 3px; --frame-glow: 0 0 8px rgba(192, 192, 200, 0.65); }
.frame-gold {
    --frame-ring: 4px;
    --frame-glow: 0 0 12px rgba(255, 196, 64, 0.75);
    --frame-anim: avatar-frame-shimmer 3s ease-in-out infinite;
}
.frame-platinum {
    --frame-ring: 4px;
    --frame-glow: 0 0 16px rgba(170, 120, 255, 0.8);
    --frame-anim: avatar-frame-shimmer 2.2s ease-in-out infinite;
}
.theme-kiri { --frame-c1: #c7cdd6; --frame-c2: #8b95a5; --frame-c3: #e9edf2; }
.theme-hare { --frame-c1: #4fa8e8; --frame-c2: #1c6fb8; --frame-c3: #bfe3ff; }
.theme-yuuyake { --frame-c1: #ff9a56; --frame-c2: #e0526a; --frame-c3: #ffd39a; }
.theme-yuki { --frame-c1: #eaf6ff; --frame-c2: #a9d6f5; --frame-c3: #ffffff; }
.theme-hoshizora { --frame-c1: #2e2a6e; --frame-c2: #7b4fd6; --frame-c3: #f4d35e; }
@keyframes avatar-frame-shimmer {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.35); }
}

.avatar-frame {
    display: inline-flex;
    border-radius: 50%;
    padding: var(--frame-ring, 3px);
    background: linear-gradient(135deg, var(--frame-c1, #ccc), var(--frame-c2, #999), var(--frame-c3, #eee));
    box-shadow: var(--frame-glow, none);
    flex: 0 0 auto;
    animation: var(--frame-anim, none);
}

/* プロフィールカード自体の縁取り。アバターの輪(丸)と違い、カードは角丸の四角なので
   上部に太いグラデーションの縁取り帯を敷き、段階が高いほど発光を足す(控えめに、
   本文の読みやすさを損なわない程度にとどめる)。 */
.profile-card-frame {
    border-top: 5px solid transparent;
    border-image: linear-gradient(90deg, var(--frame-c1, #ccc), var(--frame-c2, #999), var(--frame-c3, #eee)) 1;
    background: linear-gradient(180deg, var(--frame-c1, transparent) 0%, transparent 12%);
    background-blend-mode: overlay;
}
.profile-card-frame.frame-silver, .profile-card-frame.frame-gold, .profile-card-frame.frame-platinum {
    box-shadow: var(--frame-glow, none);
}
.profile-card-frame.frame-gold, .profile-card-frame.frame-platinum {
    animation: var(--frame-anim, none);
}

.member-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.8rem;
}
.member-tile {
    display: block;
    text-align: center;
    text-decoration: none;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.1rem 0.8rem;
    transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.member-tile:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-1px); }

.role-tag {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    margin-top: 0.3rem;
}
.role-tag.admin { background: var(--color-danger-bg); color: var(--color-danger); }
.role-tag.general { background: var(--color-primary-lighter); color: var(--color-primary-dark); }

/* メンバーページのログイン回数ランキング。以前は装飾の無い番号付きリストだったため、
   順位バッジ・アバター・件数に応じた比較バーを加えて一目で分かるようにした。 */
.ranking-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.ranking-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.6rem 0.7rem;
    border-radius: var(--radius-md);
    background: var(--color-bg);
}
.ranking-badge {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    background: var(--color-primary-lighter);
    color: var(--color-primary-dark);
}
.ranking-item.rank-1 .ranking-badge { background: #d4af37; color: #fff; }
.ranking-item.rank-2 .ranking-badge { background: #a8a8b0; color: #fff; }
.ranking-item.rank-3 .ranking-badge { background: #b08d57; color: #fff; }
.ranking-item.rank-1 { background: linear-gradient(90deg, rgba(212, 175, 55, 0.13), transparent); }
.ranking-avatar, .ranking-avatar-fallback {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
}
.ranking-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-lighter);
    color: var(--color-primary-dark);
    font-weight: 700;
    font-size: 0.9rem;
}
.ranking-info { flex: 1 1 auto; min-width: 0; }
.ranking-name {
    display: block;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ranking-name:hover { text-decoration: underline; }
.ranking-bar-track {
    margin-top: 0.3rem;
    height: 5px;
    border-radius: 999px;
    background: var(--color-border);
    overflow: hidden;
}
.ranking-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--color-primary);
}
.ranking-item.rank-1 .ranking-bar-fill { background: #d4af37; }
.ranking-stats {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
    font-size: 0.8rem;
}
.ranking-count { font-weight: 700; color: var(--color-text); white-space: nowrap; }
.ranking-streak {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: var(--color-warning);
    color: #fff;
    white-space: nowrap;
}
.ranking-toggle-btn {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.72rem;
    font-family: inherit;
}
.ranking-toggle-btn.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.ranking-toggle-btn + .ranking-toggle-btn { margin-left: 0.3rem; }

/* メンバー詳細ページの実績バッジ。未達成もロック表示することで、あと何を
   すれば獲得できるかが分かるようにしている(達成済みだけに絞り込まない)。 */
.badge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.7rem;
}
.badge-tile {
    text-align: center;
    padding: 0.9rem 0.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    transition: box-shadow 0.15s ease;
}
.badge-tile:not(.locked):hover { box-shadow: var(--shadow-card-hover); }
.badge-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0 auto 0.5rem;
    border-radius: 50%;
    background: var(--color-primary-lighter);
    color: var(--color-primary-dark);
    font-weight: 700;
    font-size: 1.1rem;
}
.badge-label { font-weight: 600; font-size: 0.85rem; }
.badge-desc { font-size: 0.72rem; color: var(--color-text-muted); margin-top: 0.2rem; }
.badge-tile.locked { opacity: 0.45; }
.badge-tile.locked .badge-icon { background: var(--color-border); color: var(--color-text-muted); }

/* メンバー詳細のログイン履歴。以前は1行1件の縦長テーブルで横幅を持て余していたため、
   カード幅いっぱいに折り返す複数列のグリッドに変える。 */
.login-history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 0.4rem;
}
.login-history-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    font-size: 0.8rem;
}
.login-history-index { color: var(--color-text-muted); flex: 0 0 auto; }
.login-history-date { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* station_detail.htmlの「最新の気象情報」。項目数が少ない縦長テーブルのままだと
   カード幅の大半が余白になるため、login-history-gridと同様に折り返すタイル状にする。 */
.weather-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.6rem;
}
.weather-info-item {
    padding: 0.5rem 0.8rem;
    border-radius: var(--radius-sm);
    background: var(--color-bg);
}
.weather-info-label { font-size: 0.76rem; color: var(--color-text-muted); }
.weather-info-value { font-size: 1.05rem; font-weight: 600; margin-top: 0.15rem; }
.sim-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.8rem;
    margin-bottom: 1rem;
}
.sim-form-grid p {
    margin: 0;
}

.heatmap-wrap { overflow-x: auto; padding-bottom: 0.2rem; }
.heatmap-months {
    display: flex;
    font-size: 0.68rem;
    color: var(--color-text-muted);
    margin-bottom: 0.25rem;
}
.heatmap-months span { width: 14px; flex: 0 0 14px; }
.heatmap {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(7, 11px);
    grid-auto-columns: 11px;
    gap: 3px;
}
.heatmap .cell, p .cell {
    width: 11px;
    height: 11px;
    border-radius: 2px;
    background: var(--color-border);
    display: inline-block;
}
.heatmap .cell.l1, p .cell.l1 { background: #cfe0ee; }
.heatmap .cell.l2, p .cell.l2 { background: #9dc3de; }
.heatmap .cell.l3, p .cell.l3 { background: #5f93c0; }
.heatmap .cell.l4, p .cell.l4 { background: var(--color-primary-dark); }

.avatar-crop-viewport {
    width: 240px;
    height: 240px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    background: var(--color-border);
    cursor: grab;
    touch-action: none;
}
.avatar-crop-viewport:active { cursor: grabbing; }
.avatar-crop-viewport img {
    position: absolute;
    left: 0;
    top: 0;
    max-width: none;
    user-select: none;
    pointer-events: none;
}

/* ログイン/新規登録申請ページ用の独立レイアウト(base_auth.html)。
   base.htmlのヘッダー・ナビ・サイドバーを一切持たず、中央寄せの1枚カードのみで構成する
   (cockpit等のログイン画面を参考に、認証前は本体アプリのナビを見せない)。 */
.auth-body { min-height: 100vh; }
.auth-page {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    box-sizing: border-box;
    overflow: hidden;
    background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-bg) 65%);
}
/* 背景の霧演出。帯状の要素をぼかして左右にゆっくり漂わせる(CSSのみ、画像・JS不要)。 */
.fog-layer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}
.fog-band {
    position: absolute;
    left: -25%;
    width: 150%;
    height: 240px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.55), transparent);
    filter: blur(28px);
    opacity: 0.5;
    animation: fogDrift 42s ease-in-out infinite;
}
.fog-band-1 { top: 6%; animation-duration: 38s; }
.fog-band-2 { top: 40%; animation-duration: 55s; animation-direction: reverse; opacity: 0.35; }
.fog-band-3 { top: 72%; animation-duration: 65s; opacity: 0.4; }
@keyframes fogDrift {
    0% { transform: translateX(-8%); }
    50% { transform: translateX(8%); }
    100% { transform: translateX(-8%); }
}
@media (prefers-reduced-motion: reduce) {
    .fog-band { animation: none; }
}
.auth-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card-hover);
    padding: 2rem 1.8rem;
    text-align: center;
}
.auth-title {
    font-size: 1.25rem;
    color: var(--color-primary);
    margin: 0 0 1.4rem;
}
.auth-card .card {
    box-shadow: none;
    border: none;
    padding: 0;
    margin-bottom: 1.2rem;
}
.auth-card form { text-align: left; }
.auth-theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: var(--color-surface);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}
.auth-theme-toggle:hover { background: var(--color-bg); }

/* 管理者メニューの左サイドバー(_admin_sidebar.html)。_station_sidebar.htmlと同じ
   .sidebar-panel/.sidebar-search/.sidebar-listを流用し、グループ見出しだけ追加する。 */
.sidebar-group { margin-bottom: 0.6rem; }
.sidebar-group:last-child { margin-bottom: 0; }
.sidebar-group-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 0.6rem 0 0.2rem;
    padding: 0 0.6rem;
    background: none;
    border: none;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
    text-transform: uppercase;
    cursor: pointer;
}
.sidebar-group-label .icon { transition: transform 0.15s ease; }
.sidebar-group.collapsed .sidebar-group-label .icon { transform: rotate(-90deg); }
.sidebar-group.collapsed .sidebar-list { max-height: 0; opacity: 0; }
@media (prefers-reduced-motion: reduce) {
    .sidebar-list { transition: none; }
}
