/* =============================================================
   Klangregie Reference — style.css
   Brand: Squaresmile Media / Klangregie
   Architecture: BEM, CSS custom properties, mobile-first
   ============================================================= */

/* === SECTION 1: DESIGN TOKENS =============================== */

:root {
  --bg-primary:    #0f0f0f;
  --bg-surface:    #1a1d22;
  --text-primary:  #f0ece4;
  --text-muted:    #9e9e9e; /* ~5.1:1 on #0f0f0f — WCAG AA (QA-05) */
  --accent-amber:  #e8a838;
  --accent-teal:   #3a8c8c;
  --color-success: #47c78a;
  --color-warning: #f5b759;
  --color-error:   #ef5b5b;
  --glow-amber:    0 0 60px rgba(232, 168, 56, 0.15);
  --transition:    0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --radius:        12px;
  --font-heading:  'Playfair Display', Georgia, serif;
  --font-body:     'DM Sans', system-ui, sans-serif;
  --font-mono:     'DM Mono', monospace;

  /* Spacing scale */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Layout heights */
  --top-bar-height:    56px;
  --tab-bar-height:    48px;
  --footer-height:     48px;
  --content-max-width: 1200px;
}

/* === SECTION 2: BOX-SIZING RESET AND BODY =================== */

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === SECTION 3: DIM MODE =================================== */

.body--dim {
  filter: brightness(0.6);
}

/* === SECTION 4: SCREEN-READER UTILITY ====================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === SECTION 5: GLOBAL FOCUS-VISIBLE ======================= */

:focus-visible {
  outline: 2px solid var(--accent-amber);
  outline-offset: 2px;
}

/* === SECTION 6: TOP BAR ==================================== */

.top-bar {
  height: var(--top-bar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid rgba(240, 236, 228, 0.08);
  box-shadow: var(--glow-amber);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar__title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--accent-amber);
  margin: 0;
}

.top-bar__controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.top-bar__venue-select {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid rgba(240, 236, 228, 0.15);
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  min-height: 44px;
  transition: border-color var(--transition);
}

.top-bar__venue-select:hover { border-color: var(--accent-teal); }
.top-bar__venue-select:focus-visible { outline: 2px solid var(--accent-teal); outline-offset: 2px; }

.top-bar__btn {
  background: transparent;
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  min-height: 44px;
  cursor: pointer;
  transition: background-color var(--transition);
}

.top-bar__btn--save {
  border: 1px solid var(--accent-teal);
  color: var(--accent-teal);
}
.top-bar__btn--save:hover  { background: rgba(58, 140, 140, 0.12); }
.top-bar__btn--save:active { background: rgba(58, 140, 140, 0.20); }
.top-bar__btn--save:focus-visible { outline: 2px solid var(--accent-teal); outline-offset: 2px; }

.top-bar__btn--delete {
  border: 1px solid var(--color-error);
  color: var(--color-error);
}
.top-bar__btn--delete:hover  { background: rgba(239, 91, 91, 0.12); }
.top-bar__btn--delete:active { background: rgba(239, 91, 91, 0.20); }
.top-bar__btn--delete:focus-visible { outline: 2px solid var(--color-error); outline-offset: 2px; }

.top-bar__dim-toggle {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 20px;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: color var(--transition);
}
.top-bar__dim-toggle:hover { color: var(--text-primary); }
.top-bar__dim-toggle:focus-visible { outline: 2px solid var(--accent-amber); outline-offset: 2px; }
.top-bar__dim-toggle[aria-pressed="true"] { color: var(--accent-amber); }
.top-bar__dim-toggle[aria-pressed="true"]:hover { color: var(--accent-amber); opacity: 0.8; }

/* === SECTION 7: TAB BAR ==================================== */

.tab-bar {
  height: var(--tab-bar-height);
  background: var(--bg-surface);
  display: flex;
  align-items: stretch;
  position: sticky;
  top: var(--top-bar-height);
  z-index: 90;
}

.tab-bar__item {
  flex: 1;
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  min-height: 44px;
  padding: 0 var(--space-md);
  cursor: pointer;
  transition: color var(--transition), background-color var(--transition), border-color var(--transition);
}

