/* --- Base Reset & Typography --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    background-color: #f1f5f9;
    color: #1e293b;
    overflow: hidden;
}

.main-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; flex-shrink: 0; }
.bucket-help { font-size: .75rem; color: #475569; text-align: center; max-width: 340px; margin: 4px 0; }
#bucket-slider { touch-action: none; cursor: ns-resize; }
#bucket-slider:focus-visible { outline: 3px solid #4f46e5; outline-offset: -3px; }
#bucket-slider.dragging #bucket-fill { transition: none; }
.student-view #pause-overlay { flex-direction: column; gap: 20px; }
.student-view #btn-main-pause { min-height: 44px; }
#detection-status { margin: 8px 0; line-height: 1.5; }
.soundstreak-help { margin: 10px 0; }
.soundstreak-help summary { cursor: pointer; font-weight: 600; }
.soundstreak-help p { margin: 8px 0; line-height: 1.5; }

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* --- 70% Student View --- */
.student-view {
    width: 70%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #ffffff 0%, #f8fafc 100%);
    position: relative;
}

.student-view h1 {
    font-size: clamp(1.2rem, 5vw, 3rem);
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 3vh;
    letter-spacing: -1px;
    text-align: center;
    padding: 0 10px;
    word-break: break-word;
}

#status-message {
    margin-top: 4vh;
    font-size: clamp(1rem, 4vw, 1.75rem);
    font-weight: 600;
    color: #64748b;
    transition: color 0.3s;
    text-align: center;
    padding: 0 10px;
    word-break: break-word;
}

#pause-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

#pause-overlay h2 {
    font-size: clamp(1.5rem, 8vw, 4rem);
    color: #3b82f6;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
    word-break: break-word;
    padding: 0 10px;
}

.hidden {
    display: none !important;
}

.full-width {
    width: 100% !important;
    border-right: none !important;
}

/* Modern Gauge / Bucket */
.manual-adjust-btn {
    background-color: #e2e8f0;
    color: #475569;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    font-size: 3rem;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    padding: 0;
    border: 2px solid #cbd5e1;
}
.manual-adjust-btn:hover {
    background-color: #cbd5e1;
}

.visuals-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 20px;
}

/* Real-time Volume Meter */
.meter-container {
    width: clamp(15px, 3vw, 25px);
    height: 55vh;
    background-color: #e2e8f0;
    border-radius: 100px;
    position: relative;
    box-shadow: inset 0 4px 6px rgba(0,0,0,0.1);
    overflow: hidden;
}

#meter-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background-color: #10b981;
    transition: height 0.05s ease-out, background-color 0.2s;
}

#meter-threshold-line {
    position: absolute;
    bottom: 0%; /* Set dynamically */
    left: 0;
    width: 100%;
    height: 4px;
    background-color: #ef4444;
    z-index: 2;
    box-shadow: 0 0 4px rgba(239, 68, 68, 0.8);
}

.bucket-outer {
    padding: 10px;
    background: #ffffff;
    border-radius: 100px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

.bucket-container {
    width: clamp(90px, 15vw, 140px);
    height: 55vh;
    border-radius: 100px;
    background-color: #e2e8f0;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 4px 6px rgba(0,0,0,0.1);
}

#bucket-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%; 
    background: linear-gradient(to top, #3b82f6, #8b5cf6, #ef4444);
    transition: height 0.5s ease-out;
    border-radius: 100px;
}

/* --- 30% Teacher Control Panel --- */
.teacher-panel {
    width: 30%;
    min-width: 220px;
    background-color: #f8fafc;
    border-left: 1px solid #cbd5e1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 2vh 2vw;
    gap: 1.5vh;
    box-shadow: -4px 0 15px rgba(0,0,0,0.02);
    overflow-y: auto;
}

.speech-activity {
    margin-top: 10px;
    font-size: 0.78rem;
    color: #475569;
}

.speech-activity-track {
    height: 8px;
    margin-top: 5px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

#speech-activity-fill {
    width: 0%;
    height: 100%;
    background: #6366f1;
    border-radius: inherit;
    transition: width 0.3s ease;
}

.panel-header h2 {
    font-size: 1.5rem;
    color: #334155;
    margin-bottom: 1vh;
}

.control-card {
    background: #ffffff;
    padding: 1.5vh 1.5vw;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.control-card h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    margin-bottom: 1vh;
}

.btn-row {
    display: flex;
    gap: 10px;
}
.btn-row .btn {
    flex: 1;
}

.btn-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn {
    padding: 10px 15px;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.primary { background-color: #3b82f6; color: white; }
.primary:not(:disabled):hover { background-color: #2563eb; }

.secondary { background-color: #f59e0b; color: white; }
.secondary:not(:disabled):hover { background-color: #d97706; }

.warning { background-color: #ef4444; color: white; }
.warning:not(:disabled):hover { background-color: #dc2626; }

.mode-btn { background-color: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.mode-btn:hover { background-color: #e2e8f0; }
.mode-btn.active { background-color: #6366f1; color: white; border-color: #6366f1; }

.stats-card {
    display: flex;
    justify-content: space-between;
    background: #ffffff;
    padding: 1.5vh 1.5vw;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.stat-box {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.8rem;
    color: #94a3b8;
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: bold;
    color: #0f172a;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    background: #ffffff;
    padding: 25px;
    border-radius: 12px;
    width: 450px;
    max-width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-content.history-modal {
    width: 900px;
    max-width: 94%;
}

.history-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px;
}

.history-controls label {
    display: flex;
    flex: 1 1 150px;
    flex-direction: column;
    gap: 5px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}

.history-controls input,
.history-controls select {
    min-width: 0;
    padding: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    color: #0f172a;
}

.history-help,
.history-empty {
    margin: 12px 0;
    color: #64748b;
    font-size: 0.9rem;
}

.history-chart svg {
    display: block;
    width: 100%;
    max-height: 420px;
}

.history-grid {
    stroke: #e2e8f0;
    stroke-width: 1;
}

.history-axis-label {
    fill: #64748b;
    font-size: 12px;
}

.history-line {
    stroke: #6366f1;
    stroke-width: 3;
}

.history-point {
    fill: #4f46e5;
    stroke: #fff;
    stroke-width: 2;
}

.history-data {
    max-height: 180px;
    overflow-y: auto;
    border-top: 1px solid #e2e8f0;
    margin-top: 12px;
    padding-top: 8px;
}

.history-data h3 {
    color: #475569;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.history-data div {
    display: flex;
    justify-content: space-between;
    padding: 5px 2px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.85rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 10px;
}

.close-btn {
    cursor: pointer;
    font-size: 1.2rem;
    color: #94a3b8;
    transition: color 0.2s;
}

.close-btn:hover {
    color: #ef4444;
}
