/* ============================================================
   Instrument Frequency Detector — Tool Styles
   ============================================================ */

/* ── Instrument Match Card (Primary) ── */
.instrument-match-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.instrument-match-card--matched {
    border-color: var(--color-primary);
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.15), 0 0 40px rgba(0, 255, 65, 0.05);
}

.instrument-match-card__icon {
    font-size: 3rem;
    min-width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 255, 65, 0.06);
    border-radius: var(--radius-md);
    line-height: 1;
}

.instrument-match-card__body {
    flex: 1;
    min-width: 0;
}

.instrument-match-card__name {
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 4vw, 1.6rem);
    color: var(--color-text);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.instrument-match-card__confidence-wrap {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: 4px;
}

.instrument-match-card__confidence-track {
    flex: 1;
    height: 12px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.instrument-match-card__confidence-fill {
    height: 100%;
    width: 0%;
    border-radius: var(--radius-full);
    transition: width 0.3s ease, background 0.3s ease;
    background: linear-gradient(90deg, #ff1744 0%, #ffb300 40%, #00e676 70%, #00ff41 100%);
}

.instrument-match-card__confidence-pct {
    font-family: var(--font-mono);
    font-size: var(--fs-md);
    color: var(--color-primary);
    font-weight: 700;
    min-width: 52px;
    text-align: right;
}

.instrument-match-card__range {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* ── Top 3 Matches List ── */
.top-matches-list {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-xs);
    margin-bottom: var(--space-sm);
}

.top-match-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.1s ease;
}

.top-match-item:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.top-match-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.top-match-item__rank {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    min-width: 18px;
    font-weight: 700;
}

.top-match-item__icon {
    font-size: 1.1rem;
    min-width: 24px;
    text-align: center;
}

.top-match-item__name {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text);
    flex: 1;
    font-weight: 600;
}

.top-match-item__pct {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-primary);
    font-weight: 700;
    min-width: 42px;
    text-align: right;
}

.top-match-item:first-child .top-match-item__pct {
    color: #00ff41;
}

.top-match-item:nth-child(2) .top-match-item__pct {
    color: #00e5ff;
}

.top-match-item:nth-child(3) .top-match-item__pct {
    color: #ffb300;
}

/* ── Frequency Display ── */
.frequency-display {
    text-align: center;
    padding: var(--space-sm) 0;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
}

.frequency-display__label {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 4px;
}

.frequency-display__hz {
    font-family: var(--font-display);
    font-size: clamp(2rem, 6vw, 3rem);
    color: var(--color-primary);
    text-shadow: 0 0 20px rgba(0, 255, 65, 0.4);
    line-height: 1;
    letter-spacing: 0.03em;
    transition: color 0.15s ease, text-shadow 0.15s ease;
}

.frequency-display__hz--active {
    text-shadow: 0 0 30px rgba(0, 255, 65, 0.7), 0 0 60px rgba(0, 255, 65, 0.2);
}

.frequency-display__note {
    font-family: var(--font-mono);
    font-size: var(--fs-md);
    color: var(--color-secondary);
    margin-top: 4px;
    letter-spacing: 0.08em;
}

/* ── Tuning Display ── */
.tuning-display {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.tuning-display__status {
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    color: var(--color-text);
    font-weight: 600;
    margin-bottom: 4px;
}

.tuning-display__status--intune {
    color: #00e676;
}

.tuning-display__status--sharp {
    color: #ffb300;
}

.tuning-display__status--flat {
    color: #ff9100;
}

.tuning-display__status--offtune {
    color: #ff1744;
}

.tuning-display__detail {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--color-text-muted);
    line-height: 1.4;
}

/* ── Harmonic Profile Bar Chart ── */
.harmonic-profile-chart {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: var(--space-xs);
}

.harmonic-profile-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 4px;
}

.harmonic-profile-row__label {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--color-text-muted);
    min-width: 24px;
    text-align: right;
    font-weight: 700;
}

.harmonic-profile-row__track {
    flex: 1;
    height: 16px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
}

.harmonic-profile-row__fill-detected {
    position: absolute;
    top: 0;
    left: 0;
    height: 50%;
    width: 0%;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: linear-gradient(90deg, #00c853, #00e676);
    transition: width 0.15s ease;
}

.harmonic-profile-row__fill-template {
    position: absolute;
    top: 50%;
    left: 0;
    height: 50%;
    width: 0%;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    background: linear-gradient(90deg, #00b8d4, #00e5ff);
    opacity: 0.6;
    transition: width 0.15s ease;
}

.harmonic-profile-row__value {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--color-text-muted);
    min-width: 36px;
    text-align: right;
}

.harmonic-profile-chart__legend {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--color-text-muted);
}

