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

:root {
    color-scheme: dark;
    --bg-gutter:      #050E18;
    --bg-content:     #091525;
    --bg-header:      #0F2236;
    --bg-box:         #102030;
    --bg-input:       #0A1A2C;
    --bg-hover:       rgba(186, 212, 238, 0.12);
    --bg-detail:      #0C1C2E;
    --bg-detail-json: #081520;
    --bg-table-head:  #1A3450;
    --bg-sig-hover:   #1E3858;
    --bg-sig-active:  #264468;
    --bg-col-sel:     #204878;
    --bg-row-sel:     #162840;
    --bg-row-flash:   rgba(50, 130, 210, 0.45);
    --bg-cell-flash:  rgba(150, 220, 70, 0.35);
    --text-primary:   #E2F0FF;
    --text-secondary: #9EC8E8;
    --text-muted:     #5E90AC;
    --border:         #2A4E6E;
    --border-light:   #1E3C58;
    --shadow:         rgba(0,0,0,0.55);
    --btn-primary-bg: #1565C0;
    --btn-primary-border: #1E88E5;
}
html.light-theme {
    color-scheme: light;
    --bg-gutter:      #0B1D2E;
    --bg-content:     #FDFFF2;
    --bg-header:      #BAD4EE;
    --bg-box:         #FFFFFF;
    --bg-input:       #FFFFFF;
    --bg-hover:       rgba(11, 29, 46, 0.06);
    --bg-detail:      #F5FDE8;
    --bg-detail-json: #EDF8D8;
    --bg-table-head:  #C8DEED;
    --bg-sig-hover:   #E4F0FA;
    --bg-sig-active:  #CAE0F5;
    --bg-col-sel:     #B0CEEA;
    --bg-row-sel:     #F0FDE0;
    --bg-row-flash:   rgba(186, 212, 238, 0.75);
    --bg-cell-flash:  rgba(140, 220, 80, 0.35);
    --text-primary:   #0B1D2E;
    --text-secondary: #264A6A;
    --text-muted:     #506E85;
    --border:         #9BBAD4;
    --border-light:   #C8DEED;
    --shadow:         rgba(11, 29, 46, 0.15);
    --btn-primary-bg: #1565C0;
    --btn-primary-border: #0D47A1;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-gutter);
    min-height: 100vh;
    padding: 0;
    color: var(--text-primary);
    transform-origin: top left;
    transition: transform 0.25s ease, width 0.25s ease;
}
html.ui-small body {
    transform: scale(0.8);
    width: calc(100% / 0.8);
}
html.ui-large body {
    transform: scale(1.3);
    width: calc(100% / 1.3);
}
html.ui-larger body {
    transform: scale(2.0);
    width: calc(100% / 2.0);
}

/* Desktop: all variants boosted by ×1.3 */
@media (min-width: 1024px) {
    body                { transform: scale(1.3);  width: calc(100% / 1.3);  }
    html.ui-small body  { transform: scale(1.04); width: calc(100% / 1.04); }
    html.ui-large body  { transform: scale(1.69); width: calc(100% / 1.69); }
    html.ui-larger body { transform: scale(2.6);  width: calc(100% / 2.6);  }
}

.container {
    margin: 0 8px 8px;
    background: var(--bg-content);
    padding: 8px;
}

.app-footer {
    text-align: center;
    padding: 14px 16px 20px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55);
}

.app-footer a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
}

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

.footer-sep {
    margin: 0 8px;
    color: rgba(255, 255, 255, 0.3);
}

header {
    background: var(--bg-header);
    padding: 8px 16px;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
    z-index: 10;
    box-shadow: 0 3px 8px var(--shadow);
}

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

.header-row-tools {
    border-top: 1px solid var(--border);
    padding-top: 6px;
    margin-top: 2px;
}

.header-stats-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    border-top: 1px solid var(--border);
    padding-top: 6px;
    margin-top: 4px;
}

.app-logo {
    width: 24px;
    height: 24px;
    border-radius: 5px;
    flex-shrink: 0;
}

.app-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.app-version {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    opacity: 0.65;
    text-decoration: none;
    white-space: nowrap;
    margin-left: -2px;
}
.app-version:hover { text-decoration: underline; }

.header-stats {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 14px;
    min-width: 0;
}

.hstat {
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
}

.hstat-label {
    color: var(--text-secondary);
    margin-right: 3px;
}

.hstat-unit {
    color: var(--text-secondary);
    font-size: 10px;
    margin-left: 1px;
}

.hstat span:not(.hstat-label):not(.help-icon) {
    font-weight: 700;
    color: var(--text-primary);
}

/* The status frame is a flex container holding the whole connection control
   cluster: the status word, Connect/Disconnect/Stop buttons, the connected
   device name and the saved-device shortcuts. Its border/background colour
   reflects the connection state (red = disconnected, green = connected,
   yellow = connecting or paused). Individual children are shown or hidden
   per state by the rules further down. */
.status {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 12px;
}

.status-text {
    white-space: nowrap;
}

.status.disconnected {
    background: rgba(200, 40, 40, 0.18);
    color: #e05050;
    border: 1px solid rgba(200, 40, 40, 0.35);
}

.status.connected {
    background: rgba(40, 180, 80, 0.18);
    color: #3db060;
    border: 1px solid rgba(40, 180, 80, 0.35);
}

/* Yellow: a connection attempt is in progress, or collection is paused. */
.status.connecting,
.status.paused,
.status.importing {
    background: rgba(180, 130, 0, 0.18);
    color: #c89820;
    border: 1px solid rgba(180, 130, 0, 0.35);
}

html.light-theme .status.disconnected {
    background: #fee;
    color: #c33;
    border-color: #f8c0c0;
}

html.light-theme .status.connected {
    background: #efe;
    color: #2a9a2a;
    border-color: #b0e8b0;
}

