/* MODERN FOCUS TRAINER STYLES */

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

:root {
    /* Light theme */
    --primary-color: #E6E6FA;    /* Soft lavender */
    --secondary-color: #9DC183;  /* Cool sage */
    --accent-color: #B0C4DE;     /* Pale blue */
    --accent-color-2: #3492eb;   /* Bright blue */
    --text-color: #333;
    --text-color-2: #c37515;
    --bg-color: #f5faf3;         /* Very light green */
    --modal-bg: rgba(0, 0, 0, 0.2);
    --tooltip-bg: white;
    --tooltip-shadow: rgba(0, 0, 0, 0.1);
    --modal-content-bg: white;
    --success: #9DC183;
    --warning: #ffa500;
    --error: #ff6b6b;
    --base-unit: 16px;
    --golden-ratio: 1.618;
    --transition-slow: 2000ms;
    --transition-medium: 400ms;
    --transition-fast: 200ms;
    --radius-sm: calc(var(--base-unit) * 0.5);
    --radius-md: calc(var(--base-unit) * 1);
    --radius-lg: calc(var(--base-unit) * 1.5);
    --radius-full: 50%;
    --font-serif: 'Spectral', serif;
    --font-sans: 'Inter', sans-serif;
    --shadow-primary: rgba(0, 0, 0, 0.1);
    --shadow-focus: rgba(157, 193, 131, 0.3);
    --gradient-focus: linear-gradient(135deg, var(--secondary-color) 0%, var(--accent-color-2) 100%);
}

[data-theme="dark"] {
    --primary-color: #2A2A3C;    /* Dark lavender */
    --secondary-color: #5A7355;  /* Dark sage */
    --accent-color: #445C77;     /* Dark blue */
    --accent-color-2: #1C4D82;   /* Deep blue */
    --text-color: #E1E1E1;
    --text-color-2: #c37515;
    --bg-color: #1d2432;
    --modal-bg: rgba(255, 255, 255, 0.1);
    --tooltip-bg: #2A2A2A;
    --tooltip-shadow: rgba(255, 255, 255, 0.05);
    --modal-content-bg: #2A2A2A;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    margin: 0;
    transition: background-color var(--transition-medium), color var(--transition-medium);
}

/* Global smooth transitions */
body * {
    transition: background-color var(--transition-medium),
                color var(--transition-medium),
                border-color var(--transition-medium),
                box-shadow var(--transition-medium),
                transform var(--transition-medium);
}

/* Typography */
h1, h2, h3 {
    font-family: var(--font-serif);
    font-weight: 500;
    color: var(--text-color-2);
}

h1 {
    font-size: calc(var(--base-unit) * 3);
}

/* Tooltip system */
.control-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(var(--base-unit) * -2.5);
    left: 50%;
    transform: translateX(-50%);
    background: var(--tooltip-bg);
    color: var(--text-color);
    padding: calc(var(--base-unit) * 0.4) calc(var(--base-unit) * 0.8);
    border-radius: var(--radius-sm);
    font-size: calc(var(--base-unit) * 0.8);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 4px var(--tooltip-shadow);
}

.control-btn:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-2px);
}

/* New simplified layout styles */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: calc(var(--base-unit) * 1.5);
    gap: calc(var(--base-unit) * 1.5);
}

.stats-section {
    flex-shrink: 0;
}

.info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(var(--base-unit) * 1.5);
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    max-width: 600px;
    margin: 0 auto;
}

.time-display {
    font-size: calc(var(--base-unit) * 2.5);
    font-family: var(--font-serif);
    font-weight: 300;
    letter-spacing: 0.05em;
}

.focus-score {
    text-align: left;
}

.focus-score .score-value {
    font-size: calc(var(--base-unit) * 2);
    font-family: var(--font-serif);
    color: var(--text-color-2);
    display: block;
    margin-bottom: calc(var(--base-unit) * 0.25);
}

.focus-score .score-label {
    font-size: calc(var(--base-unit) * 0.9);
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.status-display {
    text-align: right;
    font-size: calc(var(--base-unit) * 1);
    opacity: 0.8;
    max-width: 200px;
}

.visual-section {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: calc(var(--base-unit) * 1) 0;
}

.focus-container {
    position: relative;
    width: min(45vh, 50vw);
    height: min(45vh, 50vw);
    border-radius: var(--radius-full);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    background: var(--primary-color);
}

.webcam-feed {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.8;
    border-radius: var(--radius-full);
}

.focus-canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    pointer-events: none;
}

