/* ============ CSS Variables ============ */
:root {
    /* Light Theme */
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-nav: rgba(255,255,255,0.97);
    --bg-input: #f5f7fa;
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a5a;
    --text-muted: #8888a0;
    --border-color: #d8dce5;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --primary: #6C5CE7;
    --primary-light: #a29bfe;
    --primary-dark: #5541d7;
    --primary-bg: rgba(108,92,231,0.08);
    --success: #00b894;
    --success-light: #55efc4;
    --warning: #fdcb6e;
    --warning-dark: #e17055;
    --danger: #d63031;
    --info: #0984e3;
    --ring-track: #e8e8e8;
    --ring-bg: #f5f5f5;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-primary: #0f1023;
    --bg-secondary: #1a1b35;
    --bg-card: #22234a;
    --bg-nav: rgba(15,16,35,0.97);
    --bg-input: #2a2b52;
    --text-primary: #f0f0f8;
    --text-secondary: #b8b8d0;
    --text-muted: #8888a8;
    --border-color: #3a3b62;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.25);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.35);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.45);
    --primary-bg: rgba(108,92,231,0.15);
    --ring-track: #2a2b52;
    --ring-bg: #22234a;
}

/* ============ Reset & Base ============ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 20px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: var(--transition);
    line-height: 1.5;
}

button {
    cursor: pointer;
    border: none;
    outline: none;
    font-family: inherit;
    transition: var(--transition);
}

input {
    font-family: inherit;
    outline: none;
}

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    transition: var(--transition);
    border: 2px solid transparent;
}

.btn-lg {
    padding: 18px 40px;
    font-size: 1.2rem;
    border-radius: var(--radius-md);
}

.btn-sm {
    padding: 8px 18px;
    font-size: 0.9rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108,92,231,0.4);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .btn-outline {
    border-color: var(--text-muted);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-warning {
    background: var(--warning-dark);
    color: white;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-group .btn {
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
}

.btn-group .btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ============ Top Navigation ============ */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: var(--bg-nav);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 1px;
}

.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-toggle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(1.08);
}

.top-nav .btn-sm {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1.2rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.top-nav .btn-sm:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ============ Mode Tabs ============ */
.mode-tabs {
    display: flex;
    gap: 6px;
    padding: 14px 32px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    scrollbar-width: none;
}

.mode-tabs::-webkit-scrollbar { display: none; }

.mode-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    border: 2px solid transparent;
}

.mode-tab:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.mode-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(108,92,231,0.35);
}

.tab-icon {
    font-size: 1.2rem;
}

/* ============ Mode Panels ============ */
.mode-panel {
    display: none;
    padding: 28px 32px;
    max-width: 1200px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease;
}

.mode-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============ Timer Display ============ */
.timer-display-area {
    display: flex;
    justify-content: center;
    margin: 24px 0;
}

.timer-ring-container {
    position: relative;
    width: 360px;
    height: 360px;
}

.timer-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: var(--ring-track);
    stroke-width: 8;
}

.ring-progress {
    fill: none;
    stroke: var(--primary);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 565.48;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.5s ease, stroke 0.3s ease;
}

.stopwatch-ring {
    stroke: var(--success);
}

.timer-text-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 80%;
}

.timer-main-text {
    font-size: 4.2rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: 3px;
    color: var(--text-primary);
    line-height: 1;
    white-space: nowrap;
}

/* Stopwatch has more digits (MM:SS.CC), use smaller font */
#panel-stopwatch .timer-main-text {
    font-size: 3rem;
    letter-spacing: 1px;
}

/* Random mode status text styling */
.timer-main-text.status-text {
    font-size: 1.8rem;
    letter-spacing: 2px;
}

.timer-sub-text {
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 12px;
    font-weight: 500;
}

/* Warning state - last 10 seconds */
.timer-warning .ring-progress {
    stroke: var(--danger) !important;
}

.timer-warning .timer-main-text {
    color: var(--danger);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

/* ============ Preset Buttons ============ */
.preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
}

.preset-btn {
    padding: 12px 24px;
    border-radius: 24px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    transition: var(--transition);
}

.preset-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108,92,231,0.2);
}

