/* Audio Audit. Loads after groups.css; the panel uses the shared .nd-panel / .nd-top / .nd-controls styles and the Crate tokens.
   The stage is a CHALKBOARD in a wooden frame in every theme, so the zone colours always read from the back of a room.
   Zone colours are the five highlighters (sky, leaf, sun, tomato) and are never the only signal: the words, the number, the number of
   lit crates and the limit line say the same thing. Everything is flat: solid fills, chalk outlines, hard offset shadows. */
.nm-main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 12px; gap: 10px; }
.nm-stage-wrap { flex: 1; min-height: min(56vh, 420px); display: flex; }
.nm-stage {
  --board: #1B2625; --chalk: #EDE4CB; --frame: #202D2C; --frame-d: #5E716B; --cast-c: transparent;
  --z-idle: #8FA19A; --z-calm: #6BB6B0; --z-good: #AFC48B; --z-warn: #E8BB56; --z-loud: #C76B48;
  --zc: var(--z-idle);
  position: relative; flex: 1; min-width: 0; container-type: size; display: grid; place-items: center; overflow: hidden; color: var(--chalk);
  background-color: var(--board); background-image: none;
  border: 1px solid var(--frame-d); border-radius: 12px; box-shadow: inset 0 0 0 7px var(--board), inset 0 0 0 8px rgb(175 196 139 / .35);
}
.nm-stage[data-zone=calm] { --zc: var(--z-calm); } .nm-stage[data-zone=good] { --zc: var(--z-good); }
.nm-stage[data-zone=warn] { --zc: var(--z-warn); } .nm-stage[data-zone=loud] { --zc: var(--z-loud); }
.nm-face { position: absolute; inset: 0 0 clamp(52px, 17cqh, 150px); display: grid; place-items: center; }
.nm-orb, .nm-stack, .nm-wave { display: none; }
.nm-stage[data-face=orb] .nm-orb { display: grid; } .nm-stage[data-face=stack] .nm-stack { display: flex; } .nm-stage[data-face=wave] .nm-wave { display: block; }

/* Dial: a flat disc that grows with the noise, inside a chalk target */
.nm-orb { position: relative; width: min(58cqmin, 500px); aspect-ratio: 1; place-items: center; }
.nm-orb::before { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid #f4efe040; }
.nm-orb > i { position: absolute; inset: 0; border-radius: 50%; }
.nm-orb-glow { background: var(--zc); opacity: .22; transform: scale(calc(.3 + var(--lv, 0) * .7)); transition: transform .1s steps(4); }
.nm-orb-core { background: var(--zc); border: 5px solid var(--chalk); box-shadow: none; transform: scale(calc(.3 + var(--lv, 0) * .62)); transition: transform .1s steps(4); }
.nm-orb-peak { border: 3px solid var(--chalk); transform: scale(calc(.3 + var(--pk, 0) * .62)); opacity: .8; transition: transform .2s steps(5); }
.nm-orb::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 4px dashed var(--chalk); transform: scale(calc(.3 + var(--ceil, .35) * .62)); pointer-events: none; opacity: .95; }

