/* ================================================================
   tuner.css — Guitar Tuner Tool
   ChordStar Music Portal — Flagship Premium Redesign
   Combines GuitarTuna-grade usability with ChordStar dark-purple studio aesthetic
   ================================================================ */

/* ── Modal overlay ───────────────────────────────────────────── */
#tunerModal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(4, 2, 8, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    justify-content: center;
    align-items: center;
    z-index: 2100;
    padding: 1rem;
    box-sizing: border-box;
}
#tunerModal.open {
    display: flex !important;
}

/* ── Main Container ──────────────────────────────────────────── */
.tuner-box {
    background: linear-gradient(165deg, #0e071c 0%, #17092e 50%, #090312 100%);
    border: 1px solid rgba(168, 85, 247, 0.28);
    border-radius: 28px;
    box-shadow:
        0 0 0 1px rgba(168, 85, 247, 0.1),
        0 24px 70px rgba(0, 0, 0, 0.85),
        0 0 50px rgba(147, 51, 234, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    width: 100%;
    max-width: 660px;
    min-width: 320px;
    margin: auto;
    padding: 0 0 1.5rem 0;
    position: relative;
    overflow-y: auto;
    max-height: calc(100dvh - 40px);
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Subtle studio noise texture & ambient violet radial light */
.tuner-box::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 50% 0%, rgba(168, 85, 247, 0.16) 0%, transparent 60%),
        linear-gradient(rgba(168, 85, 247, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(168, 85, 247, 0.025) 1px, transparent 1px);
    background-size: 100% 100%, 32px 32px, 32px 32px;
    pointer-events: none;
    border-radius: 28px;
}

/* ── Header ──────────────────────────────────────────────────── */
.tuner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.75rem 1rem;
    border-bottom: 1px solid rgba(168, 85, 247, 0.14);
    position: relative;
    z-index: 2;
}
.tuner-header-left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}
.tuner-header-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(168, 85, 247, 0.15);
    border: 1px solid rgba(168, 85, 247, 0.35);
    color: #c084fc;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 14px rgba(168, 85, 247, 0.25);
    flex-shrink: 0;
}
.tuner-header-icon svg {
    width: 20px !important;
    height: 20px !important;
    max-width: 20px !important;
    max-height: 20px !important;
    display: block;
    flex-shrink: 0;
}
.tuner-header-titles h2 {
    font-size: 1.2rem;
    font-weight: 800;
    color: #ffffff;
    margin: 0 0 2px 0;
    letter-spacing: -0.01em;
}
.tuner-header-titles span,
#tunerSubtitle {
    font-size: 0.74rem;
    font-weight: 500;
    color: rgba(224, 215, 245, 0.65);
    letter-spacing: 0.02em;
    display: block;
}
.tuner-header-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}
.tuner-engine-pill {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.25);
    color: #c084fc;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    cursor: default;
    flex-shrink: 0;
}
.tuner-engine-pill svg {
    width: 16px !important;
    height: 16px !important;
    max-width: 16px !important;
    max-height: 16px !important;
    display: block;
    flex-shrink: 0;
}
.tuner-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(230, 220, 250, 0.75);
    font-size: 1.15rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    flex-shrink: 0;
}
.tuner-close-btn:hover {
    background: rgba(168, 85, 247, 0.25);
    color: #ffffff;
    border-color: rgba(168, 85, 247, 0.6);
    transform: rotate(90deg);
}