.tab-bar__item:hover {
  color: var(--text-primary);
  background: rgba(240, 236, 228, 0.05);
}

.tab-bar__item--active {
  color: var(--accent-amber);
  border-bottom-color: var(--accent-amber);
}

.tab-bar__item:focus-visible {
  outline: 2px solid var(--accent-amber);
  outline-offset: -2px;
}

/* === SECTION 8: APP MAIN AND TAB PANELS ==================== */

.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-md);
  min-height: calc(100vh - var(--top-bar-height) - var(--tab-bar-height) - var(--footer-height));
}

.tab-panel { display: none; }
.tab-panel--active { display: block; }
.tab-panel[hidden] { display: none; }

.tab-panel__heading {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-primary);
  margin: 0 0 var(--space-md) 0;
}

.tab-panel__stub {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  margin: 0 0 var(--space-lg) 0;
}

.tab-panel__print-btn {
  background: transparent;
  border: 1px solid var(--accent-amber);
  color: var(--accent-amber);
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  min-height: 44px;
  cursor: pointer;
  transition: background-color var(--transition);
}
.tab-panel__print-btn:hover  { background: rgba(232, 168, 56, 0.10); }
.tab-panel__print-btn:active { background: rgba(232, 168, 56, 0.18); }
.tab-panel__print-btn:focus-visible { outline: 2px solid var(--accent-amber); outline-offset: 2px; }

/* === SECTION 9: SCREEN-READER LIVE REGION ================== */

.sr-announcer {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === SECTION 10: FOOTER ==================================== */

.footer {
  min-height: var(--footer-height);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-md);
}

.footer__text {
  margin: 0;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
}

.footer__link {
  color: var(--accent-teal);
  text-decoration: none;
  transition: color var(--transition);
}
.footer__link:hover  { color: var(--accent-amber); }
.footer__link:focus-visible { outline: 2px solid var(--accent-teal); outline-offset: 2px; }

/* === SECTION 11: RESPONSIVE BREAKPOINTS ==================== */

@media (min-width: 768px) {
  .top-bar { padding: 0 var(--space-lg); }
  .tab-bar__item { flex: 0 1 auto; min-width: 80px; }
  .app-main { padding: var(--space-lg); }
}

@media (min-width: 1280px) {
  .app-main { padding: var(--space-2xl) var(--space-lg); }
}

@media (min-width: 1920px) {
  .app-main { padding: var(--space-2xl) var(--space-lg); }
}

/* === SECTION 12: SPL GRID ================================== */

.spl-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

@media (min-width: 768px) {
  .spl-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
  }
}

/* === SECTION 13: CALCULATOR CARDS ========================== */

.calc-card {
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: var(--space-md);
}

@media (min-width: 768px) {
  .calc-card {
    padding: var(--space-lg);
  }
}

.calc-card__title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-primary);
  margin: 0 0 var(--space-md) 0;
}

.calc-card__input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
}

.calc-card__label {
  display: block;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
}

.calc-card__input {
  display: block;
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid rgba(240, 236, 228, 0.15);
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 400;
  color: var(--text-primary);
  min-height: 44px;
  transition: border-color var(--transition);
}

.calc-card__input:hover {
  border-color: rgba(240, 236, 228, 0.35);
}

.calc-card__input:focus-visible {
  outline: 2px solid var(--accent-amber);
  outline-offset: 2px;
}

.calc-card__input::placeholder {
  color: var(--text-muted);
  font-style: normal;
}

.calc-card__input--invalid {
  border-color: var(--color-error);
}

.calc-card__unit {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: var(--space-xs);
}

.calc-card__result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: var(--space-md);
  border-top: 1px solid rgba(240, 236, 228, 0.08);
  padding-top: var(--space-md);
}

.calc-card__result-label {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.calc-card__result {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--accent-amber);
}

.calc-card__result--success { color: var(--color-success); }
.calc-card__result--warning { color: var(--color-warning); }
.calc-card__result--error   { color: var(--color-error); }

.calc-card__result-unit {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
}

/* === SECTION 14: HEARING DAMAGE TIMER ====================== */

.damage-timer__toggle-group {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
}

