/* Redesign do Detector de Tom: somente desktop. O bloco base preserva o fluxo mobile. */
.detector-desktop-shell {
  display: block;
}

.detector-timeline-wrap {
  display: none;
}

.detector-mic-summary {
  display: none;
}

.detector-card-head {
  min-width: 0;
}

.detector-card-hint {
  display: none;
}

.detector-clear-desktop {
  display: none;
}

.detector-clear-mobile {
  display: inline;
}

.key-detector-note-desktop {
  display: none;
}

@media (min-width: 1024px) {
  .detector-clear-desktop {
    display: inline;
  }

  .detector-clear-mobile {
    display: none;
  }

  .detector-desktop-shell .detector-current > #keyDetectorCurrentNote {
    display: none;
  }

  .detector-desktop-shell .detector-current > .key-detector-note-desktop {
    display: block;
  }

  #appShell.app-shell > .detector-panel[data-section-panel="detector"] {
    width: min(calc(100% - 48px), 1260px) !important;
    max-width: 1260px !important;
    margin: 24px auto 72px !important;
    padding: 26px 28px 30px !important;
    border: 1px solid rgba(129, 140, 248, 0.2);
    border-radius: 24px;
    background: #ffffff;
    box-shadow: 0 18px 48px rgba(30, 41, 59, 0.08);
  }

  .detector-desktop-shell {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(280px, 3fr);
    grid-template-areas:
      "head mic"
      "timeline mic"
      "histogram current"
      "histogram candidates";
    grid-template-rows: auto minmax(290px, auto) auto auto;
    gap: 16px 22px;
    min-width: 0;
  }

  .detector-desktop-shell > .tuner-head {
    display: contents !important;
  }

  .detector-head-copy {
    grid-area: head;
    align-self: end;
    min-width: 0;
    padding: 4px 4px 0;
  }

  .detector-head-copy h2 {
    margin-bottom: 6px;
    font-size: clamp(1.5rem, 2vw, 2rem);
  }

  .detector-head-copy > span {
    display: block;
    color: var(--muted);
    font-family: var(--font-semi);
    font-size: 0.92rem;
  }

  .detector-desktop-shell .tuner-actions {
    grid-area: mic !important;
    align-self: stretch;
    justify-self: stretch !important;
    width: auto !important;
    justify-items: stretch;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    min-width: 0;
    padding: 18px;
    border: 1px solid rgba(129, 140, 248, 0.22);
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 10px 26px rgba(79, 70, 229, 0.07);
  }

  .detector-mic-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 2px 0 4px;
  }

  .detector-mic-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: #6d28d9;
    background: #f2edff;
  }

  .detector-mic-icon svg {
    width: 23px;
    height: 23px;
    fill: currentColor;
  }

  .detector-mic-summary > span:last-child {
    display: grid;
    gap: 3px;
    min-width: 0;
  }

  .detector-mic-summary strong {
    color: var(--ink);
    font-family: var(--font-note);
    font-size: 0.92rem;
    line-height: 1.1;
  }

  .detector-mic-summary small {
    color: var(--muted);
    font-family: var(--font-semi);
    font-size: 0.74rem;
  }

  .detector-desktop-shell .tuner-actions .primary-button,
  .detector-desktop-shell .tuner-actions .secondary-button {
    width: 100%;
    min-height: 40px;
    margin: 0;
  }

  .detector-desktop-shell .tuner-actions .save-message {
    min-height: 18px;
    text-align: center;
    font-size: 0.72rem;
  }

  .detector-desktop-shell > .detector-layout {
    display: contents;
  }

  .detector-desktop-shell .detector-main {
    display: contents;
  }

  .detector-desktop-shell .detector-result-card {
    display: none;
  }

  .detector-desktop-shell .detector-timeline-wrap,
  .detector-desktop-shell .detector-histogram-wrap,
  .detector-desktop-shell .detector-current,
  .detector-desktop-shell .detector-candidates-wrap {
    min-width: 0;
    border: 1px solid rgba(129, 140, 248, 0.18);
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 8px 22px rgba(30, 41, 59, 0.045);
  }

  .detector-desktop-shell .detector-timeline-wrap {
    display: block;
    grid-area: timeline;
    padding: 16px 16px 12px;
  }

  .detector-desktop-shell .detector-histogram-wrap {
    grid-area: histogram;
    align-self: stretch;
    padding: 16px;
  }

  .detector-desktop-shell .detector-current {
    grid-area: current;
    justify-content: center;
    min-height: 128px;
    padding: 16px 18px;
    background: #f8f7ff;
  }

  .detector-desktop-shell .detector-candidates-wrap {
    grid-area: candidates;
    padding: 16px;
  }

  .detector-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .detector-card-head .detector-section-label {
    margin-bottom: 10px;
  }

  .detector-card-hint {
    display: inline-block;
    flex: 0 0 auto;
    color: var(--muted);
    font-family: var(--font-semi);
    font-size: 0.68rem;
    white-space: nowrap;
  }

  .detector-window-controls {
    display: inline-flex;
    gap: 4px;
    padding: 3px;
    border: 1px solid rgba(129, 140, 248, 0.16);
    border-radius: 9px;
    background: #f8f7ff;
  }

  .detector-window-controls button {
    min-width: 36px;
    height: 25px;
    padding: 0 7px;
    border: 0;
    border-radius: 6px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
    font-family: var(--font-semi);
    font-size: 0.68rem;
    font-weight: 800;
  }

  .detector-window-controls button:hover,
  .detector-window-controls button[aria-pressed="true"] {
    color: #ffffff;
    background: var(--accent);
  }

  .detector-timeline-stage {
    position: relative;
    min-height: 248px;
  }

  .detector-timeline-canvas {
    display: block;
    width: 100%;
    height: 248px;
  }

  .detector-timeline-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    color: var(--muted);
    font-family: var(--font-semi);
    font-size: 0.78rem;
    text-align: center;
    pointer-events: none;
  }

  .detector-timeline-empty.is-hidden {
    display: none;
  }

  .detector-desktop-shell .detector-histogram {
    height: 142px;
    gap: 8px;
  }

  .detector-desktop-shell .kd-bar-wrap {
    border-radius: 7px 7px 2px 2px;
    background: #f4f1ff;
  }

  .detector-desktop-shell .kd-bar {
    border-radius: 7px 7px 2px 2px;
    background: linear-gradient(180deg, #8b5cf6, #6d28d9);
  }

  .detector-desktop-shell .detector-candidates-list {
    gap: 8px;
  }

  .detector-desktop-shell .kd-candidate {
    grid-template-columns: minmax(78px, auto) minmax(0, 1fr) auto;
    gap: 5px 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #fbfaff;
  }

  .detector-desktop-shell .kd-candidate.is-best {
    border-color: rgba(124, 58, 237, 0.2);
    background: #f2edff;
  }

  .detector-desktop-shell .kd-candidate.is-best .kd-candidate-name,
  .detector-desktop-shell .kd-candidate.is-best .kd-candidate-pct,
  .detector-desktop-shell .kd-candidate.is-best .kd-candidate-pt {
    color: var(--ink);
  }

  .detector-desktop-shell .kd-candidate.is-best .kd-candidate-bar-wrap {
    background: rgba(124, 58, 237, 0.12);
  }

  .detector-desktop-shell .kd-candidate.is-best .kd-candidate-bar {
    background: #7c3aed;
  }

  body[data-theme="dark"] #appShell.app-shell > .detector-panel[data-section-panel="detector"] {
    border-color: rgba(165, 180, 252, 0.22);
    background: #0f172a;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
  }

  body[data-theme="dark"] .detector-desktop-shell .tuner-actions,
  body[data-theme="dark"] .detector-desktop-shell .detector-timeline-wrap,
  body[data-theme="dark"] .detector-desktop-shell .detector-histogram-wrap,
  body[data-theme="dark"] .detector-desktop-shell .detector-current,
  body[data-theme="dark"] .detector-desktop-shell .detector-candidates-wrap {
    border-color: rgba(165, 180, 252, 0.22);
    background: rgba(15, 23, 42, 0.92);
  }

  body[data-theme="dark"] .detector-desktop-shell .detector-current,
  body[data-theme="dark"] .detector-window-controls {
    background: rgba(30, 41, 59, 0.84);
  }

  body[data-theme="dark"] .detector-window-controls {
    border-color: rgba(165, 180, 252, 0.22);
  }

  body[data-theme="dark"] .detector-desktop-shell .kd-candidate {
    background: rgba(30, 41, 59, 0.72);
  }

  body[data-theme="dark"] .detector-desktop-shell .kd-candidate.is-best {
    background: rgba(109, 40, 217, 0.22);
  }

  body[data-theme="dark"] .detector-desktop-shell .kd-bar-wrap {
    background: rgba(129, 140, 248, 0.13);
  }
}
