/* Afinador: composição mobile-first, mantendo o medidor SVG e a leitura reais. */
#appShell.app-shell > .tuner-panel[data-section-panel="afinador"] {
  display: grid;
  grid-template-columns: minmax(0, 620px);
  justify-content: center;
  gap: 14px;
  width: min(100% - 32px, 620px);
  margin: 0 auto;
  padding: 4px 0 calc(106px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#appShell.app-shell > .tuner-panel[data-section-panel="afinador"].is-hidden { display: none !important; }

.tuner-redesign-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 4px 2px 7px;
}

.tuner-back-button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 34px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 10px;
  color: #332168;
  background: transparent;
}

.tuner-back-button svg { width: 21px; height: 21px; }
.tuner-redesign-head h2 { margin: 0; color: #141331; font-family: var(--font-bold, inherit); font-size: clamp(1.1rem, 5vw, 1.35rem); line-height: 1.12; }
.tuner-redesign-head p { margin: 4px 0 0; color: #7c7b97; font-size: 0.73rem; line-height: 1.3; }

.tuner-primary-card,
.tuner-strings-card,
.tuner-tip-card {
  border: 1px solid rgba(119, 48, 232, 0.12);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(42, 27, 93, 0.055);
}

.tuner-primary-card { padding: 14px 12px 12px; }

.tuner-mic-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 4px 6px;
}

.tuner-mic-icon,
.tuner-feedback-icon,
.tuner-tip-card > span {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #7730e8;
  background: #f1eaff;
}

.tuner-mic-icon svg,
.tuner-feedback-icon svg,
.tuner-tip-card > span svg { width: 16px; height: 16px; }
.tuner-mic-copy { display: grid; gap: 2px; min-width: 0; }
.tuner-mic-copy strong { color: #171534; font-family: var(--font-bold, inherit); font-size: 0.73rem; }
.tuner-mic-copy span { color: #85829b; font-size: 0.64rem; }

.tuner-audio-indicator { display: flex; align-items: center; justify-content: center; gap: 2px; width: 28px; height: 28px; margin-left: auto; border: 1px solid rgba(119, 48, 232, 0.1); border-radius: 9px; color: #8c64e8; background: #fbfaff; }
.tuner-audio-indicator i { display: block; width: 2px; height: 7px; border-radius: 4px; background: currentColor; }
.tuner-audio-indicator i:nth-child(2) { height: 13px; }
.tuner-audio-indicator i:nth-child(3) { height: 9px; }
.tuner-meter.is-listening ~ .tuner-feedback + .tuner-toggle-button + .tuner-message { color: #6331c9; }

.tuner-primary-card .tuner-meter {
  position: relative;
  min-height: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.tuner-primary-card .tuner-gauge { width: min(100%, 460px); margin: 0 auto 3px; }
.tuner-primary-card .tuner-gauge-svg { overflow: visible; }
.tuner-primary-card .tuner-arc-shadow { stroke: rgba(119, 48, 232, 0.055); stroke-width: 10; }
.tuner-primary-card .tuner-arc-track { stroke-width: 2.7; }
.tuner-primary-card .tuner-arc-zone { stroke: #7730e8; stroke-width: 5.5; filter: drop-shadow(0 2px 3px rgba(119, 48, 232, 0.18)); }
.tuner-primary-card .tuner-arc-inner { stroke: rgba(119, 48, 232, 0.12); }
.tuner-primary-card .tuner-base-line { display: none; }
.tuner-primary-card .tuner-ticks line { stroke: #6f6683; stroke-width: 1.1; }
.tuner-primary-card .tuner-ticks line.major { stroke: #262038; stroke-width: 2.3; }
.tuner-primary-card .tuner-ticks line.center { stroke: #7730e8; stroke-width: 2.7; }
.tuner-primary-card .tuner-scale-labels text { fill: #675e7b; font-size: 11px; }
.tuner-primary-card .meter-side-label { fill: #1d1830; color: #1d1830; font-size: 29px; }
.tuner-primary-card .tuner-inner-halo { fill: #f7f3ff; stroke: transparent; }

.tuner-primary-card .meter-needle { top: 10%; width: 3px; height: 65.5%; background: #7730e8; box-shadow: 0 0 9px rgba(119, 48, 232, 0.22); transition: transform 80ms linear; }
.tuner-primary-card .meter-center { top: 75.5%; width: 11px; height: 11px; background: #7730e8; box-shadow: 0 0 0 5px rgba(119, 48, 232, 0.13), 0 4px 10px rgba(119, 48, 232, 0.18); }
.tuner-primary-card .meter-readout { bottom: -1%; width: 108px; min-width: 108px; min-height: 88px; padding: 19px 6px 11px; border-radius: 50%; color: #23203c; background: #f7f3ff; }
.tuner-primary-card .meter-readout #tunerNote { color: #7431db; font-size: clamp(2.25rem, 11vw, 3rem); line-height: 0.78; }
.tuner-primary-card .meter-readout #tunerMeterFrequency { color: #25213c; font-size: 0.73rem; font-family: var(--font-semi, inherit); }
.tuner-primary-card .meter-readout #tunerOctave { display: none; }

.tuner-feedback { display: flex; align-items: center; gap: 9px; min-height: 47px; margin-top: 2px; padding: 7px 10px; border: 1px solid rgba(119, 48, 232, 0.1); border-radius: 11px; color: #6e40ca; background: #fcfbff; }
.tuner-feedback-icon { width: 27px; height: 27px; }
.tuner-feedback > div { display: grid; gap: 2px; }
.tuner-feedback strong { color: inherit; font-family: var(--font-bold, inherit); font-size: 0.68rem; }
.tuner-feedback .tuner-status { color: #83809a; font-size: 0.59rem; line-height: 1.25; }
.tuner-meter.is-tuned ~ .tuner-feedback { color: #14834f; border-color: rgba(20, 131, 79, 0.16); background: #f2fcf6; }
.tuner-meter.is-tuned ~ .tuner-feedback .tuner-feedback-icon { color: #14834f; background: #dcf8e7; }
.tuner-meter.is-flat ~ .tuner-feedback,
.tuner-meter.is-sharp ~ .tuner-feedback { color: #b86d04; border-color: rgba(209, 129, 5, 0.18); background: #fffaf0; }
.tuner-meter.is-flat ~ .tuner-feedback .tuner-feedback-icon,
.tuner-meter.is-sharp ~ .tuner-feedback .tuner-feedback-icon { color: #b86d04; background: #fff0ce; }

.tuner-toggle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 46px;
  margin-top: 8px;
  border: 0;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(105deg, #8a48f4, #6722d7);
  box-shadow: 0 8px 14px rgba(105, 34, 215, 0.2);
  font-family: var(--font-semi, inherit);
  font-size: 0.74rem;
}

.tuner-toggle-button svg { width: 17px; height: 17px; }
.tuner-toggle-button.is-running { background: linear-gradient(105deg, #6330cc, #4b17af); }
.tuner-message { display: block; min-height: 0; margin: 6px 4px 0; color: #a13e46; font-size: 0.65rem; line-height: 1.3; text-align: center; }
.tuner-message:empty { display: none; }
.tuner-technical-values { display: none; }

.tuner-strings-card { padding: 12px 9px 10px; }
.tuner-card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 3px 9px; }
.tuner-card-title h3 { margin: 0; color: #1b1835; font-family: var(--font-bold, inherit); font-size: 0.72rem; }
.tuner-card-title span { padding: 5px 7px; border-radius: 7px; color: #7b4bd7; background: #f7f2ff; font-size: 0.53rem; }
.tuner-string-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.tuner-string-grid article { display: grid; justify-items: center; gap: 2px; min-width: 0; padding: 5px 2px 6px; border: 1px solid rgba(119, 48, 232, 0.1); border-radius: 9px; background: #f9f6ff; }
.tuner-string-grid small { display: grid; place-items: center; width: 13px; height: 13px; border-radius: 50%; color: #7358a6; background: #eee5ff; font-size: 0.48rem; }
.tuner-string-grid strong { color: #29213e; font-family: var(--font-bold, inherit); font-size: 1rem; line-height: 1; }
.tuner-string-grid span { color: #6c6880; font-size: 0.53rem; white-space: nowrap; }
.tuner-string-grid em { color: #7d52d3; font-size: 0.48rem; font-style: normal; }

.tuner-tip-card { display: flex; align-items: flex-start; gap: 10px; padding: 12px; }
.tuner-tip-card > span { width: 29px; height: 29px; }
.tuner-tip-card > div { display: grid; gap: 3px; }
.tuner-tip-card strong { color: #3b3151; font-family: var(--font-bold, inherit); font-size: 0.68rem; }
.tuner-tip-card p { margin: 0; color: #817c94; font-size: 0.6rem; line-height: 1.35; }

/* Anula somente regras do layout anterior que ainda alcançam estes IDs/classes. */
#appShell.app-shell:not(.is-home-active) > .tuner-panel[data-section-panel="afinador"] .tuner-primary-card .tuner-meter {
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

#appShell.app-shell:not(.is-home-active) > .tuner-panel[data-section-panel="afinador"] .tuner-primary-card .tuner-gauge {
  width: min(100%, 460px) !important;
  margin: 0 auto 3px !important;
}

#appShell.app-shell:not(.is-home-active) > .tuner-panel[data-section-panel="afinador"] .tuner-feedback {
  min-height: 47px !important;
  height: auto !important;
  padding: 7px 10px !important;
}

#appShell.app-shell:not(.is-home-active) > .tuner-panel[data-section-panel="afinador"] .tuner-feedback .tuner-status {
  display: block !important;
  min-height: 0 !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  font-family: inherit !important;
}

#appShell.app-shell:not(.is-home-active) > .tuner-panel[data-section-panel="afinador"] .tuner-toggle-button {
  min-height: 46px !important;
  padding: 0 12px !important;
}

body[data-theme="dark"] .tuner-redesign-head h2,
body[data-theme="dark"] .tuner-mic-copy strong,
body[data-theme="dark"] .tuner-card-title h3,
body[data-theme="dark"] .tuner-string-grid strong,
body[data-theme="dark"] .tuner-tip-card strong { color: #f8fafc; }
body[data-theme="dark"] .tuner-primary-card,
body[data-theme="dark"] .tuner-strings-card,
body[data-theme="dark"] .tuner-tip-card { border-color: rgba(167, 139, 250, 0.24); background: #17172c; box-shadow: none; }
body[data-theme="dark"] .tuner-primary-card .tuner-inner-halo,
body[data-theme="dark"] .tuner-primary-card .meter-readout { background: #221d43; }
body[data-theme="dark"] .tuner-primary-card .meter-readout #tunerMeterFrequency { color: #e5e7eb; }
body[data-theme="dark"] .tuner-feedback { background: #1e1a36; }
body[data-theme="dark"] .tuner-string-grid article { background: #211d3d; }

@media (min-width: 721px) {
  #appShell.app-shell > .tuner-panel[data-section-panel="afinador"] { width: min(100% - 54px, 620px); padding-bottom: 56px; }
  .tuner-primary-card { padding: 20px; }
  .tuner-mic-summary { padding-bottom: 11px; }
  .tuner-toggle-button { min-height: 52px; border-radius: 14px; }
  .tuner-strings-card { padding: 16px; }
  .tuner-string-grid { gap: 9px; }
  .tuner-string-grid article { padding-block: 9px; }
}

@media (max-width: 340px) {
  #appShell.app-shell > .tuner-panel[data-section-panel="afinador"] { width: calc(100% - 20px); }
  .tuner-primary-card { padding-inline: 8px; }
  .tuner-primary-card .meter-readout { width: 94px; min-width: 94px; min-height: 76px; padding-top: 16px; }
  .tuner-string-grid { gap: 3px; }
  .tuner-string-grid span { font-size: 0.47rem; }
}

/* Composição desktop: a versão mobile continua usando a sequência original. */
.tuner-desktop-layout,
.tuner-side-column,
.tuner-mic-desktop-card { display: contents; }

.tuner-redesign-tuning { display: none; }

@media (min-width: 1024px) {
  #appShell.app-shell > .tuner-panel[data-section-panel="afinador"] {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    width: min(calc(100% - 64px), 1220px);
    margin: 24px auto 72px;
    padding: 24px 28px 30px;
    border: 1px solid rgba(119, 48, 232, 0.12);
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 18px 42px rgba(42, 27, 93, 0.07);
  }

  .tuner-redesign-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 20px;
    min-height: 58px;
    padding: 0 4px;
  }

  .tuner-redesign-copy { justify-self: start; }

  .tuner-redesign-head h2 {
    color: #171534;
    font-size: clamp(1.45rem, 2.2vw, 1.85rem);
    line-height: 1.05;
  }

  .tuner-redesign-head p {
    margin-top: 7px;
    color: #77738e;
    font-size: 0.82rem;
  }

  .tuner-redesign-tuning {
    display: grid;
    justify-items: end;
    gap: 4px;
    padding: 10px 14px;
    border: 1px solid rgba(119, 48, 232, 0.12);
    border-radius: 12px;
    background: #fbfaff;
  }

  .tuner-redesign-tuning span {
    color: #89849d;
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .tuner-redesign-tuning strong {
    color: #6331c9;
    font-family: var(--font-semi, inherit);
    font-size: 0.82rem;
  }

  .tuner-desktop-layout {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(260px, 1fr);
    gap: 30px;
    align-items: start;
    min-width: 0;
  }

  .tuner-primary-card {
    min-width: 0;
    padding: 22px 26px 20px;
    overflow: visible;
  }

  .tuner-primary-card .tuner-meter {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 0 !important;
  }

  .tuner-primary-card .tuner-gauge {
    width: min(100%, 600px);
    margin: 0 auto 10px;
  }

  .tuner-primary-card .tuner-feedback {
    width: min(100%, 560px);
    margin: 3px auto 0;
  }

  .tuner-mic-desktop-card {
    position: absolute;
    top: 0;
    right: 0;
    display: grid;
    gap: 11px;
    width: calc((100% - 30px) / 2.8);
    min-width: 0;
    padding: 16px 18px 15px;
    border: 1px solid rgba(119, 48, 232, 0.12);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(42, 27, 93, 0.055);
  }

  .tuner-mic-desktop-card .tuner-mic-summary {
    min-height: 38px;
    padding: 0;
  }

  .tuner-mic-desktop-card .tuner-mic-copy strong { font-size: 0.78rem; }
  .tuner-mic-desktop-card .tuner-mic-copy span { font-size: 0.66rem; }

  .tuner-mic-desktop-card .tuner-toggle-button {
    min-height: 44px;
    margin-top: 0;
    border-radius: 11px;
    font-size: 0.75rem;
  }

  .tuner-mic-desktop-card .tuner-message {
    margin: -2px 2px 0;
    text-align: left;
  }

  .tuner-side-column {
    display: grid;
    align-content: start;
    gap: 18px;
    min-width: 0;
    padding-top: 168px;
  }

  .tuner-strings-card { padding: 16px; }
  .tuner-card-title { padding: 0 2px 11px; }
  .tuner-card-title h3 { font-size: 0.82rem; }
  .tuner-card-title span { font-size: 0.58rem; }

  .tuner-string-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .tuner-string-grid article {
    min-height: 86px;
    padding: 9px 5px 8px;
    border-radius: 11px;
  }

  .tuner-string-grid strong { font-size: 1.35rem; }
  .tuner-string-grid span { font-size: 0.62rem; }
  .tuner-string-grid em { font-size: 0.54rem; }

  .tuner-string-grid article.is-active {
    border-color: rgba(119, 48, 232, 0.42);
    background: #f0e9ff;
    box-shadow: 0 0 0 2px rgba(119, 48, 232, 0.08);
  }

  .tuner-string-grid article.is-active strong { color: #6331c9; }

  .tuner-tip-card {
    min-height: 66px;
    padding: 12px 14px;
  }

  body[data-theme="dark"] #appShell.app-shell > .tuner-panel[data-section-panel="afinador"] {
    border-color: rgba(167, 139, 250, 0.24);
    background: #17172c;
    box-shadow: none;
  }

  body[data-theme="dark"] .tuner-redesign-tuning,
  body[data-theme="dark"] .tuner-mic-desktop-card {
    border-color: rgba(167, 139, 250, 0.24);
    background: #211d3d;
  }
}
