/* ================================
   Virtual Titration Lab - Styles
   Premium Dark Theme with Glassmorphism
   ================================ */

:root {
    /* Color Palette */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a24;
    --bg-glass: rgba(26, 26, 36, 0.7);
    --bg-glass-light: rgba(255, 255, 255, 0.03);

    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;

    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);

    --success: #22c55e;
    --success-glow: rgba(34, 197, 94, 0.3);
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.3);

    /* Chemical Colors */
    --naoh-color: #c7d2fe;
    --hcl-color: #fef3c7;
    --phenolphthalein-colorless: transparent;
    --phenolphthalein-pink: #f472b6;
    --phenolphthalein-faint: rgba(244, 114, 182, 0.3);

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Borders */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --border-subtle: 1px solid rgba(255, 255, 255, 0.06);
    --border-glass: 1px solid rgba(255, 255, 255, 0.1);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px var(--accent-glow);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow: hidden;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-content {
    text-align: center;
}

.loading-flask {
    width: 80px;
    height: 100px;
    margin: 0 auto var(--space-lg);
    position: relative;
}

.loading-flask .flask-body {
    width: 60px;
    height: 80px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 0 0 30px 30px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

.loading-flask .flask-liquid {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(180deg, var(--accent-secondary), var(--accent-primary));
    animation: liquidWave 2s ease-in-out infinite;
}

@keyframes liquidWave {

    0%,
    100% {
        height: 40%;
    }

    50% {
        height: 50%;
    }
}

.loading-content h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
    background: linear-gradient(135deg, var(--text-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.loading-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--space-lg);
}

.loading-bar {
    width: 200px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin: 0 auto;
}

.loading-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-full);
    animation: loadProgress 2s ease-out forwards;
}

@keyframes loadProgress {
    to {
        width: 100%;
    }
}

/* App Container */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.app.hidden {
    display: none;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-xl);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-bottom: var(--border-subtle);
    z-index: 100;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 600;
    font-size: 1.1rem;
}

.logo-icon {
    font-size: 1.5rem;
}

.trial-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    font-family: var(--font-mono);
}

.trial-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-right: var(--space-xs);
}

.trial-number {
    color: var(--accent-secondary);
    font-weight: 600;
    font-size: 1.1rem;
}

.trial-separator {
    color: var(--text-muted);
}

.trial-total {
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-glass-light);
    color: var(--text-primary);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: var(--border-subtle);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: var(--shadow-sm), 0 0 20px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md), 0 0 30px var(--accent-glow);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-large {
    padding: var(--space-md) var(--space-xl);
    font-size: 1rem;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    flex: 1;
    overflow: hidden;
}

/* Panels */
.panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-right: var(--border-subtle);
}

.panel:last-child {
    border-right: none;
    border-left: var(--border-subtle);
}

.panel-header {
    padding: var(--space-md) var(--space-lg);
    border-bottom: var(--border-subtle);
}

.panel-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.panel-tabs {
    display: flex;
    gap: var(--space-xs);
    margin-top: var(--space-sm);
}

.tab-btn {
    padding: var(--space-xs) var(--space-sm);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    color: var(--text-secondary);
}

.tab-btn.active {
    background: var(--accent-primary);
    color: white;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
}

/* Steps List */
.step-progress {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    margin-bottom: var(--space-md);
    overflow: hidden;
}

.step-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-primary), var(--success));
    transition: width var(--transition-normal);
}

.steps-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.step-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.step-item.active {
    background: var(--bg-glass-light);
}

.step-item.completed {
    opacity: 0.6;
}

.step-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
    border: 2px solid var(--bg-tertiary);
    transition: all var(--transition-fast);
}

.step-item.active .step-icon {
    border-color: var(--accent-primary);
    background: var(--accent-glow);
}

.step-item.completed .step-icon {
    background: var(--success);
    border-color: var(--success);
}

.step-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.step-item.active .step-text {
    color: var(--text-primary);
    font-weight: 500;
}

/* Feedback Box */
.feedback-box {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--bg-glass);
    border-radius: var(--radius-md);
    border: var(--border-glass);
    margin-top: auto;
}

.feedback-icon {
    font-size: 1.25rem;
}

