/* ============================================================
   Real-Time Frequency Detector — Advanced Tool Styles
   ============================================================ */

/* ── Visualization canvas wrappers ── */
.viz-canvas-wrap {
    width: 100%;
    height: 150px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
}

.viz-canvas-wrap canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ── Circular Gauge ── */
.gauge-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: var(--space-md);
}

.gauge-svg {
    width: 260px;
    height: 260px;
    filter: drop-shadow(0 0 12px rgba(0, 255, 65, 0.15));
}

.gauge-bg {
    fill: none;
    stroke: var(--color-border);
    stroke-width: 10;
    stroke-linecap: round;
}

.gauge-fill {
    fill: none;
    stroke: var(--color-primary);
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.15s ease;
    filter: drop-shadow(0 0 6px rgba(0, 255, 65, 0.5));
}

.gauge-value {
    fill: var(--color-primary);
    font-family: var(--font-display);
    font-size: 2rem;
    text-anchor: middle;
    text-shadow: 0 0 10px rgba(0, 255, 65, 0.5);
}

.gauge-unit {
    fill: var(--color-text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-anchor: middle;
}

.gauge-note {
    fill: var(--color-secondary);
    font-family: var(--font-display);
    font-size: 1.25rem;
    text-anchor: middle;
}

/* ── Pitch Accuracy Meter ── */
.pitch-meter {
    margin-bottom: var(--space-md);
}

.pitch-meter__bar {
    position: relative;
    height: 20px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.pitch-meter__center {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--color-primary);
    transform: translateX(-50%);
    z-index: 2;
    box-shadow: 0 0 6px rgba(0, 255, 65, 0.6);
}

.pitch-meter__needle {
    position: absolute;
    top: 2px;
    bottom: 2px;
    width: 8px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    transition: left 0.1s ease, background 0.2s ease;
    transform: translateX(-50%);
    z-index: 3;
    box-shadow: 0 0 8px rgba(0, 255, 65, 0.6);
}

.pitch-meter__needle--sharp {
    background: var(--color-warning);
    box-shadow: 0 0 8px rgba(255, 179, 0, 0.6);
}

.pitch-meter__needle--flat {
    background: var(--color-error);
    box-shadow: 0 0 8px rgba(255, 23, 68, 0.6);
}

.pitch-meter__labels {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    margin-top: 4px;
}

/* ── Multi-Frequency Table ── */
.freq-table-wrap {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.freq-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
}

.freq-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.freq-table th {
    background: var(--color-surface);
    color: var(--color-primary);
    padding: var(--space-sm) var(--space-sm);
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: var(--fs-xs);
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--color-border);
}

.freq-table td {
    padding: var(--space-xs) var(--space-sm);
    border-bottom: 1px solid rgba(15, 61, 30, 0.3);
    color: var(--color-text);
}

.freq-table tr:hover td {
    background: rgba(0, 255, 65, 0.03);
}

.freq-table .amp-bar {
    display: inline-block;
    height: 8px;
    background: var(--color-primary);
    border-radius: 4px;
    min-width: 4px;
    box-shadow: 0 0 4px rgba(0, 255, 65, 0.3);
    vertical-align: middle;
}

.freq-table .peak-rank {
    color: var(--color-secondary);
    font-weight: 700;
}

/* ── Advanced Controls ── */
.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

@media (max-width: 480px) {
    .controls-grid {
        grid-template-columns: 1fr;
    }
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.control-group__label {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.control-group__value {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    text-align: right;
}

.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
}

/* Range slider */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(0, 255, 65, 0.5);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--color-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(0, 255, 65, 0.5);
}

/* Custom number input */
.tuning-input {
    width: 70px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    color: var(--color-primary);
    text-align: center;
}

.tuning-input:focus {
    border-color: var(--color-primary);
    box-shadow: var(--glow-sm);
}

/* ── Session Stats ── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.stat-box {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    text-align: center;
}

.stat-box__label {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.stat-box__value {
    font-family: var(--font-display);
    font-size: var(--fs-md);
    color: var(--color-primary);
}

/* ── History Log ── */
.history-wrap {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-top: var(--space-sm);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
}