html.light-theme .status.connecting,
html.light-theme .status.paused,
html.light-theme .status.importing {
    background: #fff8e1;
    color: #9a6800;
    border-color: #f0d890;
}

/* --- Per-state visibility of the controls inside the status frame --- */

/* Connect buttons + saved shortcuts make sense only before a connection
   exists (disconnected) or while one is being established (connecting). */
.status.connected #connectBtn,
.status.connected #connectUsbBtn,
.status.connected #connectWifiBtn,
.status.paused #connectBtn,
.status.paused #connectUsbBtn,
.status.paused #connectWifiBtn {
    display: none;
}

/* Saved shortcuts: only when fully disconnected. */
.status:not(.disconnected) #savedDevices {
    display: none;
}

/* Connect buttons carry a small sub-label naming which device kind(s) the
   transport reaches — only USB also takes a repeater. Stacked under the main
   label via a flex column + ::after. */
.btn-connect {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.15;
    gap: 1px;
    padding-top: 4px;
    padding-bottom: 4px;
}
.btn-connect::after {
    content: "(" attr(data-sub) ")";
    font-size: 9px;
    font-weight: 600;
    opacity: 0.8;
}
/* The sub-label belongs to a "Connect …" button. Once a button switches to its
   Cancel/Disconnect role (btn-action), drop it — but keep it through the
   scanning phase, while the label still reads "Connect …". */
.btn-connect.btn-action::after { display: none; }

/* Stop/Resume, Disconnect and the device name make sense only once a
   device is actually connected (green) or paused (yellow). */
.status:not(.connected):not(.paused) #pauseBtn,
.status:not(.connected):not(.paused) #disconnectBtn,
.status:not(.connected):not(.paused) #connectedDeviceName {
    display: none;
}

.connected-device-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.btn-disconnect,
.btn-disconnect:hover:not(:disabled) {
    color: #c0392b;
    border-color: #c0392b;
}

.btn-disconnect:hover:not(:disabled) {
    background: #c0392b;
    color: #fff;
}

.btn-primary {
    -webkit-appearance: none;
    appearance: none;
    background: var(--btn-primary-bg);
    color: white;
    border: 1px solid var(--btn-primary-border);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-primary:hover {
    background: var(--btn-primary-border);
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    background: var(--bg-table-head);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* The pressed/scanning connect button is shown via :disabled. In the light
   theme that lightens its background (the default above), which reads well.
   In the dark theme a lightened background is counterproductive, so keep it
   dark and brighten the text instead. */
html:not(.light-theme) .btn-connect:disabled {
    color: #cfe0f0;
}

.btn-primary.hidden {
    display: none;
}

.btn-pause {
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-box);
    color: #667eea;
    border: 1.5px solid var(--border);
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-pause:hover:not(:disabled) {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.btn-pause:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Discover pressed while not connected: flash the button red. */
.btn-pause.btn-error,
.btn-pause.btn-error:hover:not(:disabled) {
    background: #c0392b;
    color: #fff;
    border-color: #c0392b;
}

.btn-pause.collecting {
    background: var(--bg-box);
    color: #e05a20;
    border-color: #c2410c;
}

.btn-pause.collecting:hover {
    background: #c2410c;
    color: white;
    border-color: #c2410c;
}

.sound-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    padding: 2px 6px;
    border-radius: 6px;
    transition: background 0.2s, box-shadow 0.2s, color 0.2s;
}

/* Sound enabled: prominently highlight the icon, label and dropdown. */
.sound-toggle.sound-active {
    background: rgba(255, 210, 70, 0.85);
    color: #3a2e00;
    font-weight: 700;
    box-shadow: 0 0 0 1.5px rgba(224, 176, 20, 0.85), 0 0 9px rgba(255, 205, 50, 0.6);
}

.sound-toggle.sound-active .ttl-header-select {
    background: #fff6d6;
    border-color: #d9a800;
    color: #3a2e00;
    font-weight: 700;
}

.size-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
    user-select: none;
}

.map-controls .size-label {
    opacity: 0.85;
}

.size-range {
    -webkit-appearance: none;
    appearance: none;
    width: 72px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    cursor: pointer;
    outline: none;
    vertical-align: middle;
}
.size-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: 2px solid var(--bg-header);
}
.size-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: 2px solid var(--bg-header);
}

.size-val {
    min-width: 2.2ch;
    text-align: right;
    color: var(--text-primary);
    font-size: 11px;
}

.map-controls .size-val {
    opacity: 0.8;
}


.section-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    cursor: pointer;
    border-radius: 0;
    padding: 3px 16px;
    margin-left: -8px;
    margin-right: -8px;
    background: var(--bg-table-head);
    box-shadow: 0 2px 6px var(--shadow);
    transition: background 0.15s;
}

.section-hint {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: normal;
    margin-left: auto;
    white-space: nowrap;
}
.section-header:hover {
    background: var(--bg-sig-hover);
}

.section-header:hover .section-title {
    color: var(--text-primary);
}

.section-header:hover .collapse-btn {
    color: var(--text-primary);
}

.section-wrap {
    margin-bottom: 8px;
}

.section-wrap.hidden {
    display: none;
}

.section-body {
    display: grid;
    grid-template-rows: 1fr;
    overflow: hidden;
    transition: grid-template-rows 0.28s ease;
}

.section-body > * {
    min-height: 0;
    /* Grid items default to min-width: auto (= content size). Without this
       the inner wrapper grows to fit a wide table, breaking horizontal
       scrolling and stretching the filter bar past the export button. */
    min-width: 0;
    /* Without border-box, an inner wrapper's padding survives the grid
       collapse and leaves a residual band of background. */
    box-sizing: border-box;
}

.section-body.collapsed {
    grid-template-rows: 0fr;
}

