/* Modern 2025 Classroom Noise Meter */

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

:root {
    --transition-smooth: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 8px 30px rgba(0, 0, 0, 0.12);
    --shadow-strong: 0 12px 40px rgba(0, 0, 0, 0.15);
    
    --aura-opacity-min: 0.35;
    --aura-opacity-max: 0.75;
    --aura-intensity: var(--aura-opacity-min);
}

/* Background Layer (for aura and future seasonal backgrounds) */
.background-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.background-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: 400px 400px;
    background-position: center;
    background-repeat: repeat;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    mix-blend-mode: multiply;
    filter: brightness(1.05) saturate(0.9);
}

.background-image.active {
    opacity: 0.45;
}

/* Dark theme adjustments */
[data-theme="teen"] .background-image {
    mix-blend-mode: overlay;
    filter: brightness(0.6) saturate(1.1);
}

[data-theme="teen"] .background-image.active {
    opacity: 0.50;
}

/* Responsive pattern sizing for mobile */
@media (max-width: 768px) {
    .background-image {
        background-size: 250px 250px;
    }
}

@media (max-width: 480px) {
    .background-image {
        background-size: 200px 200px;
    }
}

.aura-effect {
    position: absolute;
    top: 280px;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 700px;
    height: 700px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--aura-color) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.6s ease-out, background 0.5s ease, width 0.5s ease, height 0.5s ease;
    filter: blur(50px);
    z-index: 2;
}

.aura-effect.aura-on {
    opacity: var(--aura-intensity);
    animation: auraPulse 4s ease-in-out infinite;
}

.aura-effect.aura-green {
    background: radial-gradient(circle, #10b981 0%, #34d399 20%, transparent 70%);
    opacity: 0.65;
}

.aura-effect.aura-red {
    background: radial-gradient(circle, #ff4757 0%, #ff6b6b 20%, transparent 70%);
    opacity: 0.7;
}

.aura-effect.aura-boost {
    opacity: var(--aura-opacity-max);
    filter: blur(70px);
    width: 900px;
    height: 900px;
}

@keyframes auraPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: var(--aura-opacity-min);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.08);
        opacity: var(--aura-intensity);
    }
}

.app-container {
    position: relative;
    z-index: 1;
}

/* Theme Color Palettes */
[data-theme="prek"] {
    --primary: #FF6B9D;
    --primary-light: #FFB3D9;
    --primary-dark: #D4568F;
    --secondary: #FFC947;
    --bg: #FFF5F8;
    --surface: #FFFFFF;
    --text: #2D2D2D;
    --text-light: #6B6B6B;
    --gauge-calm: #A8E6CF;
    --gauge-moderate: #FFD93D;
    --gauge-loud: #FF6B9D;
    --color-calm: #A8E6CF;
    --color-lively: #FFD93D;
    --color-loud: #FF6B9D;
    --track: #FFE7F5;
    --needle: #D4568F;
    --fg: #2D2D2D;
    --aura-color: #FF6B9D;
    --timer-color: #D4568F;
}

[data-theme="k2"] {
    --primary: #4ECDC4;
    --primary-light: #95E1D3;
    --primary-dark: #37A495;
    --secondary: #FF6B6B;
    --bg: #F0F9FF;
    --surface: #FFFFFF;
    --text: #2D2D2D;
    --text-light: #6B6B6B;
    --gauge-calm: #A8E6CF;
    --gauge-moderate: #FFC947;
    --gauge-loud: #FF6B6B;
    --color-calm: #A8E6CF;
    --color-lively: #FFC947;
    --color-loud: #FF6B6B;
    --track: #E0F4F3;
    --needle: #37A495;
    --fg: #2D2D2D;
    --aura-color: #4ECDC4;
    --timer-color: #FF6B6B;
}

[data-theme="grade35"] {
    --primary: #6C5CE7;
    --primary-light: #A29BFE;
    --primary-dark: #5849C7;
    --secondary: #00B894;
    --bg: #F6F5FF;
    --surface: #FFFFFF;
    --text: #2D2D2D;
    --text-light: #6B6B6B;
    --gauge-calm: #74B9FF;
    --gauge-moderate: #FFD93D;
    --gauge-loud: #FF7675;
    --color-calm: #74B9FF;
    --color-lively: #FFD93D;
    --color-loud: #FF7675;
    --track: #EBE9FE;
    --needle: #5849C7;
    --fg: #2D2D2D;
    --aura-color: #6C5CE7;
    --timer-color: #5849C7;
}

