:root {
    /* Base colors - light mode */
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --card-bg: #ffffff;
    --card-bg-rgb: 255, 255, 255;
    --border-color: #e5e7eb;
    --input-bg: #f3f4f6;
    --btn-primary-bg: #6366f1;
    --btn-secondary-bg: #9ca3af;
    --btn-danger-bg: #ef4444;
    --btn-resume-bg: #f59e0b;
    --btn-start-bg: #10b981;
    --btn-pause-bg: #f59e0b;
    --btn-hover-bg: #e5e7eb;
    --timer-card-width: 320px;
    --btn-primary-bg-rgb: 99, 102, 241;
    --active-glow-color: rgba(var(--btn-primary-bg-rgb), 0.4);
    --countdown-bg: rgba(255, 255, 255, 0.95);
    --countdown-text: #1f2937;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --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 30px rgba(0, 0, 0, 0.15);
}

/* Dark mode variables */
.dark-mode {
    --text-color: #f9fafb;
    --text-muted: #9ca3af;
    --card-bg: #1f2937;
    --card-bg-rgb: 31, 41, 55;
    --border-color: #4b5563;
    --input-bg: #374151;
    --btn-hover-bg: #4b5563;
    --countdown-bg: rgba(31, 41, 55, 0.95);
    --countdown-text: #f9fafb;
}

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

button, a, input, select {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: #1e2024; /* Fallback */
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
    background-size: 400% 400%;
    animation: gradientBG 25s ease infinite;
}

.dark-mode {
    animation: gradientBG-dark 25s ease infinite;
    background: linear-gradient(-45deg, #0b0f19, #2b1f3e, #2a3b5c, #193a38);
    background-size: 400% 400%;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; }
}
@keyframes gradientBG-dark {
    0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; }
}

/* Confetti Animation */
@keyframes confettiFall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* Countdown Animation */
.countdown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(16, 185, 129, 0.15));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 15px;
    z-index: 10;
}

.countdown-animation {
    display: flex;
    align-items: center;
    justify-content: center;
}

.countdown-circle {
    width: 100px;
    height: 100px;
    border: 3px solid var(--btn-primary-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--btn-primary-bg-rgb), 0.2);
    box-shadow: 0 0 40px rgba(var(--btn-primary-bg-rgb), 0.5), inset 0 0 20px rgba(var(--btn-primary-bg-rgb), 0.1);
}

.countdown-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--countdown-text);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

@keyframes countdownPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 30px rgba(var(--btn-primary-bg-rgb), 0.3);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 50px rgba(var(--btn-primary-bg-rgb), 0.6);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 30px rgba(var(--btn-primary-bg-rgb), 0.3);
    }
}

/* Final countdown card flash - slower animation */
.timer-card.final-countdown-flash {
    animation: cardFlashRed 1s ease-in-out infinite alternate;
}

@keyframes cardFlashRed {
    0% {
        background-color: rgba(var(--card-bg-rgb), 0.6);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }
    100% {
        background-color: rgba(239, 68, 68, 0.3);
        box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
    }
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: 70px;
    margin-bottom: 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, rgba(var(--card-bg-rgb), 0.85) 0%, rgba(var(--card-bg-rgb), 0.7) 100%);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border-bottom: 1px solid rgba(var(--card-bg-rgb), 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-color);
}

.header-logo i {
    color: var(--btn-primary-bg);
    font-size: 1.3rem;
}

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

/* Header Buttons */
.theme-toggle, .focus-mode-btn {
    background: rgba(var(--card-bg-rgb), 0.6);
    border: 1px solid rgba(var(--card-bg-rgb), 0.3);
    font-size: 1rem;
    color: var(--text-color);
    cursor: pointer;
    height: 38px;
    width: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.theme-toggle::before, .focus-mode-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--btn-primary-bg), var(--btn-start-bg));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.theme-toggle:hover::before, .focus-mode-btn:hover::before {
    opacity: 0.15;
}

.theme-toggle i, .focus-mode-btn i {
    position: relative;
    z-index: 1;
}