/* ── Controls & Preset Bar ───────────────────────────────────── */
.tuner-controls-bar {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1.75rem;
    background: rgba(8, 3, 16, 0.4);
    border-bottom: 1px solid rgba(168, 85, 247, 0.1);
    flex-wrap: wrap;
    position: relative;
    z-index: 2;
}
.tuner-control-group {
    flex: 1 1 170px;
    min-width: 150px;
    background: rgba(22, 10, 38, 0.7);
    border: 1px solid rgba(168, 85, 247, 0.22);
    border-radius: 16px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 9px;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.tuner-control-group:hover,
.tuner-control-group:focus-within {
    border-color: rgba(168, 85, 247, 0.55);
    background: rgba(28, 12, 48, 0.85);
    box-shadow: 0 0 14px rgba(168, 85, 247, 0.25);
}
.tuner-control-icon {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    color: rgba(192, 132, 252, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tuner-control-icon svg {
    width: 18px !important;
    height: 18px !important;
    max-width: 18px !important;
    max-height: 18px !important;
    display: block;
    flex-shrink: 0;
}
.tuner-control-inner {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}
.tuner-control-label {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: rgba(196, 181, 212, 0.45);
    margin-bottom: 2px;
}
.tuner-select {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    width: 100%;
    padding: 0 18px 0 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23c084fc' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right center;
    background-size: 11px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}
.tuner-select option {
    background: #140728;
    color: #ffffff;
    padding: 8px;
}
.tuner-mode-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    padding: 0 18px 0 0;
    text-align: left;
    outline: none;
    width: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23c084fc' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right center;
    background-size: 11px;
    transition: color 0.2s ease;
}
.tuner-mode-btn.chromatic {
    color: #38bdf8;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2338bdf8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* ── Status Bar ──────────────────────────────────────────────── */
.tuner-status-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.65rem 1.75rem 0.25rem;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(224, 215, 245, 0.65);
    position: relative;
    z-index: 2;
}
.tuner-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(196, 181, 212, 0.3);
    transition: all 0.3s ease;
    flex-shrink: 0;
}
.tuner-status-dot.listening {
    background: #c084fc;
    box-shadow: 0 0 10px rgba(192, 132, 252, 0.9);
    animation: tsPulse 1.4s ease-in-out infinite;
}
.tuner-status-dot.in-tune {
    background: #4ade80;
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.9);
    animation: tsPulse 1s ease-in-out infinite;
}
@keyframes tsPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%       { transform: scale(1.35); opacity: 0.75; }
}

/* ── Needle Meter ────────────────────────────────────────────── */
.tuner-meter {
    position: relative;
    height: 125px;
    margin: 0.25rem 1.75rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
}
.tuner-arc-wrap {
    position: relative;
    width: 340px;
    height: 96px;
    overflow: hidden;
    flex-shrink: 0;
}
.tuner-arc-wrap svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}
.tuner-scale {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    width: 330px;
    padding: 0 6px;
    margin-top: 2px;
}
.tuner-scale span {
    font-size: 0.68rem;
    font-weight: 600;
    color: rgba(224, 215, 245, 0.45);
    letter-spacing: 0.04em;
    font-family: inherit;
}
.tuner-scale span.center-label {
    color: #4ade80;
    font-weight: 800;
    font-size: 0.78rem;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.6);
}

/* Studio Needle */
#tunerNeedle {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 3px;
    height: 76px;
    background: linear-gradient(to top, rgba(168, 85, 247, 0.25) 0%, #c084fc 65%, #ffffff 100%);
    border-radius: 3px;
    transform-origin: bottom center;
    transform: translateX(-50%) rotate(0deg);
    filter: drop-shadow(0 0 8px rgba(192, 132, 252, 0.9));
    transition: transform 0.12s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 3;
}
#tunerNeedle::after {
    content: '';
    position: absolute;
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 0 14px rgba(192, 132, 252, 1), 0 0 4px #ffffff;
}
#tunerNeedle::before {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(192, 132, 252, 0.8) 0%, transparent 75%);
}

/* In-Tune needle state */
#tunerNeedle.in-tune {
    background: linear-gradient(to top, rgba(34, 197, 94, 0.3) 0%, #22c55e 60%, #4ade80 100%);
    filter: drop-shadow(0 0 10px rgba(74, 222, 128, 1));
}
#tunerNeedle.in-tune::after {
    background: #4ade80;
    box-shadow: 0 0 16px rgba(74, 222, 128, 1), 0 0 4px #ffffff;
}

/* Sharp / Flat needle state */
#tunerNeedle.sharp,
#tunerNeedle.flat {
    background: linear-gradient(to top, rgba(239, 68, 68, 0.3) 0%, #ef4444 60%, #fca5a5 100%);
    filter: drop-shadow(0 0 10px rgba(239, 68, 68, 1));
}
#tunerNeedle.sharp::after,
#tunerNeedle.flat::after {
    background: #ef4444;
    box-shadow: 0 0 16px rgba(239, 68, 68, 1), 0 0 4px #ffffff;
}

/* ── Note Readout Box ────────────────────────────────────────── */
.tuner-readout {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    margin: 0.5rem 1.75rem 1.15rem;
    padding: 0.9rem 1.5rem;
    background: rgba(16, 7, 28, 0.75);
    border: 1px solid rgba(168, 85, 247, 0.22);
    border-radius: 20px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 8px 24px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(14px);
    position: relative;
    z-index: 2;
}
.tuner-readout-item {
    text-align: center;
    flex: 1;
}
.tuner-readout-badge-item {
    flex: 1.3;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}
