:root {
    --bg: #0a0d13;
    --panel: #10151e;
    --panel-2: #141b26;
    --line: rgba(148, 178, 220, 0.1);
    --ink: #e8eef7;
    --ink-soft: #9fb0c5;
    --ink-muted: #5f6f85;
    --cyan: #4fd8ff;
    --green: #3ee6a0;
    --amber: #ffc555;
    --red: #ff5d73;
    --violet: #9b8cff;
    --font-en: "Inter", sans-serif;
    --font-jp: "Noto Sans JP", sans-serif;
}

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

body {
    font-family: var(--font-jp);
    background:
        radial-gradient(70vw 40vw at 110% -10%, rgba(79, 216, 255, 0.06), transparent 60%),
        radial-gradient(50vw 36vw at -10% 110%, rgba(155, 140, 255, 0.07), transparent 60%),
        var(--bg);
    color: var(--ink);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; border: none; background: none; cursor: pointer; color: inherit; }

.app {
    max-width: 1380px;
    margin: 0 auto;
    padding: clamp(12px, 2vw, 22px);
    display: grid;
    gap: 14px;
}

/* ===== Top bar ===== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
}

.topbar-brand {
    font-family: var(--font-en);
    font-weight: 800;
    letter-spacing: 0.18em;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.brand-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 12px var(--cyan);
    animation: blink 2.2s ease-in-out infinite;
}

@keyframes blink { 50% { opacity: 0.35; } }

.brand-sub {
    font-family: var(--font-jp);
    font-weight: 500;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    color: var(--ink-muted);
}

.topbar-status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 15px;
    border-radius: 999px;
    font-family: var(--font-en);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    border: 1px solid rgba(62, 230, 160, 0.35);
    background: rgba(62, 230, 160, 0.09);
    color: var(--green);
    transition: all 0.35s ease;
}

.status-pill.warn {
    border-color: rgba(255, 197, 85, 0.45);
    background: rgba(255, 197, 85, 0.1);
    color: var(--amber);
}

.status-pill.alarm {
    border-color: rgba(255, 93, 115, 0.5);
    background: rgba(255, 93, 115, 0.12);
    color: var(--red);
    animation: alarm-pulse 1.1s ease-in-out infinite;
}

@keyframes alarm-pulse {
    50% { box-shadow: 0 0 0 6px rgba(255, 93, 115, 0.12); }
}

.status-light {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 10px currentColor;
}

.clock-box {
    display: inline-flex;
    align-items: baseline;
    gap: 9px;
    padding: 7px 14px;
    border-radius: 12px;
    background: var(--panel-2);
    border: 1px solid var(--line);
}

.clock-label {
    font-family: var(--font-en);
    font-size: 0.58rem;
    letter-spacing: 0.24em;
    color: var(--ink-muted);
}

#liveClock {
    font-family: var(--font-en);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.08em;
    font-variant-numeric: tabular-nums;
}

.sync-pill {
    font-family: var(--font-en);
    font-size: 0.64rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    color: var(--violet);
    border: 1px dashed rgba(155, 140, 255, 0.4);
    padding: 7px 12px;
    border-radius: 999px;
    cursor: help;
}

/* ===== Alert banner ===== */
.alert-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 18px;
    border-radius: 14px;
    border: 1px solid rgba(255, 93, 115, 0.5);
    background: linear-gradient(90deg, rgba(255, 93, 115, 0.16), rgba(255, 93, 115, 0.05));
    color: var(--ink);
    font-size: 0.92rem;
}

.alert-banner[hidden] { display: none; }

.alert-icon { font-size: 1.1rem; }
.alert-banner b { color: var(--red); margin-right: 4px; }

/* ===== Grid ===== */
.grid {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr);
    gap: 14px;
    align-items: start;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
}

.panel-head h2 {
    font-family: var(--font-en);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.24em;
    color: var(--ink-soft);
}

/* ===== Map ===== */
.map-canvas-wrap {
    position: relative;
    aspect-ratio: 16 / 11;
    background: #0b0f17;
}

#cityMap {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.layer-tabs { display: flex; gap: 6px; flex-wrap: wrap; }

.layer-tab {
    font-size: 0.76rem;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--ink-muted);
    transition: all 0.25s ease;
}

.layer-tab:hover { color: var(--ink); border-color: rgba(79, 216, 255, 0.35); }

.layer-tab.is-active {
    color: #04222c;
    background: var(--cyan);
    border-color: var(--cyan);
    box-shadow: 0 4px 16px rgba(79, 216, 255, 0.35);
}

.map-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-top: 1px solid var(--line);
}

.legend {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-en);
    font-size: 0.58rem;
    letter-spacing: 0.2em;
    color: var(--ink-muted);
}

.legend-bar {
    width: 130px;
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(90deg,
            rgba(79, 216, 255, 0.9),
            rgba(62, 230, 160, 0.9),
            rgba(255, 197, 85, 0.9),
            rgba(255, 93, 115, 0.95));
}

.sim-controls { display: flex; gap: 6px; flex-wrap: wrap; }

.sim-btn {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 6px 13px;
    border-radius: 10px;
    border: 1px solid var(--line);
    color: var(--ink-soft);
    transition: all 0.2s ease;
}

.sim-btn:hover { color: var(--ink); border-color: rgba(79, 216, 255, 0.4); }

.sim-btn.is-active {
    color: #04222c;
    background: var(--cyan);
    border-color: var(--cyan);
}

.sim-btn.danger {
    color: var(--red);
    border-color: rgba(255, 93, 115, 0.4);
}

.sim-btn.danger:hover {
    background: rgba(255, 93, 115, 0.12);
    box-shadow: 0 0 18px rgba(255, 93, 115, 0.2);
}

