/*============================================================================*/
/*  [FILE_NAME]      : gpslog.css                                             */
/*  [PROJECT]        : html                                                   */
/*  [AUTHOR]         : OMKC (kc.notebook789@gmail.com)                        */
/*  OmoriLog 共通スタイル (index.html / history.html)                            */
/*============================================================================*/

:root {
    --bg: #0a0e13;
    --surface: rgba(255, 255, 255, 0.035);
    --surface-hover: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #e7edf3;
    --muted: #8a97a6;
    --faint: #56626f;

    --accent: #38bdf8;
    --accent-2: #a78bfa;
    --ok: #34d399;
    --warn: #fbbf24;
    --danger: #f87171;

    /* 計測値ごとの色 (common.js と同じ値) */
    --c-temp: #fb923c;
    --c-hum: #22d3ee;
    --c-vel: #a78bfa;
    --c-prs: #e879f9;
    --c-elev: #34d399;
    --c-deg: #fbbf24;

    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --font: "Inter", "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    background:
        radial-gradient(1000px 500px at 10% -10%, rgba(56, 189, 248, 0.10), transparent 60%),
        radial-gradient(900px 500px at 100% 0%, rgba(167, 139, 250, 0.10), transparent 60%),
        var(--bg);
    background-attachment: fixed;
}

a {
    color: var(--accent);
    text-decoration: none;
}

.num {
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

/*--------------------------------------------------------------------------*/
/* ヘッダー                                                                  */
/*--------------------------------------------------------------------------*/
.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    background: rgba(10, 14, 19, 0.72);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 1240px;
    margin: 0 auto;
    min-height: 52px;
    padding: 6px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.brand-mark {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.30);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

/* グラデーション文字は要素の範囲でしか描かれないため、
   g のような下にはみ出す部分のぶん下に余白を取り、上は詰める */
.brand-text b {
    display: block;
    margin-top: -0.06em;
    padding-bottom: 0.16em;
    font-size: 0.98rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    background: linear-gradient(135deg, #34d399, #38bdf8 55%, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.tabs {
    display: flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
}

.tabs a {
    padding: 4px 14px;
    line-height: 1.5;
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
}

.tabs a:hover {
    color: var(--text);
}

.tabs a.active {
    color: var(--text);
    background: rgba(255, 255, 255, 0.10);
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.updated {
    color: var(--muted);
    font-size: 0.82rem;
    white-space: nowrap;
}

/* LIVE 表示 */
.live-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 11px;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--muted);
    white-space: nowrap;
}

.live-chip .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--faint);
}

.live-chip.is-live {
    color: var(--ok);
    border-color: rgba(52, 211, 153, 0.35);
    background: rgba(52, 211, 153, 0.08);
}

.live-chip.is-live .dot {
    background: var(--ok);
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
    animation: pulse-dot 2s infinite;
}

.live-chip.is-idle {
    color: var(--warn);
    border-color: rgba(251, 191, 36, 0.35);
    background: rgba(251, 191, 36, 0.07);
}

.live-chip.is-idle .dot {
    background: var(--warn);
}

.live-chip.is-offline {
    color: var(--danger);
    border-color: rgba(248, 113, 113, 0.35);
}

.live-chip.is-offline .dot {
    background: var(--danger);
}

@keyframes pulse-dot {
    0% {
        box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
    }

    70% {
        box-shadow: 0 0 0 8px rgba(52, 211, 153, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(52, 211, 153, 0);
    }
}

/*--------------------------------------------------------------------------*/
/* レイアウト・カード                                                        */
/*--------------------------------------------------------------------------*/
.page {
    max-width: 1240px;
    margin: 0 auto;
    padding: 18px 16px 40px;
    display: grid;
    gap: 16px;
}

.card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    min-width: 0;
}