[data-theme="teen"] {
    --primary: #FF6348;
    --primary-light: #FF8B7E;
    --primary-dark: #E54B39;
    --secondary: #2ECC71;
    --bg: #1A1A1A;
    --surface: #2D2D2D;
    --text: #FFFFFF;
    --text-light: #B3B3B3;
    --gauge-calm: #2ECC71;
    --gauge-moderate: #F39C12;
    --gauge-loud: #E74C3C;
    --color-calm: #2ECC71;
    --color-lively: #F39C12;
    --color-loud: #E74C3C;
    --track: #3A3A3A;
    --needle: #FFFFFF;
    --fg: #FFFFFF;
    --aura-color: #FF6348;
    --timer-color: #F39C12;
}

[data-theme="adult"] {
    --primary: #3498DB;
    --primary-light: #5DADE2;
    --primary-dark: #2874A6;
    --secondary: #95A5A6;
    --bg: #ECF0F1;
    --surface: #FFFFFF;
    --text: #2C3E50;
    --text-light: #7F8C8D;
    --gauge-calm: #27AE60;
    --gauge-moderate: #F39C12;
    --gauge-loud: #E74C3C;
    --color-calm: #27AE60;
    --color-lively: #F39C12;
    --color-loud: #E74C3C;
    --track: #D5DBDB;
    --needle: #2C3E50;
    --fg: #2C3E50;
    --aura-color: #3498DB;
    --timer-color: #2874A6;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', 'Roboto', sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background 0.3s, color 0.3s;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Background pulse animations */
body.pulse-low {
    animation: backgroundPulseLow 3s ease-in-out infinite;
}

body.pulse-medium {
    animation: backgroundPulseMedium 2s ease-in-out infinite;
}

body.pulse-high {
    animation: backgroundPulseHigh 1s ease-in-out infinite;
}

@keyframes backgroundPulseLow {
    0%, 100% { 
        filter: brightness(1);
    }
    50% { 
        filter: brightness(1.03);
    }
}

@keyframes backgroundPulseMedium {
    0%, 100% { 
        filter: brightness(1);
    }
    50% { 
        filter: brightness(1.06);
    }
}

@keyframes backgroundPulseHigh {
    0%, 100% { 
        filter: brightness(1);
    }
    50% { 
        filter: brightness(1.1);
    }
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: clamp(0.5rem, 2vw, 1rem);
    gap: clamp(0.35rem, 1vw, 0.5rem);
}

/* Top Control Strip */
.control-strip {
    width: 100%;
    max-width: min(95vw, 900px);
    display: flex;
    flex-wrap: wrap;
    gap: clamp(1rem, 3vw, 2rem);
    align-items: center;
    margin: 0 auto;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    padding: clamp(0.75rem, 2vw, 1.25rem);
    border-radius: clamp(16px, 3vw, 24px);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(12px);
}

[data-theme="teen"] .control-strip {
    background: rgba(45, 45, 45, 0.9);
}

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

.toggle-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1.5rem, 4vw, 2.5rem);
    border-radius: clamp(12px, 2vw, 16px);
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-medium);
    transition: var(--transition-smooth);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-strong);
}

.toggle-btn:active {
    transform: scale(0.98);
}

.toggle-btn[data-state="running"] {
    background: var(--gauge-loud);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

.toggle-icon {
    font-size: 1.2em;
    display: inline-block;
    transition: transform 0.3s;
}

.toggle-btn[data-state="running"] .toggle-icon {
    transform: scale(0.8);
}

/* Theme Chips */
.theme-chips {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.theme-chip {
    background: var(--bg);
    color: var(--text);
    border: 2px solid transparent;
    padding: clamp(0.4rem, 1.5vw, 0.6rem) clamp(0.8rem, 2.5vw, 1.2rem);
    border-radius: clamp(10px, 2vw, 14px);
    font-size: clamp(0.75rem, 1.8vw, 0.9rem);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    white-space: nowrap;
}

.theme-chip:hover {
    transform: translateY(-1px);
    border-color: var(--primary-light);
}

.theme-chip.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border-color: var(--primary-dark);
    box-shadow: var(--shadow-soft);
}

/* Threshold Control */
.threshold-control {
    flex: 1;
    min-width: 200px;
    max-width: 300px;
}

.threshold-control label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: clamp(0.8rem, 1.8vw, 0.95rem);
}

.control-label {
    font-weight: 600;
    color: var(--text);
}

