/* tinnitus-notch-filter-generator - client-side notch therapy tool */

.tool-block {
    padding: 0;
    overflow: hidden;
}

/* ---------- Toolbar ---------- */
.tool-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border, rgba(148, 163, 184, 0.12));
}

.tool-label {
    font-size: 0.8rem;
    color: var(--accent, #00d4aa);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tool-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ---------- Buttons ---------- */
.tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0.4rem 0.875rem;
    font-size: 0.8rem;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    background: var(--accent, #00d4aa);
    color: var(--bg-primary, #0a0e17);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s ease, transform 0.15s ease, background-color 0.15s ease,
        color 0.15s ease, border-color 0.15s ease;
}

.tool-btn:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-1px);
}

.tool-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.tool-btn:focus-visible {
    outline: 2px solid var(--accent, #00d4aa);
    outline-offset: 2px;
}

.tool-btn-secondary {
    background: transparent;
    color: var(--text-secondary, #94a3b8);
    border-color: var(--border, rgba(148, 163, 184, 0.12));
}

.tool-btn-secondary:hover:not(:disabled) {
    color: var(--text-primary, #f1f5f9);
    border-color: rgba(148, 163, 184, 0.35);
}

.tool-btn-accent {
    background: transparent;
    color: var(--accent, #00d4aa);
    border-color: rgba(0, 212, 170, 0.45);
}

.tool-btn-accent:hover:not(:disabled) {
    background: rgba(0, 212, 170, 0.1);
    border-color: var(--accent, #00d4aa);
}

.tool-btn-lg {
    min-height: 40px;
    padding: 0.55rem 1.1rem;
    font-size: 0.82rem;
}

.tool-btn.is-playing {
    background: #ef4444;
    border-color: #ef4444;
    color: #ffffff;
}

.tool-btn.is-confirmed {
    background: rgba(0, 212, 170, 0.14);
    border-color: var(--accent, #00d4aa);
    color: var(--accent, #00d4aa);
}

/* ---------- Summary strip ---------- */
.notch-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    background: rgba(0, 0, 0, 0.14);
    border-bottom: 1px solid var(--border, rgba(148, 163, 184, 0.12));
}

.notch-summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    padding: 0.7rem 1.25rem;
    border-right: 1px solid var(--border, rgba(148, 163, 184, 0.12));
}

.notch-summary-item:last-child {
    border-right: none;
}

.notch-summary-label {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #64748b);
}

.notch-summary-value {
    font-size: 0.88rem;
    color: var(--accent, #00d4aa);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Steps ---------- */
.notch-step {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border, rgba(148, 163, 184, 0.12));
}

.notch-step-head {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.notch-step-num {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    font-size: 0.75rem;
    color: var(--accent, #00d4aa);
    background: rgba(0, 212, 170, 0.1);
    border: 1px solid rgba(0, 212, 170, 0.35);
    border-radius: 50%;
}

.notch-step-heading {
    min-width: 0;
}

.notch-step-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text-primary, #f1f5f9);
}

.notch-step-hint {
    margin-top: 0.2rem;
    font-size: 0.78rem;
    line-height: 1.55;
    color: var(--text-muted, #64748b);
    max-width: 76ch;
}

/* ---------- Tone stage ---------- */
.notch-stage {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    padding: 1.1rem;
    background: rgba(0, 212, 170, 0.035);
    border: 1px solid var(--border, rgba(148, 163, 184, 0.12));
    border-radius: 10px;
}

.notch-readout {
    display: flex;
    align-items: baseline;
    justify-content: center;
}

.notch-readout-value {
    font-size: clamp(2rem, 6vw, 2.6rem);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: 0.02em;
    color: var(--text-primary, #f1f5f9);
}

.notch-scale {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.notch-ticks {
    display: flex;
    justify-content: space-between;
    padding: 0 2px;
    font-size: 0.62rem;
    color: var(--text-muted, #64748b);
}

/* ---------- Nudge controls ---------- */
.notch-nudge-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.notch-nudge-group {
    display: inline-flex;
    gap: 0.25rem;
}

.notch-nudge {
    min-height: 30px;
    padding: 0 0.5rem;
    font-size: 0.72rem;
    color: var(--text-secondary, #94a3b8);
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid var(--border, rgba(148, 163, 184, 0.12));
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.notch-nudge:hover {
    color: var(--text-primary, #f1f5f9);
    border-color: rgba(148, 163, 184, 0.4);
    background: rgba(148, 163, 184, 0.14);
}

.notch-nudge:focus-visible {
    outline: 2px solid var(--accent, #00d4aa);
    outline-offset: 2px;
}

.notch-number-wrap,
.notch-number-row {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.notch-number {
    width: 7.5rem;
    min-height: 36px;
    padding: 0.35rem 0.5rem;
    font-size: 0.9rem;
    text-align: center;
    color: var(--text-primary, #f1f5f9);
    background: var(--bg-secondary, #111827);
    border: 1px solid var(--border, rgba(148, 163, 184, 0.12));
    border-radius: 6px;
}

.notch-number:focus {
    outline: none;
    border-color: var(--accent, #00d4aa);
}

.notch-unit {
    font-size: 0.75rem;
    color: var(--text-muted, #64748b);
}

/* ---------- Layout grids ---------- */
.notch-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.notch-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 0;
}

.notch-field-check {
    justify-content: flex-end;
}

.notch-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #64748b);
}

.notch-select {
    width: 100%;
    min-height: 34px;
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
    color: var(--text-primary, #f1f5f9);
    background: var(--bg-secondary, #111827);
    border: 1px solid var(--border, rgba(148, 163, 184, 0.12));
    border-radius: 6px;
}

.notch-select:focus {
    outline: none;
    border-color: var(--accent, #00d4aa);
}

/* ---------- Segmented controls ---------- */
.notch-seg {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 2px;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid var(--border, rgba(148, 163, 184, 0.12));
    border-radius: 8px;
}

.notch-seg-wide {
    width: 100%;
}

.notch-seg-wide .notch-seg-btn {
    flex: 1 1 auto;
}

.notch-seg-btn {
    min-height: 28px;
    padding: 0 0.6rem;
    font-size: 0.72rem;
    color: var(--text-secondary, #94a3b8);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.notch-seg-btn:hover {
    color: var(--text-primary, #f1f5f9);
}

.notch-seg-btn.is-active {
    color: var(--accent, #00d4aa);
    background: rgba(0, 212, 170, 0.14);
    box-shadow: inset 0 0 0 1px rgba(0, 212, 170, 0.35);
}

.notch-seg-btn:focus-visible {
    outline: 2px solid var(--accent, #00d4aa);
    outline-offset: 1px;
}

/* ---------- Ranges ---------- */
.notch-range-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.notch-range {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    height: 26px;
    margin: 0;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.notch-range::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.25);
}

.notch-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    margin-top: -6px;
    border: none;
    border-radius: 50%;
    background: var(--accent, #00d4aa);
}

.notch-range::-moz-range-track {
    height: 4px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.25);
}

.notch-range::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    background: var(--accent, #00d4aa);
}

.notch-range:focus {
    outline: none;
}

.notch-range:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.35);
}

.notch-range:focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.35);
}

.notch-output {
    flex: 0 0 auto;
    min-width: 6.4rem;
    font-size: 0.72rem;
    text-align: right;
    color: var(--accent, #00d4aa);
    white-space: nowrap;
}

/* ---------- Notes ---------- */
.notch-hint {
    font-size: 0.72rem;
    line-height: 1.6;
    color: var(--text-muted, #64748b);
}

/* ---------- Fixed-frequency confirmation ---------- */
.notch-fix-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin-top: 0.6rem;
    padding: 0.55rem 0.75rem;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--text-secondary, #94a3b8);
    background: rgba(0, 212, 170, 0.08);
    border: 1px solid rgba(0, 212, 170, 0.35);
    border-radius: 8px;
}

.notch-fix-note[hidden] {
    display: none;
}

.notch-fix-note-text {
    flex: 1 1 auto;
    min-width: 0;
}

.notch-fix-note-link {
    flex: 0 0 auto;
    padding: 0.2rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent, #00d4aa);
    background: transparent;
    border: 1px solid rgba(0, 212, 170, 0.35);
    border-radius: 6px;
    cursor: pointer;
}

.notch-fix-note-link:hover,
.notch-fix-note-link:focus-visible {
    background: rgba(0, 212, 170, 0.12);
    outline: none;
}

.notch-fix-note-link:focus-visible {
    box-shadow: 0 0 0 2px rgba(0, 212, 170, 0.35);
}

.tool-btn.is-armed:not(.is-confirmed) {
    box-shadow: 0 0 0 2px rgba(0, 212, 170, 0.28);
}

.notch-summary-item.is-fixed .notch-summary-label {
    color: var(--accent, #00d4aa);
}

.notch-step.is-flash {
    animation: notch-step-flash 1.2s ease-out;
}

@keyframes notch-step-flash {
    0% {
        background: rgba(0, 212, 170, 0.12);
    }
    100% {
        background: transparent;
    }
}

@media (prefers-reduced-motion: reduce) {
    .notch-step.is-flash {
        animation: none;
    }
}

.notch-check {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 34px;
    font-size: 0.8rem;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
}

.notch-check input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--accent, #00d4aa);
    cursor: pointer;
}

/* ---------- Panels ---------- */
.notch-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.notch-subpanel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* ---------- Response chart ---------- */
.notch-canvas-fig {
    margin: 0;
    background: var(--bg-secondary, #111827);
    border: 1px solid var(--border, rgba(148, 163, 184, 0.12));
    border-radius: 10px;
    overflow: hidden;
}

.notch-canvas {
    display: block;
    width: 100%;
    height: 280px;
    cursor: crosshair;
}

.notch-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 1rem;
    padding: 0.55rem 0.8rem;
    border-top: 1px solid var(--border, rgba(148, 163, 184, 0.12));
    font-size: 0.68rem;
    color: var(--text-muted, #64748b);
}

.notch-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.notch-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.notch-legend-dot--curve {
    background: var(--accent, #00d4aa);
}

.notch-legend-dot--target {
    background: #f59e0b;
}

.notch-legend-hint {
    margin-left: auto;
}

/* ---------- Dropzone & file chip ---------- */
.notch-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 1.4rem 1rem;
    text-align: center;
    background: rgba(148, 163, 184, 0.04);
    border: 1px dashed rgba(148, 163, 184, 0.35);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.notch-drop:hover,
.notch-drop.is-drag {
    border-color: var(--accent, #00d4aa);
    background: rgba(0, 212, 170, 0.06);
}

.notch-drop:focus-visible {
    outline: 2px solid var(--accent, #00d4aa);
    outline-offset: 2px;
}

.notch-drop-icon {
    color: var(--accent, #00d4aa);
}

.notch-drop-text {
    font-size: 0.82rem;
    color: var(--text-primary, #f1f5f9);
}

.notch-drop-hint {
    font-size: 0.7rem;
    line-height: 1.55;
    color: var(--text-muted, #64748b);
    max-width: 56ch;
}

.notch-file-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.65rem 0.85rem;
    background: rgba(0, 212, 170, 0.07);
    border: 1px solid rgba(0, 212, 170, 0.28);
    border-radius: 8px;
}

.notch-file-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.notch-file-name {
    font-size: 0.8rem;
    color: var(--text-primary, #f1f5f9);
    word-break: break-all;
}

.notch-file-meta {
    font-size: 0.7rem;
    color: var(--text-muted, #64748b);
}

/* ---------- Actions & export ---------- */
.notch-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.notch-export {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.9rem;
    background: rgba(148, 163, 184, 0.03);
    border: 1px solid var(--border, rgba(148, 163, 184, 0.12));
    border-radius: 10px;
}

.notch-export-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.notch-export-size {
    font-size: 0.72rem;
    color: var(--accent, #00d4aa);
}

.notch-timer-left {
    align-self: flex-start;
    display: inline-flex;
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
    color: var(--accent, #00d4aa);
    background: rgba(0, 212, 170, 0.08);
    border: 1px solid rgba(0, 212, 170, 0.25);
    border-radius: 999px;
}

/* ---------- Safety notice ---------- */
.notch-safety {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 1rem 1.25rem;
    background: rgba(245, 158, 11, 0.05);
    border-bottom: 1px solid var(--border, rgba(148, 163, 184, 0.12));
}

.notch-safety-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #f59e0b;
}

.notch-safety p {
    font-size: 0.72rem;
    line-height: 1.6;
    color: var(--text-muted, #64748b);
    max-width: 90ch;
}

/* ---------- Status bar ---------- */
.tool-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: rgba(0, 212, 170, 0.05);
    border-top: 1px solid var(--border, rgba(148, 163, 184, 0.12));
}

.tool-status-dot {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted, #64748b);
}

.tool-status-text {
    font-size: 0.8rem;
    color: var(--text-muted, #64748b);
}

.tool-status[data-state="ok"] {
    background: rgba(0, 212, 170, 0.08);
}

.tool-status[data-state="ok"] .tool-status-dot {
    background: var(--accent, #00d4aa);
}

.tool-status[data-state="ok"] .tool-status-text {
    color: var(--accent, #00d4aa);
}

.tool-status[data-state="error"] {
    background: rgba(239, 68, 68, 0.08);
}

.tool-status[data-state="error"] .tool-status-dot {
    background: #ef4444;
}

.tool-status[data-state="error"] .tool-status-text {
    color: #fca5a5;
}

.tool-status[data-state="warn"] {
    background: rgba(245, 158, 11, 0.08);
}

.tool-status[data-state="warn"] .tool-status-dot {
    background: #f59e0b;
}

.tool-status[data-state="warn"] .tool-status-text {
    color: #fcd34d;
}

.tool-status[data-state="processing"] {
    background: rgba(59, 130, 246, 0.08);
}

.tool-status[data-state="processing"] .tool-status-dot {
    background: #3b82f6;
    animation: notch-pulse 1s ease-in-out infinite;
}

.tool-status[data-state="processing"] .tool-status-text {
    color: #93c5fd;
}

@keyframes notch-pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.35;
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .notch-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .notch-canvas {
        height: 240px;
    }
}

@media (max-width: 640px) {
    .tool-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .tool-toolbar-actions {
        width: 100%;
    }

    .notch-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .notch-summary-item {
        padding: 0.6rem 1rem;
    }

    .notch-summary-item:nth-child(2) {
        border-right: none;
    }

    .notch-summary-item:nth-child(3),
    .notch-summary-item:nth-child(4) {
        border-top: 1px solid var(--border, rgba(148, 163, 184, 0.12));
    }

    .notch-step {
        padding: 1rem;
    }

    .notch-grid {
        grid-template-columns: 1fr;
    }

    .notch-canvas {
        height: 220px;
    }

    .notch-output {
        min-width: 5.2rem;
    }

    .notch-legend-hint {
        margin-left: 0;
        flex-basis: 100%;
    }

    .notch-actions .tool-btn {
        flex: 1 1 auto;
    }
}