.card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.card-title {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

.card-sub {
    color: var(--faint);
    font-size: 0.8rem;
}

/*--------------------------------------------------------------------------*/
/* 計測値カード                                                              */
/*--------------------------------------------------------------------------*/
.metrics {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
}

.metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 14px 10px 12px;
    text-align: center;
}

.metric-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.08em;
}

.metric-label i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--c, var(--accent));
}

/* リングゲージ */
.gauge {
    position: relative;
    width: 100%;
    max-width: 132px;
    aspect-ratio: 1;
}

.gauge svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.gauge .track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.07);
    stroke-width: 9;
    stroke-linecap: round;
}

.gauge .value {
    fill: none;
    stroke: var(--c, var(--accent));
    stroke-width: 9;
    stroke-linecap: round;
    filter: drop-shadow(0 0 6px var(--c, var(--accent)));
    transition: stroke-dashoffset 0.8s cubic-bezier(.2, .8, .2, 1);
}

.gauge-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 6px;
}

.gauge-value {
    font-size: clamp(1.5rem, 3.4vw, 2.1rem);
    font-weight: 700;
    line-height: 1;
}

.gauge-unit {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.78rem;
}

/* コンパス */
.compass {
    position: relative;
    width: 100%;
    max-width: 132px;
    aspect-ratio: 1;
}

.compass svg {
    width: 100%;
    height: 100%;
}

.compass .ring {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 2;
}

.compass .tick {
    stroke: rgba(255, 255, 255, 0.22);
    stroke-width: 2;
    stroke-linecap: round;
}

.compass .cardinal {
    fill: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: central;
    font-family: var(--font);
}

.compass .cardinal.n {
    fill: var(--danger);
}

.compass .needle {
    transform-origin: 60px 60px;
    transition: transform 0.8s cubic-bezier(.2, .8, .2, 1);
}

.compass .needle path {
    fill: var(--c-deg);
    filter: drop-shadow(0 0 5px rgba(251, 191, 36, 0.6));
}

.compass-value {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -2px;
    font-size: 0.95rem;
    font-weight: 700;
}