.preset-btn.custom {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ============ Custom Time Input ============ */
.custom-time-input {
    margin: 20px 0;
}

.time-input-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.time-input-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.time-input-item input {
    width: 80px;
    padding: 12px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1.3rem;
    text-align: center;
    background: var(--bg-input);
    color: var(--text-primary);
}

.time-input-item input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(108,92,231,0.15);
}

.time-input-label {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 600;
}

/* ============ Timer Controls ============ */
.timer-controls {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin: 28px 0;
    flex-wrap: wrap;
}

.ctrl-btn {
    padding: 16px 36px;
    border-radius: var(--radius-md);
    font-size: 1.15rem;
    font-weight: 700;
    transition: var(--transition);
    min-width: 150px;
}

.ctrl-start {
    background: var(--primary);
    color: white;
}

.ctrl-start:hover {
    background: var(--primary-dark);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(108,92,231,0.4);
}

.ctrl-pause {
    background: var(--warning-dark);
    color: white;
}

.ctrl-pause:hover {
    background: #d35400;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(225,112,85,0.4);
}

.ctrl-resume {
    background: var(--success);
    color: white;
}

.ctrl-resume:hover {
    background: #00a381;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,184,148,0.4);
}

.ctrl-lap {
    background: var(--info);
    color: white;
}

.ctrl-lap:hover {
    background: #0773c5;
    transform: translateY(-3px);
}

.ctrl-reset {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
}

.ctrl-reset:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(214,48,49,0.06);
    transform: translateY(-2px);
}

/* ============ Countdown Options ============ */
.countdown-options {
    display: flex;
    gap: 28px;
    justify-content: center;
    margin-top: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
}

/* ============ Lap List ============ */
.lap-list {
    max-width: 600px;
    margin: 0 auto;
}

.lap-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-bottom: none;
}

.lap-items {
    max-height: 350px;
    overflow-y: auto;
}

.lap-item {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    padding: 12px 20px;
    border: 1px solid var(--border-color);
    border-top: none;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
    animation: fadeIn 0.2s ease;
}

.lap-item:last-child {
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.lap-item.best {
    background: rgba(0,184,148,0.12);
    color: var(--success);
}

.lap-item.worst {
    background: rgba(214,48,49,0.12);
    color: var(--danger);
}

/* ============ Group Timer ============ */
.setting-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.setting-row > label {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.group-names {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.group-name-input {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--bg-input);
    color: var(--text-primary);
    width: 100%;
}

.group-name-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,92,231,0.15);
}

.group-timers {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin: 24px 0;
}

.group-timer-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: center;
    border: 2px solid var(--border-color);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.group-timer-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: var(--primary);
}