.calibration-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    text-align: center;
    border-radius: var(--radius-full);
}

.calibration-message h3 {
    font-family: var(--font-serif);
    font-size: calc(var(--base-unit) * 1.5);
    margin-bottom: calc(var(--base-unit) * 0.5);
}

.progress-container {
    position: absolute;
    bottom: calc(var(--base-unit) * 2);
    left: calc(var(--base-unit) * 2);
    right: calc(var(--base-unit) * 2);
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--secondary-color);
    border-radius: 2px;
    transition: width var(--transition-medium);
    width: 0%;
}

.controls-section {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: calc(var(--base-unit) * 1);
    align-items: center;
}

.main-controls {
    display: flex;
    align-items: center;
    gap: calc(var(--base-unit) * 1.5);
}

.primary-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    padding: calc(var(--base-unit) * 1.2) calc(var(--base-unit) * 2.5);
    font-family: var(--font-sans);
    font-size: calc(var(--base-unit) * 1.1);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.time-btn {
    background: none;
    border: 1px solid var(--accent-color);
    color: var(--text-color);
    border-radius: var(--radius-md);
    padding: calc(var(--base-unit) * 0.8) calc(var(--base-unit) * 1.5);
    font-family: var(--font-sans);
    font-size: calc(var(--base-unit) * 0.9);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.time-btn:hover {
    background: var(--accent-color);
    color: var(--bg-color);
}

.time-selector {
    position: absolute;
    bottom: calc(var(--base-unit) * 6);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: calc(var(--base-unit) * 0.5);
    background: rgba(0, 0, 0, 0.8);
    padding: calc(var(--base-unit) * 1);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.time-option {
    background: none;
    border: 1px solid var(--accent-color);
    color: white;
    border-radius: var(--radius-sm);
    padding: calc(var(--base-unit) * 0.6) calc(var(--base-unit) * 1);
    font-size: calc(var(--base-unit) * 0.8);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.time-option:hover {
    background: var(--accent-color);
}

.time-option.active {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
}

.secondary-controls {
    display: flex;
    gap: calc(var(--base-unit) * 1);
}

.control-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    width: calc(var(--base-unit) * 4);
    height: calc(var(--base-unit) * 4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-color);
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
}

.control-btn .icon {
    width: calc(var(--base-unit) * 1.5);
    height: calc(var(--base-unit) * 1.5);
    fill: currentColor;
}

/* Insights dropdown and Help modal */
.insights-dropdown {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.insights-dropdown[hidden] {
    display: none;
}

.insights-dropdown:not([hidden]) {
    animation: fadeIn 0.3s ease-out;
}

.insights-content {
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    padding: calc(var(--base-unit) * 3);
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 90%;
}

.insights-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: calc(var(--base-unit) * 2);
    padding-bottom: calc(var(--base-unit) * 1.5);
    border-bottom: 1px solid var(--primary-color);
}

.insights-header h3 {
    font-family: var(--font-serif);
    font-size: calc(var(--base-unit) * 2);
    margin: 0;
    color: var(--text-color-2);
}

.close-btn {
    background: none;
    border: none;
    font-size: calc(var(--base-unit) * 2);
    cursor: pointer;
    color: var(--text-color);
    opacity: 0.7;
    transition: opacity var(--transition-fast);
    padding: calc(var(--base-unit) * 0.5);
    border-radius: var(--radius-full);
    width: calc(var(--base-unit) * 2.5);
    height: calc(var(--base-unit) * 2.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    opacity: 1;
    background: var(--primary-color);
}

/* Stats panel */
.stats-panel {
    margin-bottom: calc(var(--base-unit) * 3);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: calc(var(--base-unit) * 2);
}

.stat-item {
    text-align: center;
    padding: calc(var(--base-unit) * 1.5);
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    border: 1px solid var(--primary-color);
}

.stat-value {
    font-family: var(--font-serif);
    font-size: calc(var(--base-unit) * 2);
    color: var(--secondary-color);
    display: block;
    margin-bottom: calc(var(--base-unit) * 0.5);
}

.stat-label {
    font-family: var(--font-sans);
    font-size: calc(var(--base-unit) * 0.9);
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Timeline */
.distraction-timeline {
    margin-bottom: calc(var(--base-unit) * 3);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: calc(var(--base-unit) * 1);
}

.timeline-title {
    font-family: var(--font-serif);
    font-size: calc(var(--base-unit) * 1.2);
    color: var(--text-color-2);
}

.timeline-info {
    font-size: calc(var(--base-unit) * 0.8);
    opacity: 0.6;
}

.timeline-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin-bottom: calc(var(--base-unit) * 0.5);
    position: relative;
}

.timeline-labels {
    display: flex;
    justify-content: space-between;
    font-size: calc(var(--base-unit) * 0.8);
    opacity: 0.7;
}

/* Score history */
.score-history-title {
    font-family: var(--font-serif);
    font-size: calc(var(--base-unit) * 1.2);
    color: var(--text-color-2);
    margin-bottom: calc(var(--base-unit) * 1);
}

.score-chart-container {
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: calc(var(--base-unit) * 1.5);
    border: 1px solid var(--primary-color);
}

/* Help Modal Specific Styles */
.help-sections {
    display: flex;
    flex-direction: column;
    gap: calc(var(--base-unit) * 2);
}

.help-section {
    padding: calc(var(--base-unit) * 1.5);
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.help-section-title {
    font-family: var(--font-serif);
    font-size: calc(var(--base-unit) * 1.3);
    color: var(--text-color-2);
    margin-bottom: calc(var(--base-unit) * 1);
    display: flex;
    align-items: center;
    gap: calc(var(--base-unit) * 0.5);
}

.help-text {
    font-size: calc(var(--base-unit) * 0.95);
    line-height: 1.6;
    color: var(--text-color);
    margin-bottom: calc(var(--base-unit) * 0.75);
    opacity: 0.9;
}

.help-text:last-child {
    margin-bottom: 0;
}

.help-list {
    display: flex;
    flex-direction: column;
    gap: calc(var(--base-unit) * 1);
}

.help-list-item {
    display: flex;
    gap: calc(var(--base-unit) * 1);
    align-items: flex-start;
    padding: calc(var(--base-unit) * 0.75);
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.help-list-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.help-icon {
    font-size: calc(var(--base-unit) * 1.5);
    flex-shrink: 0;
    line-height: 1;
}

.help-bullet-list {
    list-style: none;
    padding-left: calc(var(--base-unit) * 1.5);
    margin: calc(var(--base-unit) * 0.5) 0 0 0;
}

.help-bullet-list li {
    position: relative;
    padding-left: calc(var(--base-unit) * 1.5);
    margin-bottom: calc(var(--base-unit) * 0.5);
    line-height: 1.6;
    font-size: calc(var(--base-unit) * 0.95);
    opacity: 0.9;
}

.help-bullet-list li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--secondary-color);
    font-weight: bold;
}

.shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: calc(var(--base-unit) * 1);
    margin-top: calc(var(--base-unit) * 1);
}

.shortcut-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: calc(var(--base-unit) * 0.5);
    padding: calc(var(--base-unit) * 1);
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all var(--transition-fast);
}

.shortcut-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.shortcut-item kbd {
    background: var(--accent-color);
    color: var(--text-color);
    padding: calc(var(--base-unit) * 0.4) calc(var(--base-unit) * 0.8);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: calc(var(--base-unit) * 0.85);
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    min-width: calc(var(--base-unit) * 2.5);
    text-align: center;
}

.shortcut-item span {
    font-size: calc(var(--base-unit) * 0.8);
    color: var(--text-color);
    opacity: 0.8;
    text-align: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* MODERN HEADER */
.brutalist-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 80px;
    background-color: var(--primary-color);
    color: var(--text-color);
    border-bottom: 1px solid var(--primary-color);
    -webkit-backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    z-index: 1002;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 3px var(--shadow-primary);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.brutalist-title {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin: 0;
    color: var(--text-color);
}

.header-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.brutalist-btn {
    background-color: var(--accent-color-2);
    color: var(--text-color);
    border: 1px solid var(--accent-color-2);
    border-radius: 6px;
    padding: 8px 16px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    text-decoration: none;
    display: inline-block;
    box-shadow: 0 2px 8px var(--shadow-focus);
}

.brutalist-btn:hover {
    background-color: var(--accent-color-2);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow-focus);
}

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

/* Loading state */
.loading-state {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: calc(var(--base-unit) * 2);
    z-index: 999;
}

.breathing-rectangle {
    width: 60px;
    height: 60px;
    background: var(--secondary-color);
    border: 1px solid var(--secondary-color);
    border-radius: var(--radius-md);
    animation: pulse-rect 2s ease-in-out infinite;
    box-shadow: 0 4px 16px rgba(157, 193, 131, 0.3);
}

@keyframes pulse-rect {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
        box-shadow: 0 4px 16px var(--shadow-focus);
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
        box-shadow: 0 8px 24px var(--shadow-focus);
    }
}