.tuner-readout-label {
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(196, 181, 212, 0.45);
    margin-bottom: 2px;
}
.tuner-note-big {
    font-size: 2.6rem;
    font-weight: 900;
    color: #ffffff;
    line-height: 1.05;
    letter-spacing: -0.02em;
    transition: color 0.25s ease, text-shadow 0.25s ease;
}
.tuner-note-big.active {
    color: #ffffff;
    text-shadow: 0 0 20px rgba(192, 132, 252, 0.6);
}
.tuner-note-big.in-tune {
    color: #4ade80;
    text-shadow: 0 0 24px rgba(74, 222, 128, 0.8);
}
.tuner-readout-value {
    font-size: 1.35rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
    transition: color 0.25s ease;
}
.tuner-readout-value.in-tune {
    color: #4ade80;
}

/* In-Tune / State Pill Badge */
.tuner-in-tune-badge {
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-radius: 50px;
    padding: 8px 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.25s ease;
    border: 1px solid transparent;
    min-height: 36px;
    color: transparent;
    opacity: 0;
}
.tuner-in-tune-badge.show {
    opacity: 1;
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(74, 222, 128, 0.5);
    color: #4ade80;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.35);
}
.tuner-in-tune-badge.show::before {
    content: '✓ ';
    font-weight: 900;
}

/* ── Guitar Headstock + String Pegs ─────────────────────────── */
.tuner-guitar-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0 0.5rem;
    min-height: 230px;
    z-index: 2;
}
.tuner-strings-left,
.tuner-strings-right {
    display: flex;
    flex-direction: column;
    gap: 0.95rem;
    z-index: 3;
    flex-shrink: 0;
}
.tuner-strings-left { margin-right: -10px; }
.tuner-strings-right { margin-left: -10px; }

/* Interactive String Peg Buttons */
.tuner-peg {
    min-width: 84px;
    height: 56px;
    border-radius: 18px;
    border: 1.5px solid rgba(168, 85, 247, 0.26);
    background: rgba(18, 9, 32, 0.88);
    color: #ffffff;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    user-select: none;
    -webkit-user-select: none;
    flex-shrink: 0;
    font-family: inherit;
    outline: none;
}
.tuner-peg:hover {
    border-color: rgba(168, 85, 247, 0.65);
    background: rgba(168, 85, 247, 0.18);
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(168, 85, 247, 0.35);
}
.tuner-peg.active {
    border-color: rgba(192, 132, 252, 0.8);
    color: #ffffff;
    background: rgba(168, 85, 247, 0.22);
    box-shadow:
        0 0 20px rgba(192, 132, 252, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.tuner-peg.in-tune {
    border-color: #22c55e !important;
    color: #4ade80 !important;
    background: rgba(34, 197, 94, 0.2) !important;
    box-shadow:
        0 0 28px rgba(34, 197, 94, 0.8),
        inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
}
.tuner-peg.plucked {
    transform: scale(1.1);
    box-shadow: 0 0 32px rgba(217, 70, 239, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
    border-color: #d946ef !important;
}
.tuner-peg span.peg-hz {
    font-size: 0.64rem;
    font-weight: 500;
    color: rgba(224, 215, 245, 0.55);
    letter-spacing: 0.03em;
    white-space: nowrap;
    margin-top: 1px;
}
.tuner-peg.active span.peg-hz {
    color: #c084fc;
}
.tuner-peg.in-tune span.peg-hz {
    color: #4ade80;
}

/* Headstock Center Illustration */
.tuner-headstock {
    width: 200px;
    height: 230px;
    flex-shrink: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tuner-headstock-svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.85));
}

/* ── A4 Reference Calibration ────────────────────────────────── */
.tuner-a4-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    margin: 0.9rem 1.75rem 0.5rem;
    flex-wrap: wrap;
    position: relative;
    z-index: 2;
}
.tuner-a4-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(224, 215, 245, 0.65);
}
.tuner-a4-icon {
    width: 15px !important;
    height: 15px !important;
    max-width: 15px !important;
    max-height: 15px !important;
    color: #c084fc;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}
.tuner-a4-segmented {
    background: rgba(14, 6, 26, 0.8);
    border: 1px solid rgba(168, 85, 247, 0.22);
    border-radius: 14px;
    padding: 4px;
    display: inline-flex;
    gap: 4px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.tuner-a4-btn {
    background: transparent;
    color: rgba(224, 215, 245, 0.7);
    border: none;
    border-radius: 10px;
    padding: 6px 13px;
    font-size: 0.76rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}
.tuner-a4-btn:hover {
    color: #ffffff;
    background: rgba(168, 85, 247, 0.16);
}
.tuner-a4-btn.active {
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%) !important;
    color: #ffffff !important;
    font-weight: 800 !important;
    box-shadow: 0 0 16px rgba(168, 85, 247, 0.65) !important;
}

/* ── Bottom Bar: VU Meter, Start Button, Audio Indicator ─────── */
.tuner-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1.75rem 0.25rem;
    position: relative;
    z-index: 2;
}
.tuner-vu-container {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(192, 132, 252, 0.75);
    min-width: 95px;
}
.tuner-bottom-icon {
    width: 18px !important;
    height: 18px !important;
    max-width: 18px !important;
    max-height: 18px !important;
    display: block;
    flex-shrink: 0;
}
.tuner-vu-wrap {
    width: 65px;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.tuner-vu-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #22c55e 0%, #eab308 65%, #ef4444 100%);
    border-radius: 4px;
    transition: width 0.06s ease;
}
.tuner-btn-row {
    display: flex;
    justify-content: center;
    flex: 1;
}
#tunerStartBtn {
    background: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
    color: #ffffff;
    border: none;
    border-radius: 50px;
    padding: 0.92rem 2.8rem;
    font-size: 0.88rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow:
        0 8px 30px rgba(168, 85, 247, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    outline: none;
    font-family: inherit;
    white-space: nowrap;
}
#tunerStartBtn:hover {
    transform: translateY(-2px);
    box-shadow:
        0 12px 38px rgba(168, 85, 247, 0.7),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