.damage-timer__toggle {
  background: var(--bg-primary);
  border: 1px solid rgba(240, 236, 228, 0.15);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  min-height: 44px;
  min-width: 64px;
  padding: var(--space-xs) var(--space-sm);
  cursor: pointer;
  transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}

.damage-timer__toggle:hover {
  border-color: rgba(240, 236, 228, 0.35);
  color: var(--text-primary);
}

.damage-timer__toggle--active {
  background: rgba(232, 168, 56, 0.12);
  border-color: var(--accent-amber);
  color: var(--accent-amber);
}

.damage-timer__toggle--active:hover {
  background: rgba(232, 168, 56, 0.18);
}

.damage-timer__conversion {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
  margin: 0 0 var(--space-sm) 0;
}

.damage-timer__limits {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-top: var(--space-md);
  border-top: 1px solid rgba(240, 236, 228, 0.08);
  padding-top: var(--space-md);
}

.damage-timer__limit-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.damage-timer__limit-label {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 var(--space-xs) 0;
}

.damage-timer__limit-result {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--accent-amber);
  margin: 0;
}

.damage-timer__limit-result--success { color: var(--color-success); }
.damage-timer__limit-result--warning { color: var(--color-warning); }
.damage-timer__limit-result--error   { color: var(--color-error); }

/* === SECTION 15: SPL REFERENCE CHART ======================= */

.spl-chart {
  height: 280px;
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: var(--space-md);
  margin-top: var(--space-xl);
}

.spl-chart canvas {
  width: 100%;
  height: 100%;
}

/* === SECTION 16: LUFS GRID AND INPUT CARD ================== */

.lufs-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

@media (min-width: 768px) {
  .lufs-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
  }
}

.lufs-input-card {
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
}

.lufs-input-card .calc-card__input {
  min-height: 44px; /* WCAG 2.5.5 touch target minimum — functional exception */
}

.lufs-input-card__subtitle {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  margin: var(--space-xs) 0 var(--space-md) 0;
}

/* === SECTION 17: PLATFORM CARDS AND LUFS CHART ============= */

.platform-card__meta {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-sm);
}

.platform-card__target {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
}

.platform-card__ceiling {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
}

.lufs-chart {
  height: 320px; /* 10 bars — functional sizing exception, not on spacing scale */
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: var(--space-md);
  margin-top: var(--space-xl);
}

.lufs-chart canvas {
  width: 100%;
  height: 100%;
}

/* === SECTION 18: PLATFORM CARD PRIMARY SELECTION =========== */

.platform-card {
  cursor: pointer;
  outline: 2px solid transparent;
  outline-offset: 3px;
  transition: var(--transition);
}

.platform-card:focus-visible {
  outline-color: var(--accent-amber);
}

.platform-card--primary {
  outline-color: var(--accent-amber);
  box-shadow: var(--glow-amber);
}

.platform-card--secondary {
  opacity: 0.35;
}

.platform-card__gain-hint {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-muted);
  margin-top: var(--space-sm);
  min-height: 1.4em;
}

.platform-card--primary .platform-card__gain-hint {
  font-size: 16px;
  color: var(--accent-amber);
  font-weight: 600;
}

/* === SECTION 19: ROOM MODES DIMENSION CARD AND SPECTRUM CHART ========= */

