/* ==========================================================================
   POMODORO FLOW - DESIGN SYSTEM & STYLESHEET
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600;700&display=swap');

/* --- Root Variables & Color Tokens --- */
:root {
    /* Fonts */
    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-timer: 'JetBrains Mono', 'Space Grotesk', monospace;
    --font-heading: 'Space Grotesk', 'Outfit', sans-serif;

    /* Theme: Cosmic Midnight (Default) */
    --bg-dark: #0a0c16;
    --bg-surface: rgba(18, 22, 38, 0.75);
    --bg-card: rgba(26, 32, 54, 0.65);
    --bg-card-hover: rgba(34, 42, 72, 0.75);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-bright: rgba(255, 255, 255, 0.16);
    
    --text-primary: #f0f4fc;
    --text-secondary: #9aa8c7;
    --text-muted: #5e6b8c;

    /* Mode Accent Colors */
    --focus-color: #6366f1;
    --focus-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --focus-glow: rgba(99, 102, 241, 0.4);

    --short-break-color: #06b6d4;
    --short-break-gradient: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
    --short-break-glow: rgba(6, 182, 212, 0.4);

    --long-break-color: #10b981;
    --long-break-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --long-break-glow: rgba(16, 185, 129, 0.4);

    /* Dynamic active theme accent */
    --current-accent: var(--focus-color);
    --current-gradient: var(--focus-gradient);
    --current-glow: var(--focus-glow);

    /* Shadows & Glass */
    --glass-blur: blur(20px);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-glow: 0 0 35px var(--current-glow);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 9999px;

    --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Theme: Sunset Ember */
[data-theme="ember"] {
    --bg-dark: #120b0b;
    --bg-surface: rgba(36, 18, 18, 0.75);
    --bg-card: rgba(48, 24, 24, 0.65);
    --bg-card-hover: rgba(64, 30, 30, 0.75);
    --border-glass: rgba(255, 180, 160, 0.1);
    --border-glass-bright: rgba(255, 180, 160, 0.22);
    
    --text-primary: #fff2ed;
    --text-secondary: #cba294;
    --text-muted: #8c6a5e;

    --focus-color: #f97316;
    --focus-gradient: linear-gradient(135deg, #f97316 0%, #ef4444 100%);
    --focus-glow: rgba(249, 115, 22, 0.4);

    --short-break-color: #fbbf24;
    --short-break-gradient: linear-gradient(135deg, #fbbf24 0%, #ea580c 100%);
    --short-break-glow: rgba(251, 191, 36, 0.4);

    --long-break-color: #e11d48;
    --long-break-gradient: linear-gradient(135deg, #e11d48 0%, #9f1239 100%);
    --long-break-glow: rgba(225, 29, 72, 0.4);
}

/* Theme: Emerald Zen */
[data-theme="zen"] {
    --bg-dark: #07130e;
    --bg-surface: rgba(14, 32, 24, 0.75);
    --bg-card: rgba(20, 46, 34, 0.65);
    --bg-card-hover: rgba(28, 62, 46, 0.75);
    --border-glass: rgba(160, 255, 200, 0.1);
    --border-glass-bright: rgba(160, 255, 200, 0.22);
    
    --text-primary: #edfbf4;
    --text-secondary: #9fcbb3;
    --text-muted: #5e8c74;

    --focus-color: #10b981;
    --focus-gradient: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
    --focus-glow: rgba(16, 185, 129, 0.4);

    --short-break-color: #34d399;
    --short-break-gradient: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    --short-break-glow: rgba(52, 211, 153, 0.4);

    --long-break-color: #14b8a6;
    --long-break-gradient: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
    --long-break-glow: rgba(20, 184, 166, 0.4);
}

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

html, body {
    width: 100%;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    min-height: 100dvh;
    font-family: var(--font-main);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Safe area & scroll margin alignment */
.timer-hero-card, .tasks-card, .ambient-card, .stats-card {
    scroll-margin-top: calc(env(safe-area-inset-top) + 4.5rem);
}

/* Background Ambient Dynamic Canvas / Blobs */
.bg-ambient-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.22;
    transition: background var(--transition-normal), transform 12s ease-in-out infinite alternate;
}

.blob-1 {
    top: -10%;
    left: 15%;
    width: 550px;
    height: 550px;
    background: var(--current-accent);
    animation: floatBlob1 18s ease-in-out infinite alternate;
}

.blob-2 {
    bottom: -15%;
    right: 10%;
    width: 650px;
    height: 650px;
    background: #7c3aed;
    animation: floatBlob2 22s ease-in-out infinite alternate;
}

.blob-3 {
    top: 40%;
    left: 60%;
    width: 400px;
    height: 400px;
    background: #0284c7;
    animation: floatBlob3 15s ease-in-out infinite alternate;
}

@keyframes floatBlob1 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(60px, 80px) scale(1.15); }
}

@keyframes floatBlob2 {
    0% { transform: translate(0, 0) scale(1.1); }
    100% { transform: translate(-80px, -60px) scale(0.9); }
}

@keyframes floatBlob3 {
    0% { transform: translate(0, 0) scale(0.9); }
    100% { transform: translate(-50px, 40px) scale(1.2); }
}

/* --- Layout Container (Safe Areas for iPhone & Android) --- */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding-top: max(1.25rem, env(safe-area-inset-top));
    padding-bottom: max(4rem, calc(env(safe-area-inset-bottom) + 5.5rem));
    padding-left: max(1.25rem, env(safe-area-inset-left));
    padding-right: max(1.25rem, env(safe-area-inset-right));
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    margin-bottom: 2rem;
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.logo-badge {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--current-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 0 16px var(--current-glow);
    transition: all var(--transition-normal);
}

.logo-title {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(180deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-tag {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 2px 7px;
    border-radius: 99px;
    margin-left: 0.25rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.icon-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 1.15rem;
    position: relative;
}

.icon-btn:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
    border-color: var(--border-glass-bright);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.icon-btn:active {
    transform: scale(0.95);
}

.icon-btn.active {
    color: var(--current-accent);
    border-color: var(--current-accent);
    box-shadow: 0 0 14px var(--current-glow);
}

/* Tooltip helper */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -36px;
    left: 50%;
    transform: translateX(-50%) scale(0.85);
    background: rgba(10, 14, 26, 0.95);
    backdrop-filter: blur(8px);
    color: #fff;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-fast);
    border: 1px solid var(--border-glass);
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* --- Main Layout Grid --- */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 390px;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 980px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Hero Timer Card --- */
.timer-hero-card {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 2.25rem 2rem;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
}

/* Subtle glow behind timer circle */
.timer-hero-card::before {
    content: '';
    position: absolute;
    width: 320px;
    height: 320px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, var(--current-glow) 0%, transparent 70%);
    opacity: 0.35;
    pointer-events: none;
    transition: background var(--transition-normal);
}

/* --- Mode Switcher Pills --- */
.mode-switcher-container {
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-glass);
    padding: 5px;
    border-radius: var(--radius-full);
    display: flex;
    gap: 4px;
    margin-bottom: 2rem;
    max-width: 440px;
    width: 100%;
}

.mode-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 0.92rem;
    font-weight: 600;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.mode-btn:hover {
    color: var(--text-primary);
}

.mode-btn.active {
    color: #fff;
    background: var(--current-gradient);
    box-shadow: 0 4px 16px var(--current-glow);
}

/* --- Circular Timer Visualization --- */
.timer-display-wrapper {
    position: relative;
    width: 340px;
    height: 340px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
}

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

.timer-svg-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 10;
}

.timer-svg-progress {
    fill: none;
    stroke: var(--current-accent);
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.6s ease-out, stroke var(--transition-normal);
    filter: drop-shadow(0 0 10px var(--current-glow));
}

.timer-inner-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.timer-time {
    font-family: var(--font-timer);
    font-size: 4.8rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1;
    color: #ffffff;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.15);
    user-select: none;
}

.timer-status-badge {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--current-accent);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    display: inline-block;
}

