/* Toner - Dark Theme Styling */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #0a0a0a;
    color: #ffffff;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    max-width: 800px;
    width: 100%;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
}

header h1 {
    font-size: 3em;
    font-weight: 700;
    background: linear-gradient(135deg, #00d4ff, #7b2ff7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.subtitle {
    color: #888;
    font-size: 1.1em;
}

/* Main Content */
main {
    background: #1a1a1a;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Status Panel */
.status-panel {
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.status {
    padding: 16px 24px;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
    font-size: 1.1em;
}

.status-info {
    background: rgba(0, 212, 255, 0.1);
    border: 2px solid rgba(0, 212, 255, 0.3);
    color: #00d4ff;
}

.status-success {
    background: rgba(0, 255, 136, 0.1);
    border: 2px solid rgba(0, 255, 136, 0.3);
    color: #00ff88;
}

.status-error {
    background: rgba(255, 51, 51, 0.1);
    border: 2px solid rgba(255, 51, 51, 0.3);
    color: #ff3333;
}

.start-btn {
    background: linear-gradient(135deg, #00d4ff, #7b2ff7);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 16px 48px;
    cursor: pointer;
    font-size: 1.2em;
    font-weight: 700;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(0, 212, 255, 0.3);
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 212, 255, 0.4);
}

.start-btn:active {
    transform: translateY(0);
}

.error-details-btn {
    background: #ff3333;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 10px 24px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.3s ease;
}

.error-details-btn:hover {
    background: #ff5555;
    transform: translateY(-2px);
}

.error-details {
    background: #1a1a1a;
    border: 2px solid #ff3333;
    border-radius: 8px;
    padding: 20px;
    width: 100%;
    max-width: 600px;
    text-align: left;
}

.error-details h3 {
    color: #ff3333;
    font-size: 1em;
    margin-bottom: 10px;
    margin-top: 10px;
}

.error-details h3:first-child {
    margin-top: 0;
}

.error-details pre {
    background: #0d0d0d;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 12px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    color: #ff8888;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.6;
}

/* Permission help styling */
.error-details pre {
    max-height: 500px;
    overflow-y: auto;
}

/* Waveform Section */
.waveform-section {
    margin-bottom: 40px;
}

.waveform-section h2 {
    color: #00d4ff;
    font-size: 1.2em;
    margin: 0 0 8px 0;
    font-weight: 600;
}

.waveform-subtitle {
    color: #888;
    font-size: 0.85em;
    margin: 0 0 16px 0;
}

#waveformCanvas {
    width: 100%;
    aspect-ratio: 10 / 7;
    max-width: 800px;
    background: #0d0d0d;
    border: 2px solid #333;
    border-radius: 12px;
    display: block;
    margin: 0 auto;
}

/* Pitch Section */
.pitch-section {
    margin-bottom: 40px;
}

.pitch-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.pitch-section h2 {
    color: #00d4ff;
    font-size: 1.2em;
    margin: 0;
    font-weight: 600;
}

.transpose-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.transpose-selector label {
    color: #888;
    font-size: 0.9em;
    font-weight: 500;
}

.transpose-selector select {
    background: #2a2a2a;
    color: #ffffff;
    border: 2px solid #444;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.9em;
    cursor: pointer;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    transition: all 0.3s ease;
    max-width: 280px;
}

@media screen and (max-width: 47.999em) {
    .transpose-selector select {
        max-width: 200px;
        font-size: 0.85em;
    }

    .transpose-selector {
        flex-wrap: wrap;
    }
}

.transpose-selector select:hover {
    background: #3a3a3a;
    border-color: #00d4ff;
}

.transpose-selector select:focus {
    outline: none;
    border-color: #00d4ff;
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.pitch-display {
    background: #0d0d0d;
    border-radius: 12px;
    padding: 30px;
    border: 2px solid #333;
}

.pitch-main {
    text-align: center;
    margin-bottom: 20px;
}

.frequency {
    font-size: 3em;
    font-weight: 700;
    color: #00ff88;
    font-family: 'Courier New', monospace;
    margin-bottom: 10px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.note-display {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.concert-pitch,
.transposed-pitch {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 50px;
}

.note-label {
    font-size: 0.9em;
    color: #888;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 80px;
    text-align: right;
}

.note-name {
    font-size: 2.5em;
    font-weight: 700;
    background: linear-gradient(135deg, #00d4ff, #7b2ff7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.note-name-transposed {
    font-size: 2em;
    font-weight: 700;
    background: linear-gradient(135deg, #ffaa00, #ff6600);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pitch-details {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    padding-top: 20px;
    border-top: 1px solid #333;
}

.cents-display {
    flex: 2;
    text-align: center;
}

.clarity-display {
    flex: 1;
    text-align: center;
}

.pitch-details .label {
    display: block;
    color: #888;
    font-size: 0.9em;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.pitch-details .value {
    display: block;
    font-size: 1.5em;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: #00d4ff;
}

/* Cents visual indicator */
.cents-bar-container {
    position: relative;
    width: 100%;
    max-width: 300px;
    height: 30px;
    background: #0d0d0d;
    border-radius: 15px;
    border: 2px solid #333;
    margin: 10px auto 8px;
    overflow: hidden;
}

.cents-bar-center {
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    background: #00ff88;
    transform: translateX(-1px);
    z-index: 2;
}

.cents-bar-indicator {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 8px;
    height: 20px;
    background: #00d4ff;
    border-radius: 4px;
    transform: translate(-50%, -50%);
    transition: left 0.1s ease-out, background-color 0.2s ease;
    z-index: 3;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.cents-bar-marks {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.cents-bar-mark {
    position: absolute;
    top: 0;
    width: 1px;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
}

.cents-numeric {
    font-size: 1em;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    color: #00d4ff;
}

/* Spectrum Visualization Section */
.spectrum-section {
    margin-bottom: 40px;
    position: relative;
}

.spectrum-header {
    margin-bottom: 16px;
    align-items: center;
}

.spectrum-header h2 {
    margin: 0;
}

.spectrum-section h2 {
    color: #00d4ff;
    font-size: 1.2em;
    font-weight: 600;
    margin: 0;
}

.view-controls-group {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
}

@media screen and (max-width: 47.999em) {
    .view-controls-group {
        justify-content: flex-start;
        flex-wrap: wrap;
        margin-top: 10px;
    }
}

.toggle-btn {
    background: #2a2a2a;
    color: #ffffff;
    border: 2px solid #444444;
    border-radius: 8px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.toggle-btn:hover {
    background: #3a3a3a;
    border-color: #00d4ff;
    transform: translateY(-2px);
}

.toggle-btn #viewMode {
    font-weight: 600;
    color: #00ff88;
}

.toggle-btn .toggle-hint {
    font-size: 0.8em;
    color: #888;
}

/* Fullscreen mode */
.spectrum-section.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 20px;
    background: #0a0a0a;
    z-index: 9999;
}

.spectrum-section.fullscreen .spectrum-header {
    margin-bottom: 10px;
}

.spectrum-section.fullscreen #spectrumCanvas {
    height: calc(100vh - 80px);
    max-height: none;
}

#spectrumCanvas {
    width: 100%;
    height: auto;
    max-height: 400px;
    background: #0d0d0d;
    border-radius: 8px;
    border: 2px solid #333;
    display: block;
}

/* Fullscreen Tuner Overlay */
.fullscreen-tuner {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(13, 13, 13, 0.95);
    border: 2px solid rgba(0, 212, 255, 0.5);
    border-radius: 12px;
    padding: 15px 25px;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
}

.fs-tuner-notes {
    display: flex;
    gap: 20px;
    margin-bottom: 12px;
    justify-content: center;
}

.fs-concert-note,
.fs-transposed-note {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fs-note-label {
    font-size: 0.8em;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.fs-note-value {
    font-size: 1.5em;
    font-weight: 700;
}

.fs-concert-note .fs-note-value {
    background: linear-gradient(135deg, #00d4ff, #7b2ff7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.fs-transposed-note .fs-note-value {
    background: linear-gradient(135deg, #ffaa00, #ff6600);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.fs-cents-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.fs-cents-bar-container {
    position: relative;
    width: 250px;
    height: 24px;
    background: #0d0d0d;
    border-radius: 12px;
    border: 2px solid #333;
    overflow: hidden;
}

.fs-cents-bar-center {
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    background: #00ff88;
    transform: translateX(-1px);
    z-index: 2;
}

.fs-cents-bar-indicator {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 6px;
    height: 16px;
    background: #00d4ff;
    border-radius: 3px;
    transform: translate(-50%, -50%);
    transition: left 0.1s ease-out, background-color 0.2s ease;
    z-index: 3;
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.5);
}

.fs-cents-bar-marks {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.fs-cents-bar-mark {
    position: absolute;
    top: 0;
    width: 1px;
    height: 100%;
    background: rgba(255, 255, 255, 0.15);
}

.fs-cents-numeric {
    font-size: 0.9em;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    color: #00d4ff;
}

/* Test Mode Section */
.test-mode-section {
    margin-bottom: 40px;
}

.test-mode-section h2 {
    color: #7b2ff7;
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 16px;
}

.test-mode-display {
    background: #1a1a1a;
    border: 2px solid #333;
    border-radius: 12px;
    padding: 20px;
}

.test-mode-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.test-mode-btn {
    background: #7b2ff7;
    color: #ffffff;
    border: 2px solid #7b2ff7;
    border-radius: 8px;
    padding: 12px 24px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
}

.test-mode-btn:hover {
    background: #9b4fff;
    border-color: #9b4fff;
    transform: translateY(-2px);
}

.test-mode-btn.active {
    background: #00ff88;
    border-color: #00ff88;
    color: #0a0a0a;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}

.test-mode-info {
    margin-top: 20px;
    padding: 15px;
    background: #0d0d0d;
    border-radius: 8px;
    border: 2px solid #444;
}

.test-mode-info h3 {
    color: #00d4ff;
    font-size: 1em;
    margin: 0 0 10px 0;
}

.expected-harmonics {
    color: #aaa;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.6;
}

/* Drone Section */
.drone-section {
    margin-bottom: 40px;
}

.drone-section h2 {
    color: #00d4ff;
    font-size: 1.2em;
    margin-bottom: 16px;
    font-weight: 600;
}

.drone-display {
    background: #0d0d0d;
    border-radius: 12px;
    padding: 30px;
    border: 2px solid #333;
}

.drone-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.drone-btn {
    width: 100%;
    background: #2a2a2a;
    color: #ffffff;
    border: 2px solid #444;
    border-radius: 8px;
    padding: 14px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    transition: all 0.3s ease;
}

.drone-btn:hover {
    background: #3a3a3a;
    border-color: #00d4ff;
    transform: translateY(-2px);
}

.drone-btn.active {
    background: #7b2ff7;
    color: #fff;
    border-color: #7b2ff7;
    box-shadow: 0 0 20px rgba(123, 47, 247, 0.4);
}

/* Metronome Section */
.metronome-section {
    margin-bottom: 40px;
}

.metronome-section h2 {
    color: #00d4ff;
    font-size: 1.2em;
    margin-bottom: 16px;
    font-weight: 600;
}

.metronome-display {
    background: #0d0d0d;
    border-radius: 12px;
    padding: 30px;
    border: 2px solid #333;
}

.metronome-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    color: #888;
    font-size: 0.9em;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.control-group input[type="range"] {
    width: 100%;
    height: 6px;
    background: #2a2a2a;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #00d4ff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    background: #00ff88;
    transform: scale(1.2);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #00d4ff;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

.control-group input[type="range"]::-moz-range-thumb:hover {
    background: #00ff88;
    transform: scale(1.2);
}

.tempo-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.tempo-slider {
    height: 10px !important;
}

.tempo-slider::-webkit-slider-thumb {
    width: 24px !important;
    height: 24px !important;
}

.tempo-slider::-moz-range-thumb {
    width: 24px !important;
    height: 24px !important;
}

.tempo-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tempo-number {
    background: #2a2a2a;
    color: #00ff88;
    border: 2px solid #444;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 1.2em;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    width: 80px;
    text-align: center;
    transition: all 0.3s ease;
}

.tempo-number:hover {
    border-color: #00d4ff;
}

.tempo-number:focus {
    outline: none;
    border-color: #00d4ff;
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.tempo-label {
    color: #888;
    font-size: 0.9em;
    font-weight: 600;
    text-transform: uppercase;
}

.control-group select {
    background: #2a2a2a;
    color: #ffffff;
    border: 2px solid #444;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 1em;
    cursor: pointer;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    transition: all 0.3s ease;
}

.control-group select:hover {
    background: #3a3a3a;
    border-color: #00d4ff;
}

.control-group select:focus {
    outline: none;
    border-color: #00d4ff;
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.control-value {
    color: #00ff88;
    font-family: 'Courier New', monospace;
    font-size: 1.1em;
    font-weight: 600;
}

.metronome-visual {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

.beat-indicator {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #2a2a2a;
    border: 3px solid #444;
    transition: all 0.05s ease;
}

.beat-indicator.active {
    background: #00ff88;
    border-color: #00ff88;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.6);
    transform: scale(1.1);
}

.beat-indicator.accent {
    background: #ff3333;
    border-color: #ff3333;
    box-shadow: 0 0 20px rgba(255, 51, 51, 0.6);
    transform: scale(1.2);
}

.beat-indicator.subdivision {
    background: #00d4ff;
    border-color: #00d4ff;
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.5);
    transform: scale(0.95);
}

.metronome-btn {
    width: 100%;
    background: #2a2a2a;
    color: #ffffff;
    border: 2px solid #444;
    border-radius: 8px;
    padding: 14px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    transition: all 0.3s ease;
}

.metronome-btn:hover {
    background: #3a3a3a;
    border-color: #00d4ff;
    transform: translateY(-2px);
}

.metronome-btn.active {
    background: #00ff88;
    color: #000;
    border-color: #00ff88;
}

/* Meter Section */
.meter-section {
    margin-bottom: 40px;
}

.meter-section h2 {
    color: #00d4ff;
    font-size: 1.2em;
    margin-bottom: 16px;
    font-weight: 600;
}

.meter-container {
    display: flex;
    align-items: center;
    gap: 16px;
}

.level-meter {
    flex: 1;
    height: 40px;
    background: #0d0d0d;
    border-radius: 20px;
    overflow: hidden;
    border: 2px solid #333;
    position: relative;
}

.level-bar {
    height: 100%;
    background: #00ff88;
    width: 0%;
    transition: width 0.05s ease-out, background-color 0.2s ease;
    border-radius: 20px;
}

.level-value {
    min-width: 80px;
    text-align: right;
    font-family: 'Courier New', monospace;
    font-size: 1.1em;
    font-weight: 600;
    color: #00ff88;
}

/* Debug Section */
.debug-section {
    background: #0d0d0d;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #333;
}

.debug-section h3 {
    color: #7b2ff7;
    font-size: 1em;
    margin-bottom: 12px;
    font-weight: 600;
}

.debug-info {
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #888;
}

.debug-info div {
    margin-bottom: 8px;
}

.debug-info span {
    color: #00d4ff;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 600px) {
    header h1 {
        font-size: 2em;
    }

    main {
        padding: 24px;
    }

    .start-btn {
        padding: 12px 36px;
        font-size: 1.1em;
    }

    .meter-container {
        flex-direction: column;
        align-items: stretch;
    }

    .level-value {
        text-align: center;
    }

    /* Mobile-specific improvements */
    /* Fullscreen tuner - move to bottom and make more compact */
    .fullscreen-tuner {
        top: auto;
        bottom: 20px;
        left: 10px;
        right: 10px;
        transform: none;
        padding: 10px 15px;
        max-width: 100%;
        position: fixed; /* Fixed instead of absolute to stay above canvas */
        z-index: 10001; /* Higher than fullscreen canvas */
    }

    /* Reserve space for tuner at bottom of canvas in fullscreen */
    .spectrum-section.fullscreen #spectrumCanvas {
        height: calc(100vh - 200px) !important; /* Leave room for tuner */
        max-height: calc(100vh - 200px);
    }

    .fs-tuner-notes {
        flex-direction: column;
        gap: 8px;
        margin-bottom: 8px;
    }

    .fs-note-value {
        font-size: 1.2em;
    }

    .fs-cents-bar-container {
        width: 100%;
        max-width: none;
    }

    /* View control buttons - make smaller and touch-friendly */
    .toggle-btn {
        padding: 10px 12px;
        font-size: 0.9em;
        min-width: 44px;
        min-height: 44px;
    }

    .toggle-btn .toggle-hint {
        display: none; /* Hide hints on mobile to save space */
    }
}