.room-dimension-card {
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

@media (min-width: 768px) {
  .room-dimension-card {
    padding: var(--space-lg);
  }
}

.room-dimension-card .calc-card__input {
  min-height: 44px;
}

.room-dimension-card__note {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  margin: var(--space-xs) 0 var(--space-md) 0;
}

.room-dimension-card__inputs {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

@media (min-width: 768px) {
  .room-dimension-card__inputs {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .room-dimension-card__inputs .calc-card__input-group {
    flex: 1;
    min-width: 120px;
  }
}

.room-mode-spectrum {
  height: 220px; /* functional sizing for Chart.js canvas (D-05) — not on spacing scale */
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

@media (min-width: 768px) {
  .room-mode-spectrum {
    margin-bottom: var(--space-lg);
  }
}

.room-mode-spectrum canvas {
  width: 100%;
  height: 100%;
}

/* === SECTION 20: ROOM MODES LIST TABLE ================================ */

.room-mode-list {
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

@media (min-width: 768px) {
  .room-mode-list {
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
  }
}

.room-mode-list__scroll-wrapper {
  max-height: 320px; /* functional scroll cap — not on spacing scale */
  overflow-y: auto;
  margin-top: var(--space-md);
}

.room-mode-list__table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-primary);
}

.room-mode-list__th {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  padding: var(--space-sm);
  border-bottom: 1px solid rgba(240, 236, 228, 0.12);
  white-space: nowrap;
  user-select: none;
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 1;
}

.room-mode-list__th--sortable {
  cursor: pointer;
  color: var(--accent-amber); /* sort icon active color (D-06, UI-SPEC) */
  transition: color var(--transition);
}

.room-mode-list__th--sortable:hover {
  color: var(--text-primary);
}

.room-mode-list__th--sortable:focus-visible {
  outline: 2px solid var(--accent-amber);
  outline-offset: 2px;
}

.room-mode-list__td {
  padding: var(--space-sm);
  border-bottom: 1px solid rgba(240, 236, 228, 0.06);
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-primary);
}

.room-mode-list__tr--danger {
  border-left: 3px solid var(--accent-amber);
  background-color: rgba(232, 168, 56, 0.08);
}

.room-mode-list__empty {
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 14px;
  padding: var(--space-lg);
}


/* === SECTION 21: ROOM RATIO VERDICT CARD ============================== */

.room-ratio-card {
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

@media (min-width: 768px) {
  .room-ratio-card {
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
  }
}

.room-ratio-card__badges {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-top: var(--space-md);
}

@media (min-width: 768px) {
  .room-ratio-card__badges {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-lg);
  }

  .room-ratio-card__badges .room-ratio-badge {
    flex: 1;
    min-width: 200px;
  }
}

.room-ratio-badge {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.room-ratio-badge__name {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.room-ratio-badge__verdict {
  display: inline-block;
  align-self: flex-start;
  padding: 2px var(--space-sm);
  border-radius: 4px;
  border: 1px solid rgba(240, 236, 228, 0.15);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  transition: color var(--transition), border-color var(--transition);
}

.room-ratio-badge__verdict--pass {
  color: var(--color-success);
  border-color: var(--color-success);
}

.room-ratio-badge__verdict--warn {
  color: var(--color-warning);
  border-color: var(--color-warning);
}

.room-ratio-badge__explanation {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.4;
  margin: var(--space-xs) 0 0 0;
}

/* === SECTION 22: ROOM RT60 ESTIMATOR AND TREATMENT SUGGESTIONS ======== */

.room-rt60-card {
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

@media (min-width: 768px) {
  .room-rt60-card {
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
  }
}

.room-rt60-card__surfaces {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
  margin-top: var(--space-md);
}

@media (min-width: 768px) {
  .room-rt60-card__surfaces {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
  }
}

.room-rt60-surface {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.room-rt60-surface__label {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.room-rt60-surface__select {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid rgba(240, 236, 228, 0.15);
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-mono);
  font-size: 14px;
  min-height: 44px;
  cursor: pointer;
  transition: border-color var(--transition);
}

.room-rt60-surface__select:hover {
  border-color: rgba(240, 236, 228, 0.35);
}

.room-rt60-surface__select:focus-visible {
  outline: 2px solid var(--accent-amber);
  outline-offset: 2px;
}

.room-rt60-output {
  margin-top: var(--space-lg);
}

.room-rt60-output__flags {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.room-rt60-output__flag {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.room-rt60-output__flag-label {
  color: var(--text-muted);
  margin-right: var(--space-xs);
}

.room-rt60-output__flag-value {
  color: var(--text-muted);
  transition: color var(--transition);
}

.room-rt60-output__flag-value--good {
  color: var(--color-success);
}

.room-rt60-output__flag-value--marginal {
  color: var(--color-warning);
}

.room-rt60-output__flag-value--poor {
  color: var(--color-error);
}

.room-rt60-output__table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-md);
}

.room-rt60-output__table th {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-sm);
  border-bottom: 1px solid rgba(240, 236, 228, 0.12);
}

.room-rt60-output__row-label {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  padding: var(--space-sm);
  text-align: left;
}

.room-rt60-output__cell {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 400;
  text-align: center;
  padding: var(--space-sm);
  color: var(--text-muted);
  border-radius: 4px;
  transition: background-color var(--transition), color var(--transition);
}

.room-rt60-output__cell--good {
  color: var(--color-success);
  background-color: rgba(71, 199, 138, 0.12);
}

.room-rt60-output__cell--marginal {
  color: var(--color-warning);
  background-color: rgba(245, 183, 89, 0.12);
}

.room-rt60-output__cell--poor {
  color: var(--color-error);
  background-color: rgba(239, 91, 91, 0.12);
}

.room-suggestions-card {
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

@media (min-width: 768px) {
  .room-suggestions-card {
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
  }
}

.room-suggestions-card__list {
  list-style: none;
  padding: 0;
  margin: var(--space-md) 0 0 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.room-suggestions-card__item {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-primary);
  padding-left: var(--space-md);
  border-left: 2px solid rgba(240, 236, 228, 0.15);
}

.room-suggestions-card__item--empty {
  color: var(--text-muted);
  border-left-color: rgba(240, 236, 228, 0.08);
}

/* === SECTION 23: EQ & DISTANCE — PANEL LAYOUT AND AIR ABSORPTION ======= */

/* Panel cards stack vertically with gap */
.tab-panel--flex {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}
@media (min-width: 768px) {
  .tab-panel--flex {
    gap: var(--space-lg);
  }
}

.eq-air-absorption-card {
  padding: var(--space-md);
}
@media (min-width: 768px) {
  .eq-air-absorption-card {
    padding: var(--space-lg);
  }
}

.eq-air-absorption-card__note {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  margin: var(--space-xs) 0 var(--space-md) 0;
}

.eq-air-absorption-card__inputs {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}
@media (min-width: 768px) {
  .eq-air-absorption-card__inputs {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .eq-air-absorption-card__inputs .calc-card__input-group {
    flex: 1;
    min-width: 120px;
  }
}

.eq-air-absorption-card__results {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-top: var(--space-md);
}

.eq-absorption-result__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-xs) 0;
}

.eq-absorption-result__freq {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-muted);
}

.eq-absorption-result__value {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-primary);
}

/* === SECTION 24: EQ & DISTANCE — DELAY ALIGNMENT AND SUB POLARITY ====== */

.eq-delay-card {
  padding: var(--space-md);
}
@media (min-width: 768px) {
  .eq-delay-card {
    padding: var(--space-lg);
  }
}

.eq-delay-card__result-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  flex-wrap: wrap;
}

/* Large delay value — reuses 32px mono treatment (same as SPL-01 result) */
.eq-delay__value {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1;
}

.eq-delay__unit {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-muted);
  align-self: flex-end;
  padding-bottom: 4px;
}

/* Haas zone badge — pill shape matching Phase 4 ratio badge pattern */
.eq-delay__zone {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  border-radius: 4px;
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  transition: color var(--transition), border-color var(--transition), background-color var(--transition);
}

/* Badge hidden when empty — JS sets textContent to '' for no-result state */
.eq-delay__zone:empty {
  display: none;
}

.eq-delay__zone--error {
  color: var(--color-error);
  border-color: var(--color-error);
  background-color: rgba(239, 91, 91, 0.12);
}

.eq-delay__zone--success {
  color: var(--color-success);
  border-color: var(--color-success);
  background-color: rgba(71, 199, 138, 0.12);
}

.eq-delay__zone--warning {
  color: var(--color-warning);
  border-color: var(--color-warning);
  background-color: rgba(245, 183, 89, 0.12);
}

.eq-polarity-card {
  padding: var(--space-md);
}
@media (min-width: 768px) {
  .eq-polarity-card {
    padding: var(--space-lg);
  }
}

.eq-polarity-card__inputs {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}
@media (min-width: 768px) {
  .eq-polarity-card__inputs {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .eq-polarity-card__inputs .calc-card__input-group {
    flex: 1;
    min-width: 160px;
  }
}

.eq-polarity-card__result {
  margin-top: var(--space-md);
}

.eq-polarity__phase-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-xs) 0;
  margin-bottom: var(--space-sm);
}