.status-dot.pulsing {
    animation: statusPulse 1.6s infinite ease-in-out;
}

@keyframes statusPulse {
    0%, 100% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 0 var(--current-glow); }
    50% { transform: scale(1.3); opacity: 0.7; box-shadow: 0 0 10px 4px var(--current-glow); }
}

/* --- Cycle Dots --- */
.cycle-tracker {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.85rem;
}

.cycle-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid var(--border-glass);
    transition: all var(--transition-normal);
}

.cycle-dot.completed {
    background: var(--current-accent);
    box-shadow: 0 0 10px var(--current-glow);
    border-color: transparent;
    transform: scale(1.1);
}

.cycle-dot.active-now {
    border-color: var(--current-accent);
    background: transparent;
    animation: dotPulse 1.8s infinite;
}

@keyframes dotPulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--current-glow); }
    50% { box-shadow: 0 0 12px 3px var(--current-glow); }
}

.cycle-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* --- Controls Button Bar --- */
.timer-controls {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-top: 0.5rem;
}

.control-btn {
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-family: var(--font-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    width: 52px;
    height: 52px;
    font-size: 1.3rem;
}

.btn-secondary:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
    border-color: var(--border-glass-bright);
    transform: translateY(-2px);
}

.btn-secondary:active {
    transform: scale(0.94);
}