.theme-toggle:hover, .focus-mode-btn:hover {
    transform: translateY(-2px) scale(1.05);
    color: var(--btn-primary-bg);
    box-shadow: var(--shadow-md);
}

/* Focus Mode */
.focus-mode header,
.focus-mode .add-timer-container,
.focus-mode .templates-section {
    display: none !important;
}

.focus-mode .timer-actions,
.focus-mode .quick-presets,
.focus-mode .settings-container {
    display: none !important;
}

.focus-mode .focus-mode-info {
    display: block !important;
}

.focus-mode-exit {
    position: fixed;
    top: 20px; right: 20px;
    background: rgba(0, 0, 0, 0.5); color: white;
    border: none; border-radius: 50%;
    width: 40px; height: 40px;
    font-size: 1.2rem;
    display: none; align-items: center; justify-content: center;
    cursor: pointer; z-index: 1000;
}
.focus-mode .focus-mode-exit { display: flex; }

/* Focus mode info */
.focus-mode-info {
    display: none;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid rgba(var(--card-bg-rgb), 0.3);
}

.focus-info-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.focus-info-item i {
    width: 12px;
    text-align: center;
    font-size: 0.75rem;
}

/* Main Container */
.main-container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px;
}

.timers-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin: 0 auto;
}

.timer-card {
    background: linear-gradient(135deg, rgba(var(--card-bg-rgb), 0.9) 0%, rgba(var(--card-bg-rgb), 0.7) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(var(--card-bg-rgb), 0.2);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: var(--timer-card-width);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    height: fit-content;
    overflow: visible;
    position: relative;
    flex-shrink: 0;
    cursor: grab;
}
.timer-card:active { cursor: grabbing; }

.timer-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--btn-primary-bg), var(--btn-start-bg), var(--btn-primary-bg));
    background-size: 200% 100%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.timer-card.timer-running-visual::before {
    opacity: 1;
    animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Drag & Drop and Focus styling */
.timer-card.dragging {
    opacity: 0.5;
    transform: scale(1.05);
}
.timer-card.focused {
    box-shadow: 0 0 0 3px var(--btn-primary-bg), 0 8px 25px rgba(0,0,0,0.2);
    transform: translateY(-2px);
}

.timer-card:hover { 
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.timer-card.timer-running-visual {
    box-shadow: 0 0 30px 4px var(--active-glow-color), var(--shadow-lg);
    border-color: rgba(var(--btn-primary-bg-rgb), 0.6);
    animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 20px 2px var(--active-glow-color), var(--shadow-lg); }
    50% { box-shadow: 0 0 40px 6px var(--active-glow-color), var(--shadow-lg); }
}

.timer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.timer-name-container {
    display: flex;
    align-items: center;
    gap: 8px;
}
.timer-name {
    font-size: 0.95rem;
    font-weight: 600;
}
.category-icon {
    color: var(--btn-primary-bg);
    font-size: 0.9rem;
    opacity: 0.8;
}

.timer-actions {
    position: relative;
}
.timer-more-options-btn {
    background: transparent; border: none; cursor: pointer; color: var(--text-color); font-size: 1rem;
}
.timer-options-menu {
    position: absolute; top: 100%; right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    z-index: 10; display: none;
    min-width: 180px;
}
.timer-options-menu.show { display: block; }
.timer-options-item {
    padding: 8px 12px; display: flex; align-items: center; gap: 10px;
    cursor: pointer; font-size: 0.9rem;
}
.timer-options-item:hover { background-color: var(--btn-hover-bg); }
.timer-options-item.delete-option { color: var(--btn-danger-bg); }

.timer-display-container {
    text-align: center;
    margin: 12px 0;
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

/* Circular Progress Ring */
.circular-progress {
    position: relative;
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.circular-progress svg {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.circular-progress-bg {
    fill: none;
    stroke: var(--input-bg);
    stroke-width: 6;
}

.circular-progress-bar {
    fill: none;
    stroke: url(#progressGradient);
    stroke-width: 7;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.1s linear, stroke-width 0.3s ease;
    filter: drop-shadow(0 0 8px rgba(var(--btn-primary-bg-rgb), 0.4));
}

.timer-card.timer-running-visual .circular-progress-bar {
    stroke-width: 8;
    animation: pulse-progress 2s ease-in-out infinite;
}

@keyframes pulse-progress {
    0%, 100% {
        filter: drop-shadow(0 0 8px rgba(var(--btn-primary-bg-rgb), 0.4));
    }
    50% {
        filter: drop-shadow(0 0 16px rgba(var(--btn-primary-bg-rgb), 0.7));
    }
}

.timer-card.final-countdown-flash .circular-progress-bar {
    stroke: #ef4444;
    filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.6));
}

.timer-inner-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.timer-text {
    font-size: 2rem;
    font-weight: 700;
    transition: color 0.3s ease;
    letter-spacing: -0.5px;
    line-height: 1;
}

.timer-status-container {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 12px;
    width: 100%;
    text-align: center;
}
.progress-bar-container {
    width: 100%; height: 8px;
    background-color: var(--input-bg);
    border-radius: 4px; overflow: hidden; margin: 10px 0;
}
.progress-bar {
    height: 100%; width: 0%;
    background-color: var(--btn-primary-bg);
    transition: width 0.1s linear;
}

/* Side Button Positioning */
.btn-side-left,
.btn-side-right {
    position: relative;
    flex-shrink: 0;
}

.btn-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    background: linear-gradient(135deg, #6b7280, #4b5563);
}

.btn-icon:hover:not([disabled]) {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.btn-icon:active:not([disabled]) {
    transform: translateY(0) scale(0.98);
}

.btn-icon.btn-start,
.btn-icon.btn-resume {
    background: linear-gradient(135deg, #10b981, #059669);
}

.btn-icon.btn-pause {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.btn-icon.btn-stop {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.btn-icon.btn-stop:hover:not([disabled]) {
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.6);
}

.btn-icon[disabled] {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.controls {
    display: grid; 
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

.btn {
    padding: 10px 14px; border-radius: 10px; font-weight: 600; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); border: none;
    font-size: 0.95rem;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn:hover:not([disabled]) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn i {
    transition: transform 0.3s ease;
}

.btn:hover:not([disabled]) i {
    transform: scale(1.05);
}
.btn-primary { background: var(--btn-primary-bg); color: white; }
.btn-secondary { background: var(--btn-secondary-bg); color: white; }
.btn-start { background: var(--btn-start-bg); color: white; font-size: 0.9rem; }
.btn-pause { background: var(--btn-pause-bg); color: white; }
.btn-resume { background: var(--btn-resume-bg); color: white; }
.btn-stop { background: var(--btn-danger-bg); color: white; font-size: 0.9rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.settings-container {
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px solid rgba(var(--card-bg-rgb), 0.3);
}

.advanced-settings {
    padding-top: 12px;
}

.advanced-settings-header {
    padding: 10px 0;
    margin-top: 8px;
    border-top: 1px solid rgba(var(--card-bg-rgb), 0.3);
}

/* Disabled settings styling */
.settings-container.disabled,
.advanced-settings.disabled,
.quick-presets.disabled {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.settings-container.disabled::after,
.advanced-settings.disabled::after {
    content: "Settings locked while active";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 10;
}

.settings-container.disabled:hover::after,
.advanced-settings.disabled:hover::after {
    opacity: 1;
}

.time-settings {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 12px;
}
.input-group {
    display: flex; flex-direction: column; gap: 4px;
}
.input-group label {
    font-size: 0.75rem; color: var(--text-muted); text-align: center; font-weight: 600;
}
.time-input {
    width: 100%;
    padding: 10px;
    background: var(--input-bg);
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.95rem;
    text-align: center;
    text-align-last: center;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: all 0.2s ease;
}
.time-input option {
    text-align: center;
}
.time-input:focus {
    outline: none;
    border-color: var(--btn-primary-bg);
    box-shadow: 0 0 0 2px rgba(var(--btn-primary-bg-rgb), 0.2);
}
.preset-row {
    display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px;
}
.preset-btn {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    background: var(--input-bg);
    cursor: pointer;
    color: var(--text-color);
    transition: all 0.2s ease;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.preset-btn:hover, .preset-btn.active {
    background-color: var(--btn-primary-bg);
    color: white;
    border-color: var(--btn-primary-bg);
    transform: translateY(-1px);
}
.advanced-settings-header {
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
}
.advanced-settings-label {
    display: flex;
    align-items: center;
    gap: 6px;
}
.advanced-settings {
    display: none;
}
.advanced-settings.show {
    display: block;
}
.setting-group { margin-bottom: 12px; }
.setting-group.compact { margin-bottom: 10px; }
.setting-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}
.setting-group label { 
    display: flex; 
    align-items: center; 
    gap: 6px; 
    margin-bottom: 6px; 
    font-size: 0.75rem; 
    font-weight: 600;
    color: var(--text-muted);
}
.setting-group label i {
    width: 14px;
    text-align: center;
    color: var(--text-muted);
}

.add-timer-container {
    display: flex; justify-content: center; margin: 20px 0;
}
.add-timer-btn {
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--btn-primary-bg) 0%, #5558e3 100%);
    color: white;
    font-weight: 600;
    font-size: 1.05rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(var(--btn-primary-bg-rgb), 0.3);
    border: none;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
}

.add-timer-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(255, 255, 255, 0.2) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.add-timer-btn:hover::after {
    opacity: 1;
}

.add-timer-btn:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 36px rgba(var(--btn-primary-bg-rgb), 0.6);
    animation: subtle-float 2s ease-in-out infinite;
}

@keyframes subtle-float {
    0%, 100% { transform: translateY(-4px) scale(1.02); }
    50% { transform: translateY(-6px) scale(1.02); }
}

.add-timer-btn i {
    font-size: 1.2rem;
}

/* Completion Overlay */
.completion-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    background-color: rgba(16, 185, 129, 0.95);
    border-radius: 15px; z-index: 5;
    transition: background-color 0.3s;
}
.timer-card.completed {
    border: 1px solid rgba(16, 185, 129, 0.3);
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.2);
}
.timer-card.completed .timer-display-container > *:not(.completion-overlay) {
    visibility: hidden;
}
.completion-content {
    text-align: center;
    color: white;
    padding: 20px;
}
.completion-message {
    font-size: 1rem;
    font-weight: bold;
    line-height: 1.4;
    max-width: 280px;
    animation: completionPulse 2s ease-in-out infinite;
}
.completion-message i {
    display: block;
    margin-bottom: 10px;
}

@keyframes completionPulse {
    0% { 
        transform: scale(1); 
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }
    25% { 
        transform: scale(1.05); 
        box-shadow: 0 8px 30px rgba(16, 185, 129, 0.5);
    }
    50% { 
        transform: scale(1.02); 
        box-shadow: 0 12px 40px rgba(16, 185, 129, 0.7);
    }
    75% { 
        transform: scale(1.05); 
        box-shadow: 0 8px 30px rgba(16, 185, 129, 0.5);
    }
    100% { 
        transform: scale(1); 
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }
}

/* Templates Section */
.templates-section {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}
.section-title {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.5rem;
    color: var(--text-color);
}
.templates-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}
.template-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    width: 220px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.2s ease;
}
.template-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.template-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.template-name {
    font-weight: bold;
    font-size: 1rem;
}
.template-actions button {
    background: none; border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 5px;
}
.template-actions button:hover { color: var(--btn-primary-bg); }
.template-actions .delete-template-btn:hover { color: var(--btn-danger-bg); }
.template-details { font-size: 0.85rem; color: var(--text-muted); }
.empty-message {
    color: var(--text-muted);
    font-style: italic;
    width: 100%;
    text-align: center;
}

/* Notification styles */
.notification {
    animation: slideInRight 0.3s ease-out, slideOutRight 0.3s ease-in 2.7s forwards;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Timer Categories */
.timer-category-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 8px;
}

.category-work { background: rgba(99, 102, 241, 0.15); color: var(--btn-primary-bg); }
.category-exercise { background: rgba(16, 185, 129, 0.15); color: var(--btn-start-bg); }
.category-study { background: rgba(59, 130, 246, 0.15); color: var(--info-color); }
.category-cooking { background: rgba(245, 158, 11, 0.15); color: var(--warning-color); }
.category-meditation { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.category-custom { background: rgba(107, 114, 128, 0.15); color: var(--text-muted); }

.category-selector {
    margin-bottom: 12px;
}

.category-dropdown {
    width: 100%;
    padding: 10px 12px;
    background: var(--input-bg);
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-color);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.category-dropdown:focus {
    outline: none;
    border-color: var(--btn-primary-bg);
    box-shadow: 0 0 0 3px rgba(var(--btn-primary-bg-rgb), 0.15);
}

.category-dropdown:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.category-selector label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}

.category-options {
    display: none;
}

.category-option {
    display: none;
    padding: 8px 6px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    background: var(--input-bg);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    text-align: center;
}

.category-option i {
    font-size: 0.75rem;
}

.category-option:hover {
    border-color: var(--btn-primary-bg);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(var(--btn-primary-bg-rgb), 0.2);
}

.category-option.selected {
    background: var(--btn-primary-bg);
    color: white;
    border-color: var(--btn-primary-bg);
    box-shadow: 0 2px 8px rgba(var(--btn-primary-bg-rgb), 0.3);
}

/* Statistics Panel */
.stats-panel {
    background: linear-gradient(135deg, rgba(var(--card-bg-rgb), 0.9) 0%, rgba(var(--card-bg-rgb), 0.7) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(var(--card-bg-rgb), 0.2);
    border-radius: 24px;
    padding: 25px;
    margin: 30px auto;
    max-width: 1200px;
    box-shadow: var(--shadow-lg);
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.stats-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.stat-card {
    background: var(--input-bg);
    border-radius: 16px;
    padding: 20px;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-color);
}

.stat-trend {
    font-size: 0.8rem;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-trend.up { color: var(--success-color); }
.stat-trend.down { color: var(--btn-danger-bg); }

.toggle-stats-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-color);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

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

/* Mobile responsiveness */
@media (max-width: 768px) {
    .timer-card {
        max-width: 100%;
    }
    
    .main-container {
        padding: 10px;
    }
    
    .timers-container {
        gap: 12px;
    }
    
    .completion-message {
        font-size: 0.85rem;
        max-width: 200px;
    }
    
    .countdown-circle {
        width: 90px;
        height: 90px;
    }
    
    .countdown-number {
        font-size: 2rem;
    }

    .circular-progress {
        width: 120px;
        height: 120px;
    }

    .timer-text {
        font-size: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .header-logo span {
        display: none;
    }
    
    .category-options {
        grid-template-columns: repeat(2, 1fr);
    }
    
    header {
        height: 55px;
        padding: 0 15px;
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

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

.modal-content {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.modal-header h2 i {
    color: var(--btn-primary-bg);
}

.modal-close-btn {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    background: var(--btn-hover-bg);
    color: var(--text-color);
}

.modal-body {
    padding: 24px;
}

.modal-body .input-group {
    margin-bottom: 16px;
}

.modal-body .input-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.text-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.text-input:focus {
    outline: none;
    border-color: var(--btn-primary-bg);
    box-shadow: 0 0 0 3px rgba(var(--btn-primary-bg-rgb), 0.1);
}

.time-settings-modal {
    margin-bottom: 16px;
}

.custom-time-inputs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 12px;
}

.time-input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 8px;
}

.time-input-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.time-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

.advanced-template-settings {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.modal-footer .btn {
    padding: 10px 20px;
}

/* Empty States */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-state-icon {
    font-size: 4rem;
    color: var(--text-muted);
    opacity: 0.5;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 10px;
}

.empty-state-description {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 24px;
    max-width: 400px;
}

/* Loading Skeleton */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--input-bg) 0%,
        var(--border-color) 50%,
        var(--input-bg) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Focus Ring for Accessibility */
*:focus-visible {
    outline: 2px solid var(--btn-primary-bg);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Selection styling */
::selection {
    background: rgba(var(--btn-primary-bg-rgb), 0.3);
    color: var(--text-color);
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}