.eq-polarity__phase-label {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.eq-polarity__phase-value {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-primary);
}

.eq-polarity__recommendation {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-muted);
  margin: 0;
  transition: color var(--transition);
}

.eq-polarity__recommendation--in-phase {
  color: var(--color-success);
}

.eq-polarity__recommendation--add-delay {
  color: var(--color-warning);
}

.eq-polarity__recommendation--invert {
  color: var(--color-error);
}

/* === SECTION 25: EQ & DISTANCE — CROSSOVER REFERENCE TABLE ============= */

.eq-crossover-card {
  padding: var(--space-md);
}
@media (min-width: 768px) {
  .eq-crossover-card {
    padding: var(--space-lg);
  }
}

.eq-crossover-card__table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: var(--space-md);
}

.eq-crossover-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-primary);
}

.eq-crossover-table th {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  padding: var(--space-sm);
  border-bottom: 1px solid rgba(240, 236, 228, 0.12);
  white-space: nowrap;
}

.eq-crossover-table td {
  padding: var(--space-sm);
  border-bottom: 1px solid rgba(240, 236, 228, 0.06);
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-primary);
}

/* Crossover frequency column — amber emphasis, weight 600 (per UI-SPEC.md crossover freq column spec) */
.eq-crossover-table__freq {
  color: var(--accent-amber);
  font-weight: 600;
}