.feedback-box p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Workspace */
.workspace {
    position: relative;
    background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* PPE Overlay */
.ppe-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: all var(--transition-slow);
}

.ppe-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.ppe-modal {
    background: var(--bg-glass);
    border: var(--border-glass);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    text-align: center;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.ppe-icon {
    font-size: 4rem;
    margin-bottom: var(--space-md);
}

.ppe-modal h2 {
    font-size: 1.5rem;
    margin-bottom: var(--space-sm);
}

.ppe-modal p {
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
}

.ppe-checklist {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    text-align: left;
}

.ppe-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ppe-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.ppe-item input {
    display: none;
}

.checkmark {
    width: 24px;
    height: 24px;
    border: 2px solid var(--text-muted);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.ppe-item input:checked+.checkmark {
    background: var(--success);
    border-color: var(--success);
}

.ppe-item input:checked+.checkmark::after {
    content: '✓';
    color: white;
    font-weight: bold;
}

/* Lab Bench */
.lab-bench {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    grid-template-rows: 1fr auto;
    gap: var(--space-lg);
    padding: var(--space-xl);
    position: relative;
}

.lab-bench.hidden {
    display: none;
}

/* Equipment Styles */
.equipment {
    position: relative;
}

/* Burette Stand */
.burette-stand {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: var(--space-lg);
    z-index: 10;
    /* Above flask-area for click handling */
    pointer-events: none;
    /* Allow clicks to pass through except on children */
}

.burette-stand>* {
    pointer-events: auto;
    /* Re-enable clicks on actual equipment */
}


.burette {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.burette:hover .burette-tube {
    border-color: var(--accent-secondary);
    box-shadow: 0 0 10px var(--accent-glow);
}


.burette-tube {
    width: 30px;
    height: 300px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.1) 100%);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px 4px 2px 2px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.burette-tube:hover {
    border-color: var(--accent-secondary);
}

.burette-liquid {
    position: absolute;
    top: 0;
    left: 2px;
    right: 2px;
    height: 0%;
    background: linear-gradient(180deg, var(--naoh-color) 0%, rgba(199, 210, 254, 0.8) 100%);
    transition: height 0.1s linear;
    pointer-events: none;
    /* Allow clicks to pass through to burette-tube */
}

.meniscus {
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 6px;
    background: radial-gradient(ellipse at center bottom, rgba(255, 255, 255, 0.5) 0%, transparent 70%);
    border-radius: 0 0 50% 50%;
    pointer-events: none;
}

.burette-graduations {
    position: absolute;
    top: 0;
    left: 100%;
    height: 100%;
    width: 40px;
    margin-left: 4px;
    pointer-events: none;
    /* Allow clicks to pass through */
}


.graduation {
    position: absolute;
    left: 0;
    display: flex;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
}

.graduation::before {
    content: '';
    width: 8px;
    height: 1px;
    background: var(--text-muted);
    margin-right: 4px;
}

.graduation.major::before {
    width: 12px;
    background: var(--text-secondary);
}

.burette-stopcock {
    width: 50px;
    height: 20px;
    background: var(--bg-tertiary);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    position: relative;
    cursor: pointer;
    margin-top: -2px;
}

.stopcock-handle {
    width: 40px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 4px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(0deg);
    transition: transform var(--transition-fast), background var(--transition-fast);
}

.burette-stopcock.open .stopcock-handle {
    transform: translate(-50%, -50%) rotate(90deg);
    background: var(--success);
}

.burette-stopcock.ready {
    box-shadow: 0 0 15px var(--accent-primary);
    border-color: var(--accent-primary);
}

.burette-stopcock.ready .stopcock-handle {
    background: var(--warning);
}

.burette-stopcock:hover {
    border-color: var(--accent-primary);
}

.burette-stopcock:hover .stopcock-handle {
    filter: brightness(1.2);
}

.burette-tip {
    width: 6px;
    height: 30px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-top: none;
}

.drip {
    width: 6px;
    height: 6px;
    background: var(--naoh-color);
    border-radius: 50% 50% 50% 50%;
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    animation: none;
}

.drip.falling {
    animation: dripFall 0.5s ease-in forwards;
}

@keyframes dripFall {
    0% {
        bottom: 0;
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }

    100% {
        bottom: -150px;
        opacity: 0;
        transform: translateX(-50%) scale(0.5);
    }
}

.burette-reading-display {
    margin-top: var(--space-lg);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-glass);
    border: var(--border-glass);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.reading-label {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.reading-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent-secondary);
}

.reading-unit {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Flask */
.flask-area {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: var(--space-xl);
}

.flask {
    position: relative;
    width: 120px;
    height: 140px;
}

.flask-neck {
    width: 30px;
    height: 30px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-bottom: none;
    margin: 0 auto;
    border-radius: 4px 4px 0 0;
}

.flask-body {
    width: 120px;
    height: 100px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.05));
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px 10px 50% 50%;
    position: relative;
    overflow: hidden;
}