.section-body-inner {
    min-height: 0;
    overflow: hidden;
}

.section-body.collapsed > * {
    padding: 0;
    margin: 0;
}

.collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    padding: 0 2px;
    line-height: 1;
    transition: transform 0.2s, color 0.15s;
    flex-shrink: 0;
}

.collapse-btn:hover {
    color: var(--text-primary);
}

.collapse-btn.collapsed {
    transform: rotate(-90deg);
}

.rep-table-scroll {
    background: var(--bg-box);
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow);
    max-height: 160px;
    overflow: auto;
}

.rep-table-scroll.expanded {
    max-height: none;
}

.rep-table-empty {
    padding: 14px 16px;
    color: var(--text-muted);
    font-style: italic;
}
.rep-table-empty.hidden { display: none; }

.rep-expand-bar {
    padding: 5px 10px 6px;
}

.rep-expand-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.rep-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.rep-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bg-table-head);
    color: var(--text-secondary);
    font-weight: 600;
    text-align: left;
    padding: 5px 6px;
    border-bottom: 1px solid var(--border);
}
.rep-table th:first-child {
    padding-left: 4px;
}

.rep-table th[data-sort-key] {
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, color 0.15s;
}

.rep-table th[data-sort-key]:hover {
    background: var(--bg-sig-hover);
    color: var(--text-primary);
}

.rep-table th.sort-asc::after { content: ' ↑'; }
.rep-table th.sort-desc::after { content: ' ↓'; }

.rep-table td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}
.rep-table td:first-child {
    padding-left: 4px;
}

.rep-table tr:last-child td {
    border-bottom: none;
}

.rl-id {
    font-weight: 700;
    white-space: nowrap;
}

.rl-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
    flex-shrink: 0;
}

.rl-num {
    text-align: right;
}

.rl-time {
    text-align: center;
}

.rep-table th:not(:first-child):last-child {
    text-align: center;
}

.rep-table th:not(:first-child):not(:last-child) {
    text-align: right;
}

.snr-toggle-bar {
    display: flex;
    gap: 14px;
    padding: 3px 2px 5px;
}
.snr-toggle-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}
.snr-toggle-label input[type="checkbox"] {
    accent-color: #667eea;
    cursor: pointer;
}

.chart-box {
    background: var(--bg-box);
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow);
    padding: 8px 8px 4px;
}

.chart-svg-wrap {
    overflow: hidden;
    height: 180px;
    min-height: 80px;
    max-height: calc(100vh - 80px);
}

.chart-resize-handle {
    height: 14px;
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    touch-action: none;
    transition: opacity 0.15s;
    margin-bottom: 2px;
    border-radius: 0 0 4px 4px;
}
.chart-resize-handle:hover,
.chart-resize-handle:active { opacity: 1; }
.chart-resize-handle::before {
    content: '▲  ▼';
    font-size: 12px;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-right: 8px;
    line-height: 1;
    opacity: 0.8;
}
.chart-resize-handle::after {
    content: '';
    display: block;
    width: 40px;
    height: 2px;
    border-radius: 2px;
    background: var(--text-muted);
    box-shadow: 0 -4px 0 var(--text-muted), 0 4px 0 var(--text-muted);
    opacity: 0.55;
}
.chart-resize-handle:hover::before,
.chart-resize-handle:active::before { opacity: 1; color: var(--text-primary); }
.chart-resize-handle:hover::after,
.chart-resize-handle:active::after  { opacity: 1; }

.rssi-chart {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}

.msg-table-empty {
    padding: 14px 16px;
    color: var(--text-muted);
    font-style: italic;
}
.msg-table-empty.hidden { display: none; }

.msg-table-scroll {
    background: var(--bg-box);
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow);
    overflow-x: auto;
}

.msg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
    white-space: nowrap;
}

.msg-table th,
.msg-table td {
    border: 1px solid var(--border);
}

.msg-table th {
    position: sticky;
    top: 0;
    background: var(--bg-table-head);
    color: var(--text-secondary);
    font-weight: 600;
    text-align: center;
    padding: 3px 6px;
    z-index: 1;
}

.msg-table td {
    padding: 1px 5px;
    color: var(--text-primary);
}


.msg-col-rep {
    font-size: 10px;
    font-weight: 700;
    text-align: center;
}

.msg-sub-rssi,
.msg-sub-snr {
    font-size: 8px;
    color: #bbb;
    font-weight: 600;
    text-align: right;
    padding: 1px 4px 2px;
}

.sig-rssi,
.sig-snr {
    font-weight: 700;
    font-size: 10px;
    text-align: right;
    padding: 1px 4px;
}