.eq-crossover-card__notes {
  margin-top: var(--space-md);
}

.eq-crossover-card__textarea {
  display: block;
  width: 100%;
  min-height: 72px;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid rgba(240, 236, 228, 0.15);
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  resize: vertical;
  transition: border-color var(--transition);
  margin-top: var(--space-sm);
}

.eq-crossover-card__textarea:hover {
  border-color: rgba(240, 236, 228, 0.35);
}

.eq-crossover-card__textarea:focus-visible {
  outline: 2px solid var(--accent-amber);
  outline-offset: 2px;
}

/* === SECTION 26: EQ & DISTANCE — GAIN CHAIN CHART ====================== */

.eq-gain-chain-card {
  padding: var(--space-md);
}
@media (min-width: 768px) {
  .eq-gain-chain-card {
    padding: var(--space-lg);
  }
}

.eq-gain-chain-card__inputs {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}
@media (min-width: 768px) {
  .eq-gain-chain-card__inputs {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .eq-gain-chain-card__inputs .calc-card__input-group {
    flex: 1;
    min-width: 120px;
  }
}

/* Chart container — 220px fixed height matches room mode spectrum from Phase 4 */
.eq-gain-chain-card__chart {
  height: 220px;
  background: var(--bg-surface);
  border-radius: var(--radius);
  margin-top: var(--space-md);
}

.eq-gain-chain-card__chart canvas {
  width: 100%;
  height: 100%;
}

/* === SECTION 27: VENUE PROFILES — TOP BAR ADDITIONS ======== */

/* Venue name text input — mirrors .top-bar__venue-select visual style */
.top-bar__venue-input {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid rgba(240, 236, 228, 0.15);
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  min-height: 44px;
  transition: border-color var(--transition);
}
.top-bar__venue-input::placeholder { color: var(--text-muted); }
.top-bar__venue-input:hover { border-color: var(--accent-teal); }
.top-bar__venue-input:focus-visible { outline: 2px solid var(--accent-teal); outline-offset: 2px; }

/* Export button — amber accent (signals download action) */
.top-bar__btn--export {
  border: 1px solid var(--accent-amber);
  color: var(--accent-amber);
}
.top-bar__btn--export:hover  { background: rgba(232, 168, 56, 0.12); }
.top-bar__btn--export:active { background: rgba(232, 168, 56, 0.20); }
.top-bar__btn--export:focus-visible { outline: 2px solid var(--accent-amber); outline-offset: 2px; }

/* Import button — teal accent (mirrors .top-bar__btn--save, additive action) */
.top-bar__btn--import {
  border: 1px solid var(--accent-teal);
  color: var(--accent-teal);
}
.top-bar__btn--import:hover  { background: rgba(58, 140, 140, 0.12); }
.top-bar__btn--import:active { background: rgba(58, 140, 140, 0.20); }
.top-bar__btn--import:focus-visible { outline: 2px solid var(--accent-teal); outline-offset: 2px; }

/* Mobile overflow fix: at 480px and below, top bar wraps into two rows */
@media (max-width: 480px) {
  .top-bar {
    height: auto;
    min-height: var(--top-bar-height);
    padding: var(--space-sm) var(--space-md);
  }

  .top-bar__controls {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  /* Shift tab-bar down to clear the wrapped top bar (approx two rows = 112px) */
  .tab-bar {
    top: 112px;
  }
}

/* === SECTION 28: PRINT / A5 ================================= */

/* --- PRINT-01 / PRINT-02: A5 landscape print output --- */

/* Top-level @page — NOT nested in @media print (Firefox ignores nested @page) */
@page {
  size: A5 landscape; /* 210mm × 148mm */
  margin: 12mm 14mm;
}

@media print {

  /* Hide page chrome and interactive controls */
  .top-bar,
  .tab-bar,
  .tab-panel__print-btn,
  .top-bar__dim-toggle {
    display: none !important;
  }

  /* Belt-and-suspenders: keep [hidden] panels invisible */
  [hidden] {
    display: none !important;
  }

  /* Light paper / dark text inversion */
  body {
    background: #ffffff !important;
    color: #111111 !important;
  }

  .app-main,
  .tab-panel--active,
  .calc-card {
    background: #ffffff !important;
    color: #111111 !important;
    box-shadow: none !important;
    border-color: #cccccc !important;
  }

  /* Hide interactive input controls — print-summary replaces them */
  .calc-card__input-group,
  .damage-timer__toggle-group,
  .room-rt60-card__surfaces,
  .lufs-input-card,
  .eq-gain-chain-card__inputs,
  select,
  textarea {
    display: none !important;
  }

  /* Hide LUFS platform cards grid (too many cards for A5; summary covers it) */
  .lufs-grid {
    display: none !important;
  }

  /* Reveal print summary */
  .tab-panel__print-summary {
    display: block !important;
    font-family: var(--font-mono);
    font-size: 11pt;
    color: #111111;
    margin: 8mm 0;
    white-space: pre-wrap;
    line-height: 1.6;
  }

  /* Hide Chart.js canvases (axis/grid label colors are screen-tuned; illegible on white) */
  canvas {
    display: none !important;
  }

  /* Collapse SPL grid to single column for A5 width */
  .spl-grid {
    grid-template-columns: 1fr !important;
  }

  /* Footer: keep visible, invert colors */
  .footer {
    display: block !important;
    background: transparent !important;
    color: #111111 !important;
    position: static !important;
    border-top: 1px solid #cccccc;
    padding-top: 4mm;
  }

  .footer__link {
    color: #111111 !important;
  }
}
/* === SECTION 29: LIVE LUFS METER =========================== */

/* --- Outer container --- */
.live-meter {
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

@media (min-width: 768px) {
  .live-meter {
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
  }
}

/* --- File-guard info card --- */
.live-meter__file-guard {
  border: 1px solid var(--accent-amber);
  border-radius: var(--radius);
  padding: var(--space-md);
  background: rgba(232, 168, 56, 0.06);
}

.live-meter__file-guard-text {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  margin: 0 0 var(--space-sm) 0;
}

.live-meter__file-guard-text:last-child {
  margin-bottom: 0;
}

.live-meter__file-guard-code {
  display: block;
  background: var(--bg-primary);
  border: 1px solid rgba(240, 236, 228, 0.12);
  border-radius: calc(var(--radius) / 2);
  color: var(--accent-amber);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: var(--space-xs) var(--space-sm);
  margin: var(--space-xs) 0 var(--space-sm) 0;
  user-select: all;
}

/* --- Controls row (device select + start button + indicator) --- */
.live-meter__controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.live-meter__device-label {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
}

.live-meter__device-select {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid rgba(240, 236, 228, 0.15);
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-mono);
  font-size: 14px;
  min-height: 44px;
  cursor: pointer;
  transition: border-color var(--transition);
  flex: 1;
  min-width: 160px;
}

.live-meter__device-select:hover {
  border-color: rgba(240, 236, 228, 0.35);
}

.live-meter__device-select:focus-visible {
  outline: 2px solid var(--accent-amber);
  outline-offset: 2px;
}

/* --- Start / Stop button --- */
.live-meter__start-btn {
  background: var(--bg-primary);
  border: 1px solid rgba(240, 236, 228, 0.15);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  min-height: 44px;
  min-width: 72px;
  padding: var(--space-xs) var(--space-sm);
  cursor: pointer;
  transition: background-color var(--transition), border-color var(--transition), color var(--transition);
  flex-shrink: 0;
}

.live-meter__start-btn:hover {
  border-color: rgba(240, 236, 228, 0.35);
  color: var(--text-primary);
}

.live-meter__start-btn:focus-visible {
  outline: 2px solid var(--accent-amber);
  outline-offset: 2px;
}

.live-meter__start-btn--active {
  background: rgba(232, 168, 56, 0.12);
  border-color: var(--accent-amber);
  color: var(--accent-amber);
}

.live-meter__start-btn--active:hover {
  background: rgba(232, 168, 56, 0.18);
}

/* --- Mic activity indicator dot --- */
@keyframes live-meter-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.2; }
}