.loading-text {
    font-size: 1.2rem;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-color);
    text-align: center;
}

/* Main app */
.app {
    background-color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 12px;
    margin: 10px;
    padding: 24px;
    min-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px var(--shadow-primary);
}

.app.hidden {
    display: none;
}

.focus-view {
    display: flex;
    flex-direction: column;
    gap: 25px;
    width: 100%;
    flex: 1;
}

/* Old brutalist focus-view grid layout removed - now using simple centered layout */

.focus-level, .focus-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    padding: 12px;
    min-height: 80px;
    justify-content: center;
}

.level-label, .state-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.level-number, .state-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color-2);
}

/* Old duplicate styles removed - using new simplified layout styles defined earlier */


/* Distraction Timeline */
.distraction-timeline {
    width: 100%;
    margin: 20px 0;
    padding: 16px;
    background-color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 8px;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

/* timeline styles are defined earlier in new layout section */

.timeline-info {
    font-size: 0.85rem;
    color: var(--text-color);
}

/* timeline-bar is defined earlier in new layout section */

.distraction-marker {
    position: absolute;
    top: 0;
    height: 100%;
    background-color: var(--error);
    opacity: 0.6;
    border-radius: 2px;
}

.timeline-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-color);
    text-transform: uppercase;
}

/* Analytics Dashboard */
.analytics-dashboard {
    width: 100%;
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 0;
    transition: all 0.3s ease;
}