.control-value {
    font-weight: 800;
    color: var(--primary);
    font-size: clamp(1rem, 2.2vw, 1.3rem);
    min-width: 3ch;
    text-align: right;
}

/* Modern Slider */
.modern-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, 
        var(--gauge-calm) 0%, 
        var(--gauge-moderate) 50%, 
        var(--gauge-loud) 100%);
    outline: none;
    transition: opacity 0.2s;
}

.modern-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--primary);
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    transition: var(--transition-smooth);
}

.modern-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: var(--shadow-medium);
}

.modern-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--primary);
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    transition: var(--transition-smooth);
}

/* Gauge Container */
.gauge-container {
    position: relative;
    width: 100%;
    max-width: min(95vw, 900px);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gauge-svg {
    max-width: min(65vmin, 500px);
    width: 100%;
    display: block;
    margin-inline: auto;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
}

/* Semicircular Gauge Elements */
#gaugeTrack,
#segCalm,
#segLively,
#segLoud {
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.06));
    transition: var(--transition-smooth);
}

/* Needle */
#needle {
    transition: transform 0.2s ease-out;
}

#needle line {
    stroke: var(--needle);
    stroke-width: 6;
    stroke-linecap: round;
}

#needle circle {
    fill: var(--needle);
}

/* Gauge Value Text */
#gaugeValue {
    fill: var(--fg);
    font-size: 24px;
    font-weight: 700;
    user-select: none;
}

/* Mood Face - emoji display */
#moodFace {
    font-size: clamp(60px, 8vw, 78px);
    fill: var(--primary);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    user-select: none;
    transition: opacity 0.2s;
}

[data-theme="teen"] #moodFace,
[data-theme="adult"] #moodFace {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Timer States */
#streakCounter {
    transition: fill 0.3s ease, opacity 0.3s ease;
}

#streakCounter.timer-green {
    fill: var(--color-calm) !important;
}

#streakCounter.timer-red {
    fill: var(--color-loud) !important;
}

#streakCounter.timer-blink {
    animation: timerBlink 0.5s ease-in-out infinite;
}

@keyframes timerBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Streak Ring - progressive fill */
#streakRing {
    stroke: var(--color-calm);
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    transition: stroke-dashoffset 0.18s linear;
}

#streakRing.streak-high {
    stroke: var(--color-lively);
}

#streakRing.streak-full {
    stroke: var(--color-calm);
    filter: drop-shadow(0 0 10px rgba(16,185,129,.6));
}

/* Legacy SVG aura styles removed - now using CSS background layer */

/* Cooldown Ring - animated countdown */
#cooldownRing {
    opacity: 0;
    transition: opacity 0.15s;
}

#cooldownRing.active {
    opacity: 0.85 !important;
    transition: stroke-dashoffset linear var(--cooldown-ms, 10000ms), opacity 0.15s;
    animation: cooldownPulse 0.5s ease-in-out infinite;
}

@keyframes cooldownPulse {
    0%, 100% { opacity: 0.75; }
    50% { opacity: 0.95; }
}

/* Status Message - positioned below gauge */
.status-message {
    width: 100%;
    max-width: min(95vw, 900px);
    background: var(--surface);
    padding: 0;
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
    margin: 0 auto;
    font-size: clamp(0.95rem, 2vw, 1.1rem);
    font-weight: 600;
    color: var(--primary);
    text-align: center;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    margin: 0;
    transition: max-height 0.3s, opacity 0.3s, padding 0.3s, margin 0.3s;
    line-height: 1.4;
}

.status-message.show {
    max-height: 150px;
    opacity: 1;
    padding: 0.65rem 1.25rem;
    margin: 0.25rem 0;
}