#tunerStartBtn.active {
    background: linear-gradient(135deg, #1b0e2b 0%, #28143d 100%);
    border: 1px solid rgba(168, 85, 247, 0.45);
    color: #f0e7ff;
    box-shadow:
        0 6px 24px rgba(0, 0, 0, 0.5),
        0 0 18px rgba(168, 85, 247, 0.25);
}
.tuner-audio-out-indicator {
    display: flex;
    align-items: center;
    gap: 7px;
    color: rgba(192, 132, 252, 0.75);
    min-width: 95px;
    justify-content: flex-end;
}
.tuner-out-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 12px;
}
.tuner-out-bars span {
    width: 3px;
    background: #4ade80;
    border-radius: 1px;
    animation: eqPulse 1.2s ease-in-out infinite;
}
.tuner-out-bars span:nth-child(1) { height: 4px; animation-delay: 0.1s; }
.tuner-out-bars span:nth-child(2) { height: 8px; animation-delay: 0.3s; }
.tuner-out-bars span:nth-child(3) { height: 12px; animation-delay: 0.2s; }
@keyframes eqPulse {
    0%, 100% { transform: scaleY(0.4); opacity: 0.6; }
    50%       { transform: scaleY(1); opacity: 1; }
}

/* ── Mic Permission Error ────────────────────────────────────── */
.tuner-mic-error {
    display: none;
    text-align: center;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.14);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 14px;
    font-size: 0.8rem;
    margin: 0.75rem 1.75rem 0;
    padding: 10px 16px;
    line-height: 1.5;
    position: relative;
    z-index: 2;
}
.tuner-mic-error.show {
    display: block;
    animation: cttCardIn 0.3s ease;
}