.live-meter__indicator {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(240, 236, 228, 0.15);
  flex-shrink: 0;
  transition: background-color var(--transition);
}

.live-meter__indicator--active {
  background: var(--accent-amber);
  animation: live-meter-blink 1.2s ease-in-out infinite;
}

/* --- Readout grid (M / S / I) --- */
.live-meter__readouts {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-md);
  border-top: 1px solid rgba(240, 236, 228, 0.08);
  padding-top: var(--space-md);
}

.live-meter__readout {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.live-meter__readout-label {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
}

.live-meter__readout-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--accent-amber);
  margin: 0;
}

.live-meter__readout-unit {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  margin: 0;
}

/* --- Mobile: stack controls + single-column readouts --- */
@media (max-width: 767px) {
  .live-meter__controls {
    flex-direction: column;
    align-items: flex-start;
  }

  .live-meter__device-select {
    width: 100%;
  }

  .live-meter__readouts {
    grid-template-columns: 1fr;
  }
}

/* --- Print: hide live meter (no static output to print) --- */
@media print {
  .live-meter {
    display: none !important;
  }
}

/* === SECTION 30: ROOM MODES EXTENSIONS (Phase 9) =========== */

/* --- Audience count input wrapper (ROOM-07) --- */
.room-rt60-audience {
  margin-bottom: var(--space-md);
}

