/* === Base Reset & Typography === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --cream: #FAF3E0;
    --cream-dark: #F0E6CC;
    --saffron: #FF9933;
    --saffron-dark: #E0851A;
    --brown: #5C3A1E;
    --brown-light: #8B6914;
    --brown-dark: #3A1F0B;
    --green-accent: #2E7D32;
    --text: #3A2A1A;
    --text-muted: #7A6A5A;
    --shadow: rgba(92, 58, 30, 0.15);
}

html {
    font-size: 16px;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--cream);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* === Decorative Border === */
.decorative-border {
    height: 6px;
    background: repeating-linear-gradient(
        90deg,
        var(--saffron) 0px,
        var(--saffron) 20px,
        var(--brown) 20px,
        var(--brown) 22px,
        var(--green-accent) 22px,
        var(--green-accent) 42px,
        var(--brown) 42px,
        var(--brown) 44px
    );
}

/* === Header === */
.header {
    text-align: center;
    padding: 1.5rem 1rem 1rem;
    background: linear-gradient(180deg, var(--cream-dark), var(--cream));
}

.header h1 {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 2.2rem;
    color: var(--brown-dark);
    font-weight: 700;
    letter-spacing: 0.02em;
}

.header .subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
    font-style: italic;
}

/* === Controls Bar === */
.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 1.5rem;
    flex-wrap: wrap;
    background: var(--cream-dark);
    border-bottom: 1px solid rgba(139, 105, 20, 0.15);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Scale selector */
.scale-select {
    padding: 0.45rem 0.8rem;
    border: 2px solid var(--brown-light);
    border-radius: 6px;
    background: white;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s;
}

.scale-select:focus {
    outline: none;
    border-color: var(--saffron);
    box-shadow: 0 0 0 3px rgba(255, 153, 51, 0.2);
}

/* Toggle switch */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toggle-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
    font-weight: 500;
}

.toggle-label.active {
    color: var(--saffron-dark);
    font-weight: 700;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--saffron);
    border-radius: 24px;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--brown-light);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* Start/Stop button */
.start-btn {
    padding: 0.6rem 1.8rem;
    border: none;
    border-radius: 8px;
    background: var(--saffron);
    color: white;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(255, 153, 51, 0.3);
    letter-spacing: 0.02em;
}

.start-btn:hover {
    background: var(--saffron-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 153, 51, 0.4);
}

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

.start-btn.active {
    background: #D32F2F;
    box-shadow: 0 2px 8px rgba(211, 47, 47, 0.3);
}

.start-btn.active:hover {
    background: #B71C1C;
}

/* Status indicator */
.status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
    transition: background 0.3s;
}

.status-dot.active {
    background: #4CAF50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
    animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Error message */
.error-msg {
    text-align: center;
    color: #D32F2F;
    font-size: 0.9rem;
    padding: 0 1rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s, padding 0.3s;
}

.error-msg.visible {
    max-height: 60px;
    padding: 0.5rem 1rem;
}

/* === Note Display === */
.note-section {
    text-align: center;
    padding: 2rem 1rem 1rem;
    flex-shrink: 0;
}

.note-display {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 6rem;
    font-weight: 700;
    color: var(--brown-dark);
    line-height: 1.1;
    transition: all 0.15s;
    min-height: 7rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.note-display.active {
    color: var(--saffron-dark);
    text-shadow: 0 0 30px rgba(255, 153, 51, 0.3);
}

.note-subtext {
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.octave-label {
    font-size: 0.85rem;
    color: var(--brown-light);
    margin-top: 0.2rem;
    font-style: italic;
    text-transform: capitalize;
    min-height: 1.2em;
}

/* Cents indicator */
.cents-bar {
    width: 200px;
    height: 6px;
    background: var(--cream-dark);
    border-radius: 3px;
    margin: 0.8rem auto 0;
    position: relative;
    opacity: 0;
    transition: opacity 0.3s;
}

.cents-bar.visible {
    opacity: 1;
}

.cents-bar::before {
    content: '';
    position: absolute;
    left: 50%;
    top: -2px;
    width: 2px;
    height: 10px;
    background: var(--text-muted);
    transform: translateX(-50%);
}

.cents-indicator {
    position: absolute;
    top: -3px;
    width: 12px;
    height: 12px;
    background: var(--saffron);
    border-radius: 50%;
    transform: translateX(-50%);
    transition: left 0.1s;
    left: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.cents-labels {
    display: flex;
    justify-content: space-between;
    width: 200px;
    margin: 0.2rem auto 0;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* === Bansuri Canvas Section === */
.bansuri-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    min-height: 200px;
}

.bansuri-scale-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--brown);
    margin-bottom: 0.5rem;
}

.bansuri-canvas {
    width: 100%;
    max-width: 900px;
    height: 150px;
    display: block;
}

/* === Footer === */
.footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid rgba(139, 105, 20, 0.1);
}

.footer p {
    margin: 0.2rem 0;
}

/* === Responsive === */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.6rem;
    }

    .controls {
        gap: 1rem;
        padding: 0.8rem 1rem;
    }

    .note-display {
        font-size: 4.5rem;
        min-height: 5.5rem;
    }

    .bansuri-canvas {
        height: 120px;
    }

    .start-btn {
        padding: 0.5rem 1.4rem;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.3rem;
    }

    .controls {
        flex-direction: column;
        gap: 0.8rem;
    }

    .note-display {
        font-size: 3.5rem;
        min-height: 4.5rem;
    }

    .note-section {
        padding: 1.5rem 1rem 0.5rem;
    }

    .bansuri-canvas {
        height: 100px;
    }
}