/* Stats Toggle Button */
.stats-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    background: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: all 0.2s ease;
}

.stats-toggle:hover {
    background: var(--accent-color);
    color: var(--text-color);
}

.toggle-icon {
    display: inline-block;
    transition: transform 0.3s ease;
    font-size: 0.8rem;
}

.stats-toggle[aria-expanded="false"] .toggle-icon {
    transform: rotate(-90deg);
}

/* Collapsible Content */
.stats-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
    max-height: 1000px;
    overflow: hidden;
    opacity: 1;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stats-content.collapsed {
    max-height: 0;
    margin-top: 0;
    opacity: 0;
    pointer-events: none;
}

.analytics-dashboard .stats-panel {
    margin: 0;
}

.analytics-dashboard .distraction-timeline {
    margin: 0;
}

/* Score History Section - Full Width */
.score-history-section {
    width: 100%;
    margin: 0;
    padding: 24px;
    background-color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 12px;
    box-shadow: 0 4px 16px var(--shadow-primary);
    position: relative;
    z-index: 1;
}

.score-history-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 20px;
    text-align: center;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.score-chart-container {
    position: relative;
    background-color: var(--accent-color);
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    padding: 20px;
    width: 100%;
    overflow: hidden;
}

#scoreChart {
    width: 100%;
    max-width: 100%;
    height: 150px;
    display: block;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    image-rendering: pixelated;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.legend-dot.recent {
    background-color: var(--accent-color-2);
}

.legend-dot.trend {
    background-color: var(--success);
}

.legend-label {
    font-size: 0.7rem;
    color: var(--text-color);
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Calibration overlay */
.calibration-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 17, 23, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 15;
    pointer-events: none;
}

.calibration-overlay.active {
    display: flex;
}

.calibration-message {
    text-align: center;
    padding: 30px;
    background: var(--primary-color);
    border: 2px solid var(--accent-color-2);
    border-radius: 12px;
    animation: pulse 2s ease-in-out infinite;
}

.calibration-message h3 {
    color: var(--accent-color-2);
    margin-bottom: 10px;
    font-size: 1.4rem;
    letter-spacing: 2px;
}

.calibration-message p {
    color: var(--text-color);
    margin: 5px 0;
}

.calibration-status {
    color: var(--warning);
    font-weight: 600;
    margin-top: 15px;
}