@keyframes statusBounce {
    0% { transform: scale(0.95); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* Settings Panel */
.settings-panel {
    width: 100%;
    max-width: min(95vw, 900px);
    background: rgba(255, 255, 255, 0.9);
    border-radius: clamp(16px, 3vw, 20px);
    box-shadow: var(--shadow-soft);
    overflow: visible;
    backdrop-filter: blur(12px);
}

[data-theme="teen"] .settings-panel {
    background: rgba(45, 45, 45, 0.9);
}

.settings-toggle, .log-toggle {
    width: 100%;
    background: rgba(255, 255, 255, 0.5);
    border: 2px solid var(--bg);
    padding: 1rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: var(--transition-smooth);
    border-radius: clamp(16px, 3vw, 20px);
}

[data-theme="teen"] .settings-toggle,
[data-theme="teen"] .log-toggle {
    background: rgba(45, 45, 45, 0.5);
}

/* Inline threshold control in Settings button */
.threshold-control-inline {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    max-width: 350px;
}

.threshold-control-inline .threshold-label {
    font-weight: 600;
    color: var(--text);
    font-size: 1rem;
    white-space: nowrap;
}

.threshold-control-inline .control-value {
    min-width: 32px;
    text-align: center;
    font-weight: 700;
    color: var(--primary);
    font-size: 1rem;
}

.inline-slider {
    flex: 1;
    min-width: 100px;
}

.settings-toggle:hover, .log-toggle:hover, .timer-toggle:hover {
    background: var(--bg);
    border-color: var(--primary);
}

[data-theme="teen"] .settings-toggle:hover,
[data-theme="teen"] .log-toggle:hover,
[data-theme="teen"] .timer-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
}

.toggle-icon-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chevron {
    font-size: 1.5rem;
    transition: transform 0.3s;
    color: var(--primary);
}

.settings-panel.open .chevron,
.log-panel.open .chevron {
    transform: rotate(90deg);
}

.settings-content, .log-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0 0 clamp(16px, 3vw, 20px) clamp(16px, 3vw, 20px);
}

.settings-panel.open .settings-content {
    max-height: 800px;
    padding: 1rem;
}

.log-panel.open .log-content {
    max-height: 300px;
    padding: 1rem;
    padding-top: 0.5rem;
}

.setting-row {
    margin-bottom: 1.25rem;
}

.setting-row label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.setting-row strong {
    color: var(--primary);
}

.modern-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--bg);
    border-radius: 12px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.modern-select:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--primary);
    background: transparent;
    color: var(--primary);
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    font-size: 0.9rem;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
}

.btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Log Panel */
.log-panel {
    width: 100%;
    max-width: min(95vw, 900px);
    background: rgba(255, 255, 255, 0.9);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
    overflow: visible;
    margin-top: 1rem;
    backdrop-filter: blur(12px);
}

[data-theme="teen"] .log-panel {
    background: rgba(45, 45, 45, 0.9);
}

.log-actions {
    padding: 0.5rem 0 0 0;
    display: flex;
    justify-content: flex-end;
}

/* Event Log */
.event-log-mini {
    width: 100%;
    max-height: 150px;
    overflow-y: auto;
    background: var(--bg);
    border-radius: 12px;
    padding: 1rem;
    font-size: 0.8rem;
}

.log-entry {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: var(--bg);
    border-left: 3px solid var(--primary);
    border-radius: 8px;
    opacity: 0;
    animation: slideIn 0.3s forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.log-date {
    color: var(--text-light);
    font-size: 0.7rem;
    margin-right: 0.3rem;
}

.log-time {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.75rem;
}

.log-session {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    margin-right: 0.5rem;
}

.log-duration {
    color: var(--secondary);
    font-weight: 600;
    font-size: 0.75rem;
}

.log-empty {
    text-align: center;
    color: var(--text-light);
    font-style: italic;
    padding: 1rem;
}

/* Alert Overlay */
.alert-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle, rgba(255, 107, 107, 0.15), transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 100;
}

.alert-overlay.active {
    opacity: 1;
    animation: alertFlash 0.5s infinite;
}

@keyframes alertFlash {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* Calibrating Overlay */
.calibrating-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 200;
}

.calibrating-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.calibrating-content {
    background: var(--surface);
    padding: 3rem;
    border-radius: 24px;
    text-align: center;
    box-shadow: var(--shadow-strong);
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid var(--bg);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.countdown {
    font-size: 3rem;
    font-weight: 800;
    color: var(--primary);
    margin-top: 1rem;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.modern-checkbox {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
}

/* Toggle Switch */
.toggle-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    cursor: pointer;
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
    display: inline-block;
}

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

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

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-input:checked + .toggle-slider {
    background-color: var(--primary);
}

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

.toggle-slider:hover {
    box-shadow: 0 0 0 2px var(--primary-light);
}

/* Gauge Timer Display (in SVG) */
#gaugeTimerDisplay {
    font-family: 'Courier New', 'SF Mono', Monaco, monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.08em;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}

#gaugeTimerDisplay.active {
    opacity: 0.6;
}

/* Timer Panel */
.timer-panel {
    margin: 1.5rem auto;
    max-width: min(95vw, 900px);
    background: rgba(255, 255, 255, 0.9);
    border-radius: 24px;
    box-shadow: var(--shadow-soft);
    overflow: visible;
    transition: var(--transition-smooth);
    backdrop-filter: blur(12px);
}