/* Crates: a tower that rises with the noise; empty slots are chalk outlines */
.nm-stack { flex-direction: column-reverse; gap: 1.3cqmin; width: min(36cqmin, 300px); height: min(62cqmin, 520px); position: relative; }
.nm-block { flex: 1; border-radius: 1.2cqmin; background: transparent; border: 2px dashed #f4efe059; transition: background .1s steps(3), transform .1s steps(3); }
.nm-block.on { border: 3px solid var(--chalk); box-shadow: none; translate: -.4cqmin -.4cqmin; }
.nm-block.on[data-z=calm] { background: var(--z-calm); } .nm-block.on[data-z=good] { background: var(--z-good); }
.nm-block.on[data-z=warn] { background: var(--z-warn); } .nm-block.on[data-z=loud] { background: var(--z-loud); }
.nm-ceil { position: absolute; left: -12%; right: -12%; bottom: calc(var(--ceil, .35) * 100%); border-top: 4px dashed var(--chalk); pointer-events: none; }
.nm-ceil::after { content: "LIMIT"; position: absolute; right: 0; bottom: 5px; font: 800 clamp(11px, 2.6cqmin, 18px)/1 var(--font-display); letter-spacing: .18em; color: var(--chalk); }

/* History: one bar for each of the last 60 seconds */
.nm-wave { width: 88%; height: 54%; overflow: visible; shape-rendering: crispEdges; }
.nm-wave .bar { stroke: var(--cast-c); stroke-width: 2; }
.nm-wave .z-calm { fill: var(--z-calm); } .nm-wave .z-good { fill: var(--z-good); } .nm-wave .z-warn { fill: var(--z-warn); } .nm-wave .z-loud { fill: var(--z-loud); }
.nm-wave .now { stroke: var(--chalk); stroke-width: 3; }
.nm-wave .base { stroke: var(--chalk); stroke-width: 3; }

/* Words and number */
.nm-word { position: absolute; left: 0; right: 0; bottom: 4cqh; text-align: center; font: 800 clamp(26px, 8cqmin, 84px)/1 var(--font-display); letter-spacing: .02em; text-transform: uppercase;  }
.nm-num { position: absolute; top: 4cqh; right: 4cqw; font: 800 clamp(24px, 8cqmin, 80px)/1 var(--font-display); font-variant-numeric: tabular-nums;  }
.nm-num:empty, .nm-word:empty { display: none; }
.nm-stage[data-face=orb] .nm-num { top: 50%; right: auto; left: 50%; translate: -50% -50%; font-size: clamp(30px, 15cqmin, 150px);  }
.nm-stage[data-status=demo]::before { content: "DEMO"; position: absolute; top: 12px; left: 14px; padding: 4px 10px; border: 2px solid var(--chalk); border-radius: 6px; font: 800 12px/1 var(--font-display); letter-spacing: .2em; }

/* Alarm: the wooden frame turns tomato and blinks in steps */
.nm-stage[data-alarm=true] { border-color: var(--z-loud); box-shadow: inset 0 0 0 7px var(--board), inset 0 0 0 8px var(--z-loud); }

/* Panel */
.nm-presets { display: grid; gap: 6px; }
.nm-preset { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; padding: 8px 12px; min-height: 0; height: auto; }
.nm-preset small { color: var(--muted); font-weight: 500; font-size: var(--t-cap); }
.nm-preset[aria-pressed=true] { border-color: var(--ui-accent); box-shadow: inset 0 0 0 1px var(--ui-accent); background: color-mix(in srgb, var(--ui-accent) 10%, var(--raised)); }
.nm-panel input[type=range] { width: 100%; padding: 0; accent-color: var(--ui-accent); }
.nm-panel label output { font-weight: 700; color: var(--ink); }
.nm-scale { display: flex; justify-content: space-between; margin: 2px 0 8px; }
.nm-key { list-style: none; margin: var(--s2) 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: var(--t-cap); color: var(--muted); }
.nm-key li { display: flex; align-items: center; gap: 6px; }
.nm-key i, .nm-rep i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; background: var(--c); flex: none; }
.nm-key [data-zone=calm], .nm-rep[data-zone=calm] { --c: #38bdf8; } .nm-key [data-zone=good], .nm-rep[data-zone=good] { --c: #34d399; }
.nm-key [data-zone=warn], .nm-rep[data-zone=warn] { --c: #fbbf24; } .nm-key [data-zone=loud], .nm-rep[data-zone=loud] { --c: #ff5d73; }
.nm-reportbars { display: grid; gap: 6px; }
.nm-rep { display: grid; grid-template-columns: 96px 1fr 38px; align-items: center; gap: 8px; font-size: var(--t-cap); }
.nm-rep i { width: auto; height: 10px; border-radius: 6px; background: linear-gradient(90deg, var(--c) var(--w, 0%), color-mix(in srgb, var(--ink) 10%, transparent) var(--w, 0%)); }
.nm-rep b { text-align: right; font-variant-numeric: tabular-nums; }
.nm-repbtns { display: flex; gap: 8px; margin: 6px 0; }

/* Full screen */
.nm-main.nm-fs { position: fixed; inset: 0; z-index: 60; background: var(--bg); padding: 18px; }
.nm-main:fullscreen { background: var(--bg); padding: 18px; }
.nm-fs .nd-hint { display: none; }

@media (max-width: 800px) { .nm-stage-wrap { flex: none; height: min(72vh, 640px); } }
@media (prefers-reduced-motion: no-preference) {
  .nm-stage[data-zone=idle] .nm-orb-core { animation: nm-breathe 3.2s steps(8) infinite; }
  .nm-stage[data-alarm=true] { animation: nm-blink 1s steps(2) infinite; }
  .nm-stage[data-alarm=true][data-face=stack] .nm-stack { animation: nm-shake .4s steps(2) infinite; }
  .nm-stage[data-alarm=true][data-face=orb] .nm-orb-core { animation: nm-thump .5s steps(3) infinite; }
  @keyframes nm-breathe { 50% { scale: 1.06; } }
  @keyframes nm-blink { 50% { border-color: #ffb199; } }
  @keyframes nm-shake { 25% { translate: .9cqmin 0; } 75% { translate: -.9cqmin 0; } }
  @keyframes nm-thump { 50% { scale: 1.05; } }
}
@media (prefers-reduced-motion: reduce) { .nm-orb-glow, .nm-orb-core, .nm-orb-peak, .nm-block { transition: none; } }
@media print { .nm-main { display: none !important; } }