/* Focus challenge overlay */
.focus-challenge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: all 0.3s ease;
}

.focus-challenge.active {
    opacity: 1;
}

.challenge-dot {
    width: 12px;
    height: 12px;
    background: var(--accent-color-2);
    border-radius: 50%;
    margin: 0 auto 8px;
    animation: pulse-dot 2s ease-in-out infinite;
    box-shadow: 0 0 20px var(--shadow-focus);
}

@keyframes pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

.challenge-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
    text-align: center;
    background: rgba(13, 17, 23, 0.8);
    padding: 4px 8px;
    border-radius: 4px;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    white-space: nowrap;
}

.webcam-feed {
    width: 100%;
    /* max-width: 500px;
    height: 375px; */
    /* background-color: var(--primary-color); */
    border: 1px solid var(--accent-color);
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 4px 16px var(--shadow-primary);
    z-index: 150;
}

.focus-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    border-radius: 12px;
    z-index: 10;
    transition: border-color 0.3s ease;
}

.focus-canvas.focused {
    border: 3px solid var(--success);
    box-shadow: 0 0 30px rgba(63, 185, 80, 0.4), inset 0 0 20px rgba(63, 185, 80, 0.2);
    animation: focusGlow 3s ease-in-out infinite;
}

.focus-canvas.distracted {
    border: 3px solid var(--error);
    box-shadow: 0 0 30px rgba(248, 81, 73, 0.4), inset 0 0 20px rgba(248, 81, 73, 0.2);
    animation: distraction-pulse 1s ease-in-out infinite;
}

@keyframes focusGlow {
    0%, 100% { 
        box-shadow: 0 0 20px rgba(63, 185, 80, 0.3), inset 0 0 15px rgba(63, 185, 80, 0.1);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 40px rgba(63, 185, 80, 0.6), inset 0 0 25px rgba(63, 185, 80, 0.3);
        transform: scale(1.01);
    }
}

@keyframes distraction-pulse {
    0%, 100% { 
        opacity: 1;
        box-shadow: 0 0 20px rgba(248, 81, 73, 0.4), inset 0 0 15px rgba(248, 81, 73, 0.2);
    }
    50% { 
        opacity: 0.7;
        box-shadow: 0 0 40px rgba(248, 81, 73, 0.7), inset 0 0 25px rgba(248, 81, 73, 0.4);
    }
}

/* Enhanced progress visualization */
.progress-container {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--accent-color);
    border: 1px solid var(--accent-color);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--secondary-color);
    width: 0%;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 4px;
    position: relative;
}

.progress-segments {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 24px,
        var(--accent-color) 24px,
        var(--accent-color) 25px
    );
    pointer-events: none;
}

.focus-quality-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-top: 16px;
}

.quality-bar {
    flex: 1;
    height: 6px;
    background-color: var(--accent-color);
    border-radius: 3px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Real-time score improvements */
.score-trend {
    position: absolute;
    top: -24px;
    right: 0;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(4px);
}

.score-trend.show {
    opacity: 1;
    transform: translateY(0);
}

.score-trend.improving {
    color: var(--success);
    background: rgba(63, 185, 80, 0.1);
    border: 1px solid rgba(63, 185, 80, 0.2);
}

.score-trend.declining {
    color: var(--error);
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.2);
}

.score-trend::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -4px;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
}

.score-trend.improving::before {
    border-top: 4px solid rgba(63, 185, 80, 0.2);
}

.score-trend.declining::before {
    border-top: 4px solid rgba(248, 81, 73, 0.2);
}

.quality-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--quality-percentage, 0%);
    background: linear-gradient(90deg, 
        var(--error) 0%, 
        var(--warning) 50%, 
        var(--success) 100%);
    transition: width 0.5s ease;
    border-radius: 2px;
}

.quality-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-color);
    white-space: nowrap;
}

/* Controls bar */
/* Unified Controls Section */
.unified-controls {
    width: 100%;
    margin: 24px 0;
    padding: 20px;
    background-color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.action-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: center;
    position: relative;
}

.secondary-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.unified-controls .status-text {
    text-align: center;
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-color);
}

/* Legacy controls bar (keeping for compatibility) */
.controls-bar {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    position: relative;
}