.legend-swatch {
    display: inline-block;
    width: 12px;
    height: 8px;
    border-radius: 2px;
}

.legend-swatch--detected { background: linear-gradient(90deg, #00c853, #00e676); }
.legend-swatch--template { background: linear-gradient(90deg, #00b8d4, #00e5ff); opacity: 0.6; }

/* ── Instrument Range Reference Table ── */
.range-table-wrap {
    max-height: 420px;
    overflow-y: auto;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-sm);
}

.range-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
}

.range-table th {
    position: sticky;
    top: 0;
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-weight: 600;
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.range-table td {
    padding: 5px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--color-text);
    vertical-align: middle;
}

.range-table tr:last-child td { border-bottom: none; }
.range-table tr:nth-child(even) td { background: rgba(255, 255, 255, 0.02); }

.range-table__instrument {
    display: flex;
    align-items: center;
    gap: 6px;
}

.range-table__icon {
    font-size: 1rem;
    min-width: 20px;
    text-align: center;
}

.range-bar-wrap {
    height: 10px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.range-bar {
    position: absolute;
    top: 0;
    height: 100%;
    border-radius: var(--radius-full);
    transition: opacity 0.2s ease;
}

.range-bar--active {
    box-shadow: 0 0 6px rgba(0, 255, 65, 0.4);
}

.range-table tr.range-table__row--active td {
    background: rgba(0, 255, 65, 0.06);
}

/* ── Timbre Comparison ── */
.timbre-comparison {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: var(--space-sm);
}

#timbre-canvas {
    display: block;
    width: 100%;
    height: 140px;
}

/* ── Spectrum Canvas ── */
.spectrum-wrap {
    position: relative;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: var(--space-sm);
}

#spectrum-canvas {
    display: block;
    width: 100%;
    height: 160px;
}

/* ── History Log ── */
.history-log-wrap {
    max-height: 200px;
    overflow-y: auto;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-sm);
}

.history-log {
    padding: var(--space-xs);
}

.history-log__empty {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    text-align: center;
    padding: var(--space-sm);
    font-style: italic;
}

.history-log__entry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-family: var(--font-mono);
    font-size: 10px;
}

.history-log__entry:last-child {
    border-bottom: none;
}

.history-log__time {
    color: var(--color-text-muted);
    min-width: 52px;
}

.history-log__icon {
    font-size: 0.9rem;
    min-width: 18px;
    text-align: center;
}

.history-log__name {
    color: var(--color-text);
    font-weight: 600;
    flex: 1;
}

.history-log__freq {
    color: var(--color-primary);
    min-width: 60px;
    text-align: right;
}

.history-log__conf {
    color: var(--color-secondary);
    min-width: 36px;
    text-align: right;
}

/* ── Upload Row ── */
.upload-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

/* ── 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.2);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
}

.privacy-callout__icon { font-size: 1rem; }

.browser-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: auto;
}

.browser-badge {
    padding: 2px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    font-size: 10px;
    color: var(--color-text-muted);
}

/* ── Keyboard Hints ── */
.kbd-hints {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.kbd-hint {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.kbd-hint kbd {
    display: inline-block;
    padding: 2px 6px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--color-text);
}

/* ── Export Actions ── */
.export-actions {
    display: flex;
    gap: var(--space-xs);
}

/* ── Scrollbar ── */
.range-table-wrap::-webkit-scrollbar,
.history-log-wrap::-webkit-scrollbar { width: 4px; }
.range-table-wrap::-webkit-scrollbar-track,
.history-log-wrap::-webkit-scrollbar-track { background: transparent; }
.range-table-wrap::-webkit-scrollbar-thumb,
.history-log-wrap::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }

/* ── Freeze Badge ── */
.freeze-badge {
    display: inline-block;
    padding: 2px 10px;
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    font-weight: 700;
    color: #00e5ff;
    background: rgba(0, 229, 255, 0.12);
    border: 1px solid #00e5ff;
    border-radius: var(--radius-full);
    letter-spacing: 0.08em;
    vertical-align: middle;
    animation: freeze-pulse 1.5s ease-in-out infinite;
}

@keyframes freeze-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .tool-grid { grid-template-columns: 1fr !important; }
    .instrument-match-card { flex-direction: column; text-align: center; }
    .instrument-match-card__icon { min-width: 56px; height: 56px; }
}

@media (max-width: 640px) {
    .frequency-display__hz { font-size: clamp(1.6rem, 8vw, 2.4rem); }
    #spectrum-canvas { height: 120px; }
    #timbre-canvas { height: 110px; }
    .harmonic-profile-row__value { display: none; }
    .range-table { font-size: 10px; }
}
