
:root {
    --bg: #e8e8e3;
    --panel: #f4f4ef;
    --raised: #ffffff;
    --line: #d2d8d0;
    --ink: #202923;
    --muted: #68756c;
    --faint: #8b968e;
    --green: #16865a;
    --green-soft: rgba(22, 134, 90, .10);
    --mono: "Roboto Mono", monospace;
    --sans: "Roboto", sans-serif;
}

:root.dark-theme {
    color-scheme: dark;
    --bg: #111312;
    --panel: #191d1a;
    --raised: #202621;
    --line: #303a32;
    --ink: #e8e8e3;
    --muted: #89948c;
    --faint: #68746b;
    --green: #39b77e;
    --green-soft: rgba(57, 183, 126, .10);
}

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

html, body {
    width: 100%;
    height: 100%;
    min-width: 320px;
}

body {
    overflow: hidden;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
}

button, input {
    font: inherit;
}

button {
    color: inherit;
    cursor: pointer;
}

/* Main layout */

.app {
    position: relative;
    width: 100%;
    height: 100vh;
    min-height: 540px;
    overflow: hidden;
    background: var(--bg);
}

.main-content {
    position: absolute;
    inset: 0;
}

#map {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: #dce2dc;
}

.leaflet-container {
    font-family: var(--sans);
}

.leaflet-control-zoom {
    display: none !important;
}

/* Header */

.topbar {
    position: absolute;
    z-index: 500;
    inset: 0 0 auto;
    height: 66px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 25px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.brand,
.topbar-status,
.connection {
    display: flex;
    align-items: center;
}

.brand {
    gap: 12px;
}

.brand-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid var(--green);
    color: var(--green);
    font-family: var(--mono);
    font-weight: 700;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.brand-text h1 {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -.5px;
}

.brand-text span {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 8px;
    letter-spacing: .07em;
}

.topbar-status {
    gap: 20px;
}

.utc-clock {
    font-family: var(--mono);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.connection {
    gap: 8px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 9px;
}

.status-dot {
    width: 7px;
    height: 7px;
    display: inline-block;
    border-radius: 50%;
    background: #c18b3a;
}

.status-dot.online {
    background: var(--green);
    box-shadow: 0 0 0 3px var(--green-soft);
}

.theme-toggle {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: transparent;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 9px;
}

.theme-toggle:hover {
    border-color: var(--green);
    color: var(--green);
}

/* Left console */

.console {
    position: absolute;
    z-index: 400;
    top: 82px;
    bottom: 18px;
    left: 18px;
    width: 355px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow: 0 5px 22px rgba(0, 0, 0, .10);
}

/* Frequency */

.frequency-panel {
    padding: 19px 20px 17px;
    border-bottom: 1px solid var(--line);
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: .06em;
}

.section-code {
    color: var(--faint);
    font-size: 8px;
}

.frequency-display {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 12px;
}

.frequency-value {
    color: var(--ink);
    font-family: var(--mono);
    font-size: 35px;
    font-weight: 500;
    letter-spacing: -2px;
    font-variant-numeric: tabular-nums;
}

.frequency-unit {
    color: var(--muted);
    font-size: 12px;
}

.active-band {
    margin-top: 5px;
    color: var(--green);
    font-family: var(--mono);
    font-size: 9px;
}

/* Band selection */

.band-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin-top: 15px;
}

.band-btn {
    min-height: 31px;
    border: 1px solid var(--line);
    border-radius: 2px;
    background: transparent;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 9px;
}

.band-btn:hover {
    border-color: var(--green);
    color: var(--green);
}

.band-btn.active {
    border-color: var(--green);
    background: var(--green-soft);
    color: var(--green);
}

/* Activity */

.activity-panel {
    padding: 15px 20px;
    border-bottom: 1px solid var(--line);
}

.activity-count {
    display: flex;
    align-items: baseline;
    gap: 9px;
    margin-top: 10px;
}

#stat-count {
    color: var(--green);
    font-family: var(--mono);
    font-size: 24px;
    font-weight: 500;
}