.primary-btn-old {
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    padding: calc(var(--base-unit) * 1.2) calc(var(--base-unit) * 2.5);
    font-family: var(--font-sans);
    font-size: calc(var(--base-unit) * 1.1);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    box-shadow: 0 4px 16px var(--shadow-focus);
    position: relative;
    overflow: hidden;
}

.primary-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.primary-btn:hover::before {
    left: 100%;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow-focus);
}

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

.btn-text {
    display: inline-block;
}

.time-btn {
    background-color: var(--primary-color);
    color: var(--text-color);
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    padding: 12px 24px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    box-shadow: 0 2px 8px var(--shadow-primary);
}

.time-btn:hover {
    background-color: var(--accent-color-2);
    color: var(--text-color);
    border-color: var(--accent-color-2);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow-focus);
}

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

/* Old time-option and stats-panel styles removed - defined earlier in new layout section */

/* stats-title is defined earlier in the file - removing duplicate */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
}

.stat-item {
    text-align: center;
    background-color: var(--accent-color);
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    padding: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow-primary);
}

.stat-value {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 1px;
    display: block;
    margin-bottom: 4px;
    opacity: 0.85;
    color: var(--accent-color-2);
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-color);
}

/* Status text */
.status-text {
    text-align: center;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-color);
}

/* Audio controls */
.audio-controls {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--accent-color);
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    padding: 8px 16px;
}

.volume-label {
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-color);
    white-space: nowrap;
}

.volume-slider {
    width: 100px;
    height: 4px;
    background-color: var(--bg-primary);
    border: 1px solid var(--primary-color);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background-color: var(--accent-color-2);
    border: 1px solid var(--accent-color-2);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px var(--shadow-focus);
}

.volume-slider::-webkit-slider-thumb:hover {
    background-color: var(--accent-color-2);
    transform: scale(1.1);
    box-shadow: 0 4px 8px var(--shadow-focus);
}

.volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background-color: var(--accent-color-2);
    border: 1px solid var(--accent-color-2);
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px var(--shadow-focus);
}

.volume-slider::-moz-range-thumb:hover {
    background-color: var(--accent-color-2);
    transform: scale(1.1);
    box-shadow: 0 4px 8px var(--shadow-focus);
}

.volume-display {
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    color: var(--text-color);
    min-width: 35px;
    text-align: center;
}