/* --- Occupied RT60 row modifier (ROOM-07) --- */
/* Semantic hook only — default appearance same as unmodified cell.        */
/* JS applies --good / --marginal / --poor modifiers (already in Sec 22)  */
/* when audience > 0. No extra color rule needed here.                     */
.room-rt60-output__cell--occupied {
  color: var(--text-muted);
}

/* --- Treatment Sizing card shell (ROOM-08) --- */
.room-treatment-card {
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

@media (min-width: 768px) {
  .room-treatment-card {
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
  }
}

.room-treatment-card__note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

/* --- Treatment inputs row --- */
.room-treatment-card__inputs {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

@media (min-width: 768px) {
  .room-treatment-card__inputs {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
  }
  .room-treatment-card__inputs .calc-card__input-group {
    flex: 1;
    min-width: 160px;
  }
}

/* --- Treatment output table (mirrors .room-rt60-output__table) --- */
.room-treatment-output {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.room-treatment-output__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.room-treatment-output__table th,
.room-treatment-output__table td {
  padding: 0.35rem 0.5rem;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.room-treatment-output__table th {
  color: var(--text-muted);
  font-weight: 400;
  font-family: var(--font-mono);
}

.room-treatment-output__row-label {
  text-align: left;
  color: var(--text-muted);
  white-space: nowrap;
}

.room-treatment-output__cell {
  font-family: var(--font-mono);
  color: var(--text-primary);
}

/* --- Print: hide treatment card (no static output to print) --- */
@media print {
  .room-treatment-card {
    display: none !important;
  }
}