.btn-primary {
    background: var(--current-gradient);
    color: #ffffff;
    min-width: 170px;
    height: 60px;
    padding: 0 2rem;
    font-size: 1.15rem;
    font-weight: 700;
    gap: 0.6rem;
    box-shadow: 0 6px 24px var(--current-glow);
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 30px var(--current-glow);
}

.btn-primary:active {
    transform: scale(0.97);
}

/* --- Picture-in-Picture (Floating Mini-Player) Trigger --- */
.pip-trigger-row {
    margin-top: 1.25rem;
    display: flex;
    justify-content: center;
}

.pip-quick-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    padding: 0.45rem 1.1rem;
    border-radius: var(--radius-full);
    font-size: 0.82rem;
    font-weight: 500;
    font-family: var(--font-main);
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pip-quick-btn:hover {
    background: rgba(255, 255, 255, 0.09);
    color: var(--text-primary);
    border-color: var(--border-glass-bright);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pip-quick-btn.active {
    background: rgba(255, 255, 255, 0.12);
    color: var(--current-accent);
    border-color: var(--current-accent);
    box-shadow: 0 0 14px var(--current-glow);
}

.pip-badge {
    background: var(--current-gradient);
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 0 8px var(--current-glow);
}

/* Active Working Task Pill */
.active-task-banner {
    margin-top: 1.75rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    max-width: 90%;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.active-task-banner .task-label {
    font-weight: 500;
    color: var(--text-muted);
}

.active-task-banner .task-title {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

/* --- Task List Section (Left/Bottom) --- */
.tasks-card {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-md);
    margin-top: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.card-title {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title i {
    color: var(--current-accent);
}

.task-input-wrapper {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.task-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.95rem;
    padding: 0.75rem 1.1rem;
    border-radius: var(--radius-md);
    outline: none;
    transition: all var(--transition-fast);
}

.task-input:focus {
    border-color: var(--current-accent);
    box-shadow: 0 0 14px var(--current-glow);
    background: rgba(0, 0, 0, 0.4);
}

.task-pomos-input {
    width: 75px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.95rem;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    outline: none;
    text-align: center;
    transition: border-color var(--transition-fast);
}

.btn-add-task {
    background: var(--current-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 0 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.btn-add-task:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--current-glow);
}

.tasks-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 4px;
}

/* Custom Scrollbar */
.tasks-list::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
    width: 6px;
}
.tasks-list::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
    background: var(--border-glass-bright);
    border-radius: 99px;
}

.task-item {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.task-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-glass-bright);
    transform: translateX(3px);
}