/* ===== Side column ===== */
.side-col { display: grid; gap: 14px; }

.stat-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.stat-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 16px 12px;
    transition: transform 0.25s ease, border-color 0.25s ease;
}

.stat-card:hover { transform: translateY(-3px); border-color: rgba(79, 216, 255, 0.3); }

.stat-card header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.metric-name { font-size: 0.76rem; color: var(--ink-soft); }

.trend {
    font-family: var(--font-en);
    font-size: 0.78rem;
    color: var(--ink-muted);
    transition: color 0.3s ease;
}

.trend.up { color: var(--green); }
.trend.down { color: var(--cyan); }
.trend.warn { color: var(--amber); }
.trend.alarm { color: var(--red); }

.stat-card strong {
    font-family: var(--font-en);
    font-weight: 800;
    font-size: 1.75rem;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    display: block;
}

.stat-card strong small {
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--ink-muted);
    margin-left: 5px;
    letter-spacing: 0.06em;
}

.sparkline {
    width: 100%;
    height: 46px;
    display: block;
    margin-top: 8px;
}

/* ===== Feed ===== */
.live-dot-wrap {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-en);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    color: var(--red);
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--red);
    box-shadow: 0 0 10px var(--red);
    animation: blink 1.3s ease-in-out infinite;
}

.feed-list {
    list-style: none;
    max-height: 380px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 178, 220, 0.2) transparent;
}

.feed-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
    padding: 11px 16px;
    border-bottom: 1px solid rgba(148, 178, 220, 0.06);
    animation: feed-in 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@keyframes feed-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.feed-time {
    font-family: var(--font-en);
    font-size: 0.66rem;
    color: var(--ink-muted);
    font-variant-numeric: tabular-nums;
    padding-top: 2px;
}

.feed-text { font-size: 0.84rem; color: var(--ink-soft); }

.feed-item.warn .feed-text b,
.feed-item.alarm .feed-text b { color: inherit; }

.feed-item.warn .feed-text strong { color: var(--amber); }
.feed-item.alarm .feed-text strong { color: var(--red); }

.feed-tag {
    display: inline-block;
    font-family: var(--font-en);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    padding: 2px 8px;
    border-radius: 999px;
    margin-right: 7px;
    vertical-align: 1px;
}

.feed-tag.temp  { color: var(--cyan);  background: rgba(79, 216, 255, 0.12); }
.feed-tag.quake { color: var(--amber); background: rgba(255, 197, 85, 0.12); }
.feed-tag.rain  { color: var(--violet); background: rgba(155, 140, 255, 0.14); }
.feed-tag.wind  { color: var(--green);  background: rgba(62, 230, 160, 0.12); }

/* ===== Footer ===== */
.app-foot {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 6px 4px 14px;
    font-size: 0.72rem;
    color: var(--ink-muted);
}

.app-foot a:hover { color: var(--cyan); }

/* ===== Responsive ===== */
@media (max-width: 1020px) {
    .grid { grid-template-columns: 1fr; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 540px) {
    .stat-cards { grid-template-columns: 1fr; }
    .topbar-status { width: 100%; justify-content: space-between; }
    .feed-list { max-height: 300px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== v2: popover / toasts / kbd hint ===== */
.station-pop {
    position: absolute;
    width: 188px;
    background: rgba(13, 18, 27, 0.96);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(79, 216, 255, 0.35);
    border-radius: 14px;
    padding: 12px 14px;
    z-index: 5;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

.station-pop[hidden] { display: none; }

.station-pop header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.station-pop header b { font-size: 0.86rem; }

#popClose {
    font-size: 1rem;
    color: var(--ink-muted);
    line-height: 1;
}

#popClose:hover { color: var(--ink); }

#popList { list-style: none; }

#popList li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 4px 0;
    font-size: 0.78rem;
    color: var(--ink-soft);
}

#popList li b {
    font-family: var(--font-en);
    font-variant-numeric: tabular-nums;
}

#popList li small { margin-left: 3px; color: var(--ink-muted); }
#popList li.warn b { color: var(--amber); }
#popList li.alarm b { color: var(--red); }

.kbd-hint {
    padding: 0 16px 12px;
    font-size: 0.66rem;
    color: var(--ink-muted);
}

.kbd-hint b {
    font-family: var(--font-en);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 1px 6px;
    margin: 0 2px;
}

.toast-wrap {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 100;
    display: grid;
    gap: 8px;
    justify-items: end;
}

.toast {
    max-width: 320px;
    background: rgba(13, 18, 27, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(148, 178, 220, 0.25);
    color: var(--ink);
    font-size: 0.82rem;
    padding: 11px 16px;
    border-radius: 12px;
    opacity: 0;
    transform: translateX(14px);
    transition: all 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.toast.show { opacity: 1; transform: translateX(0); }

.toast.warn { border-color: rgba(255, 197, 85, 0.55); color: var(--amber); }
.toast.alarm { border-color: rgba(255, 93, 115, 0.6); color: var(--red); box-shadow: 0 0 26px rgba(255,93,115,0.15); }

/* ===== clarity pass ===== */
.guide-strip {
    padding: 10px 16px;
    border-radius: 12px;
    background: rgba(79, 216, 255, 0.07);
    border: 1px dashed rgba(79, 216, 255, 0.3);
    color: var(--ink-soft);
    font-size: 0.8rem;
}

.guide-strip span {
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    margin: 0 3px;
    border-radius: 50%;
    background: var(--cyan);
    color: #04222c;
    font-family: var(--font-en);
    font-weight: 800;
    font-size: 0.66rem;
}

.legend-info {
    font-family: var(--font-jp);
    font-weight: 500;
    font-size: 0.7rem;
    letter-spacing: 0;
    color: var(--ink-soft);
    margin-left: 6px;
}