.flask-liquid {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0%;
    background: var(--hcl-color);
    transition: background-color 0.3s ease, height 0.3s ease;
}

.flask.has-analyte .flask-liquid {
    height: 40%;
}

.flask.swirling {
    animation: swirl 0.3s ease-in-out;
}

@keyframes swirl {

    0%,
    100% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(-5deg);
    }

    75% {
        transform: rotate(5deg);
    }
}

.flask-status {
    margin-top: var(--space-sm);
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    min-height: 1.5em;
}

.swirl-hint {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-glass);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.flask-area:hover .swirl-hint {
    opacity: 1;
}

kbd {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Equipment Shelf */
.equipment-shelf {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    gap: var(--space-lg);
    justify-content: center;
    padding: var(--space-md);
    background: var(--bg-glass);
    border-radius: var(--radius-lg);
    border: var(--border-glass);
}

.shelf-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.shelf-item:hover {
    background: var(--bg-glass-light);
    transform: translateY(-2px);
}

.shelf-item:focus-visible {
    outline: 2px solid var(--accent-primary);
}

.shelf-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* Pipette */
.pipette-body {
    width: 8px;
    height: 60px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    position: relative;
}

.pipette-body::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Bottles */
.bottle-body {
    width: 40px;
    height: 50px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px 4px 8px 8px;
    position: relative;
    overflow: hidden;
}

.bottle-body::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 12px;
    background: var(--bg-tertiary);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.bottle-liquid {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70%;
}

.indicator-bottle .bottle-liquid {
    background: rgba(244, 114, 182, 0.5);
}

.bottle-body.naoh .bottle-liquid {
    background: var(--naoh-color);
}

/* Beaker */
.beaker-body {
    width: 50px;
    height: 45px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 2px 2px 6px 6px;
    position: relative;
    overflow: hidden;
}

.beaker-liquid {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60%;
    background: var(--hcl-color);
}

/* Start Flow Button */
.btn-start-flow {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: 20;
    font-size: 1rem;
    padding: var(--space-md) var(--space-lg);
    box-shadow: 0 0 15px var(--accent-primary);
}

.btn-start-flow.hidden {
    display: none;
}

/* Flow Control */
.flow-control {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-lg);
    background: var(--bg-glass);
    border: var(--border-glass);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    text-align: center;
    z-index: 20;
}

.flow-control.hidden {
    display: none;
}

.flow-control h4 {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.flow-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin-bottom: var(--space-sm);
}

.flow-btn {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: var(--border-subtle);
    color: var(--text-secondary);
    font-size: 0.8rem;
    justify-content: center;
}

.flow-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* Zoom Modal */
.zoom-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
}

.zoom-overlay.hidden {
    display: none;
}

.zoom-modal {
    background: var(--bg-secondary);
    border: var(--border-glass);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    max-width: 400px;
    position: relative;
}

.zoom-close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.zoom-modal h3 {
    text-align: center;
    margin-bottom: var(--space-lg);
}

.zoom-burette {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-lg);
}

.zoom-tube {
    width: 60px;
    height: 200px;
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.zoom-liquid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: var(--naoh-color);
    transition: height 0.2s ease;
}

.zoom-meniscus {
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 8px;
    background: radial-gradient(ellipse at center bottom, rgba(255, 255, 255, 0.6) 0%, transparent 70%);
    border-radius: 0 0 50% 50%;
}