/* 数値 + 推移 */
.stat {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-value {
    font-size: clamp(1.5rem, 3.4vw, 2.1rem);
    font-weight: 700;
    line-height: 1.1;
}

.stat-unit {
    color: var(--muted);
    font-size: 0.78rem;
}

.spark {
    width: 100%;
    height: 44px;
    margin-top: 4px;
}

.spark path.line {
    fill: none;
    stroke: var(--c, var(--accent));
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.spark path.area {
    fill: var(--c, var(--accent));
    opacity: 0.12;
}

.stat-delta {
    color: var(--faint);
    font-size: 0.75rem;
}

/*--------------------------------------------------------------------------*/
/* 地図                                                                      */
/*--------------------------------------------------------------------------*/
.map-card {
    padding: 0;
    overflow: hidden;
}

.map-card .card-head {
    position: absolute;
    z-index: 500;
    top: 12px;
    left: 12px;
    right: 64px;
    margin: 0;
    pointer-events: none;
    justify-content: flex-start;
}

.map-chip {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(10, 14, 19, 0.78);
    border: 1px solid var(--border);
    backdrop-filter: blur(8px);
    font-size: 0.82rem;
    color: var(--muted);
}

.map-chip b {
    color: var(--text);
}

.map {
    height: 520px;
    background: #111820;
    /* Leaflet の部品 (z-index 1000) がヘッダーの上に出ないよう、重なり順を地図の中で閉じる */
    isolation: isolate;
}

.map-tools {
    position: absolute;
    z-index: 500;
    bottom: 36px;
    right: 12px;
}

/* ダーク地図 (OSM を反転して暗くする) */
.leaflet-tile.tile-dark,
.tile-dark {
    filter: invert(1) hue-rotate(185deg) brightness(0.92) contrast(0.88) saturate(0.6);
}

/* Leaflet のダーク調整 */
.leaflet-container {
    font-family: var(--font);
    background: #111820;
}

.leaflet-bar,
.leaflet-control-layers {
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    overflow: hidden;
    box-shadow: var(--shadow) !important;
}

.leaflet-bar a,
.leaflet-control-layers {
    background: rgba(16, 22, 30, 0.92) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

.leaflet-bar a:hover {
    background: rgba(30, 40, 52, 0.95) !important;
}

.leaflet-control-layers-expanded {
    padding: 8px 12px !important;
    color: var(--text);
}

.leaflet-control-attribution {
    background: rgba(10, 14, 19, 0.7) !important;
    color: var(--faint) !important;
}

.leaflet-control-attribution a {
    color: var(--muted) !important;
}

.leaflet-control-scale-line {
    background: rgba(10, 14, 19, 0.7);
    color: var(--muted);
    border-color: var(--muted);
}

.leaflet-tooltip.gl-tip {
    background: rgba(12, 17, 24, 0.94);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    color: var(--text);
    box-shadow: var(--shadow);
    font-size: 0.8rem;
    line-height: 1.6;
    padding: 6px 10px;
}

.leaflet-tooltip.gl-tip::before {
    display: none;
}

.gl-tip .t {
    color: var(--muted);
    font-size: 0.75rem;
}

/* 点をクリックしたときのポップアップ */
.gl-popup .leaflet-popup-content-wrapper {
    background: rgba(12, 17, 24, 0.96);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    color: var(--text);
    box-shadow: var(--shadow);
}

.gl-popup .leaflet-popup-content {
    margin: 10px 12px;
    font-size: 0.8rem;
    line-height: 1.6;
}

.gl-popup .leaflet-popup-tip {
    background: rgba(12, 17, 24, 0.96);
}

.gl-popup .t {
    color: var(--muted);
    font-size: 0.75rem;
}

.gl-links {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.gl-links a {
    flex: 1;
    padding: 5px 8px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    color: var(--accent);
    text-align: center;
    white-space: nowrap;
}

.gl-links a:hover {
    background: var(--surface-hover);
}

/* 地図上のボタン群 */
.map-tools {
    display: flex;
    gap: 8px;
}

.map-tools .btn {
    background: rgba(16, 22, 30, 0.92);
}

/* ボタンを並べる */
.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn-row .btn {
    flex: 1;
}

/* 現在地マーカー (進行方向の矢印 + 波紋) */
.pos-marker {
    position: relative;
    width: 44px;
    height: 44px;
}

.pos-marker .pulse {
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    background: rgba(56, 189, 248, 0.35);
    animation: pos-pulse 2.2s ease-out infinite;
}

.pos-marker .core {
    position: absolute;
    inset: 13px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #7dd3fc, #0284c7);
    border: 2px solid #fff;
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.9);
}

.pos-marker .arrow {
    position: absolute;
    inset: 0;
    transition: transform 0.6s ease;
}

.pos-marker .arrow::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 10px solid #e0f2fe;
    filter: drop-shadow(0 0 3px rgba(56, 189, 248, 0.9));
}

@keyframes pos-pulse {
    0% {
        transform: scale(0.6);
        opacity: 0.9;
    }

    100% {
        transform: scale(2.2);
        opacity: 0;
    }
}

/*--------------------------------------------------------------------------*/
/* グラフ                                                                    */
/*--------------------------------------------------------------------------*/
.charts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.chart-card .card-head {
    margin-bottom: 6px;
}

.chart-now {
    font-size: 1.15rem;
    font-weight: 700;
}

.chart-now small {
    margin-left: 3px;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.chart-box {
    position: relative;
    height: 200px;
}

.legend {
    display: flex;
    gap: 12px;
    color: var(--muted);
    font-size: 0.78rem;
}

.legend i {
    display: inline-block;
    width: 10px;
    height: 3px;
    border-radius: 2px;
    margin-right: 5px;
    vertical-align: middle;
    background: var(--c);
}

/*--------------------------------------------------------------------------*/
/* フォーム部品                                                              */
/*--------------------------------------------------------------------------*/
.btn,
.field {
    font: inherit;
    font-size: 0.9rem;
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    min-height: 38px;
    padding: 6px 12px;
}

.field {
    color-scheme: dark;
}

.field:focus,
.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.btn {
    white-space: nowrap;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 600;
    transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
    background: var(--surface-hover);
    border-color: rgba(255, 255, 255, 0.28);
}

.btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.btn-icon {
    width: 38px;
    padding: 0;
}

.btn-primary {
    color: #06121a;
    background: linear-gradient(135deg, #38bdf8, #a78bfa);
    border-color: transparent;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5ccafa, #b9a2fb);
    border-color: transparent;
}

.btn.on {
    border-color: rgba(56, 189, 248, 0.6);
    color: var(--accent);
}

select.field option {
    background: #121922;
}

/*--------------------------------------------------------------------------*/
/* 過去ログ                                                                  */
/*--------------------------------------------------------------------------*/
.controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 24px;
}

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

.control-label {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
    gap: 12px;
    align-items: stretch;
}

.kpi {
    padding: 14px 16px;
}

.kpi-label {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.08em;
}

.kpi-value {
    margin-top: 2px;
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.2;
}

.kpi-value small {
    margin-left: 4px;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.summary-side {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

.view-label {
    font-weight: 700;
    font-size: 1.05rem;
}

.status {
    min-height: 1.3em;
    color: var(--muted);
    font-size: 0.85rem;
}

.status.error {
    color: var(--danger);
}

.status:empty {
    display: none;
}

.table-wrap {
    overflow-x: auto;
    margin: 0 -4px;
}

table.trips {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 4px;
    font-size: 0.92rem;
    white-space: nowrap;
}

table.trips th {
    color: var(--faint);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-align: right;
    padding: 4px 12px;
}

table.trips td {
    padding: 10px 12px;
    text-align: right;
    background: rgba(255, 255, 255, 0.025);
    border-top: 1px solid transparent;
    border-bottom: 1px solid transparent;
}

table.trips th:first-child,
table.trips td:first-child {
    text-align: left;
}

table.trips td:first-child {
    border-left: 1px solid transparent;
    border-radius: 10px 0 0 10px;
}

table.trips td:last-child {
    border-right: 1px solid transparent;
    border-radius: 0 10px 10px 0;
}

table.trips tbody tr {
    cursor: pointer;
}

table.trips tbody tr:hover td {
    background: rgba(255, 255, 255, 0.06);
}

table.trips tbody tr.selected td {
    background: rgba(56, 189, 248, 0.10);
    border-color: rgba(56, 189, 248, 0.4);
}

table.trips td.empty {
    text-align: center;
    color: var(--muted);
    cursor: default;
}

.trip-no {
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    margin-right: 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    vertical-align: middle;
}

.swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 10px;
    vertical-align: middle;
}

/*--------------------------------------------------------------------------*/
/* 共有ボタン (フロート)                                                     */
/*--------------------------------------------------------------------------*/
.share {
    position: fixed;
    z-index: 1100;
    right: max(20px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.share-fab {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #06121a;
    background: linear-gradient(135deg, #34d399, #38bdf8 55%, #a78bfa);
    box-shadow: 0 10px 28px rgba(56, 189, 248, 0.45), 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s;
}

.share-fab:hover {
    transform: translateY(-2px);
}

.share-fab:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

.share-fab svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
}

.share-fab svg circle {
    fill: currentColor;
    stroke: none;
}

.share-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    min-width: 230px;
    border-radius: 14px;
    border: 1px solid var(--border-strong);
    background: rgba(12, 17, 24, 0.96);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
}

.share-menu[hidden] {
    display: none;
}

.share-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.share-item:hover:not(:disabled) {
    background: var(--surface-hover);
    border-color: var(--border);
}

.share-item:disabled {
    opacity: 0.4;
    cursor: default;
}

.share-title {
    font-weight: 700;
    font-size: 0.92rem;
}

.share-desc {
    color: var(--muted);
    font-size: 0.78rem;
}

.toast {
    position: fixed;
    z-index: 1200;
    left: 50%;
    bottom: max(24px, env(safe-area-inset-bottom));
    transform: translate(-50%, 20px);
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: rgba(12, 17, 24, 0.96);
    color: var(--text);
    font-size: 0.88rem;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* フロートボタンでページ末尾が隠れないように */
.has-share .page {
    padding-bottom: 96px;
}

/*--------------------------------------------------------------------------*/
/* ライブ: 周辺の環境 (時刻・外の天気・地域名・警報)                         */
/*--------------------------------------------------------------------------*/
.env {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 6px 16px;
    align-items: center;
}

.env-clock {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.env-time {
    font-size: 2rem;
    font-weight: 800;
}

.env-date {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
}

.env-weather {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.env-icon {
    font-size: 2.4rem;
    line-height: 1;
}

.env-temp {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

.env-temp small {
    font-size: 0.9rem;
    color: var(--muted);
    font-weight: 600;
}

.env-desc {
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

.env-desc b {
    color: var(--text);
}

.env-place {
    text-align: right;
    font-size: 0.85rem;
    font-weight: 700;
}

.env-place small {
    display: block;
    color: var(--faint);
    font-weight: 500;
    font-size: 0.72rem;
}

.env-chips {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.env-chips:empty {
    display: none;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
}

.chip b {
    color: var(--text);
}

.chip.rain-ok b {
    color: var(--ok);
}

.chip.rain-soon b {
    color: var(--warn);
}

.chip.rain-now b {
    color: var(--accent);
}

/* 気象警報・注意報 */
.alerts {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.alerts:empty {
    display: none;
}

.alert {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 800;
}

.alert.advisory {
    color: #1a1300;
    background: #facc15;
}

.alert.warning {
    color: #fff;
    background: #ef4444;
}

.alert.special {
    color: #fff;
    background: #7e22ce;
    box-shadow: 0 0 0 2px #f0abfc inset;
}

.alerts-none {
    color: var(--muted);
    font-size: 0.78rem;
}

.alerts-src {
    color: var(--faint);
    font-size: 0.7rem;
}

.env-credit {
    grid-column: 1 / -1;
    color: var(--faint);
    font-size: 0.65rem;
}

.env-credit a {
    color: var(--muted);
}

/* 車のデータ (スマホ用の小さなタイル。PC では非表示) */
.tiles {
    display: none;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.tile {
    padding: 8px 10px;
}

/* ラベルの行: 左に名前、右端に補足 (外との差・1時間の変化) */
.tile-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    min-width: 0;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
}

.tile-name {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
}

.tile-label i {
    flex: none;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--c);
}

.tile-value {
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
}

.tile-value small {
    margin-left: 2px;
    font-size: 0.7rem;
    color: var(--muted);
    font-weight: 600;
}

/* 方位の矢印 (➤ は右向きなので -90度して北を 0 度にする) */
.tile-arrow {
    display: inline-block;
    margin-right: 4px;
    color: var(--c-deg);
    font-size: 0.85em;
    transform: rotate(-90deg);
    transition: transform 0.6s ease;
}

.tile-sub {
    flex: none;
    color: var(--faint);
    font-size: 0.62rem;
    font-weight: 700;
    white-space: nowrap;
}

.tile-sub.hot {
    color: var(--c-temp);
}

.tile-sub.cool {
    color: var(--c-hum);
}

/* 1画面目 (dash) と 2画面目 (グラフ) の間 */
.page.below {
    padding-top: 0;
}

/*--------------------------------------------------------------------------*/
/* 過去ログ: 速度の凡例・走行リプレイ                                        */
/*--------------------------------------------------------------------------*/
.speed-legend {
    position: absolute;
    z-index: 500;
    left: 12px;
    bottom: 96px;
    width: min(240px, calc(100% - 24px));
    padding: 6px 10px 2px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(10, 14, 19, 0.82);
    pointer-events: none;
}

.speed-scale {
    display: block;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, #60a5fa, #22d3ee 20%, #34d399 40%, #facc15 60%, #fb923c 80%, #f87171);
}

.speed-ticks {
    position: relative;
    display: block;
    height: 1.3em;
    color: var(--muted);
    font-size: 0.65rem;
}

.speed-ticks span {
    position: absolute;
    transform: translateX(-50%);
}

.speed-ticks span:nth-child(1) { left: 0; transform: none; }
.speed-ticks span:nth-child(2) { left: 20%; }
.speed-ticks span:nth-child(3) { left: 40%; }
.speed-ticks span:nth-child(4) { left: 60%; }
.speed-ticks span:nth-child(5) { left: 80%; }
.speed-ticks span:nth-child(6) { right: 0; transform: none; }

.speed-title {
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.replay {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
}

.replay input[type=range] {
    flex: 1;
    min-width: 0;
    accent-color: var(--accent);
}

.replay-play {
    flex: none;
}

.replay-speed {
    flex: none;
    min-height: 36px;
    padding: 4px 8px;
}

/*--------------------------------------------------------------------------*/
/* 雨雲レーダー                                                              */
/*--------------------------------------------------------------------------*/
.rain-bar {
    position: absolute;
    z-index: 500;
    top: 52px;
    left: 12px;
    width: min(380px, calc(100% - 72px));
    padding: 8px 10px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(10, 14, 19, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.rain-bar[hidden] {
    display: none;
}

.rain-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rain-row .btn-icon {
    width: 32px;
    min-height: 32px;
    flex: none;
    font-size: 0.8rem;
}

.rain-row input[type=range] {
    flex: 1;
    min-width: 0;
    accent-color: var(--accent);
}

.rain-time {
    flex: none;
    min-width: 7.5em;
    text-align: right;
    font-size: 0.8rem;
    font-weight: 700;
}

.rain-time.forecast {
    color: var(--warn);
}

/* 気象庁の降水強度の配色 */
.rain-legend {
    margin-top: 6px;
}

.rain-scale {
    display: block;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg,
            #f2f2ff 0 12.5%, #a0d2ff 12.5% 25%, #218cff 25% 37.5%, #0041ff 37.5% 50%,
            #faf500 50% 62.5%, #ff9900 62.5% 75%, #ff2800 75% 87.5%, #b40068 87.5% 100%);
}

.rain-ticks {
    position: relative;
    display: block;
    height: 1.2em;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.65rem;
}

/* 目盛りの数字を色の境目に置く */
.rain-ticks span {
    position: absolute;
    transform: translateX(-50%);
}

.rain-ticks span:nth-child(1) { left: 12.5%; }
.rain-ticks span:nth-child(2) { left: 25%; }
.rain-ticks span:nth-child(3) { left: 37.5%; }
.rain-ticks span:nth-child(4) { left: 50%; }
.rain-ticks span:nth-child(5) { left: 62.5%; }
.rain-ticks span:nth-child(6) { left: 75%; }
.rain-ticks span:nth-child(7) { left: 87.5%; }

.rain-ticks span:nth-child(8) {
    right: 0;
    transform: none;
}

.rain-status {
    color: var(--warn);
    font-size: 0.75rem;
}

.rain-status:empty {
    display: none;
}

/*--------------------------------------------------------------------------*/
/* 接近通知                                                                  */
/*--------------------------------------------------------------------------*/
/* 共有ボタンの上に置くベル (共有ボタンと同じ見た目) */
.bell-fab {
    position: relative;
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #06121a;
    background: linear-gradient(135deg, #34d399, #38bdf8 55%, #a78bfa);
    box-shadow: 0 10px 28px rgba(56, 189, 248, 0.45), 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s;
}

.bell-fab:hover {
    transform: translateY(-2px);
}

.bell-fab:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

.bell-fab svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

/* 接近通知の実行中 */
.bell-fab.on {
    color: #06121a;
    border-color: transparent;
    background: linear-gradient(135deg, #34d399, #38bdf8 55%, #a78bfa);
}

.bell-fab.on::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(56, 189, 248, 0.6);
    animation: ring-pulse 1.8s ease-out infinite;
}

@keyframes ring-pulse {
    0% {
        transform: scale(0.9);
        opacity: 1;
    }

    100% {
        transform: scale(1.35);
        opacity: 0;
    }
}

.approach-setup {
    width: min(320px, calc(100vw - 40px));
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-radius: 16px;
    border: 1px solid var(--border-strong);
    background: rgba(12, 17, 24, 0.98);
    box-shadow: var(--shadow);
}

.approach-setup[hidden] {
    display: none;
}

.approach-setup-title {
    font-weight: 800;
    font-size: 1rem;
}

.approach-setup-desc,
.approach-setup-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.6;
}

.approach-setup-note {
    color: var(--faint);
    font-size: 0.75rem;
}

/* 50m / 100m / 200m の切り替え */
.segmented {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
}

.segmented label {
    position: relative;
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented span {
    display: block;
    padding: 8px 0;
    border-radius: 9px;
    text-align: center;
    font-weight: 700;
    color: var(--muted);
    cursor: pointer;
}

.segmented input:checked + span {
    color: var(--text);
    background: rgba(56, 189, 248, 0.16);
    box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.5);
}

.segmented input:focus-visible + span {
    outline: 2px solid var(--accent);
}

/* 待っている間の大きな表示 */
.approach-panel {
    position: fixed;
    z-index: 1150;
    left: 50%;
    bottom: max(12px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: min(560px, calc(100vw - 24px));
    padding: 16px 18px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-strong);
    background: rgba(10, 14, 19, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.approach-panel[hidden] {
    display: none;
}

.approach-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.approach-state {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.approach-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 0 10px;
}

.approach-label {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.approach-dist {
    font-size: clamp(3rem, 15vw, 4.6rem);
    font-weight: 800;
    line-height: 1.05;
    background: linear-gradient(135deg, #34d399, #38bdf8 55%, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    padding-bottom: 0.08em;
}

.approach-dist small {
    margin-left: 6px;
    font-size: 0.4em;
}

.approach-eta {
    font-size: 1.15rem;
    font-weight: 700;
}

.approach-bands {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.approach-bands span {
    padding: 6px 0;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--faint);
    text-align: center;
    font-size: 0.82rem;
    font-weight: 700;
    transition: background 0.3s, color 0.3s;
}

.approach-bands span.reached {
    color: #06121a;
    border-color: transparent;
    background: linear-gradient(135deg, #34d399, #38bdf8);
}

.approach-bands span.flash {
    animation: band-flash 0.6s ease-in-out 3;
}

@keyframes band-flash {
    50% {
        transform: scale(1.12);
        box-shadow: 0 0 18px rgba(56, 189, 248, 0.8);
    }
}

.approach-foot {
    margin-top: 10px;
    color: var(--faint);
    font-size: 0.75rem;
    text-align: center;
}

.approach-foot.warn {
    color: var(--warn);
}

/* 到着 (指定距離に入った) */
.approach-panel.arrived {
    border-color: rgba(52, 211, 153, 0.7);
    background: rgba(6, 40, 30, 0.95);
    animation: arrived-glow 1.2s ease-in-out infinite alternate;
}

.approach-panel.arrived .approach-dist {
    background: none;
    color: #6ee7b7;
}

.approach-panel.arrived .approach-state {
    color: #6ee7b7;
    font-size: 1rem;
    font-weight: 800;
}

@keyframes arrived-glow {
    from {
        box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5), 0 20px 50px rgba(0, 0, 0, 0.6);
    }

    to {
        box-shadow: 0 0 0 10px rgba(52, 211, 153, 0), 0 20px 50px rgba(0, 0, 0, 0.6);
    }
}

/* 実行中は共有ボタンを隠し、ページ末尾が表示に隠れないようにする */
.approach-active .share {
    display: none;
}

.approach-active .page {
    padding-bottom: 300px;
}

/*--------------------------------------------------------------------------*/
/* レスポンシブ                                                              */
/*--------------------------------------------------------------------------*/
@media (max-width: 1000px) {
    .metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .summary-side {
        grid-column: 1 / -1;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

@media (max-width: 760px) {
    body {
        font-size: 14px;
    }

    .charts {
        grid-template-columns: 1fr;
    }

    .map {
        height: 420px;
    }

    .updated {
        display: none;
    }
}

@media (max-width: 480px) {
    .topbar-inner {
        gap: 10px;
        min-height: 48px;
        padding: 5px 12px;
    }

    .brand {
        gap: 8px;
    }

    .brand-mark {
        width: 30px;
        height: 30px;
        border-radius: 8px;
    }

    .tabs a {
        padding: 3px 12px;
    }


    .page {
        padding: 12px 12px 32px;
        gap: 12px;
    }

    .metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .card {
        padding: 12px;
    }

    .map-card {
        padding: 0;
    }

    .map {
        height: 360px;
    }

    .kpi-value {
        font-size: 1.4rem;
    }

    .summary-side {
        flex-direction: column;
        align-items: stretch;
    }
}

/* スマホ (600px 以下): ライブは地図まで 1 画面に収める */
@media (max-width: 600px) {
    .dash {
        display: flex;
        flex-direction: column;
        gap: 8px;
        /* ヘッダー (49px) を除いた画面の高さいっぱいに並べ、地図が残りを使う */
        height: calc(100dvh - 49px);
        padding: 8px 10px 10px;
    }

    .has-share .dash,
    .approach-active .dash {
        padding-bottom: 10px;
    }

    .dash .metrics {
        display: none;
    }

    .dash .tiles {
        display: grid;
    }

    .dash .card {
        padding: 10px 12px;
    }

    .dash .tile {
        padding: 7px 9px;
    }

    .dash .map-card {
        flex: 1;
        min-height: 240px;
        padding: 0;
        display: flex;
        flex-direction: column;
    }

    .dash .map {
        flex: 1;
        height: auto;
        min-height: 0;
    }

    /* 地図のボタンは右下の共有ボタンと重ならないよう左に寄せる */
    .dash .map-tools {
        left: 10px;
        right: auto;
        bottom: 32px;
    }

    .dash .map-tools .btn {
        min-height: 34px;
        padding: 4px 10px;
        font-size: 0.82rem;
    }

    .env {
        grid-template-columns: auto 1fr;
        gap: 4px 12px;
    }

    .env-place {
        grid-column: 1 / -1;
        grid-row: 1;
        text-align: left;
        display: flex;
        gap: 8px;
        align-items: baseline;
    }

    .env-place small {
        display: inline;
    }

    .env-time,
    .env-temp {
        font-size: 1.6rem;
    }

    .env-icon {
        font-size: 2rem;
    }

    .env-desc {
        font-size: 0.75rem;
    }

    .page.below {
        padding-top: 4px;
    }
}

@media (prefers-reduced-motion: reduce) {

    .live-chip.is-live .dot,
    .pos-marker .pulse {
        animation: none;
    }

    .gauge .value,
    .compass .needle,
    .pos-marker .arrow,
    .share-fab,
    .toast {
        transition: none;
    }

    .bell-fab.on::after,
    .approach-bands span.flash,
    .approach-panel.arrived {
        animation: none;
    }
}
