
.mic-vol-track::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 4px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: linear-gradient(to top, var(--mic-fill) 0%, var(--mic-fill) var(--mic-level), var(--control-bg) var(--mic-level), var(--control-bg) 100%);
  z-index: 0;
  pointer-events: none;
}

.mic-vol-track::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: calc(var(--mic-level) + var(--mic-thumb-offset));
  width: var(--mic-thumb-size);
  height: var(--mic-thumb-size);
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--mic-fill);
  border: 2px solid var(--surface);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 0 3px rgba(var(--accent-rgb),0.18);
  z-index: 1;
  pointer-events: none;
}

.mic-vol-track.muted {
  --mic-fill: var(--red);
}

.mic-vol-track.muted::after {
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 0 3px rgba(var(--danger-rgb),0.18);
}

.mic-vol-slider {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 90px;
  height: 36px;
  transform: translate(-50%, -50%) rotate(-90deg);
  transform-origin: center;
  border-radius: 999px;
  background: transparent;
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  z-index: 2;
  margin: 0;
  padding: 0;
}
.mic-vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--surface);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 0 3px rgba(var(--accent-rgb),0.18);
  cursor: pointer;
}

.mic-vol-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--dim-text);
  text-align: center;
  line-height: 1.2;
}

/* ── Mic App Mixer ─────────────────────────────────────────── */
.mic-apps {
  grid-column: 1 / -1;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: 2px;
}

/* Reuse .app-mix-row layout from AudioSection; override colours for dark mic panel */
.mic-apps .app-mix-name  { color: var(--muted-text); }
.mic-apps .app-mix-vol   { color: var(--dim-text); }
.mic-apps .app-mix-mute  { background: var(--control-bg); border-color: var(--divider); }

/* Mic rendered as the "Microfono" tab inside the System hub: a centered
   column (button + sensitivity). Class-based (not id) so a duplicated System
   tile keeps this layout. :not([hidden]) so the rule doesn't override the
   [hidden] attribute used to switch tabs. */
.system-mic-pane:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  gap: 12px;
  padding: 22px 16px;
  height: 100%;
  text-align: center;
}
/* Hub mic: clean horizontal sensitivity row instead of the vertical slider */
.system-mic-pane .mic-vol {
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(100%, 360px);
  height: auto;
  padding: 12px 16px;
}
.system-mic-pane .mic-vol-value { order: 3; min-width: 3ch; text-align: right; font-size: 15px; }
.system-mic-pane .mic-vol-label { order: 1; line-height: 1.15; }
.system-mic-pane .mic-vol-track {
  order: 2;
  width: auto;
  flex: 1 1 auto;
  height: 22px;
}
.system-mic-pane .mic-vol-track::before {
  left: 0;
  right: 0;
  top: 50%;
  bottom: auto;
  width: auto;
  height: 4px;
  transform: translateY(-50%);
  background: linear-gradient(to right, var(--mic-fill) 0%, var(--mic-fill) var(--mic-level), var(--control-bg) var(--mic-level), var(--control-bg) 100%);
}
.system-mic-pane .mic-vol-track::after {
  left: var(--mic-level);
  bottom: auto;
  top: 50%;
  transform: translate(-50%, -50%);
}
.system-mic-pane .mic-vol-slider {
  width: 100%;
  height: 100%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Container queries: adapt mic-panel to its actual rendered size */
@container micpanel (max-height: 320px) {
  .mic-panel { padding: 10px 12px; row-gap: 6px; column-gap: 10px; }
  .mic-head { gap: 3px; }
  .status-label { min-height: 20px; padding: 0 10px; font-size: 10.5px; }
  .mic-context { font-size: 12.5px; }
  .btn-wrap { width: 78px; height: 78px; }
  .mic-btn { width: 56px; height: 56px; }
  .mic-btn svg { width: 22px; height: 22px; }
  .mic-vol { width: 46px; gap: 5px; padding: 8px 6px; border-radius: 12px; }
  .mic-vol-value { font-size: 12.5px; }
  .mic-vol-track { width: 28px; height: 70px; --mic-thumb-size: 12px; --mic-thumb-offset: -6px; }
  .mic-vol-slider { width: 70px; height: 28px; }
  .mic-vol-slider::-webkit-slider-thumb { width: 12px; height: 12px; border-width: 2px; }
  .mic-vol-label { font-size: 8.5px; }
}

/* Large layout only when the panel is BOTH wide and tall enough (e.g. the
   full-screen ?panel=mic embed). Bento dashboard tiles are wide but short,
   so they fall back to the base/compact layout and never clip. */
@container micpanel (min-aspect-ratio: 3/2) and (min-height: 420px) {
  .mic-panel {
    grid-template-columns: auto auto;
    grid-template-areas:
      'head head'
      'button volume';
    justify-content: center;
    justify-items: center;
    align-items: center;
    padding: clamp(14px, 6cqh, 32px) clamp(20px, 5cqw, 50px);
    row-gap: clamp(10px, 4cqh, 22px);
    column-gap: clamp(16px, 5cqw, 40px);
    text-align: center;
  }
  .mic-head {
    align-items: center;
    text-align: center;
    width: min(100%, clamp(220px, 52cqw, 540px));
    gap: clamp(4px, 1.6cqh, 10px);
  }
  .status-label {
    min-height: clamp(22px, 8cqh, 40px);
    padding: 0 clamp(12px, 2.4cqw, 26px);
    font-size: clamp(10px, 3.2cqh, 17px);
  }
  .mic-context {
    font-size: clamp(12px, 4cqh, 22px);
    width: min(100%, 540px);
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .btn-wrap {
    width: clamp(110px, 60cqh, 220px);
    height: clamp(110px, 60cqh, 220px);
  }
  .mic-btn {
    width: clamp(78px, 42cqh, 156px);
    height: clamp(78px, 42cqh, 156px);
  }
  .mic-btn svg {
    width: clamp(28px, 15cqh, 58px);
    height: clamp(28px, 15cqh, 58px);
  }
  .mic-vol {
    width: clamp(54px, 12cqw, 76px);
    gap: clamp(6px, 2cqh, 10px);
    padding: clamp(9px, 3cqh, 14px) clamp(6px, 1.4cqw, 10px);
  }
  .mic-vol-value { font-size: clamp(12px, 4cqh, 20px); }
  .mic-vol-track {
    width: clamp(34px, 8cqw, 50px);
    height: clamp(80px, 40cqh, 160px);
    --mic-thumb-size: clamp(13px, 3.5cqh, 18px);
    --mic-thumb-offset: clamp(-9px, -1.75cqh, -6.5px);
  }
  .mic-vol-slider {
    width: clamp(80px, 40cqh, 160px);
    height: clamp(34px, 8cqw, 50px);
  }
  .mic-vol-slider::-webkit-slider-thumb {
    width: clamp(13px, 3.5cqh, 18px);
    height: clamp(13px, 3.5cqh, 18px);
  }
  .mic-vol-label { font-size: clamp(8px, 2.2cqh, 11px); }
}