.zoom-graduations {
    position: absolute;
    top: 0;
    left: 100%;
    height: 100%;
    width: 60px;
    margin-left: 8px;
}

.zoom-reading {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    align-items: center;
}

.zoom-reading label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.zoom-reading input {
    width: 120px;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: var(--border-glass);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 1.1rem;
    text-align: center;
}

.zoom-reading input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Data Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.data-section {
    margin-bottom: var(--space-lg);
}

.data-section h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th,
.data-table td {
    padding: var(--space-sm);
    text-align: left;
    border-bottom: var(--border-subtle);
}

.data-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.data-table td:last-child {
    text-align: right;
    font-family: var(--font-mono);
}

.trial-table td {
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.trial-table td[data-pending] {
    color: var(--text-muted);
    font-style: italic;
}

/* Graph */
.graph-container {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    height: 250px;
}

.graph-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Calculations */
.calc-section {
    padding: var(--space-sm);
}

.formula {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    color: var(--accent-secondary);
    text-align: center;
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.calc-steps {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.calc-step {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.calc-step label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.calc-step input {
    padding: var(--space-sm);
    background: var(--bg-tertiary);
    border: var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.calc-step.highlight input {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
}

.calc-result {
    margin-top: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    text-align: center;
}

.calc-result.correct {
    background: var(--success-glow);
    color: var(--success);
}

.calc-result.incorrect {
    background: var(--danger-glow);
    color: var(--danger);
}

/* Action Bar */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-xl);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-top: var(--border-subtle);
}

.action-right {
    display: flex;
    gap: var(--space-sm);
}

.endpoint-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--success-glow);
    border-radius: var(--radius-full);
    color: var(--success);
    font-weight: 600;
    animation: pulseGlow 1.5s ease-in-out infinite;
}

.endpoint-indicator.hidden {
    display: none;
}

.endpoint-pulse {
    width: 10px;
    height: 10px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.7;
    }
}

@keyframes pulseGlow {

    0%,
    100% {
        box-shadow: 0 0 10px var(--success-glow);
    }

    50% {
        box-shadow: 0 0 20px var(--success-glow);
    }
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--bg-secondary);
    border: var(--border-glass);
    border-radius: var(--radius-xl);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.modal-large {
    max-width: 600px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: var(--border-subtle);
}

.modal-header h2 {
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: var(--space-xs);
    line-height: 1;
}

.modal-content {
    padding: var(--space-lg);
    overflow-y: auto;
    max-height: 60vh;
}

.modal-content h3 {
    font-size: 1rem;
    margin: var(--space-md) 0 var(--space-sm);
    color: var(--text-primary);
}

.modal-content p,
.modal-content li {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.modal-content ul {
    padding-left: var(--space-lg);
}

.modal-content li {
    margin-bottom: var(--space-xs);
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) 0;
    border-bottom: var(--border-subtle);
}

.setting-row label {
    color: var(--text-secondary);
}

.setting-row select {
    padding: var(--space-sm);
    background: var(--bg-tertiary);
    border: var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

/* Toggle Switch */
input[type="checkbox"].toggle-switch {
    appearance: none;
    width: 44px;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    position: relative;
    cursor: pointer;
    transition: background var(--transition-fast);
}

input[type="checkbox"].toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all var(--transition-fast);
}

input[type="checkbox"].toggle-switch:checked {
    background: var(--accent-primary);
}

input[type="checkbox"].toggle-switch:checked::after {
    left: 22px;
    background: white;
}

/* Completion Modal */
.score-display {
    text-align: center;
    margin-bottom: var(--space-lg);
}

.score-value {
    font-size: 4rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.completion-details {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-lg);
}

.completion-details p {
    display: flex;
    justify-content: space-between;
    padding: var(--space-sm) 0;
    border-bottom: var(--border-subtle);
}

.completion-details p:last-child {
    border-bottom: none;
}

.completion-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Colorblind Mode */
.colorblind-mode .flask-liquid.endpoint {
    background: repeating-linear-gradient(45deg, var(--hcl-color), var(--hcl-color) 5px, #888 5px, #888 10px) !important;
}

/* Responsive */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 240px 1fr 280px;
    }
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }

    .panel-guidance,
    .panel-data {
        max-height: 200px;
    }
}