/* ── Light Theme Overrides ───────────────────────────────────── */
[data-theme="light"] .tuner-box {
    background: linear-gradient(165deg, #f7f2ff 0%, #ece0fc 50%, #f4ebff 100%);
    border-color: rgba(147, 51, 234, 0.25);
    box-shadow:
        0 20px 60px rgba(91, 45, 140, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
[data-theme="light"] .tuner-box::before {
    background: radial-gradient(circle at 50% 0%, rgba(168, 85, 247, 0.08) 0%, transparent 60%);
}
[data-theme="light"] .tuner-header-titles h2 { color: #1a0535; }
[data-theme="light"] #tunerSubtitle { color: rgba(91, 45, 140, 0.65); }
[data-theme="light"] .tuner-header-icon {
    background: rgba(147, 51, 234, 0.12);
    border-color: rgba(147, 51, 234, 0.25);
    color: #7c3aed;
}
[data-theme="light"] .tuner-close-btn {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1a0535;
}
[data-theme="light"] .tuner-control-group {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(147, 51, 234, 0.2);
}
[data-theme="light"] .tuner-select {
    color: #1a0535;
}
[data-theme="light"] .tuner-select option {
    background: #ffffff;
    color: #1a0535;
}
[data-theme="light"] .tuner-mode-btn {
    color: #1a0535;
}
[data-theme="light"] .tuner-readout {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(147, 51, 234, 0.18);
}
[data-theme="light"] .tuner-note-big { color: #1a0535; }
[data-theme="light"] .tuner-readout-value { color: #1a0535; }
[data-theme="light"] .tuner-scale span { color: rgba(91, 45, 140, 0.55); }
[data-theme="light"] .tuner-peg {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(147, 51, 234, 0.22);
    color: #1a0535;
    box-shadow: 0 4px 14px rgba(91, 45, 140, 0.1);
}
[data-theme="light"] .tuner-peg span.peg-hz { color: rgba(91, 45, 140, 0.6); }
[data-theme="light"] .tuner-a4-segmented {
    background: rgba(255, 255, 255, 0.75);
    border-color: rgba(147, 51, 234, 0.2);
}
[data-theme="light"] .tuner-a4-btn {
    color: rgba(91, 45, 140, 0.75);
}

/* ── Responsive Adaptations ──────────────────────────────────── */
@media (max-width: 640px) {
    .tuner-box {
        border-radius: 20px;
        padding-bottom: 1.25rem;
    }
    .tuner-header {
        padding: 1rem 1.25rem 0.75rem;
    }
    .tuner-controls-bar {
        padding: 0.65rem 1.25rem;
        gap: 0.5rem;
    }
    .tuner-control-group {
        flex: 1 1 100%;
        padding: 6px 12px;
    }
    .tuner-meter {
        margin: 0.25rem 1rem 0.5rem;
    }
    .tuner-arc-wrap {
        width: 300px;
        height: 85px;
    }
    #tunerNeedle {
        height: 66px;
    }
    .tuner-scale {
        width: 290px;
    }
    .tuner-readout {
        margin: 0.5rem 1.25rem 1rem;
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }
    .tuner-note-big {
        font-size: 2.2rem;
    }
    .tuner-readout-value {
        font-size: 1.15rem;
    }
    .tuner-headstock {
        width: 160px;
        height: 200px;
    }
    .tuner-peg {
        min-width: 68px;
        height: 50px;
        font-size: 1rem;
        border-radius: 14px;
    }
    .tuner-strings-left { margin-right: -6px; }
    .tuner-strings-right { margin-left: -6px; }
    .tuner-a4-row {
        margin: 0.75rem 1.25rem 0.5rem;
        gap: 0.5rem;
    }
    .tuner-a4-btn {
        padding: 5px 9px;
        font-size: 0.72rem;
    }
    .tuner-bottom-bar {
        padding: 0.5rem 1.25rem 0.25rem;
    }
    #tunerStartBtn {
        padding: 0.85rem 2rem;
        font-size: 0.82rem;
    }
}

@media (max-width: 440px) {
    .tuner-arc-wrap {
        width: 260px;
        height: 75px;
    }
    #tunerNeedle {
        height: 56px;
    }
    .tuner-scale {
        width: 250px;
    }
    .tuner-headstock {
        width: 135px;
        height: 180px;
    }
    .tuner-peg {
        min-width: 58px;
        height: 46px;
        font-size: 0.92rem;
        border-radius: 12px;
    }
    .tuner-readout {
        gap: 0.4rem;
        padding: 0.6rem 0.8rem;
    }
    .tuner-note-big {
        font-size: 1.85rem;
    }
    .tuner-readout-value {
        font-size: 0.95rem;
    }
    .tuner-in-tune-badge {
        font-size: 0.68rem;
        padding: 6px 10px;
        min-width: 75px;
    }
    .tuner-vu-container,
    .tuner-audio-out-indicator {
        min-width: 60px;
    }
    .tuner-vu-wrap {
        width: 45px;
    }
    #tunerStartBtn {
        padding: 0.78rem 1.4rem;
        font-size: 0.76rem;
    }
}