.group-timer-card[data-color="1"]::before { background: #e74c3c; }
.group-timer-card[data-color="2"]::before { background: #3498db; }
.group-timer-card[data-color="3"]::before { background: #2ecc71; }
.group-timer-card[data-color="4"]::before { background: #f39c12; }
.group-timer-card[data-color="5"]::before { background: #9b59b6; }
.group-timer-card[data-color="6"]::before { background: #1abc9c; }

.group-timer-card.running {
    border-color: var(--success);
    box-shadow: 0 0 24px rgba(0,184,148,0.2);
}

.group-timer-card.finished {
    border-color: var(--danger);
    animation: flashBorder 1s ease-in-out 3;
}

@keyframes flashBorder {
    0%, 100% { border-color: var(--danger); }
    50% { border-color: transparent; }
}

.group-timer-name {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.group-timer-rank {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.group-timer-display {
    font-size: 2.4rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    margin: 14px 0;
    color: var(--text-primary);
}

.group-timer-btns {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.group-timer-btns button {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    min-width: 56px;
}

.g-start {
    background: var(--success);
    color: white;
}

.g-pause {
    background: var(--warning-dark);
    color: white;
}

.g-reset {
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
}

.group-controls {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 20px;
}

/* ============ Section Title ============ */
.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
}

/* ============ Rotation Mode ============ */
.rotation-items {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 14px;
}

.rotation-item {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
}

.rotation-item:hover {
    border-color: var(--primary-light);
}

.rotation-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--primary-bg);
    border-bottom: 1px solid var(--border-color);
}

.rotation-phase {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    background: transparent;
    color: var(--text-muted);
}

.btn-remove:hover {
    background: var(--danger);
    color: white;
}

.rotation-item-body {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.rotation-name {
    flex: 1;
    min-width: 140px;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--bg-input);
    color: var(--text-primary);
}

.rotation-name:focus {
    border-color: var(--primary);
}

.rotation-time-set {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.rotation-time-set input {
    width: 80px;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    text-align: center;
    background: var(--bg-input);
    color: var(--text-primary);
}

.rotation-time-set input:focus {
    border-color: var(--primary);
}

.rotation-display {
    text-align: center;
}

.rotation-current-label {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.rotation-current-name {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 12px;
}

.rotation-timeline {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    margin: 24px 0;
    flex-wrap: wrap;
}

.timeline-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.timeline-block {
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 0.95rem;
    font-weight: 600;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
    white-space: nowrap;
}

.timeline-block.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.timeline-block.done {
    background: var(--success);
    color: white;
    border-color: var(--success);
    opacity: 0.7;
}

.timeline-arrow {
    color: var(--text-muted);
    font-size: 1rem;
}

.rotation-start-btn {
    text-align: center;
    margin-top: 20px;
}

/* ============ Random Mode ============ */
.random-info {
    text-align: center;
    margin-bottom: 28px;
}

.random-icon {
    font-size: 56px;
    margin-bottom: 12px;
}

.random-info p {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

.random-range {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.range-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.range-group label {
    font-size: 1rem;
    color: var(--text-secondary);
    white-space: nowrap;
    font-weight: 600;
}

.range-group input {
    width: 90px;
    padding: 12px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    text-align: center;
    background: var(--bg-input);
    color: var(--text-primary);
}

.range-group input:focus {
    border-color: var(--primary);
}

.range-divider {
    font-size: 1.8rem;
    color: var(--text-muted);
}

.random-quick-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

.random-options {
    display: flex;
    gap: 28px;
    justify-content: center;
    margin-top: 16px;
}

/* ============ Exam Mode ============ */
.exam-phases {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.exam-phase-item {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    transition: var(--transition);
}

.exam-phase-item:hover {
    border-color: var(--primary-light);
}

.phase-color {
    width: 10px;
    height: 48px;
    border-radius: 5px;
    flex-shrink: 0;
}

.phase-info {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    flex-wrap: wrap;
}

.phase-name {
    flex: 1;
    min-width: 140px;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--bg-input);
    color: var(--text-primary);
}

.phase-name:focus {
    border-color: var(--primary);
}

.phase-time-set {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.phase-time-set input {
    width: 80px;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    text-align: center;
    background: var(--bg-input);
    color: var(--text-primary);
}

.phase-time-set input:focus {
    border-color: var(--primary);
}

.exam-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.exam-quick {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.exam-quick span {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.exam-display {
    text-align: center;
}

.exam-phase-indicator {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.exam-indicator-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.exam-indicator-block {
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 0.95rem;
    font-weight: 600;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
    white-space: nowrap;
}

.exam-indicator-block.active {
    color: white;
    border-color: transparent;
}

.exam-indicator-block.done {
    opacity: 0.6;
    color: white;
}

.exam-indicator-arrow {
    color: var(--text-muted);
    font-size: 1rem;
}

.exam-current-phase {
    margin-bottom: 12px;
}

.exam-phase-label {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 500;
}

.exam-phase-name {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
}

.exam-total-time {
    margin-top: 20px;
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.exam-total-bar {
    width: 100%;
    max-width: 500px;
    height: 10px;
    background: var(--ring-track);
    border-radius: 5px;
    margin: 10px auto 0;
    overflow: hidden;
}

.exam-total-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 5px;
    transition: width 0.5s ease;
}

/* ============ Modal ============ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(6px);
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 40px;
    max-width: 520px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-timeup {
    text-align: center;
}

.timeup-icon {
    font-size: 72px;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-15deg); }
    75% { transform: rotate(15deg); }
}

.timeup-title {
    font-size: 2.4rem;
    color: var(--danger);
    margin: 20px 0 10px;
    font-weight: 800;
}

.timeup-message {
    color: var(--text-secondary);
    margin-bottom: 28px;
    font-size: 1.1rem;
}

/* ============ Toast ============ */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    font-size: 1rem;
    border-left: 5px solid var(--primary);
    font-weight: 500;
}

.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning-dark); }
.toast.error { border-left-color: var(--danger); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-20px); }
}

/* ============ Fullscreen mode ============ */
.fullscreen-mode .top-nav,
.fullscreen-mode .mode-tabs {
    display: none;
}

.fullscreen-mode .timer-main-text {
    font-size: 7rem;
}

.fullscreen-mode #panel-stopwatch .timer-main-text {
    font-size: 4.5rem;
}

.fullscreen-mode .timer-main-text.status-text {
    font-size: 2.8rem;
}

.fullscreen-mode .timer-ring-container {
    width: 500px;
    height: 500px;
}

.fullscreen-mode .timer-sub-text {
    font-size: 1.3rem;
}

/* Fullscreen: hide all panels, only show active one */
.fullscreen-mode .mode-panel {
    display: none !important;
}

.fullscreen-mode .mode-panel.active {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    max-width: 100%;
    padding: 32px;
    overflow-y: auto;
}

.fullscreen-mode .ctrl-btn {
    padding: 20px 48px;
    font-size: 1.4rem;
    min-width: 180px;
}

.fullscreen-mode .preset-btn {
    padding: 14px 28px;
    font-size: 1.15rem;
}

/* ============ Responsive - Large Screens (Classroom Displays) ============ */
@media (min-width: 1400px) {
    .timer-ring-container {
        width: 400px;
        height: 400px;
    }

    .timer-main-text {
        font-size: 4.8rem;
    }

    #panel-stopwatch .timer-main-text {
        font-size: 3.4rem;
    }

    .timer-main-text.status-text {
        font-size: 2rem;
    }

    .mode-panel {
        max-width: 1400px;
    }

    .group-timers {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

/* ============ Responsive - Tablets & Small Laptops ============ */
@media (max-width: 1024px) {
    html {
        font-size: 18px;
    }

    .timer-ring-container {
        width: 300px;
        height: 300px;
    }

    .timer-main-text {
        font-size: 3.6rem;
    }

    #panel-stopwatch .timer-main-text {
        font-size: 2.4rem;
    }

    .timer-main-text.status-text {
        font-size: 1.5rem;
    }

    .mode-panel {
        padding: 20px 24px;
    }

    .group-timers {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
}

/* ============ Responsive - Tablets Portrait ============ */
@media (max-width: 768px) {
    html {
        font-size: 16px;
    }

    .mode-tabs {
        padding: 10px 16px;
        gap: 4px;
    }

    .mode-tab {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    .tab-name {
        display: none;
    }

    .tab-icon {
        font-size: 1.4rem;
    }

    .mode-panel {
        padding: 18px 16px;
    }

    .timer-ring-container {
        width: 260px;
        height: 260px;
    }

    .timer-main-text {
        font-size: 3rem;
    }

    #panel-stopwatch .timer-main-text {
        font-size: 2.1rem;
    }

    .timer-main-text.status-text {
        font-size: 1.4rem;
    }

    .ctrl-btn {
        padding: 14px 28px;
        font-size: 1.05rem;
        min-width: 130px;
    }

    .group-timers {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .group-timer-display {
        font-size: 2rem;
    }

    .exam-phase-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .phase-info {
        width: 100%;
    }

    .top-nav {
        padding: 12px 20px;
    }

    .nav-right .btn-sm span {
        display: none;
    }
}

/* ============ Responsive - Mobile ============ */
@media (max-width: 480px) {
    html {
        font-size: 15px;
    }

    .timer-ring-container {
        width: 220px;
        height: 220px;
    }

    .timer-main-text {
        font-size: 2.6rem;
    }

    #panel-stopwatch .timer-main-text {
        font-size: 1.9rem;
    }

    .timer-main-text.status-text {
        font-size: 1.2rem;
    }

    .preset-buttons {
        gap: 8px;
    }

    .preset-btn {
        padding: 10px 18px;
        font-size: 0.9rem;
    }

    .random-range {
        flex-direction: column;
        gap: 10px;
    }

    .range-divider {
        display: none;
    }

    .countdown-options,
    .random-options {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
}

/* ============ Scrollbar ============ */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