.task-item.selected-task {
    border-color: var(--current-accent);
    background: rgba(99, 102, 241, 0.12);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.2);
}

.task-item.completed {
    opacity: 0.55;
    text-decoration: line-through;
}

.task-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex: 1;
    overflow: hidden;
}

.task-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid var(--text-muted);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.task-checkbox.checked {
    background: var(--long-break-color);
    border-color: var(--long-break-color);
    color: white;
}

.task-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-right {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.task-pomo-count {
    font-size: 0.8rem;
    font-family: var(--font-timer);
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 99px;
}

.task-del-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color var(--transition-fast);
}

.task-del-btn:hover {
    color: #ef4444;
}

.tasks-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* --- Right Column: Side Cards --- */
.side-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Ambient Audio Mixer */
.ambient-card, .stats-card {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

.ambient-tracks {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
    margin-top: 1rem;
}

.ambient-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.ambient-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--current-accent);
    font-size: 1rem;
    flex-shrink: 0;
}

.ambient-info {
    flex: 1;
}

.ambient-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
}

.ambient-title span {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Custom Slider */
.slider-input {
    width: 100%;
    -webkit-appearance: none;
    height: 5px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    transition: background var(--transition-fast);
}

.slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--current-accent);
    cursor: pointer;
    box-shadow: 0 0 10px var(--current-glow);
    transition: transform var(--transition-fast);
}

.slider-input::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-top: 1rem;
}

.stat-box {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 1rem 0.6rem;
    text-align: center;
    transition: transform var(--transition-fast);
}

.stat-box:hover {
    transform: translateY(-2px);
    border-color: var(--border-glass-bright);
}

.stat-value {
    font-family: var(--font-timer);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

/* Shortcut hints */
.shortcuts-hint {
    display: flex;
    justify-content: space-around;
    padding-top: 1rem;
    border-top: 1px solid var(--border-glass);
    margin-top: 1.25rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.kbd {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-glass-bright);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-timer);
    color: var(--text-secondary);
}

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: #111528;
    border: 1px solid var(--border-glass-bright);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    transform: translateY(20px) scale(0.95);
    transition: transform var(--transition-spring);
}

.modal-overlay.open .modal-box {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-glass);
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    transition: color var(--transition-fast);
}

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

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.settings-section-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.time-inputs-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
}

.time-input-group label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    font-weight: 500;
}

.time-input-group input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-glass);
    color: #fff;
    font-family: var(--font-timer);
    font-size: 1rem;
    padding: 0.6rem 0.5rem;
    border-radius: var(--radius-sm);
    text-align: center;
    outline: none;
    transition: border-color var(--transition-fast);
}

.time-input-group input:focus {
    border-color: var(--focus-color);
}

.settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.toggle-info .toggle-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
}

.toggle-info .toggle-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-switch {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: 0.3s;
    border-radius: 99px;
}

.slider-switch:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider-switch {
    background-color: var(--current-accent);
}

input:checked + .slider-switch:before {
    transform: translateX(20px);
}

/* Theme picker chips */
.theme-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
}

.theme-chip {
    padding: 0.65rem 0.5rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    transition: all var(--transition-fast);
}

.theme-chip:hover {
    border-color: var(--border-glass-bright);
    color: var(--text-primary);
}

.theme-chip.active {
    border-color: var(--current-accent);
    color: var(--text-primary);
    box-shadow: 0 0 12px var(--current-glow);
}

.theme-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-glass);
    gap: 0.75rem;
}