/* Controls group */
.controls-group {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    padding: calc(var(--base-unit) * 1.2) calc(var(--base-unit) * 2);
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

/* Milestone Celebration Animation */
.milestone-celebration {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    background: var(--primary-color);
    border: 3px solid var(--success);
    border-radius: 16px;
    padding: 30px 50px;
    text-align: center;
    animation: celebrationPulse 0.5s ease-out;
    box-shadow: 0 0 50px var(--shadow-focus);
}

@keyframes celebrationPulse {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.milestone-text {
    font-size: 2rem;
    font-weight: 800;
    color: var(--success);
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.milestone-subtext {
    font-size: 1rem;
    color: var(--text-color);
    letter-spacing: 1px;
}

/* Focus Mode Styles */
body.focus-mode .secondary-controls {
    transition: opacity 0.3s ease;
}

body.focus-mode .stats-toggle {
    background: var(--accent-color);
    opacity: 0.7;
}

body.focus-mode .time-display {
    font-size: 4rem;
    animation: focusModePulse 4s ease-in-out infinite;
}

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

/* Completion view */
.completion-view {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-color);
    border: 1px solid var(--primary-color);
    border-radius: 12px;
    margin: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    -webkit-backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.completion-view.hidden {
    display: none;
}

.completion-content {
    text-align: center;
    padding: calc(var(--base-unit) * 3);
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: calc(var(--base-unit) * 2);
    animation: fadeIn 0.8s ease;
}

.completion-score {
    font-family: var(--font-serif);
    font-size: calc(var(--base-unit) * 8);
    font-weight: 100;
    line-height: 1;
    background: var(--gradient-focus);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: calc(var(--base-unit) * 2);
    display: inline-block;
}

.completion-score::after {
    content: '%';
    font-size: calc(var(--base-unit) * 3);
    margin-left: calc(var(--base-unit) * 0.25);
}

.completion-title {
    font-family: var(--font-serif);
    font-size: calc(var(--base-unit) * 2);
    font-weight: 200;
    letter-spacing: 0.05em;
    margin-bottom: calc(var(--base-unit) * 1);
    color: var(--text-color);
}

.completion-time {
    font-family: var(--font-sans);
    font-size: calc(var(--base-unit) * 1.1);
    color: var(--text-color);
    opacity: 0.8;
}

.completion-metrics {
    display: flex;
    justify-content: center;
    gap: calc(var(--base-unit) * 2);
    flex-wrap: wrap;
}

.metric-item {
    text-align: center;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-md);
    padding: calc(var(--base-unit) * 1.5);
    min-width: 100px;
    transition: all var(--transition-fast);
}

.metric-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.metric-value {
    font-family: var(--font-serif);
    font-size: calc(var(--base-unit) * 2);
    color: var(--secondary-color);
    display: block;
    margin-bottom: calc(var(--base-unit) * 0.5);
}

.metric-label {
    font-family: var(--font-sans);
    font-size: calc(var(--base-unit) * 0.9);
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-color);
}

/* Hidden utility classes */
.hidden {
    display: none !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .app {
        padding: calc(var(--base-unit) * 1);
        gap: calc(var(--base-unit) * 2);
    }

    .info-bar {
        flex-direction: column;
        gap: calc(var(--base-unit) * 1);
        max-width: 100%;
    }

    .focus-container {
        width: min(70vh, 80vw);
        height: min(70vh, 80vw);
    }

    .secondary-controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    .insights-content {
        width: 95%;
        padding: calc(var(--base-unit) * 2);
        max-height: 90vh;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .controls-group {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .btn {
        width: 100%;
        max-width: 250px;
        text-align: center;
    }

    .audio-controls {
        margin: 15px 0;
    }

    .volume-control {
        flex-direction: column;
        gap: 10px;
        padding: 15px 20px;
    }

    .volume-slider {
        width: 120px;
    }

    .completion-score {
        font-size: 4rem;
        padding: 20px 30px;
        letter-spacing: 4px;
    }

    .completion-title {
        font-size: 2rem;
        letter-spacing: 3px;
    }

    .completion-time {
        font-size: 1.2rem;
        letter-spacing: 2px;
    }

    .completion-metrics {
        gap: 20px;
        margin-bottom: 30px;
    }

    .metric-item {
        padding: 15px 20px;
        min-width: 100px;
    }

    .metric-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .app {
        padding: calc(var(--base-unit) * 0.5);
        gap: calc(var(--base-unit) * 1.5);
    }

    .info-bar {
        flex-direction: column;
        gap: calc(var(--base-unit) * 0.75);
        padding: calc(var(--base-unit) * 1);
    }

    .time-display {
        font-size: calc(var(--base-unit) * 2);
    }

    .focus-container {
        width: min(75vh, 90vw);
        height: min(75vh, 90vw);
    }

    .main-controls {
        flex-direction: column;
        gap: calc(var(--base-unit) * 1);
    }

    .primary-btn {
        width: 100%;
        max-width: 280px;
    }

    .secondary-controls {
        gap: calc(var(--base-unit) * 0.75);
    }

    .control-btn {
        width: calc(var(--base-unit) * 3.5);
        height: calc(var(--base-unit) * 3.5);
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: calc(var(--base-unit) * 1);
    }

    .stat-item {
        padding: calc(var(--base-unit) * 1);
    }

    .stat-value {
        font-size: calc(var(--base-unit) * 1.5);
    }

    .completion-score {
        font-size: 3rem;
        padding: 15px 25px;
        letter-spacing: 3px;
    }

    .completion-title {
        font-size: 1.5rem;
        letter-spacing: 2px;
    }

    .completion-time {
        font-size: 1rem;
        letter-spacing: 1px;
    }

    .completion-metrics {
        flex-direction: column;
        gap: 15px;
        margin-bottom: 25px;
    }

    .metric-item {
        padding: 12px 15px;
        min-width: 80px;
    }

    .metric-value {
        font-size: 1.2rem;
    }
}

/* Prevent text selection */
.primary-btn,
.time-btn,
.time-option,
.btn {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Focus states for accessibility */
.primary-btn:focus,
.time-btn:focus,
.time-option:focus,
.btn:focus,
.brutalist-btn:focus {
    outline: 2px solid var(--accent-color-2);
    outline-offset: 2px;
}

/* Loading animations */
@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.app {
    animation: fade-in 0.5s ease-out;
}