.activity-label {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 8px;
}

#activity-meter {
    width: 100%;
    height: 3px;
    margin-top: 12px;
    overflow: hidden;
    background: var(--line);
}

.activity-meter-fill {
    width: 0;
    height: 100%;
    background: var(--green);
    transition: width .2s ease;
}

#feed-state {
    margin-top: 9px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 8px;
}

/* Report log */

.feed-panel {
    display: flex;
    flex: 1;
    min-height: 100px;
    flex-direction: column;
    padding: 16px 20px 8px;
    overflow: hidden;
}

.feed-controls {
    display: flex;
    gap: 5px;
    margin-top: 12px;
}

.feed-controls button {
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 2px;
    background: transparent;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 8px;
}

.feed-controls button:hover:not(:disabled) {
    border-color: var(--green);
    color: var(--green);
}

.feed-controls button:disabled {
    opacity: .5;
    cursor: wait;
}

#callsign-filter {
    flex-shrink: 0;
    width: 100%;
    height: 35px;
    margin-top: 12px;
    padding: 0 10px;
    outline: none;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: var(--raised);
    color: var(--ink);
    font-family: var(--mono);
    font-size: 9px;
}

#callsign-filter::placeholder {
    color: var(--faint);
}

#callsign-filter:focus {
    border-color: var(--green);
}

#spots-list {
    flex: 1;
    min-height: 0;
    margin: 9px -20px 0;
    padding: 0 20px 8px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
}

.empty-state {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 9px;
}

.spot-card {
    padding: 11px 0;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
}

.spot-card:first-child {
    padding-top: 7px;
}

.spot-topline,
.spot-bottomline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.spot-topline {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 8px;
}

.spot-route {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 8px 0;
    color: var(--ink);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
}

.route-arrow {
    color: var(--green);
}

.spot-info {
    color: var(--muted);
    font-size: 9px;
}

.spot-bottomline {
    margin-top: 8px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 8px;
}

.signal-label {
    color: var(--green);
}

/* Footer */

.console-footer {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 11px 20px;
    border-top: 1px solid var(--line);
    color: var(--faint);
    font-family: var(--mono);
    font-size: 8px;
}

/* Map controls and labels */

.map-section {
    position: absolute;
    inset: 0;
}

.map-caption {
    position: absolute;
    z-index: 400;
    right: 22px;
    bottom: 20px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: var(--panel);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 8px;
}

.map-controls {
    position: absolute;
    z-index: 400;
    top: 84px;
    right: 22px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, .12);
}

.map-controls button {
    width: 36px;
    height: 36px;
    border: 0;
    background: var(--panel);
    color: var(--ink);
    font-size: 18px;
}

.map-controls button + button {
    border-top: 1px solid var(--line);
}

.map-controls button:hover {
    color: var(--green);
}

.map-hub {
    position: absolute;
    z-index: 400;
    left: 390px;
    bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: var(--panel);
    color: var(--ink);
    font-family: var(--mono);
    font-size: 9px;
}

.hub-indicator {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
}

/* Leaflet popups */

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background: var(--panel);
    color: var(--ink);
}

.leaflet-popup-content {
    font-family: var(--mono);
    font-size: 10px;
}

.popup strong {
    color: var(--green);
}

/* Responsive */

@media (max-width: 760px) {
    .topbar {
        height: 58px;
        padding: 0 14px;
    }

    .topbar-status {
        gap: 10px;
    }

    .connection {
        display: none;
    }

    .console {
        top: 70px;
        bottom: 12px;
        left: 10px;
        width: min(355px, calc(100vw - 20px));
    }

    .map-controls {
        top: 72px;
        right: 10px;
    }

    .map-caption {
        right: 10px;
        bottom: 14px;
    }

    .map-hub {
        left: 15px;
        bottom: 55px;
    }
}

@media (max-width: 420px) {
    .brand-text span {
        display: none;
    }

    .utc-clock {
        font-size: 9px;
    }

    .theme-toggle {
        padding: 7px;
    }
}