.empty-state {
    background: var(--bg-box);
    padding: 50px 40px;
    border-radius: 10px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.empty-state.hidden {
    display: none;
}

.saved-devices {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.saved-devices.hidden {
    display: none;
}

.saved-label {
    font-size: 10px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.saved-device {
    display: inline-flex;
    align-items: center;
}

.saved-btn {
    background: var(--bg-box);
    color: #667eea;
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 5px 0 0 5px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.saved-btn:hover {
    background: #667eea;
    color: white;
}

.forget-btn {
    background: var(--bg-box);
    color: #c05050;
    border: 1px solid var(--border);
    border-radius: 0 5px 5px 0;
    padding: 3px 7px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
}

.forget-btn:hover {
    background: #c33;
    color: white;
}

/* Clickable signal cells — RSSI+SNR highlight together as a pair */
.sig-rssi,
.sig-snr {
    cursor: pointer;
    user-select: none;
}

.sig-rssi.sig-pair-hover,
.sig-snr.sig-pair-hover {
    background: var(--bg-sig-hover);
}

.sig-rssi.sig-active,
.sig-snr.sig-active {
    background: var(--bg-sig-active);
}

/* Row animations */
@keyframes rowFlash {
    0%   { background-color: var(--bg-row-flash); }
    100% { background-color: transparent; }
}

.row-new {
    animation: rowFlash 0.8s ease-out forwards;
}

.row-removing {
    transition: opacity 0.35s ease, transform 0.35s ease;
    opacity: 0 !important;
    transform: translateX(14px);
    pointer-events: none;
}

/* Combined RX log cell */
.msg-col-rx-head {
    text-align: center;
}

.msg-col-rx {
    white-space: nowrap;
    padding: 2px 3px 2px 5px;
    width: 1px;
    cursor: pointer;
}

.msg-col-rx:hover {
    background: #f0f0ff;
}

.rx-time {
    color: #aaa;
    font-size: 9px;
}

.rx-type {
    font-size: 10px;
    font-weight: 600;
    color: #555;
    margin-left: 4px;
    display: inline-block;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
}

/* Detail row */
.detail-row td {
    background: var(--bg-detail);
    border-top: none;
}

.detail-cell {
    padding: 6px 10px !important;
    animation: detailOpen 0.16s ease-out;
}

.detail-content {
    font-size: 11px;
    color: #444;
    line-height: 1.7;
}

.detail-content b {
    color: #888;
    font-weight: 600;
}

.detail-type {
    font-size: 13px;
    font-weight: 700;
    color: #333;
    margin-bottom: 6px;
}
.detail-pubkey {
    font-size: 11px;
    color: #666;
    margin-bottom: 6px;
    word-break: break-all;
}
.detail-pubkey code {
    font-size: 11px;
    color: #999;
}

.detail-json {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 10px;
    background: var(--bg-detail-json);
    padding: 5px 8px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
}

.detail-sig {
    font-size: 12px;
    color: #444;
    margin-bottom: 6px;
    padding-bottom: 5px;
    border-bottom: 1px solid #e8e8f0;
    cursor: pointer;
}

.detail-col-name {
    color: #555;
    margin-left: 4px;
    margin-right: 4px;
}

.detail-time {
    color: #888;
    font-size: 11px;
}

/* JSON syntax highlighting inside .detail-json */
.detail-json .jh-key  { color: #7c3aed; font-weight: 600; }
.detail-json .jh-str  { color: #059669; }
.detail-json .jh-num  { color: #2563eb; }
.detail-json .jh-bool { color: #d97706; }
.detail-json .jh-null { color: #9ca3af; }

.raw-hex {
    font-family: 'Courier New', monospace;
    font-size: 9px;
    background: #eee;
    padding: 1px 4px;
    border-radius: 3px;
    cursor: pointer;
    word-break: break-all;
    white-space: normal;
}

.raw-hex:hover {
    background: #667eea;
    color: white;
}

/* Auto-remove in header */
.ttl-header-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
}

.ttl-header-select {
    font-size: 12px;
    padding: 1px 4px;
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    cursor: pointer;
    accent-color: #667eea;
}

#uiScaleSelect {
    min-width: 5em;
}

/* Clear data button (in header, next to auto-remove) */

.btn-clear-data-header {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 11px;
    padding: 1px 8px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-clear-data-header:hover {
    background: rgba(200, 40, 40, 0.12);
    border-color: #c66;
    color: #e05050;
}


.rep-filter-input {
    font-size: 12px;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-primary);
    flex: 1 1 80px;
    min-width: 0;
    max-width: 140px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s, background 0.15s;
}

.rep-filter-input:focus,
.msg-filter-input:focus {
    border-color: var(--text-secondary);
    background: var(--bg-input);
}

.rep-filter-input.has-value,
.msg-filter-input.has-value {
    background: var(--bg-input);
    border-color: #667eea;
}

.chart-tooltip {
    position: fixed;
    background: rgba(30, 30, 40, 0.92);
    color: #fff;
    font-size: 11px;
    line-height: 1.5;
    padding: 5px 9px;
    border-radius: 6px;
    pointer-events: none;
    white-space: nowrap;
    z-index: 1000;
    display: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

/* Positioned in document (body-local) coordinates so it stays anchored to the
   chart point and scrolls with the page. `position: fixed` would break under
   the body `transform: scale()` used by the text-size / desktop zoom feature. */
#chartTooltip {
    position: absolute;
    z-index: 150; /* below the corner notice (B, z-index 200) */
}

/* A pinned infobox (shown on click/tap) can be clicked to dismiss it. No
   pointer cursor — it isn't a link, clicking just closes it. */
#chartTooltip.pinned {
    pointer-events: auto;
}

/* Light theme: keep the infobox light, consistent with the 3D map infobox. */
html.light-theme .chart-tooltip {
    background: rgba(255, 255, 255, 0.95);
    color: #222;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.ct-name {
    display: flex;
    align-items: center;
}

.ct-colname {
    color: #7ab;
    font-size: 11px;
    margin-left: 4px;
}
html.light-theme .ct-colname {
    color: #2a7da0;
}

.ct-sig {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 2px;
}

.ct-time {
    margin-left: auto;
    font-size: 10px;
    opacity: 0.7;
    white-space: nowrap;
}

.battery-status {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.battery-status.hidden {
    display: none;
}

.battery-status.battery-low {
    color: #c33;
}

.batt-icon {
    filter: grayscale(1) brightness(0.85);
}
html.light-theme .batt-icon {
    filter: grayscale(1) brightness(0.45);
}

@keyframes detailOpen {
    from { opacity: 0; transform: translateY(-5px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes detailClose {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-5px); }
}

.detail-row.detail-closing .detail-cell {
    animation: detailClose 0.13s ease-in forwards;
}

/* ── Help system ─────────────────────────────────────── */

.help-btn {
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-box);
    color: #667eea;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 3px 10px;
    line-height: 1;
    flex-shrink: 0;
    white-space: nowrap;
    transition: all 0.15s;
}

.help-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(102, 126, 234, 0.22);
    color: #8fa8f0;
    font-size: 9px;
    font-weight: 700;
    cursor: pointer;
    margin-left: 3px;
    flex-shrink: 0;
    vertical-align: middle;
    user-select: none;
    transition: all 0.15s;
    position: relative;
    top: -1px;
    border: 1px solid rgba(102, 126, 234, 0.35);
}

.help-icon:hover {
    background: #667eea;
    color: white;
}

.help-icon.active {
    background: #667eea;
    color: white;
}

html.light-theme .help-icon {
    background: rgba(70, 90, 200, 0.12);
    color: #3a50c0;
    border-color: rgba(70, 90, 200, 0.30);
}
html.light-theme .help-icon:hover,
html.light-theme .help-icon.active {
    background: #4a5ed0;
    color: white;
}

/* On coloured backgrounds (section headers, filter bar, main header) use
   white-on-translucent so the ? is always visible. */
.section-header .help-icon,
.rep-filter-bar .help-icon,
header .help-icon {
    background: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.90);
    border-color: rgba(255, 255, 255, 0.28);
}

.section-header .help-icon:hover,
.section-header .help-icon.active,
.rep-filter-bar .help-icon:hover,
.rep-filter-bar .help-icon.active,
header .help-icon:hover,
header .help-icon.active {
    background: rgba(255, 255, 255, 0.32);
    color: white;
    border-color: rgba(255, 255, 255, 0.45);
}

/* Shared floating tooltip used by help icons */
.help-tip-float {
    white-space: normal !important;
    max-width: 260px !important;
    font-size: 12px !important;
    line-height: 1.55 !important;
    padding: 8px 11px !important;
    z-index: 1001 !important;
}

/* Help modal */
.help-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 16px;
    overflow: hidden;
    box-sizing: border-box;
}

.help-modal-overlay.hidden {
    display: none;
}

/* ---- WiFi connect modal ---- */
.wifi-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}
.wifi-modal-overlay.hidden { display: none; }
.wifi-modal {
    background: #fff;
    color: #333;
    border-radius: 12px;
    max-width: 360px;
    width: 100%;
    padding: 22px 20px 20px;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
    font-size: 13px;
}
.wifi-modal h3 { margin: 0 0 6px; font-size: 17px; }
.wifi-modal-sub { margin: 0 0 16px; color: #666; line-height: 1.5; }
.wifi-modal-close {
    position: absolute; top: 12px; right: 14px;
    background: none; border: none; font-size: 18px; line-height: 1;
    cursor: pointer; color: #bbb; padding: 0; transition: color 0.15s;
}
.wifi-modal-close:hover { color: #333; }
.wifi-field {
    display: flex; flex-direction: column; gap: 4px;
    font-weight: 600; margin-bottom: 12px;
}
.wifi-field input {
    font-weight: 400; font-size: 15px; padding: 9px 11px;
    border: 1px solid #ccc; border-radius: 8px; box-sizing: border-box;
}
.wifi-field input:focus { outline: none; border-color: #4a90d9; box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.25); }
.wifi-modal-error {
    color: #c0392b; font-size: 12px; margin: -4px 0 12px; line-height: 1.4;
}
.wifi-modal-error.hidden { display: none; }
.wifi-modal-actions {
    display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px;
}

.help-modal {
    background: #262a33;
    border-radius: 12px;
    max-width: 520px;
    width: 100%;
    padding: 22px 20px 26px;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    font-size: 13px;
    line-height: 1.6;
    color: #c8ccd4;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    box-sizing: border-box;
}

.help-modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #888;
    padding: 0;
    line-height: 1;
    transition: color 0.15s;
}

.help-modal-close:hover { color: #e6e8ec; }

.help-modal-title {
    font-size: 17px;
    font-weight: 700;
    color: #f0f1f4;
    margin-bottom: 7px;
    padding-right: 24px;
}

.help-modal-intro {
    color: #99a0ac;
    margin-bottom: 16px;
    font-size: 13px;
}

.help-modal p {
    color: #c0c5cf;
    margin-bottom: 10px;
}

.help-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #9aa2f5;
    margin: 18px 0 8px;
}

.help-dl {
    display: grid;
    /* Cap the term column so a long term (e.g. a code token) wraps instead of
       stretching the column and squashing the definition. */
    grid-template-columns: fit-content(10em) 1fr;
    gap: 6px 14px;
    align-items: baseline;
}

.help-dt {
    font-weight: 700;
    color: #dde0e7;
    font-size: 12px;
    /* Let long tokens (e.g. MESH_PACKET_LOGGING) wrap instead of forcing the
       column wider than the modal. */
    overflow-wrap: anywhere;
    min-width: 0;
}

.help-dd {
    color: #b6bbc5;
    font-size: 12px;
    min-width: 0;
}

.help-list {
    padding-left: 16px;
    color: #b6bbc5;
    font-size: 12px;
}

.help-list li {
    margin-bottom: 6px;
}

.help-modal code {
    background: rgba(255, 255, 255, 0.09);
    padding: 0 3px;
    border-radius: 3px;
    overflow-wrap: anywhere;
}

.help-modal a {
    color: #60a5fa;
    text-decoration: none;
}
.help-modal a:hover { text-decoration: underline; }

/* Light theme: restore the bright modal palette. */
html.light-theme .help-modal { background: #fff; color: #333; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28); }
html.light-theme .help-modal-close { color: #bbb; }
html.light-theme .help-modal-close:hover { color: #333; }
html.light-theme .help-modal-title { color: #333; }
html.light-theme .help-modal-intro { color: #666; }
html.light-theme .help-modal p { color: #555; }
html.light-theme .help-section-title { color: #667eea; }
html.light-theme .help-dt { color: #444; }
html.light-theme .help-dd,
html.light-theme .help-list { color: #555; }
html.light-theme .help-modal code { background: rgba(0, 0, 0, 0.06); }
html.light-theme .help-modal a { color: #1565C0; }

/* ── Filter bar & export ────────────────────────────── */

.msg-filter-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0 5px;
}

.msg-filter-bar.hidden {
    display: none;
}

.msg-filter-input {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 5px;
    outline: none;
    color: var(--text-primary);
    background: var(--bg-input);
    transition: border-color 0.15s, background 0.15s;
    font-family: inherit;
}

.msg-filter-clear {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 11px;
    padding: 3px 7px;
    transition: all 0.15s;
    flex-shrink: 0;
    line-height: 1;
}

.msg-filter-clear:hover {
    background: rgba(255, 255, 255, 0.28);
    color: white;
}

.msg-filter-clear.hidden {
    display: none;
}

html.light-theme .msg-filter-clear {
    background: rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.25);
    color: rgba(0, 0, 0, 0.65);
}
html.light-theme .msg-filter-clear:hover {
    background: rgba(0, 0, 0, 0.16);
    color: rgba(0, 0, 0, 0.9);
}

.msg-filter-count {
    font-size: 11px;
    /* Theme-aware so it stays legible in the light theme too (a hardcoded
       translucent white vanished on a light background). */
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.msg-filter-count.hidden {
    display: none;
}

.rep-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 0 6px;
}

.rep-filter-label {
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
}

.rep-filter-bar .rep-filter-input {
    flex: 0 1 180px;
    max-width: 220px;
}

.filter-applied-indicator {
    background: #ff3b3b;
    color: white;
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 7px;
    border-radius: 3px;
    white-space: nowrap;
    box-shadow: 0 0 0 1px rgba(255, 80, 80, 0.4), 0 2px 6px rgba(255, 60, 60, 0.35);
    animation: filterAppliedPulse 1.6s ease-in-out infinite;
}

.filter-applied-indicator.hidden {
    display: none;
}

@keyframes filterAppliedPulse {
    0%, 100% { box-shadow: 0 0 0 1px rgba(255, 80, 80, 0.4), 0 2px 6px rgba(255, 60, 60, 0.35); }
    50%      { box-shadow: 0 0 0 2px rgba(255, 80, 80, 0.6), 0 2px 10px rgba(255, 60, 60, 0.6); }
}

@keyframes cellFlash {
    0%   { background-color: var(--bg-cell-flash); }
    100% { background-color: transparent; }
}

.sig-rssi.cell-flash,
.sig-snr.cell-flash {
    animation: cellFlash 0.8s ease-out forwards;
}

/* ---- Signal 3D map ---- */

.map-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 8px 4px;
    font-size: 12px;
    color: rgba(255,255,255,0.8);
}

.map-controls .btn-primary.hidden {
    display: none;
}

.location-status {
    font-weight: 400;
    opacity: 0.65;
}

.location-status-settings {
    font-size: 11px;
    color: #aaa;
    font-style: italic;
}

.btn-show-all-repeaters {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 5px;
    border: 1px solid rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.15);
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
}
.btn-show-all-repeaters:hover {
    background: rgba(255,255,255,0.28);
    border-color: rgba(255,255,255,0.7);
}
html.light-theme .btn-show-all-repeaters {
    border-color: rgba(0,0,0,0.35);
    background: rgba(0,0,0,0.12);
    color: #0f1a2e;
}
html.light-theme .btn-show-all-repeaters:hover {
    background: rgba(0,0,0,0.22);
}
/* Pressed / active state (e.g. "Center on me" while follow mode is on).
   Scoped under html.light-theme as well so it beats the light-theme base
   rule's specificity. Text colour is left to the theme default (dark text in
   light theme, white in dark) — only the blue border/ring marks it pressed. */
.btn-show-all-repeaters.active,
.btn-show-all-repeaters.active:hover,
html.light-theme .btn-show-all-repeaters.active,
html.light-theme .btn-show-all-repeaters.active:hover {
    background: rgba(79, 140, 255, 0.22);
    border-color: #4f8cff;
    box-shadow: 0 0 0 1px #4f8cff, 0 0 8px rgba(79, 140, 255, 0.55);
}

.map-hint {
    font-size: 11px;
    opacity: 0.65;
}

.map-source-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #c0c0c0;
}

.map-source-select {
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 12px;
    color: #444;
    cursor: pointer;
}

.map-source-select:hover {
    border-color: #bbb;
}

.map-container {
    position: relative;
    width: 100%;
    height: 460px;
    min-height: 200px;
    max-height: calc(100vh - 80px);
    border-radius: 8px;
    overflow: hidden;
    background: #eef2f7;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
}

.map-resize-handle {
    height: 14px;
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    touch-action: none;
    transition: opacity 0.15s;
    margin-bottom: 2px;
    border-radius: 0 0 4px 4px;
}
.map-resize-handle:hover,
.map-resize-handle:active { opacity: 1; }
.map-resize-handle::before {
    content: '▲  ▼';
    font-size: 12px;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-right: 8px;
    line-height: 1;
    opacity: 0.8;
}
.map-resize-handle::after {
    content: '';
    display: block;
    width: 40px;
    height: 2px;
    border-radius: 2px;
    background: var(--text-muted);
    box-shadow: 0 -4px 0 var(--text-muted), 0 4px 0 var(--text-muted);
    opacity: 0.55;
}
.map-resize-handle:hover::before,
.map-resize-handle:active::before { opacity: 1; color: var(--text-primary); }
.map-resize-handle:hover::after,
.map-resize-handle:active::after  { opacity: 1; }

.map-fullscreen-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(255, 255, 255, 0.85);
    border: none;
    border-radius: 6px;
    width: 30px;
    height: 30px;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
    z-index: 10;
    backdrop-filter: blur(4px);
    transition: background 0.15s;
    line-height: 1;
}

.map-fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.97);
}

.map-container:fullscreen {
    border-radius: 0;
    max-height: 100vh;
    height: 100vh;
    resize: none;
}

.map-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: grab;
}

.map-canvas:active {
    cursor: grabbing;
}

.map-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    color: #777;
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

.map-empty.hidden {
    display: none;
}

/* WebGL unavailable: collapse the map area to just an inline notice */
.map-offline .map-controls,
.map-offline .map-canvas,
.map-offline .map-fullscreen-btn {
    display: none;
}

.map-offline .map-container {
    height: auto;
    min-height: 0;
    resize: none;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

.map-offline .map-empty {
    position: static;
    padding: 2px 0 8px;
    color: #aab;
    font-size: 12px;
    text-align: left;
    justify-content: flex-start;
    pointer-events: auto;
}
html.light-theme .map-offline .map-empty {
    color: #444;
}

.map-info {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 8px;
    padding: 7px 11px 8px;
    font-size: 12px;
    line-height: 1.6;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.13);
    backdrop-filter: blur(4px);
    min-width: 0;
    pointer-events: auto;
}

.map-info.hidden {
    display: none;
}

.smi-close {
    position: absolute;
    top: 5px;
    right: 7px;
    background: none;
    border: none;
    font-size: 11px;
    color: #999;
    cursor: pointer;
    padding: 2px 3px;
    line-height: 1;
}

.smi-close:hover {
    color: #333;
}

.smi-look,
.smi-pin {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    padding: 0 2px;
    margin-left: 6px;
    opacity: 0.8;
    flex-shrink: 0;
}

.smi-look:hover,
.smi-pin:hover {
    opacity: 1;
}

/* Inline SVG pushpin: drawn pointing straight down, so upright = kept on the
   map and a CSS tilt = shown only temporarily. Platform-independent. */
.smi-pin {
    display: inline-flex;
    align-items: center;
    transform: rotate(32deg);
    transition: transform 0.15s ease;
}

.smi-pin.pinned {
    transform: rotate(0deg);
    opacity: 1;
}

.smi-pin-svg {
    width: 16px;
    height: 16px;
    display: block;
}

.smi-name {
    font-size: 12px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 0;
    padding-right: 16px;
}

.smi-colname {
    font-size: 11px;
    font-weight: normal;
    color: #8cc;
    margin-left: 5px;
}

.smi-filter {
    margin-top: 6px;
    display: block;
    width: 100%;
    padding: 3px 0;
    font-size: 11px;
    background: #4a6cf7;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.smi-filter:hover {
    background: #3558e8;
}

.smi-sig {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.smi-time {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 10px;
    white-space: nowrap;
    opacity: 0.75;
}

@media (max-width: 600px) {
    .map-container { height: 340px; }
    .map-hint { display: none; }
}

/* ---- Debug section ---- */

.debug-inner {
    padding: 2px 4px 4px;
}

.debug-hint {
    color: #aab;
    font-size: 11px;
    margin: 0 0 8px;
    line-height: 1.5;
}
html.light-theme .debug-hint {
    color: #444;
}

.debug-hint code {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 10px;
}
html.light-theme .debug-hint code {
    background: rgba(0, 0, 0, 0.1);
    color: #222;
}

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

.debug-input-label {
    font-size: 11px;
    color: #aab;
    white-space: nowrap;
}
html.light-theme .debug-input-label {
    color: #444;
}

.debug-input {
    flex: 0 1 220px;
    font-size: 12px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg-input);
    color: var(--text-primary);
    outline: none;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    transition: border-color 0.15s, background 0.15s;
}

.debug-input:focus {
    border-color: var(--text-secondary);
    background: var(--bg-input);
}

.debug-feedback {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.85);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---- Map settings gear ---- */
.map-settings-wrap {
    position: relative;
    margin-left: auto;
}

.map-settings-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.45);
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    padding: 2px 5px;
    color: rgba(255,255,255,0.9);
    line-height: 1;
}
.map-settings-btn:hover { background: rgba(255,255,255,0.28); border-color: rgba(255,255,255,0.7); }
html.light-theme .map-settings-btn {
    background: rgba(0,0,0,0.12);
    border-color: rgba(0,0,0,0.35);
    color: #0f1a2e;
}
html.light-theme .map-settings-btn:hover { background: rgba(0,0,0,0.22); border-color: rgba(0,0,0,0.6); }

.map-settings-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 50;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.13);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 240px;
    max-width: min(320px, calc(100vw - 24px));
    white-space: normal;
    word-break: break-word;
    color: #444;
}
.map-settings-panel.hidden { display: none; }

.map-setting-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    cursor: pointer;
    color: #444;
    white-space: normal;
}
.map-setting-toggle input[type="checkbox"] { cursor: pointer; }

.map-settings-panel .size-label,
.map-settings-panel .size-val { color: #444; }

/* ---- Repeater table selection ---- */
.rl-id-clickable { cursor: pointer; }
.rl-id-clickable:hover { text-decoration: underline; }

.rl-row-sel { background: var(--bg-row-sel) !important; font-weight: 600; }
.rl-row-dim { opacity: 0.4; }

/* ---- Message table column selection ---- */
th.msg-col-rep { cursor: pointer; }
th.msg-col-rep:hover { background: var(--bg-sig-hover); }
th.col-sel { background: var(--bg-col-sel) !important; color: var(--text-primary) !important; font-weight: 700; }
th.col-dim { opacity: 0.4; }
td.col-dim { opacity: 0.25; }

/* ---- Corner notices (filter / selection) ---- */
.corner-notice {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 200;
    background: var(--bg-box);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 4px 20px var(--shadow);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 180px;
    max-width: 300px;
    font-size: 12px;
    color: var(--text-primary);
}
.corner-notice.hidden { display: none; }

.corner-notice-line1 {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-secondary);
}
.corner-notice-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}
.corner-notice-id {
    font-weight: 700;
    color: var(--text-primary);
}
.corner-notice-close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 1px 3px;
    line-height: 1;
    flex-shrink: 0;
}
.corner-notice-close:hover { color: var(--text-primary); }
.corner-notice-name {
    font-size: 12px;
    font-weight: 600;
    color: #8cc;
    margin: 2px 0 4px;
}
.corner-notice-name-inline {
    font-size: 11px;
    font-weight: 600;
    color: #8cc;
    margin-left: 4px;
}
.corner-notice-extra {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.cn-showmore-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}
.cn-stats {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--bg-table-head);
    border-radius: 5px;
    padding: 5px 7px;
}
.cn-contact-note {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}
.cn-contact-note .help-icon {
    font-style: normal;
}
.cn-showmore-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.cn-map-btns {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
}
.cn-map-btn {
    padding: 3px 8px;
    border-radius: 5px;
    border: 1px solid rgba(80,140,200,0.35);
    background: rgba(40,70,120,0.25);
    cursor: pointer;
    font-size: 11px;
    color: #8bbcdc;
    text-align: left;
}
.cn-map-btn:hover { background: rgba(40,70,120,0.4); border-color: rgba(80,140,200,0.6); }
.cn-map-btn-active { background: rgba(40,100,40,0.3); border-color: rgba(80,180,80,0.45); color: #8dd88d; }
.cn-map-btn-active:hover { background: rgba(40,100,40,0.45); }
html.light-theme .cn-map-btn {
    border: 1px solid #b8d8e8;
    background: #e8f4fb;
    color: #2a6080;
}
html.light-theme .cn-map-btn:hover { background: #d0eaf8; border-color: #80b8d8; }
html.light-theme .cn-map-btn-active { background: #c8e8c8; border-color: #80b880; color: #206020; }
html.light-theme .cn-map-btn-active:hover { background: #b8ddb8; }

html.light-theme .smi-colname,
html.light-theme .corner-notice-name,
html.light-theme .corner-notice-name-inline,
html.light-theme .rl-name,
html.light-theme .col-contact-name,
html.light-theme .contacts-loading { color: #1a6080; }
.corner-notice-btns {
    display: flex;
    gap: 6px;
}
.corner-notice-btn {
    padding: 4px 9px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--bg-table-head);
    cursor: pointer;
    font-size: 11px;
    color: var(--text-primary);
    flex: 1;
    text-align: center;
    white-space: nowrap;
}
.corner-notice-btn:hover { background: var(--bg-hover); border-color: var(--text-muted); }
.corner-notice-btn-primary {
    background: var(--btn-primary-bg);
    border-color: var(--btn-primary-border);
    color: #fff;
    font-weight: 600;
}
.corner-notice-btn-primary:hover { background: var(--btn-primary-border); border-color: var(--btn-primary-bg); }

.rl-name {
    display: block;
    font-size: 10px;
    color: #8cc;
    font-weight: normal;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 10em;
}
.col-contact-name {
    font-size: 9px;
    font-weight: normal;
    color: #8cc;
    display: block;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.ttl-header-select option {
    font-size: 13px;
}
.contacts-loading {
    font-size: 11px;
    color: #8cc;
    font-style: italic;
    margin-left: 12px;
}
.ping-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0 8px;
}
.ping-hint {
    font-size: 12px;
    color: #aab;
}
html.light-theme .ping-hint {
    color: #444;
}
.theme-toggle-btn {
    background: rgba(40,40,60,0.75);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    border-radius: 5px;
    padding: 2px 8px;
    font-size: 13px;
    cursor: pointer;
    line-height: 1.6;
}
.theme-toggle-btn:hover {
    background: rgba(60,60,90,0.90);
}
html.light-theme .theme-toggle-btn {
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(0,0,0,0.25);
    color: #f0f0f0;
}
html.light-theme .theme-toggle-btn:hover {
    background: rgba(0,0,0,0.55);
    color: #fff;
}

/* Repeater stock-firmware caveat banner */
.repeater-notice.hidden { display: none; }
.repeater-notice {
    position: relative;
    margin: 0 0 14px;
    padding: 12px 36px 12px 14px;
    border: 1px solid #B8860B;
    border-left: 4px solid #E0A800;
    border-radius: 6px;
    background: rgba(224, 168, 0, 0.10);
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}
.repeater-notice strong { color: var(--text-primary); }
.repeater-notice p { margin: 7px 0 0; }
.repeater-notice ul { margin: 4px 0 0; padding-left: 20px; }
.repeater-notice li { margin: 2px 0; }
.repeater-notice code {
    background: var(--bg-input);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
}
.repeater-notice-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    line-height: 20px;
    text-align: center;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
}
.repeater-notice-close:hover { background: var(--bg-hover); color: var(--text-primary); }

/* --- Unexpected-disconnect alarm: subdued red wash + centered modal --- */
.disconnect-alarm {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(180, 30, 30, 0.22);
}
.disconnect-alarm.hidden { display: none; }
.disconnect-alarm-box {
    background: var(--bg-box);
    border: 2px solid #c0392b;
    border-radius: 12px;
    padding: 24px 28px;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}
.disconnect-alarm-icon { font-size: 42px; line-height: 1; }
.disconnect-alarm-title {
    font-size: 18px;
    font-weight: 700;
    color: #c0392b;
    margin: 10px 0 6px;
}
.disconnect-alarm-msg {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 18px;
}
