.maf-shell {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
    width: 100%;
}

.maf-canvas-host {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.maf-host-root {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow: hidden;
    touch-action: none;
}

.maf-theme-light {
    background: var(--bg-primary, #f1f5f9);
}

.maf-theme-dark {
    background: #0f172a;
}

.maf-shell[data-theme="dark"] {
    background: #0f172a;
    color: #e2e8f0;
}

.maf-svg {
    display: block;
    width: 100%;
    height: 100%;
    flex: 1;
    min-height: 0;
    cursor: grab;
}

.maf-svg:active {
    cursor: grabbing;
}

.maf-stratum {
    fill: rgba(214, 211, 205, 0.35);
    stroke: none;
}

.maf-stratum-0 { fill: rgba(226, 232, 240, 0.55); }
.maf-stratum-1 { fill: rgba(217, 207, 190, 0.4); }
.maf-stratum-2 { fill: rgba(203, 196, 184, 0.38); }

.maf-shaft-column {
    fill: rgba(14, 165, 233, 0.12);
    stroke: rgba(14, 165, 233, 0.45);
    stroke-width: 2;
    rx: 4;
}

.maf-depth-line {
    stroke: rgba(100, 116, 139, 0.28);
    stroke-width: 1;
    stroke-dasharray: 5 7;
}

.maf-depth-label,
.maf-axis-caption {
    font-family: Inter, system-ui, sans-serif;
    fill: var(--text-secondary, #475569);
    font-size: 12px;
    font-weight: 500;
}

.maf-axis-caption {
    fill: var(--text-tertiary, #64748b);
    font-size: 11px;
}

.maf-edge-vertical {
    stroke: rgba(14, 165, 233, 0.55);
    stroke-width: 2;
    stroke-dasharray: 6 5;
}

.maf-fork-arm {
    fill: none;
    stroke: rgba(100, 116, 139, 0.5);
    stroke-width: 3;
    stroke-linecap: round;
}

.maf-fork-arm-highlight {
    fill: none;
    stroke: rgba(126, 34, 206, 0.35);
    stroke-width: 5;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

.maf-tunnel-bore-path {
    fill: none;
    stroke: #94a3b8;
    stroke-width: 34;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

.maf-split-hub {
    fill: rgba(243, 232, 255, 0.85);
    stroke: #7e22ce;
    stroke-width: 3;
    pointer-events: none;
}

.maf-split-halo {
    fill: rgba(243, 232, 255, 0.45);
    stroke: #a855f7;
    stroke-width: 2;
    pointer-events: none;
}

.maf-bore-outline {
    stroke: #475569;
    stroke-width: 38;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    pointer-events: none;
}

.maf-bore-fill {
    stroke: rgba(203, 213, 225, 0.95);
    stroke-width: 34;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    pointer-events: none;
}

.maf-bore-centerline {
    stroke: rgba(71, 85, 105, 0.3);
    stroke-width: 1.25;
    stroke-dasharray: 5 5;
    fill: none;
    pointer-events: none;
}

.maf-bore-length-chip {
    fill: rgba(255, 255, 255, 0.92);
    stroke: rgba(100, 116, 139, 0.45);
    stroke-width: 1;
    pointer-events: none;
}

.maf-bore-length-chip-text {
    font-family: Inter, system-ui, sans-serif;
    font-size: 8px;
    font-weight: 700;
    fill: #475569;
    pointer-events: none;
}

/* legacy aliases retained for any cached references */
.maf-tunnel-band {
    fill: rgba(148, 163, 184, 0.62);
    stroke: #64748b;
    stroke-width: 2;
}

.maf-tunnel-label {
    font-family: Inter, system-ui, sans-serif;
    font-size: 10px;
    font-weight: 600;
    fill: var(--text-secondary, #475569);
    pointer-events: none;
}

.maf-tunnel-label-below {
    fill: var(--text-tertiary, #64748b);
}

.maf-shape {
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
}

.maf-shaft {
    fill: rgba(14, 165, 233, 0.92);
    stroke: #0369a1;
}

.maf-shaft-head {
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.2));
}

.maf-shaft-label {
    font-weight: 600;
    font-size: 11px;
}

.maf-accessPoint {
    fill: rgba(204, 251, 241, 0.95);
    stroke: #0f766e;
}

.maf-ap-icon-base {
    fill: rgba(13, 148, 136, 0.95);
    stroke: #0f766e;
    stroke-width: 1.5;
}

.maf-ap-icon-wave {
    fill: none;
    stroke: #0f766e;
    stroke-width: 2;
    stroke-linecap: round;
}

.maf-ap-icon-dot {
    fill: #0f766e;
    stroke: none;
}

.maf-ap-ssid-chip {
    fill: rgba(204, 251, 241, 0.98);
    stroke: rgba(15, 118, 110, 0.55);
    stroke-width: 1;
    pointer-events: none;
}

.maf-ap-ssid-chip-text {
    font-family: Inter, system-ui, sans-serif;
    font-size: 7px;
    font-weight: 700;
    fill: #0f766e;
    pointer-events: none;
}

.maf-ap-connector {
    stroke: rgba(15, 118, 110, 0.65);
    stroke-width: 2;
    stroke-dasharray: 3 4;
    stroke-linecap: round;
    fill: none;
    pointer-events: none;
}

.maf-split {
    fill: rgba(243, 232, 255, 0.98);
    stroke: #7e22ce;
    stroke-width: 2.5;
}

.maf-tunnel {
    fill: rgba(241, 245, 249, 0.9);
    stroke: #475569;
}

.maf-lampRoom {
    fill: rgba(254, 249, 195, 0.95);
    stroke: #a16207;
}

.maf-lampRoom-card {
    filter: drop-shadow(0 1px 3px rgba(120, 53, 15, 0.15));
}

.maf-lampRoom-bulb {
    fill: #fbbf24;
    stroke: #b45309;
    stroke-width: 1.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.maf-sensor {
    fill: rgba(254, 243, 199, 0.98);
    stroke: #b45309;
}

.maf-sensor-in-tunnel {
    fill: #f59e0b;
    stroke: #92400e;
    stroke-width: 2;
}

.maf-sensor-halo {
    fill: rgba(245, 158, 11, 0.18);
    stroke: none;
    pointer-events: none;
}

.maf-sensor-tunnel-label {
    font-size: 9px;
    fill: #92400e;
}

.maf-generic {
    fill: #fff;
    stroke: #64748b;
}

.maf-node-label {
    font-family: Inter, system-ui, sans-serif;
    font-size: 10px;
    font-weight: 600;
    fill: #0f172a;
    pointer-events: none;
}

.maf-node-sublabel {
    font-family: Inter, system-ui, sans-serif;
    font-size: 8px;
    font-weight: 500;
    fill: #0f766e;
    pointer-events: none;
}

.maf-live-status {
    position: absolute;
    left: 12px;
    top: 12px;
    z-index: 6;
    max-width: min(520px, calc(100% - 24px));
    padding: 8px 12px;
    border-radius: 8px;
    font-family: Inter, system-ui, sans-serif;
    font-size: 12px;
    line-height: 1.4;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(148, 163, 184, 0.4);
    color: #334155;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

.maf-live-status-ok {
    border-color: rgba(245, 158, 11, 0.45);
    background: rgba(255, 251, 235, 0.96);
    color: #92400e;
}

.maf-live-status-warn {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(254, 242, 242, 0.96);
    color: #991b1b;
}

.maf-live-confidence {
    fill: rgba(245, 158, 11, 0.12);
    stroke: rgba(245, 158, 11, 0.55);
    stroke-width: 1.5;
    stroke-dasharray: 4 3;
}

.maf-live-dot {
    fill: #f59e0b;
    stroke: #b45309;
    stroke-width: 2;
}

.maf-live-miner {
    pointer-events: none;
    filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.45));
}

.maf-live-pulse {
    animation: maf-live-pulse 2s ease-in-out infinite;
}

@keyframes maf-live-pulse {
    0%, 100% { opacity: 1; stroke-width: 2; }
    50% { opacity: 0.75; stroke-width: 3; }
}

.maf-live-in-tunnel {
    pointer-events: none;
}

.maf-live-sensor-hit {
    cursor: pointer;
}

.maf-live-hit-target {
    fill: transparent;
    stroke: none;
    pointer-events: all;
    cursor: pointer;
}

.maf-live-selected .maf-live-dot {
    stroke: #1d4ed8;
    stroke-width: 3;
}

.maf-live-selected .maf-live-confidence {
    stroke: rgba(29, 78, 216, 0.75);
    fill: rgba(59, 130, 246, 0.15);
}

.maf-live-selected .maf-live-miner {
    filter: drop-shadow(0 0 4px rgba(59, 130, 246, 0.95));
}

.maf-sensor-callout {
    position: absolute;
    z-index: 10;
    min-width: 220px;
    max-width: 280px;
    padding: 10px 12px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(148, 163, 184, 0.45);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
    font-family: Inter, system-ui, sans-serif;
    font-size: 12px;
    color: #0f172a;
    pointer-events: auto;
}

.maf-sensor-callout-hidden {
    display: none;
}

.maf-callout-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #64748b;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.maf-callout-close:hover {
    background: rgba(148, 163, 184, 0.15);
    color: #0f172a;
}

.maf-callout-header {
    font-size: 13px;
    font-weight: 700;
    margin: 0 28px 8px 0;
    color: #92400e;
}

.maf-callout-body {
    margin: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
}

.maf-callout-body dt {
    margin: 0;
    color: #64748b;
    font-weight: 500;
}

.maf-callout-body dd {
    margin: 0;
    font-weight: 600;
    color: #0f172a;
}

.maf-callout-warn {
    color: #b91c1c !important;
}

.maf-callout-scans {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 2px;
    max-height: 88px;
    overflow-y: auto;
}

.maf-callout-scan {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 11px;
    font-weight: 500;
    color: #334155;
}

.maf-callout-scan span {
    color: #64748b;
    font-weight: 600;
    white-space: nowrap;
}

.maf-live-confidence.maf-live-in-tunnel {
    fill: rgba(245, 158, 11, 0.18);
    stroke: rgba(245, 158, 11, 0.65);
}

.maf-live-label {
    font-family: Inter, system-ui, sans-serif;
    font-size: 10px;
    font-weight: 600;
    fill: #92400e;
    pointer-events: none;
}

.maf-legend-overlay {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
    pointer-events: none;
    font-family: Inter, system-ui, sans-serif;
    font-size: 11px;
    color: var(--text-primary, #0f172a);
}

.maf-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.maf-legend-icon {
    display: inline-flex;
    width: 32px;
    justify-content: center;
}

.maf-legend-label {
    line-height: 1;
}

.maf-footer-note {
    margin: 0;
    font-size: 0.78rem;
    color: #94a3b8;
    line-height: 1.45;
    text-align: left;
    width: 100%;
}

.maf-shell[data-theme="dark"] .maf-host-root,
.maf-shell[data-theme="dark"] .maf-theme-dark {
    background: #0f172a;
}

.maf-shell[data-theme="dark"] .maf-stratum-0 { fill: rgba(30, 41, 59, 0.55); }
.maf-shell[data-theme="dark"] .maf-stratum-1 { fill: rgba(38, 38, 46, 0.5); }
.maf-shell[data-theme="dark"] .maf-stratum-2 { fill: rgba(30, 35, 45, 0.5); }

.maf-shell[data-theme="dark"] .maf-depth-label,
.maf-shell[data-theme="dark"] .maf-axis-caption {
    fill: rgba(226, 232, 240, 0.85);
}

.maf-shell[data-theme="dark"] .maf-depth-line {
    stroke: rgba(148, 163, 184, 0.22);
}

.maf-shell[data-theme="dark"] .maf-edge-vertical {
    stroke: rgba(56, 189, 248, 0.42);
}

.maf-shell[data-theme="dark"] .maf-shaft-column {
    fill: rgba(14, 165, 233, 0.16);
    stroke: rgba(56, 189, 248, 0.5);
}

.maf-shell[data-theme="dark"] .maf-bore-outline {
    stroke: #1e293b;
}

.maf-shell[data-theme="dark"] .maf-bore-fill {
    stroke: rgba(71, 85, 105, 0.95);
}

.maf-shell[data-theme="dark"] .maf-bore-centerline {
    stroke: rgba(148, 163, 184, 0.3);
}

.maf-shell[data-theme="dark"] .maf-tunnel-label {
    fill: rgba(203, 213, 225, 0.92);
}

.maf-shell[data-theme="dark"] .maf-tunnel-label-below {
    fill: rgba(148, 163, 184, 0.85);
}

.maf-shell[data-theme="dark"] .maf-node-label {
    fill: #f1f5f9;
}

.maf-shell[data-theme="dark"] .maf-accessPoint {
    fill: rgba(13, 148, 136, 0.28);
    stroke: #2dd4bf;
}

.maf-shell[data-theme="dark"] .maf-ap-icon-base {
    fill: rgba(45, 212, 191, 0.92);
    stroke: #5eead4;
}

.maf-shell[data-theme="dark"] .maf-ap-icon-wave {
    stroke: #5eead4;
}

.maf-shell[data-theme="dark"] .maf-ap-icon-dot {
    fill: #134e4a;
}

.maf-shell[data-theme="dark"] .maf-ap-connector {
    stroke: rgba(45, 212, 191, 0.7);
}

.maf-shell[data-theme="dark"] .maf-lampRoom {
    fill: rgba(161, 98, 7, 0.35);
    stroke: #fbbf24;
}

.maf-shell[data-theme="dark"] .maf-node-sublabel {
    fill: rgba(148, 163, 184, 0.9);
}

.maf-shell[data-theme="dark"] .maf-shaft {
    fill: rgba(14, 165, 233, 0.9);
    stroke: #38bdf8;
}

.maf-shell[data-theme="dark"] .maf-shaft-head {
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
}

.maf-shell[data-theme="dark"] .maf-sensor-in-tunnel {
    fill: #fbbf24;
    stroke: #b45309;
}

.maf-shell[data-theme="dark"] .maf-live-status {
    background: rgba(15, 23, 42, 0.9);
    border-color: rgba(148, 163, 184, 0.3);
    color: #e2e8f0;
}

.maf-shell[data-theme="dark"] .maf-legend-overlay {
    background: rgba(15, 23, 42, 0.88);
    border-color: rgba(148, 163, 184, 0.2);
    color: #e2e8f0;
}

.maf-shell[data-theme="dark"] .maf-sensor-callout {
    background: rgba(15, 23, 42, 0.97);
    border-color: rgba(148, 163, 184, 0.3);
    color: #e2e8f0;
}

.maf-shell[data-theme="dark"] .maf-callout-close {
    color: #94a3b8;
}

.maf-shell[data-theme="dark"] .maf-callout-close:hover {
    background: rgba(148, 163, 184, 0.12);
    color: #f1f5f9;
}

.maf-shell[data-theme="dark"] .maf-callout-header {
    color: #fbbf24;
}

.maf-shell[data-theme="dark"] .maf-callout-body dt {
    color: #94a3b8;
}

.maf-shell[data-theme="dark"] .maf-callout-body dd {
    color: #f1f5f9;
}

.maf-shell[data-theme="dark"] .maf-callout-scan {
    color: #cbd5e1;
}

.maf-shell[data-theme="dark"] .maf-callout-scan span {
    color: #94a3b8;
}

/* --- Ant Farm rework: toolbar, grid, uncertainty, callout v2 --- */

.maf-toolbar {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 6;
    display: flex;
    gap: 6px;
    padding: 6px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.82);
    border: 1px solid rgba(148, 163, 184, 0.25);
    backdrop-filter: blur(8px);
}

.maf-tool-btn {
    min-width: 34px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 7px;
    background: rgba(30, 41, 59, 0.9);
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.maf-tool-btn:hover {
    background: rgba(51, 65, 85, 0.95);
    border-color: rgba(148, 163, 184, 0.45);
}

.maf-distance-gridline {
    stroke: rgba(148, 163, 184, 0.14);
    stroke-width: 1;
    stroke-dasharray: 4 8;
}

.maf-distance-tick {
    font-family: Inter, system-ui, sans-serif;
    font-size: 10px;
    font-weight: 600;
    fill: rgba(148, 163, 184, 0.85);
}

.maf-level-pill {
    fill: rgba(245, 158, 11, 0.55);
}

.maf-callout-meta {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 8px;
}

.maf-callout-aps {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(148, 163, 184, 0.25);
}

.maf-callout-aps-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    margin-bottom: 6px;
}

.maf-callout-ap-row {
    font-size: 11px;
    font-weight: 500;
    color: #334155;
    padding: 3px 0;
}

.maf-live-uncertainty {
    fill: rgba(245, 158, 11, 0.12);
    stroke-width: 2;
    pointer-events: none;
}

.maf-live-uncertainty.maf-live-conf-high {
    stroke: rgba(34, 197, 94, 0.75);
    fill: rgba(34, 197, 94, 0.1);
}

.maf-live-uncertainty.maf-live-conf-med {
    stroke: rgba(245, 158, 11, 0.75);
    fill: rgba(245, 158, 11, 0.1);
}

.maf-live-uncertainty.maf-live-conf-low {
    stroke: rgba(248, 113, 113, 0.75);
    fill: rgba(248, 113, 113, 0.08);
}

.maf-live-uncertainty-pulse {
    fill: none;
    stroke: rgba(245, 158, 11, 0.35);
    stroke-width: 1.5;
    pointer-events: none;
    animation: maf-uncertainty-pulse 2.4s ease-out infinite;
}

@keyframes maf-uncertainty-pulse {
    0% { opacity: 0.85; transform-origin: center; }
    70% { opacity: 0; }
    100% { opacity: 0; }
}

.maf-shell[data-theme="dark"] .maf-distance-tick {
    fill: rgba(203, 213, 225, 0.75);
}

.maf-shell[data-theme="dark"] .maf-distance-gridline {
    stroke: rgba(100, 116, 139, 0.22);
}

.maf-shell[data-theme="dark"] .maf-callout-meta {
    color: #94a3b8;
}

.maf-shell[data-theme="dark"] .maf-callout-ap-row {
    color: #cbd5e1;
}

.maf-shell[data-theme="dark"] .maf-legend-overlay {
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.maf-shell[data-theme="dark"] .maf-bore-length-chip {
    fill: rgba(30, 41, 59, 0.92);
    stroke: rgba(100, 116, 139, 0.5);
}

.maf-shell[data-theme="dark"] .maf-bore-length-chip-text {
    fill: #cbd5e1;
}

.maf-shell[data-theme="dark"] .maf-ap-ssid-chip {
    fill: rgba(19, 78, 74, 0.85);
    stroke: rgba(45, 212, 191, 0.45);
}

.maf-shell[data-theme="dark"] .maf-ap-ssid-chip-text {
    fill: #99f6e4;
}