.btn-modal-save {
    background: var(--current-gradient);
    border: none;
    color: white;
    padding: 0.65rem 1.5rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-modal-save:hover {
    box-shadow: 0 4px 16px var(--current-glow);
    transform: translateY(-2px);
}

/* ==========================================================================
   CROSS-PLATFORM MOBILE & RESPONSIVE ADAPTATIONS (iPhone, Android & Web)
   ========================================================================== */

/* Mobile Bottom Navigation Dock (Default hidden on Desktop) */
.mobile-nav-dock {
    display: none;
}

.modal-drag-handle {
    display: none;
}

/* Tablet & Mobile Screens (iPhone, Android & small viewports) */
@media (max-width: 768px) {
    .app-header {
        padding: 0.65rem 1rem;
        margin-bottom: 1.25rem;
    }

    .logo-badge {
        width: 34px;
        height: 34px;
        font-size: 1.05rem;
    }

    .logo-title {
        font-size: 1.15rem;
    }

    /* Fixed ergonomic bottom nav dock */
    .mobile-nav-dock {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 90;
        background: rgba(10, 12, 22, 0.88);
        backdrop-filter: blur(25px) saturate(190%);
        -webkit-backdrop-filter: blur(25px) saturate(190%);
        border-top: 1px solid var(--border-glass-bright);
        padding: 0.45rem 0.5rem max(0.45rem, env(safe-area-inset-bottom));
        justify-content: space-around;
        align-items: center;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.6);
    }

    .mobile-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        background: transparent;
        border: none;
        color: var(--text-muted);
        font-family: var(--font-main);
        font-size: 0.72rem;
        font-weight: 500;
        padding: 0.4rem 0.2rem;
        cursor: pointer;
        border-radius: var(--radius-sm);
        transition: all var(--transition-fast);
        -webkit-tap-highlight-color: transparent;
        user-select: none;
    }

    .mobile-nav-item svg {
        transition: transform var(--transition-fast), stroke var(--transition-fast);
    }

    .mobile-nav-item.active {
        color: var(--current-accent);
        font-weight: 700;
    }

    .mobile-nav-item.active svg {
        stroke: var(--current-accent);
        transform: translateY(-2px) scale(1.08);
        filter: drop-shadow(0 0 8px var(--current-glow));
    }

    .mobile-nav-item:active {
        transform: scale(0.92);
    }
}

/* Smartphone Adjustments & Native Bottom-Sheet Modal (iOS & Android) */
@media (max-width: 640px) {
    .timer-display-wrapper {
        width: 290px;
        height: 290px;
    }

    .timer-time {
        font-size: 4rem;
    }

    .btn-primary {
        min-width: 130px;
        height: 52px;
        font-size: 1rem;
    }

    .btn-secondary {
        width: 44px;
        height: 44px;
    }

    .mode-btn {
        font-size: 0.8rem;
        padding: 0.55rem 0.5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.6rem;
    }

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

    /* Native iOS & Android Bottom-Sheet Modal */
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal-box {
        width: 100%;
        max-width: 100%;
        border-radius: 26px 26px 0 0;
        max-height: 86vh;
        padding-bottom: max(1.5rem, calc(env(safe-area-inset-bottom) + 1rem));
        transform: translateY(100%);
        transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
        border-left: none;
        border-right: none;
        border-bottom: none;
    }

    .modal-overlay.open .modal-box {
        transform: translateY(0);
    }

    .modal-drag-handle {
        display: block;
        width: 42px;
        height: 5px;
        border-radius: 99px;
        background: rgba(255, 255, 255, 0.25);
        margin: 0.75rem auto 0.25rem;
    }
}

/* Compact Smartphones (e.g. iPhone SE, mini, compact Androids) */
@media (max-width: 414px) {
    .timer-display-wrapper {
        width: 250px;
        height: 250px;
    }

    .timer-time {
        font-size: 3.3rem;
    }

    .mode-btn {
        font-size: 0.72rem;
        padding: 0.45rem 0.3rem;
    }

    .time-inputs-grid {
        gap: 0.4rem;
    }

    .btn-primary {
        min-width: 115px;
        height: 48px;
        font-size: 0.92rem;
    }

    .shortcuts-hint {
        display: none; /* Hide keyboard shortcuts on small touch screens */
    }
}

/* Platform-specific refinements (applied via platform.js) */
.platform-ios body {
    -webkit-user-select: none;
}

.platform-standalone .app-header {
    padding-top: max(0.75rem, env(safe-area-inset-top));
}

