/* Audio lane UI (web/audio.js): "hears" pills on the node markers, the node rail, the unplaced tray,
   the tools drawer and the manual ground-truth layer. Loaded after style.css and reuses its tokens. */

#map.mode-armed { cursor: crosshair; }

/* worker banner + chip */
.banner { position: absolute; top: 56px; left: calc((100% - var(--rail-w)) / 2); transform: translateX(-50%); z-index: 810; background: rgba(245,158,11,.16); border: 1px solid var(--color-warning); color: #fcd34d; padding: 6px 14px; border-radius: var(--radius-control); font-size: 12px; font-weight: 600; white-space: nowrap; }
#tools-toggle.on { background: var(--color-signal); color: var(--color-bg); border-color: transparent; font-weight: 600; }

/* layers additions */
.layers-sep { height: 1px; background: var(--color-border); margin: 6px 0 4px; }
.badge-manual { background: rgba(168,85,247,.18); color: #d8b4fe; border: 1px solid rgba(168,85,247,.4); }
.truth-tools { display: flex; gap: 6px; margin: 2px 0 4px; }
.truth-tools .btn { flex: 1; padding: 4px 8px; min-height: 26px; font-size: 12px; }
#truth-add[aria-pressed="true"] { background: var(--color-signal); color: var(--color-bg); border-color: transparent; }
.layer-note { margin: 4px 0; font-size: 11px; line-height: 15px; color: var(--color-text-muted); max-width: 230px; }

/* unplaced phones tray */
.unplaced-tray { position: absolute; left: 16px; bottom: 64px; z-index: 820; max-width: 260px; background: rgba(13,27,43,.94); backdrop-filter: blur(8px); border: 1px solid var(--color-warning); border-radius: var(--radius-panel); padding: 10px 12px; }
.unplaced-tray h4 { margin: 0 0 6px; font-size: 12px; color: #fcd34d; }
.unplaced-list { display: flex; flex-direction: column; gap: 4px; max-height: 160px; overflow-y: auto; }
.unplaced-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 8px; border-radius: 6px; background: var(--color-surface); border: 1px solid transparent; cursor: pointer; font-size: 12px; }
.unplaced-item:hover { border-color: var(--color-border); }
.unplaced-item.armed { border-color: var(--color-signal); background: rgba(34,211,238,.12); }
.unplaced-tray .hint { margin: 6px 0 0; font-size: 11px; color: var(--color-text-muted); }

/* ground truth form + marker */
.truth-form { position: absolute; left: 16px; bottom: 64px; z-index: 940; width: 250px; background: rgba(13,27,43,.96); border: 1px solid var(--color-signal); border-radius: var(--radius-panel); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-panel); }
.truth-form label { font-size: 11px; color: var(--color-text-muted); }
.truth-form input { font: 500 13px var(--font-sans); background: var(--color-surface-raised); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--radius-control); padding: 6px 8px; }
.truth-form .controls { display: flex; gap: 6px; }
.truth-form .controls .btn { flex: 1; }
.hint { margin: 0; font-size: 11px; line-height: 15px; color: var(--color-text-muted); }
.hint code { color: var(--color-signal); }
.truth-marker { width: 14px; height: 14px; background: #fff; border: 2px solid #000; transform: rotate(45deg); box-shadow: 0 0 4px rgba(0,0,0,.6); cursor: pointer; }
.leaflet-tooltip.truth-label { background: rgba(5,11,20,.88); color: #fff; border: 1px solid rgba(255,255,255,.4); font: 700 10px/13px var(--font-mono); letter-spacing: .04em; text-transform: uppercase; padding: 2px 6px; }

/* node rail */
.sub-head { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--color-text-muted); margin: 6px 0 4px; display: flex; justify-content: space-between; gap: 8px; }
.sub-head:first-of-type { margin-top: 0; }
.node-list { display: flex; flex-direction: column; gap: 8px; }
.node-row { border: 1px solid var(--color-border); border-radius: var(--radius-control); padding: 8px 10px; }
.node-row.status-offline { opacity: .55; }
.node-row-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; flex-wrap: wrap; }
.node-row .status-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--color-unknown); }
.node-row.status-live .status-dot { background: var(--color-signal); }
.node-row.status-stale .status-dot { background: var(--color-warning); }
.node-row-label { font-weight: 600; font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-status { font: 600 9px/12px var(--font-sans); letter-spacing: .04em; text-transform: uppercase; color: var(--color-text-muted); }
.node-row-meta { font-size: 11px; color: var(--color-text-secondary); margin-bottom: 4px; display: flex; flex-wrap: wrap; gap: 4px 8px; }
.node-row-meta .clip-warn { color: var(--color-danger); font-weight: 700; }
.capture-flags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.capture-flag { font: 600 10px/14px var(--font-sans); padding: 0 5px; border-radius: 4px; background: rgba(245,158,11,.16); color: #fcd34d; border: 1px solid rgba(245,158,11,.4); }
.class-bars { display: flex; flex-direction: column; gap: 3px; margin-bottom: 4px; }
.class-bar-row { display: grid; grid-template-columns: 62px 1fr 34px; align-items: center; gap: 6px; font-size: 11px; }
.class-bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-text-secondary); }
.class-bar-track { position: relative; height: 8px; background: var(--color-surface-raised); border-radius: 999px; }
.class-bar-fill { position: absolute; inset: 0; width: 0; border-radius: 999px; background: var(--color-fusion); transition: width var(--duration-standard) var(--ease-standard); }
.class-bar-fill.active { box-shadow: 0 0 6px currentColor; }
.class-bar-tick { position: absolute; top: -2px; bottom: -2px; width: 1px; background: rgba(245,249,252,.55); }
.class-bar-tick.off { background: rgba(245,249,252,.3); }
.class-bar-row .val { text-align: right; color: var(--color-text-muted); }
#audio-nodes.worker-offline .class-bars, #audio-nodes.worker-offline .top-labels { opacity: .4; }
.quiet-toggle { display: block; width: 100%; padding: 4px 8px; font-size: 11px; min-height: 24px; margin: 2px 0; }
.top-labels { font-size: 10px; color: var(--color-text-muted); margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-row-actions { display: flex; gap: 6px; }
.node-row-actions .btn { flex: 1; padding: 5px 8px; font-size: 12px; min-height: 26px; }
.btn-danger { border-color: var(--color-danger); color: #fca5a5; }
.node .drop { color: #fcd34d; font-size: 10px; margin-left: 2px; }

.clip-wrap { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; padding: 6px 8px; background: var(--color-surface); border-radius: var(--radius-control); border: 1px solid var(--color-border); }
.clip-wrap span { font-size: 11px; color: var(--color-text-muted); }
.clip-wrap audio { width: 100%; height: 32px; }

/* provenance tags — always visible, never hidden behind a hover */
.tag-prov { font: 600 9px/12px var(--font-mono); letter-spacing: .05em; padding: 0 4px; border-radius: 3px; white-space: nowrap; }
.prov-replay { color: #d8b4fe; background: rgba(168,85,247,.2); border: 1px solid rgba(168,85,247,.45); }
.prov-warn { color: #fcd34d; background: rgba(245,158,11,.18); border: 1px solid rgba(245,158,11,.45); }
.prov-off { color: var(--color-text-muted); background: rgba(100,116,139,.2); border: 1px solid rgba(100,116,139,.5); }

/* tools drawer */
.tools { position: absolute; top: 0; right: 0; bottom: 0; width: min(380px, 100%); z-index: 950; background: var(--color-surface); border-left: 1px solid var(--color-border); box-shadow: var(--shadow-panel); display: flex; flex-direction: column; gap: 8px; padding: 12px; overflow-y: auto; }
.tools-head { display: flex; align-items: center; justify-content: space-between; }
.tools-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.tool-form { display: flex; flex-direction: column; gap: 6px; }
.tool-form input[type=text], .tool-form input[type=file], .tool-form select { font: 500 12px var(--font-sans); background: var(--color-surface-raised); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--radius-control); padding: 6px 8px; width: 100%; }
.tool-form .inline { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--color-text-secondary); }
.tool-form .inline input { accent-color: var(--color-signal); }
.tool-form .controls { display: flex; gap: 6px; margin-top: 2px; }
.tool-form .controls .btn { flex: 1; }
.rec-indicator { color: var(--color-danger); font-size: 11px; font-weight: 700; animation: recblink 1.2s steps(2, jump-none) infinite; }
@keyframes recblink { 50% { opacity: .25; } }
.replay-list { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.replay-item { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 6px; border-radius: 6px; background: var(--color-surface); }
.replay-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.replay-item button { padding: 3px 8px; min-height: 24px; font-size: 11px; }
.thresholds { display: flex; flex-direction: column; gap: 10px; }
.threshold-row { font-size: 12px; }
.threshold-row .head { display: flex; justify-content: space-between; margin-bottom: 3px; }
.threshold-row .head .name { display: flex; align-items: center; gap: 6px; }
.threshold-row .swatch { width: 9px; height: 9px; border-radius: 3px; }
.threshold-sliders { display: flex; flex-direction: column; gap: 2px; }
.threshold-sliders .row { display: grid; grid-template-columns: 30px 1fr 34px; align-items: center; gap: 6px; }
.threshold-sliders label { font-size: 10px; color: var(--color-text-muted); }
.threshold-sliders input[type=range] { accent-color: var(--color-signal); width: 100%; }
.threshold-sliders .v { font-size: 11px; color: var(--color-text-muted); text-align: right; }
.tune-globals { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; margin-top: 8px; border-top: 1px solid var(--color-border); }
.tune-row { display: grid; grid-template-columns: 108px 1fr 40px; align-items: center; gap: 8px; font-size: 12px; }
.tune-row label { color: var(--color-text-secondary); }
.tune-row input[type=range] { accent-color: var(--color-signal); width: 100%; }
.tune-row .v { text-align: right; color: var(--color-text-muted); }

/* toast */
.toast { position: absolute; left: 16px; right: calc(var(--rail-w) + 16px); bottom: 16px; z-index: 960; display: flex; justify-content: center; pointer-events: none; }
.toast span { background: rgba(239,68,68,.92); color: #fff; font-size: 12px; font-weight: 600; padding: 7px 14px; border-radius: 999px; box-shadow: var(--shadow-panel); }

/* map marker for an audio node: 28 px ring, pills above, label + provenance tags below */
.node-marker { width: 140px; display: flex; flex-direction: column; align-items: center; }
.node-marker > * { pointer-events: none; }
.node-anchor { position: relative; width: 28px; height: 28px; flex: none; }
.node-pills { position: absolute; left: 50%; bottom: calc(100% + 5px); transform: translateX(-50%); display: flex; flex-direction: column-reverse; align-items: center; gap: 3px; }
.node-pill { display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; font: 800 10px/13px var(--font-sans); letter-spacing: .03em; padding: 2px 7px; border-radius: 5px; box-shadow: 0 1px 4px rgba(0,0,0,.65), 0 0 0 1px rgba(5,11,20,.55); }
.node-pill.pill-drone { font-size: 12px; line-height: 15px; padding: 3px 9px; border-radius: 6px; animation: dronepulse 1.6s ease-in-out infinite; }
@keyframes dronepulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,.55), 0 1px 4px rgba(0,0,0,.65), 0 0 0 1px rgba(5,11,20,.55); } 50% { box-shadow: 0 0 0 6px rgba(245,158,11,0), 0 1px 4px rgba(0,0,0,.65), 0 0 0 1px rgba(5,11,20,.55); } }
.node-ring { width: 28px; height: 28px; border-radius: 50%; border: 2.5px solid var(--color-signal); background: rgba(13,27,43,.92); position: relative; box-shadow: 0 0 0 2px var(--color-bg-deep); pointer-events: auto; cursor: grab; }
.node-core { position: absolute; inset: 0; margin: auto; width: 10px; height: 10px; border-radius: 50%; background: var(--color-signal); }
.node-marker.status-stale .node-ring { border-color: var(--color-warning); border-style: dashed; }
.node-marker.status-stale .node-core { background: var(--color-warning); }
.node-marker.status-offline .node-ring { border-color: var(--color-unknown); opacity: .55; }
.node-marker.status-offline .node-core { background: var(--color-unknown); }
.node-marker.capture-warn .node-ring { border-color: var(--color-warning); }
.node-marker.source-replay .node-ring { outline: 2px dashed var(--color-fusion); outline-offset: 3px; }
.node-marker.source-sim .node-ring { outline: 2px dashed var(--color-forecast); outline-offset: 3px; }
.node-level-bar { width: 30px; height: 4px; border-radius: 2px; background: var(--color-surface-raised); margin-top: 3px; overflow: hidden; }
.node-level-bar i { display: block; height: 100%; width: 0; background: var(--color-signal); }
.node-marker.status-offline .node-level-bar { visibility: hidden; }
.node-label { font: 700 12px/15px var(--font-sans); color: #fff; max-width: 136px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; background: rgba(5,11,20,.75); padding: 1px 7px; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.5); }
.node-tags { display: flex; gap: 3px; margin-top: 2px; flex-wrap: wrap; justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  .node-pill.pill-drone { animation: none; box-shadow: 0 0 0 2px rgba(245,158,11,.7), 0 0 0 1px rgba(5,11,20,.8); }
  .rec-indicator { animation: none; }
  .class-bar-fill { transition: none; }
}

@media (max-width: 900px) {
  /* the topbar does not wrap: keep the worker state as a coloured dot and shrink the Tools button */
  #worker-pill span { display: none; }
  #worker-pill { padding: 6px; }
  #tools-toggle { padding: 4px 8px; min-height: 26px; font-size: 12px; }
  .banner { left: 50%; top: 104px; }
  .tools { width: 100%; }
  .unplaced-tray, .truth-form { max-width: calc(100vw - 32px); bottom: calc(45% + 56px); }
  .toast { right: 16px; bottom: calc(45% + 12px); }
}