.history-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.history-table th {
    background: var(--color-surface);
    color: var(--color-secondary);
    padding: 6px var(--space-sm);
    text-align: left;
    font-weight: 600;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--color-border);
}

.history-table td {
    padding: 4px var(--space-sm);
    border-bottom: 1px solid rgba(15, 61, 30, 0.2);
    color: var(--color-text);
}

/* ── Export Buttons ── */
.export-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.btn--sm {
    padding: 6px 12px;
    font-size: var(--fs-xs);
}

/* ── Freeze indicator ── */
.freeze-badge {
    display: none;
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-secondary);
    background: rgba(0, 229, 255, 0.1);
    border: 1px solid var(--color-secondary);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    animation: freezePulse 1.5s ease-in-out infinite;
}

.freeze-badge.active {
    display: inline-flex;
}

@keyframes freezePulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ── Tool layout (full-width stacking on mobile) ── */
.tool-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: var(--space-md);
}

@media (max-width: 900px) {
    .tool-grid {
        grid-template-columns: 1fr;
    }

    .gauge-svg {
        width: 200px;
        height: 200px;
    }
}

/* ── Privacy Callout ── */
.privacy-callout {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(0, 255, 65, 0.04);
    border: 1px solid rgba(0, 255, 65, 0.15);
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.privacy-callout__icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.browser-badges {
    display: flex;
    gap: 6px;
    margin-left: auto;
    flex-wrap: wrap;
}

.browser-badge {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    padding: 2px 7px;
    border: 1px solid rgba(0, 255, 65, 0.3);
    border-radius: var(--radius-full);
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ── Keyboard Shortcuts Hint ── */
.kbd-hints {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.kbd-hint kbd {
    display: inline-block;
    padding: 1px 6px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: var(--color-surface);
    color: var(--color-secondary);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    box-shadow: 0 1px 0 var(--color-border);
}

/* ── Confidence Bar ── */
.confidence-wrap {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.confidence-track {
    flex: 1;
    height: 8px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.confidence-bar {
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--color-success, #00c853);
    transition: width 0.2s ease, background 0.3s ease;
    box-shadow: 0 0 6px rgba(0, 200, 83, 0.4);
}

.confidence-label {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    min-width: 32px;
    text-align: right;
}

/* ── LOG badge on spectrum title ── */
.badge-log {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    padding: 1px 5px;
    border: 1px solid var(--color-secondary);
    border-radius: var(--radius-full);
    color: var(--color-secondary);
    vertical-align: middle;
    letter-spacing: 0.08em;
}

/* ── Instrument Reference Grid ── */
.instrument-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

@media (max-width: 768px) {
    .instrument-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .instrument-grid {
        grid-template-columns: 1fr;
    }
}

.instrument-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    transition: border-color 0.2s ease;
}

.instrument-card:hover {
    border-color: rgba(0, 255, 65, 0.3);
}

.instrument-card__icon {
    font-size: 1.75rem;
    margin-bottom: var(--space-xs);
}

.instrument-card__name {
    font-family: var(--font-display);
    font-size: var(--fs-sm);
    color: var(--color-primary);
    margin-bottom: 4px;
}

.instrument-card__range {
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    color: var(--color-secondary);
    margin-bottom: var(--space-xs);
    font-weight: 700;
}

.instrument-card__notes {
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    line-height: 1.5;
    margin: 0;
}

/* ── Note Frequency Reference Table ── */
.note-freq-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-top: var(--space-lg);
}

.note-freq-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
}

.note-freq-table th {
    background: var(--color-surface);
    color: var(--color-primary);
    padding: var(--space-sm);
    text-align: center;
    font-weight: 700;
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--color-border);
}

.note-freq-table td {
    padding: 6px var(--space-sm);
    text-align: center;
    border-bottom: 1px solid rgba(15, 61, 30, 0.25);
    color: var(--color-text);
}

.note-freq-table tr:last-child td {
    border-bottom: none;
}

.note-freq-table tr:hover td {
    background: rgba(0, 255, 65, 0.03);
}

.note-freq-table td:nth-child(odd) {
    color: var(--color-secondary);
    font-weight: 600;
}