:root {
  --tuner-cyan: #6ed8ff;
  --tuner-green: #78e29a;
  --tuner-amber: #f1bd62;
  --tuner-red: #ff6672;
  --tuner-slot: #0b0e12;
}

html,
body {
  min-height: 100%;
}

body {
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.tuner-page {
  padding-bottom: max(18px, env(safe-area-inset-bottom));
}

.tuner-console {
  position: relative;
  width: min(760px, 100%);
  margin: 0 auto;
  padding: clamp(14px, 2vw, 20px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(31, 36, 44, 0.97), rgba(17, 20, 25, 0.99)),
    #15191f;
  box-shadow: var(--shadow), var(--inset);
  overflow: hidden;
}

.tuner-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.tuner-kicker {
  margin: 0 0 2px;
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tuner-toolbar h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1;
  letter-spacing: -0.05em;
}

.reference-button {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-height: 42px;
  padding: 8px 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #11151a;
  box-shadow: var(--inset);
  cursor: pointer;
}

.reference-button span {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.reference-button strong {
  color: #fff;
  font-size: 17px;
}

.reference-button:hover,
.reference-button:focus-visible {
  border-color: rgba(110, 216, 255, 0.72);
}

.instrument-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 10px;
}

.instrument-button {
  min-height: 42px;
  padding: 7px 5px;
  color: #c3cad4;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: #12161b;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.instrument-button:hover,
.instrument-button:focus-visible {
  border-color: #697483;
  color: #fff;
}

.instrument-button.is-active {
  color: #071008;
  border-color: #b7f1a5;
  background: #b0ed9c;
  box-shadow: 0 0 0 1px rgba(176, 237, 156, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.38);
}

.mode-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  background: #11151a;
}

.mode-copy {
  min-width: 0;
}

.mode-copy strong,
.mode-copy span {
  display: block;
}

.mode-copy strong {
  color: #fff;
  font-size: 13px;
  font-weight: 950;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.mode-copy span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


.tuning-picker-button[hidden],
.string-panel[hidden],
.stop-button[hidden],
.error-panel[hidden] {
  display: none !important;
}

.tuning-picker-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 138px;
  min-height: 36px;
  padding: 7px 10px;
  color: #e9eef4;
  border: 1px solid #48515e;
  border-radius: 10px;
  background: #1b2027;
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
}

.tuning-picker-button b {
  color: var(--green);
  font-size: 15px;
}

.tuning-popover {
  position: absolute;
  z-index: 30;
  top: 126px;
  right: 18px;
  width: min(360px, calc(100% - 36px));
  max-height: min(56vh, 460px);
  border: 1px solid #5a6471;
  border-radius: 14px;
  background: #151a20;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.72);
  overflow: hidden;
}

.tuning-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.tuning-popover-head strong {
  font-size: 12px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.tuning-popover-head button,
.reference-head button {
  width: 34px;
  height: 34px;
  color: #cfd6df;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: #0f1317;
  font-size: 20px;
  cursor: pointer;
}

.tuning-options {
  max-height: 390px;
  padding: 7px;
  overflow-y: auto;
}

.tuning-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  color: #e7ebf0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.tuning-option:hover,
.tuning-option:focus-visible {
  background: #20262e;
  border-color: #46505c;
}

.tuning-option.is-selected {
  background: rgba(176, 237, 156, 0.1);
  border-color: rgba(176, 237, 156, 0.55);
}

.tuning-option strong,
.tuning-option small {
  display: block;
}

.tuning-option strong {
  font-size: 12px;
}

.tuning-option small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.tuning-option i {
  align-self: center;
  color: var(--green);
  font-style: normal;
  font-size: 10px;
  font-weight: 900;
}

.display-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 305px;
  border: 1px solid #404957;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 38%, rgba(110, 216, 255, 0.07), transparent 44%),
    linear-gradient(180deg, #11161c, #090c10);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.025), inset 0 -30px 70px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.start-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 22px;
  background: linear-gradient(180deg, rgba(14, 18, 23, 0.84), rgba(7, 9, 12, 0.94));
}

.start-layer[hidden] {
  display: none;
}

.start-button {
  min-width: 190px;
  min-height: 54px;
  padding: 12px 22px;
  color: #071008;
  border: 1px solid #d1ffc3;
  border-radius: 14px;
  background: #b0ed9c;
  box-shadow: 0 12px 35px rgba(66, 211, 107, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  font-size: 15px;
  font-weight: 950;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
}

.start-button:hover,
.start-button:focus-visible {
  background: #c6f7b7;
}

.start-layer p,
.start-layer small {
  margin: 0;
  text-align: center;
}

.start-layer p {
  color: #eef2f6;
  font-size: 12px;
  font-weight: 850;
}

.start-layer small {
  color: var(--muted);
  font-size: 11px;
}

.pitch-display {
  width: min(630px, 100%);
  padding: 14px clamp(14px, 4vw, 32px) 16px;
  text-align: center;
}

.target-label {
  min-height: 24px;
  color: var(--tuner-cyan);
  font-size: clamp(14px, 2.8vw, 19px);
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.note-row {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 104px;
  margin-top: 2px;
}

.note-name {
  color: #f7f9fb;
  font-size: clamp(76px, 14vw, 116px);
  font-weight: 950;
  line-height: 0.95;
  letter-spacing: -0.085em;
  text-shadow: 0 0 30px rgba(110, 216, 255, 0.08);
}

.note-octave {
  margin: 10px 0 0 5px;
  color: #b9c3cf;
  font-size: clamp(22px, 4vw, 34px);
  font-weight: 900;
}

.detected-line {
  min-height: 20px;
  margin-top: -2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.meter-wrap {
  margin-top: 10px;
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  color: #848e9b;
  font-size: 9px;
  font-weight: 950;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.meter {
  position: relative;
  height: 62px;
  border-radius: 12px;
  background: #080b0e;
  border: 1px solid #343c47;
  overflow: hidden;
}

.meter::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255, 102, 114, 0.025), transparent 40%, transparent 60%, rgba(241, 189, 98, 0.025));
  pointer-events: none;
}

.meter-segments {
  position: absolute;
  inset: 11px 12px;
  display: grid;
  grid-template-columns: repeat(25, 1fr);
  align-items: center;
  gap: clamp(2px, 0.7vw, 6px);
}

.meter-segment {
  width: 100%;
  height: 24px;
  border-radius: 2px;
  background: #2d3540;
  opacity: 0.72;
  transition: opacity 0.08s linear, height 0.08s linear, background 0.08s linear;
}

.meter-segment:nth-child(4n + 1) {
  height: 34px;
}

.meter-segment.is-center {
  height: 40px;
  background: #687482;
}

.meter-center {
  position: absolute;
  left: 50%;
  top: 5px;
  bottom: 5px;
  width: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  transform: translateX(-50%);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.18);
}

.meter-indicator {
  position: absolute;
  left: 50%;
  top: 50%;
  box-sizing: border-box;
  width: var(--meter-cell-width, 14px);
  height: 45px;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 5px;
  background: var(--tuner-cyan);
  box-shadow: 0 0 18px rgba(110, 216, 255, 0.5);
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.08s linear, background 0.08s linear, box-shadow 0.08s linear, width 0.12s ease;
}

.tuner-console.has-pitch .meter-indicator {
  opacity: 1;
}

.tuner-console.is-in-tune .meter-indicator {
  width: var(--meter-cell-width, 14px);
  background: var(--tuner-green);
  box-shadow: 0 0 24px rgba(120, 226, 154, 0.65);
}

.tuner-console.is-in-tune .meter-center {
  width: 4px;
  background: #fff;
}

.tuner-console.is-in-tune .meter-segment:nth-child(13) {
  height: 42px;
  background: var(--tuner-green);
  opacity: 1;
}

.readout-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 34px;
  margin-top: 9px;
}

.readout-row > strong {
  min-width: 74px;
  color: #dce2e9;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 108px;
  min-height: 30px;
  padding: 5px 10px;
  color: #d2d9e2;
  border: 1px solid #424b57;
  border-radius: 999px;
  background: #151a20;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tuner-console.is-in-tune .status-badge {
  color: #08120a;
  border-color: #b7f1a5;
  background: var(--tuner-green);
}

.tuner-console.is-flat .status-badge {
  color: #061016;
  border-color: #9ae6ff;
  background: var(--tuner-cyan);
}

.tuner-console.is-sharp .status-badge {
  color: #1a1002;
  border-color: #ffe0a0;
  background: var(--tuner-amber);
}

.string-panel {
  margin-top: 9px;
}

.string-buttons {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.string-button {
  position: relative;
  min-height: 44px;
  padding: 6px 3px 5px;
  color: #aeb7c2;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #11151a;
  cursor: pointer;
}

.string-button strong,
.string-button small {
  display: block;
}

.string-button strong {
  color: inherit;
  font-size: 12px;
  line-height: 1.1;
}

.string-button small {
  margin-top: 2px;
  color: #78828e;
  font-size: 9px;
  font-weight: 850;
}

.string-button:hover,
.string-button:focus-visible {
  border-color: #66717e;
  color: #fff;
}

.string-button.is-auto {
  font-weight: 950;
}

.string-button.is-current {
  color: #071008;
  border-color: #c7ffb8;
  background: #b0ed9c;
}

.string-button.is-current small {
  color: #263d28;
}

.string-button.is-locked {
  box-shadow: inset 0 -3px 0 var(--tuner-amber);
}

.string-button.is-complete::after {
  content: "✓";
  position: absolute;
  top: 3px;
  right: 5px;
  color: var(--tuner-green);
  font-size: 10px;
  font-weight: 950;
}

.string-button.is-current.is-complete::after {
  color: #173b1b;
}

.tuner-footer-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  margin-top: 8px;
  padding: 5px 2px 0;
}

.mic-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mic-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5a626d;
}