[data-theme="teen"] .timer-panel {
    background: rgba(45, 45, 45, 0.9);
}

.timer-toggle {
    width: 100%;
    padding: 1.2rem 1.5rem;
    background: rgba(255, 255, 255, 0.5);
    border: 2px solid var(--bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    transition: var(--transition-smooth);
    border-radius: 24px;
}

[data-theme="teen"] .timer-toggle {
    background: rgba(45, 45, 45, 0.5);
}

.timer-toggle:hover {
    background: var(--bg);
    border-color: var(--primary);
}

.timer-compact-display {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    background: linear-gradient(135deg, var(--color-lively), var(--color-loud));
    color: white;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    transform: scale(0.95);
}

.timer-compact-display.active {
    opacity: 1;
    transform: scale(1);
}

.timer-compact-display.warn {
    background: linear-gradient(135deg, #ff6b6b, #ff4757);
    animation: compactPulse 2s ease-in-out infinite;
}

@keyframes compactPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.timer-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0 1.5rem;
    border-radius: 0 0 24px 24px;
}

.timer-panel.open .timer-content {
    max-height: 800px;
    padding: 0 1.5rem 1.5rem;
}

.timer-panel.open .chevron {
    transform: rotate(90deg);
}

.timer-controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
}

.mode-selector {
    display: flex;
    gap: 0.5rem;
}

.mode-selector .chip {
    padding: 0.5rem 1rem;
    background: var(--track);
    border: 2px solid transparent;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    transition: all 0.2s;
}

.mode-selector .chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.mode-selector .chip:hover:not(.active) {
    border-color: var(--primary-light);
}

.duration-inputs {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.duration-inputs.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.input-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
    margin-right: 0.3rem;
}

.timer-number-input {
    width: 60px;
    padding: 0.5rem;
    border: 2px solid var(--track);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s;
}

.timer-number-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.timer-sound-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex: 1;
    min-width: 200px;
}

.timer-select {
    flex: 1;
    min-width: 150px;
}

.btn-preview {
    padding: 0.5rem 0.75rem;
    background: var(--primary-light);
    border: none;
    border-radius: 8px;
    color: var(--primary-dark);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-preview:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

.btn-preview:active {
    transform: scale(0.95);
}

.timer-volume-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex: 1;
    min-width: 150px;
}

.timer-volume-slider {
    flex: 1;
}

.timer-display-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin: 2rem 0;
    position: relative;
}

.timer-display {
    font-size: clamp(40px, 8vw, 92px);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    color: var(--primary);
    font-family: 'Courier New', 'SF Mono', Monaco, monospace;
    text-align: center;
    line-height: 1;
}

.timer-exceed-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    background: var(--track);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    transition: all 0.3s;
    opacity: 0.6;
}

.timer-exceed-badge.active {
    opacity: 1;
    background: linear-gradient(135deg, var(--color-lively), var(--color-loud));
    color: white;
    animation: badgePulse 2s ease-in-out;
}

.timer-exceed-badge.warn {
    background: linear-gradient(135deg, #ff6b6b, #ff4757);
    color: white;
    animation: badgeWarn 1s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 107, 107, 0); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 8px rgba(255, 107, 107, 0.2); }
}

@keyframes badgeWarn {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.badge-icon {
    font-size: 1rem;
}

.badge-count {
    font-variant-numeric: tabular-nums;
}

.timer-button-row {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.timer-btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 100px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

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

.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 2px solid var(--track);
}

.btn-ghost:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary-dark);
}

.btn-ghost.danger {
    border-color: #ff6b6b;
    color: #ff6b6b;
}

.btn-ghost.danger:hover {
    background: #ff6b6b;
    color: white;
}

.timer-summary {
    min-height: 24px;
    padding: 0.75rem;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--bg);
    border-radius: 12px;
    margin-top: 1rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.timer-summary.visible {
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .control-strip {
        flex-direction: column;
    }
    
    .theme-chips {
        width: 100%;
    }
    
    .threshold-control {
        width: 100%;
        max-width: none;
    }
    
    .setting-row:last-child {
        display: flex;
        gap: 0.5rem;
    }
    
    .setting-row:last-child button {
        flex: 1;
        font-size: 0.8rem;
        padding: 0.6rem;
    }
}

@media (min-width: 1200px) {
    .app-container {
        padding: 2rem;
    }
}

/* Print Styles */
@media print {
    .control-strip,
    .settings-panel,
    .event-log-mini {
        display: none;
    }
}