.tuner-console.is-running .mic-dot {
  background: var(--green);
  box-shadow: 0 0 10px rgba(66, 211, 107, 0.72);
}

.stop-button,
.error-panel button {
  min-height: 36px;
  padding: 7px 13px;
  color: #f4f6f8;
  border: 1px solid #5c6673;
  border-radius: 10px;
  background: #171c22;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.stop-button:hover,
.stop-button:focus-visible,
.error-panel button:hover,
.error-panel button:focus-visible {
  border-color: var(--tuner-red);
}

.error-panel {
  position: absolute;
  z-index: 40;
  inset: 50% auto auto 50%;
  width: min(420px, calc(100% - 30px));
  padding: 18px;
  border: 1px solid rgba(255, 102, 114, 0.66);
  border-radius: 15px;
  background: #181318;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.72);
  transform: translate(-50%, -50%);
  text-align: center;
}

.error-panel strong {
  display: block;
  color: #fff;
  font-size: 16px;
  text-transform: uppercase;
}

.error-panel p {
  margin: 8px 0 14px;
  color: #c3c9d1;
  font-size: 12px;
  line-height: 1.5;
}

.reference-panel {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(5px);
}

.reference-panel[hidden] {
  display: none;
}

.reference-card {
  width: min(390px, 100%);
  padding: 16px;
  border: 1px solid #596370;
  border-radius: 17px;
  background: #181d24;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.75);
}

.reference-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.reference-head small {
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.reference-head h2 {
  margin: 3px 0 0;
  font-size: 26px;
}

.reference-actions {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

.reference-actions button {
  min-height: 46px;
  color: #f2f5f8;
  border: 1px solid #4a5460;
  border-radius: 11px;
  background: #11161b;
  font-weight: 900;
  cursor: pointer;
}

.reference-actions button:first-child,
.reference-actions button:last-child {
  font-size: 22px;
}

.reference-actions button:hover,
.reference-actions button:focus-visible {
  border-color: var(--green);
}

.reference-card > p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.tuner-notes {
  width: min(760px, 100%);
  margin: 14px auto 0;
  padding: 18px 20px;
}

.tuner-notes h2 {
  margin: 0 0 7px;
  font-size: 18px;
}

.tuner-notes p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

@media (max-width: 760px) {
  .tuner-page {
    min-height: 100svh;
  }

  .site-nav {
    margin-bottom: 9px;
  }

  .tuner-console {
    display: flex;
    flex-direction: column;
    min-height: calc(100svh - 96px - env(safe-area-inset-bottom));
    padding: 10px;
    border-radius: 17px;
  }

  .tuner-toolbar {
    margin-bottom: 8px;
  }

  .tuner-kicker {
    font-size: 8.5px;
  }

  .tuner-toolbar h1 {
    font-size: 24px;
  }

  .reference-button {
    min-height: 37px;
    padding: 6px 10px;
  }

  .reference-button strong {
    font-size: 15px;
  }

  .instrument-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    margin-bottom: 7px;
  }

  .instrument-button {
    min-height: 37px;
    padding: 5px 3px;
    font-size: 10.5px;
  }

  .mode-strip {
    min-height: 43px;
    margin-bottom: 7px;
    padding: 6px 8px;
  }

  .mode-copy strong {
    font-size: 11px;
  }

  .mode-copy span {
    font-size: 10.5px;
  }

  .tuning-picker-button {
    min-width: 116px;
    min-height: 32px;
    padding: 5px 8px;
    font-size: 10px;
  }

  .tuning-popover {
    top: 154px;
    right: 10px;
    width: calc(100% - 20px);
    max-height: 48svh;
  }

  .display-stage {
    flex: 1 1 auto;
    min-height: 0;
  }

  .pitch-display {
    padding: 8px 10px 9px;
  }

  .target-label {
    min-height: 19px;
    font-size: 12px;
  }

  .note-row {
    min-height: 78px;
  }

  .note-name {
    font-size: clamp(66px, 20vw, 88px);
  }

  .note-octave {
    margin-top: 7px;
    font-size: 23px;
  }

  .detected-line {
    min-height: 16px;
    font-size: 10.5px;
  }

  .meter-wrap {
    margin-top: 5px;
  }

  .meter-labels {
    margin-bottom: 4px;
    font-size: 8px;
  }

  .meter {
    height: 54px;
  }

  .meter-segments {
    inset: 9px 8px;
    gap: 2px;
  }

  .meter-segment {
    height: 20px;
  }

  .meter-segment:nth-child(4n + 1) {
    height: 28px;
  }

  .meter-segment.is-center {
    height: 34px;
  }

  .meter-indicator {
    height: 39px;
  }

  .readout-row {
    min-height: 29px;
    margin-top: 6px;
  }

  .readout-row > strong {
    min-width: 67px;
    font-size: 12px;
  }

  .status-badge {
    min-width: 94px;
    min-height: 27px;
    padding: 4px 8px;
    font-size: 9.5px;
  }

  .string-panel {
    margin-top: 6px;
  }

  .string-buttons {
    gap: 4px;
  }

  .string-button {
    min-height: 39px;
    border-radius: 8px;
  }

  .string-button strong {
    font-size: 10.5px;
  }

  .string-button small {
    font-size: 8px;
  }

  .tuner-footer-controls {
    min-height: 34px;
    margin-top: 4px;
  }

  .tuner-notes,
  .site-footer {
    display: none;
  }
}

@media (max-width: 380px) {
  .tuner-console {
    min-height: calc(100svh - 92px - env(safe-area-inset-bottom));
    padding: 8px;
  }

  .instrument-button {
    min-height: 35px;
    font-size: 10px;
  }

  .mode-strip {
    min-height: 40px;
  }

  .note-row {
    min-height: 70px;
  }

  .note-name {
    font-size: 64px;
  }

  .meter {
    height: 50px;
  }

  .string-button {
    min-height: 37px;
  }
}

@media (max-height: 720px) and (max-width: 760px) {
  .site-nav {
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .site-links {
    display: none;
  }

  .tuner-console {
    min-height: calc(100svh - 67px - env(safe-area-inset-bottom));
  }

  .tuner-toolbar {
    margin-bottom: 5px;
  }

  .tuner-kicker {
    display: none;
  }

  .instrument-grid {
    margin-bottom: 5px;
  }

  .instrument-button {
    min-height: 33px;
  }

  .mode-strip {
    min-height: 37px;
    margin-bottom: 5px;
  }

  .display-stage {
    min-height: 240px;
  }

  .target-label {
    min-height: 17px;
  }

  .note-row {
    min-height: 65px;
  }

  .note-name {
    font-size: 61px;
  }

  .meter {
    height: 46px;
  }

  .meter-segments {
    inset-top: 7px;
    inset-bottom: 7px;
  }

  .string-button {
    min-height: 34px;
  }

  .tuner-footer-controls {
    min-height: 30px;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .site-wrap {
    padding-top: 7px;
  }

  .site-nav {
    display: none;
  }

  .tuner-console {
    width: min(980px, 100%);
    min-height: calc(100svh - 14px);
    padding: 8px 10px;
  }

  .tuner-toolbar {
    margin-bottom: 5px;
  }

  .tuner-toolbar h1 {
    font-size: 20px;
  }

  .tuner-kicker {
    display: none;
  }

  .instrument-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    margin-bottom: 5px;
  }

  .instrument-button {
    min-height: 30px;
  }

  .mode-strip {
    min-height: 34px;
    margin-bottom: 5px;
  }

  .display-stage {
    min-height: 185px;
  }

  .pitch-display {
    display: grid;
    grid-template-columns: 0.7fr 1.4fr 1.2fr;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
  }

  .target-label,
  .note-row,
  .detected-line {
    grid-column: 1;
  }

  .target-label {
    align-self: end;
  }

  .note-row {
    min-height: 62px;
  }

  .note-name {
    font-size: 58px;
  }

  .note-octave {
    font-size: 20px;
  }

  .detected-line {
    align-self: start;
  }

  .meter-wrap {
    grid-column: 2;
    grid-row: 1 / span 3;
    width: 100%;
    margin: 0;
  }

  .readout-row {
    grid-column: 3;
    grid-row: 1 / span 3;
    flex-direction: column;
  }

  .string-panel {
    margin-top: 4px;
  }

  .string-button {
    min-height: 32px;
  }

  .tuner-footer-controls {
    margin-top: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (forced-colors: active) {
  .meter-indicator,
  .meter-center,
  .instrument-button.is-active,
  .string-button.is-current,
  .status-badge {
    forced-color-adjust: none;
    outline: 2px solid CanvasText;
  }
}

/* --------------------------------------------------------------------------
   Temporary tuner test panel
   Remove the HTML block between TUNER TEST PANEL START/END when testing ends.
   These styles can then be removed as one block as well.
   -------------------------------------------------------------------------- */
.detected-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 9px;
  flex-wrap: wrap;
}

.detected-line strong {
  color: #eef4f8;
  font-size: clamp(18px, 3.5vw, 25px);
  font-weight: 950;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.025em;
}

.detected-line span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.tuner-test-panel {
  width: min(760px, 100%);
  margin: 12px auto 0;
  padding: 0;
  overflow: hidden;
  border-color: rgba(110, 216, 255, 0.26);
  background: linear-gradient(180deg, rgba(13, 18, 24, 0.96), rgba(8, 12, 16, 0.96));
}

.tuner-test-details {
  display: block;
}

.tuner-test-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 12px 16px;
  color: #e7edf3;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
}

.tuner-test-summary::-webkit-details-marker {
  display: none;
}

.tuner-test-summary::before {
  content: "▸";
  flex: 0 0 auto;
  color: var(--tuner-cyan);
  font-size: 12px;
  transition: transform 160ms ease;
}

.tuner-test-details[open] .tuner-test-summary::before {
  transform: rotate(90deg);
}

.tuner-test-summary > span:first-child {
  margin-right: auto;
}

.tuner-test-summary-meta {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.02em;
  text-transform: none;
}

.tuner-test-summary-meta strong {
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.tuner-test-body {
  padding: 0 16px 14px;
  border-top: 1px solid rgba(78, 90, 104, 0.42);
}

.tuner-test-markers {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin-top: 12px;
}

.tuner-test-markers button,
.tuner-test-actions button {
  min-height: 36px;
  padding: 6px 8px;
  color: #d9e0e7;
  border: 1px solid #46515e;
  border-radius: 9px;
  background: #151a20;
  font-size: 11px;
  font-weight: 950;
  cursor: pointer;
}

.tuner-test-markers button:hover,
.tuner-test-markers button:focus-visible,
.tuner-test-actions button:hover,
.tuner-test-actions button:focus-visible {
  border-color: var(--tuner-cyan);
}

.tuner-test-markers button.is-active {
  color: #051116;
  border-color: #a6edff;
  background: var(--tuner-cyan);
}

.tuner-test-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 10px;
}

.tuner-test-actions > span {
  margin-right: auto;
  color: var(--muted);
  font-size: 11px;
}

.tuner-test-actions > span strong {
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.tuner-test-actions button.is-primary {
  color: #061108;
  border-color: #c5ffb6;
  background: var(--tuner-green);
}

@media (max-width: 760px) {
  .instrument-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .detected-line {
    gap: 6px;
  }

  .detected-line strong {
    font-size: clamp(18px, 6.4vw, 24px);
  }

  .detected-line span {
    font-size: 9.5px;
  }

  .tuner-test-panel {
    margin-top: 10px;
  }

  .tuner-test-summary {
    padding: 11px 12px;
  }

  .tuner-test-body {
    padding: 0 12px 12px;
  }

  .tuner-test-markers {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .tuner-test-summary {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .tuner-test-summary-meta {
    flex-basis: 100%;
    padding-left: 20px;
  }

  .tuner-test-markers {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tuner-test-actions {
    flex-wrap: wrap;
  }

  .tuner-test-actions > span {
    flex-basis: 100%;
  }

  .tuner-test-actions button {
    flex: 1 1 110px;
  }
}


/* Browser translation seed for dynamic microphone error text. */
.tuner-translation-seed {
  position: fixed;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0.01;
  pointer-events: none;
  overflow: visible;
  z-index: -1;
  font-size: 1px;
  line-height: 1;
}

.tuner-translation-seed p {
  margin: 0;
  padding: 0;
  white-space: normal;
}

/* V1.301 optional cloud setups and mobile app workspace */
.tuner-mobile-head-actions,
.tuner-mobile-app-nav,
.tuner-mobile-drawer,
.tuner-mobile-tuning-panel {
  display: none;
}

.tuner-save-panel {
  width: min(760px, 100%);
  margin: 12px auto 0;
}

.tuner-save-heading,
.cloud-tuner-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tuner-save-heading h2,
.tuner-save-view h3 {
  margin: 0;
}

.tuner-save-kicker {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 10px;
  font-weight: 950;
  letter-spacing: .12em;
}

.cloud-tuner-state {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.cloud-tuner-state.is-signed-in {
  color: #a8ffbd;
  border-color: rgba(51, 224, 117, .38);
  background: rgba(51, 224, 117, .08);
}

.tuner-save-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 14px 0 10px;
}

.tuner-save-tab,
.tuner-cloud-button,
.tuner-cloud-small,
.tuner-drawer-close,
.tuner-mobile-mode-shortcut {
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #121820;
  color: var(--text);
  font: inherit;
  font-size: 10px;
  font-weight: 950;
  text-decoration: none;
  cursor: pointer;
}

.tuner-save-tab.active,
.tuner-cloud-button.is-primary {
  color: #c6ffd3;
  border-color: rgba(51, 224, 117, .55);
  background: rgba(51, 224, 117, .14);
}

.tuner-save-view {
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  background: #10151b;
}

.tuner-save-view[hidden] {
  display: none;
}

.tuner-save-view p {
  margin: 7px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.cloud-tuner-actions {
  align-items: stretch;
}

.cloud-tuner-actions input {
  flex: 1 1 220px;
  min-width: 0;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0d1218;
  color: var(--text);
  font: inherit;
}

.cloud-tuner-message {
  min-height: 18px;
  margin: 9px 0 0 !important;
}

.cloud-tuner-message.is-success { color: #9bffb3; }
.cloud-tuner-message.is-error { color: #ff9fa9; }

.cloud-tuner-list {
  display: grid;
  gap: 7px;
  margin-top: 9px;
}

.cloud-tuner-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(4, auto);
  align-items: center;
  gap: 6px;
  padding: 9px;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: #0b1016;
}

.cloud-tuner-item.is-current { border-color: rgba(51, 224, 117, .5); }
.cloud-tuner-item > div { min-width: 0; }
.cloud-tuner-item > div > strong,
.cloud-tuner-item > div > span { display: block; }
.cloud-tuner-item > div > strong { overflow-wrap: anywhere; }
.cloud-tuner-item > div > span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.tuner-cloud-small { min-height: 32px; padding: 6px 8px; }
.tuner-cloud-small.is-danger { color: #ffb0b8; border-color: rgba(255, 90, 105, .4); }
.tuner-cloud-empty { margin: 0 !important; }

@media (max-width: 760px), (max-width: 1024px) and (max-height: 620px) and (orientation: landscape) {
  html.tuner-mobile-app,
  body.tuner-mobile-app {
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow: hidden !important;
    overscroll-behavior: none;
  }

  body.tuner-mobile-app .tuner-page {
    width: 100%;
    max-width: none;
    height: var(--sol-mobile-viewport-height, 100svh);
    min-height: 0;
    box-sizing: border-box;
    margin: 0 !important;
    padding: max(6px, env(safe-area-inset-top)) 6px calc(5px + env(safe-area-inset-bottom)) !important;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 46px minmax(0, 1fr) 48px;
    gap: 5px;
    overflow: hidden;
  }

  body.tuner-mobile-app .site-nav {
    grid-row: 1;
    position: relative !important;
    inset: auto !important;
    z-index: 240;
    width: 100%;
    min-height: 0 !important;
    height: 46px;
    margin: 0 !important;
    padding: 7px 9px !important;
    border-radius: 13px;
    display: flex;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center;
  }

  body.tuner-mobile-app .site-brand { font-size: 20px; }
  body.tuner-mobile-app .site-links { display: none; }

  .tuner-mobile-head-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-left: auto;
  }

  .tuner-mobile-head-button,
  .tuner-mobile-account {
    min-height: 32px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #10151b;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font: inherit;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .05em;
    text-decoration: none;
  }

  .tuner-mobile-account span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #8b98a8;
    box-shadow: 0 0 0 3px rgba(139, 152, 168, .12);
  }

  .tuner-mobile-account.is-signed-in span { background: var(--green); }

  body.tuner-mobile-app .tuner-console {
    grid-row: 2;
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 6px;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  body.tuner-mobile-app .tuner-toolbar,
  body.tuner-mobile-app .tuner-console > .instrument-grid,
  body.tuner-mobile-app .tuner-console > .tuning-popover,
  body.tuner-mobile-app .tuner-console > .tuner-mobile-tuning-panel,
  body.tuner-mobile-app .tuner-save-panel:not(.mobile-drawer-content),
  body.tuner-mobile-app .tuner-notes:not(.mobile-drawer-content),
  body.tuner-mobile-app .tuner-test-panel,
  body.tuner-mobile-app .counter-strip,
  body.tuner-mobile-app .related-tools:not(.mobile-drawer-content),
  body.tuner-mobile-app .tool-feedback:not(.mobile-drawer-content),
  body.tuner-mobile-app .site-footer {
    display: none !important;
  }

  body.tuner-mobile-app .mode-strip {
    flex: 0 0 auto;
    min-height: 42px;
    margin: 0 0 5px;
    padding: 6px 9px;
  }

  body.tuner-mobile-app .mode-copy strong { font-size: 11px; }
  body.tuner-mobile-app .mode-copy span { font-size: 10px; }
  body.tuner-mobile-app .tuning-picker-button { min-height: 30px; min-width: 96px; }

  body.tuner-mobile-app .display-stage {
    flex: 1 1 auto;
    min-height: 0 !important;
    height: auto;
    border-radius: 13px;
  }

  body.tuner-mobile-app .pitch-display {
    width: 100%;
    max-height: 100%;
    padding: 5px 7px 6px;
  }

  body.tuner-mobile-app .target-label { min-height: 17px; font-size: 10px; }
  body.tuner-mobile-app .note-row { min-height: 64px; }
  body.tuner-mobile-app .note-name { font-size: clamp(62px, 22vw, 86px); }
  body.tuner-mobile-app .note-octave { font-size: 21px; }
  body.tuner-mobile-app .detected-line { min-height: 17px; }
  body.tuner-mobile-app .detected-line strong { font-size: clamp(17px, 5.5vw, 22px); }
  body.tuner-mobile-app .meter-wrap { margin-top: 4px; }
  body.tuner-mobile-app .meter { height: min(54px, 8dvh); }
  body.tuner-mobile-app .readout-row { min-height: 28px; margin-top: 5px; }

  body.tuner-mobile-app .start-button {
    min-width: min(220px, 72vw);
    min-height: 58px;
    font-size: 16px;
  }

  body.tuner-mobile-app .string-panel { flex: 0 0 auto; margin-top: 5px; }
  body.tuner-mobile-app .string-buttons { gap: 3px; }
  body.tuner-mobile-app .string-button { min-height: 37px; padding: 4px 2px; }
  body.tuner-mobile-app .string-button strong { font-size: 10px; }
  body.tuner-mobile-app .string-button small { font-size: 7px; }

  body.tuner-mobile-app .tuner-footer-controls {
    flex: 0 0 36px;
    min-height: 36px;
    margin: 2px 0 0;
    padding: 3px 2px 0;
  }

  body.tuner-mobile-app .stop-button { min-height: 32px; }
  body.tuner-mobile-app .error-panel { width: calc(100% - 18px); }
  body.tuner-mobile-app .reference-panel { z-index: 1100; }

  .tuner-mobile-app-nav {
    grid-row: 3;
    position: fixed;
    z-index: 901;
    left: 6px;
    right: 6px;
    bottom: max(6px, env(safe-area-inset-bottom));
    width: auto;
    height: 46px;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    padding: 5px;
    border: 1px solid rgba(51, 224, 117, .28);
    border-radius: 14px;
    background: rgba(13, 18, 24, .98);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .42), var(--inset);
  }

  .tuner-mobile-app-nav button {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #171c23;
    color: var(--text);
    font: inherit;
    font-size: 8.5px;
    font-weight: 1000;
    letter-spacing: .03em;
    line-height: 1;
    white-space: nowrap;
  }

  .tuner-mobile-app-nav button.active,
  .tuner-mobile-app-nav .save-load { border-color: rgba(51, 224, 117, .48); }
  .tuner-mobile-app-nav button span,
  .tuner-mobile-app-nav button strong { font: inherit; }

  .tuner-mobile-drawer {
    position: fixed;
    z-index: 900;
    top: calc(58px + env(safe-area-inset-top));
    left: 6px;
    right: 6px;
    bottom: calc(58px + env(safe-area-inset-bottom));
    width: auto !important;
    max-width: none !important;
    min-height: 0;
    border: 1px solid rgba(51, 224, 117, .34);
    border-radius: 15px;
    background: rgba(13, 18, 24, .99);
    box-shadow: 0 18px 46px rgba(0, 0, 0, .65), var(--inset);
    overflow: hidden;
    box-sizing: border-box;
  }

  .tuner-mobile-drawer:not([hidden]) {
    display: grid;
    grid-template-rows: 46px minmax(0, 1fr);
  }

  .tuner-mobile-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 9px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--green);
    font-size: 11px;
    letter-spacing: .12em;
  }

  .tuner-drawer-close { min-height: 32px; padding: 6px 10px; }

  .tuner-mobile-drawer-body {
    min-height: 0;
    padding: 7px 8px 10px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
    box-sizing: border-box;
  }

  .tuner-mobile-drawer-body::-webkit-scrollbar { display: none; width: 0; height: 0; }

  .tuner-mobile-drawer-body.is-mode-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  .mobile-drawer-content {
    width: 100%;
    max-width: none;
    margin: 0 0 9px !important;
    box-sizing: border-box;
  }

  .instrument-grid.mobile-drawer-content {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding: 10px;
    border: 1px solid var(--line-soft);
    border-radius: 13px;
    background: #11161c;
    margin-bottom: 7px !important;
  }

  .instrument-grid.mobile-drawer-content .instrument-button {
    min-height: 52px;
    font-size: 12px;
  }

  .instrument-grid.mobile-drawer-content .instrument-button:first-child { grid-column: 1 / -1; }

  .cloud-tuner-item {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .cloud-tuner-item > div {
    grid-column: 1 / -1;
    margin-bottom: 3px;
  }

  .cloud-tuner-item > div > span {
    overflow-wrap: normal;
  }

  .cloud-tuner-item .tuner-cloud-small {
    width: 100%;
  }

  .tuner-mobile-tuning-panel.mobile-drawer-content {
    display: grid !important;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
    padding: 11px;
    border: 1px solid var(--line-soft);
    border-radius: 13px;
    background: #11161c;
    margin-bottom: 0 !important;
    overflow: hidden;
  }

  .tuner-mobile-tuning-panel.mobile-drawer-content[hidden] { display: none !important; }

  .tuner-mobile-panel-copy strong,
  .tuner-mobile-panel-copy span { display: block; }
  .tuner-mobile-panel-copy span { margin-top: 4px; color: var(--muted); font-size: 11px; }
  .tuner-mobile-tuning-options {
    min-height: 0;
    display: grid;
    align-content: start;
    gap: 7px;
    margin-top: 10px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .tuner-mobile-tuning-options::-webkit-scrollbar { display: none; width: 0; height: 0; }
  .tuner-mobile-tuning-option {
    min-height: 54px;
    padding: 9px 11px;
    border: 1px solid var(--line-soft);
    border-radius: 11px;
    background: #0c1117;
    color: var(--text);
    text-align: left;
  }
  .tuner-mobile-tuning-option strong,
  .tuner-mobile-tuning-option span { display: block; }
  .tuner-mobile-tuning-option span { margin-top: 3px; color: var(--muted); font-size: 10px; }
  .tuner-mobile-tuning-option.is-active { border-color: rgba(51, 224, 117, .55); background: rgba(51, 224, 117, .12); }
  .tuner-mobile-mode-shortcut { width: 100%; }

  .tuner-save-panel.mobile-drawer-content { display: block !important; padding: 11px; }
  .tuner-save-heading h2 { font-size: 18px; }
  .tuner-save-heading .cloud-tuner-state { display: none; }
  .cloud-tuner-actions { align-items: stretch; flex-direction: column; }
  .cloud-tuner-actions input,
  .cloud-tuner-actions .tuner-cloud-button { width: 100%; flex: none; }
  .cloud-tuner-item { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .tuner-mobile-drawer .tuner-notes.mobile-drawer-content { display: block !important; padding: 13px; }
  .tuner-mobile-drawer .related-tools.mobile-drawer-content,
  .tuner-mobile-drawer .tool-feedback.mobile-drawer-content { display: block !important; }
  body.tuner-mobile-app .tool-feedback-float { display: none !important; }
}

@media (max-width: 380px) {
  body.tuner-mobile-app .site-brand { font-size: 18px; }
  .tuner-mobile-head-button,
  .tuner-mobile-account { min-height: 30px; padding: 0 8px; font-size: 9px; }
  body.tuner-mobile-app .mode-strip { min-height: 39px; }
  body.tuner-mobile-app .note-row { min-height: 58px; }
  body.tuner-mobile-app .note-name { font-size: 60px; }
  body.tuner-mobile-app .meter { height: min(48px, 7dvh); }
  .tuner-mobile-app-nav button { font-size: 8px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  body.tuner-mobile-app .tuner-page {
    grid-template-rows: minmax(0, 1fr) 46px;
  }
  body.tuner-mobile-app .site-nav { display: none; }
  body.tuner-mobile-app .tuner-console { grid-row: 1; }
  .tuner-mobile-app-nav { grid-row: 2; }
  body.tuner-mobile-app .pitch-display {
    grid-template-columns: .7fr 1.4fr 1.2fr;
  }
  .tuner-mobile-drawer { top: 6px; }
}

@supports not (height: 100svh) {
  @media (max-width: 760px) {
    body.tuner-mobile-app .tuner-page { height: var(--sol-mobile-viewport-height, 100vh); }
  }
}
