:root {
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* Variables for transitions */
    --bg-color: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;

    --ring-set: #2dd4bf;
    /* Teal */
    --ring-pause: #3b82f6;
    /* Blue */
    --ring-overtime: #f472b6;

    --btn-primary-bg: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
    --btn-secondary-bg: rgba(255, 255, 255, 0.1);
    --btn-secondary-text: #f8fafc;

    --brain-opacity: 0.6;
    --brain-blend: screen;
}

body.light-theme {
    --bg-color: #f8fafc;
    /* Clinical White/Grey */
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(203, 213, 225, 0.6);
    --glass-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

    --text-primary: #1e293b;
    /* Dark Slate */
    --text-secondary: #64748b;

    --ring-set: #0d9488;
    /* Darker Teal */
    --ring-pause: #2563eb;

    --btn-secondary-bg: #e2e8f0;
    --btn-secondary-text: #334155;

    --brain-opacity: 0.15;
    --brain-blend: multiply;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.5s ease, color 0.5s ease;
}

/* Background Brain */
.brain-bg {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vmin;
    height: 90vmin;
    max-width: 800px;
    max-height: 800px;
    /* background-image: url('brain-bg.png'); - Removed per user request */
    background-image: none;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: var(--brain-opacity);
    mix-blend-mode: var(--brain-blend);
    pointer-events: none;
    z-index: -1;
    transition: opacity 0.5s ease;
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 450px;
    height: 100vh;
    max-height: 900px;
    padding: 0.5rem 2rem 2rem 2rem;
    /* Reduced top padding only */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

/* ... skipped lines ... */

/* Header */


/* Micro-UI (Capsule Mode) */
body.mini-mode {
    background: transparent;
    /* Allow host to see transparency if supported */
}

body.mini-mode .brain-bg,
body.mini-mode .header,
body.mini-mode #settings-btn,
/* Exit Button - Default Hidden in Main Mode */
#exit-mini-mode-btn {
    display: none;
}

/* Reset Button - Visible in Micro-UI as Secondary Action */
body.mini-mode #reset-btn {
    display: flex !important;
    position: absolute;
    bottom: -12px;
    left: -12px;
    width: 32px;
    /* Increased from 24px */
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(40, 40, 40, 0.8);
    /* Much darker for contrast */
    color: #fff;
    /* White icon for visibility */
    font-size: 16px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
    z-index: 100;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

body.mini-mode #reset-btn:hover {
    background: var(--btn-primary-bg);
    border-color: transparent;
    color: white;
    transform: rotate(90deg) scale(1.1);
}

/* Exit Button - Visible in Micro-UI specifically */
body.mini-mode .progress-ring,
body.mini-mode #action-text,
body.mini-mode #exit-mini-mode-btn {
    display: none !important;
}

/* Re-flow layout for capsule */
/* Re-flow layout for capsule */
body.mini-mode .app-container {
    width: auto;
    height: auto;
    min-height: 0;
    max-width: none;
    max-height: none;
    position: relative;
    /* Anchor for absolute buttons */
    padding: 6px 8px 6px 20px;
    /* Balanced pill shape: more padding on left for text */

    /* Capsule Styling */
    background: rgba(30, 41, 59, 0.95);
    /* Force Dark Background for White Text */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    /* Hairline */
    border-radius: 9999px;
    /* Capsule */
    box-shadow:
        0 8px 20px -4px rgba(0, 0, 0, 0.25),
        0 4px 8px -2px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    /* Stronger highlight */

    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

/* Flatten structure */
body.mini-mode .timer-wrapper,
body.mini-mode .controls-bar {
    display: contents;
}

/* Timer Content Wrapper - Restore flex to stack*/
/* Timer Content Wrapper */
body.mini-mode .timer-content {
    position: static;
    transform: none;
    background: none;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    padding: 0;
    width: auto;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    /* Right align numbers and status for clean look next to button */
    justify-content: center;
    margin-right: 0;
}

/* Timer Status Text - Restored */
body.mini-mode #timer-status {
    display: block !important;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #ffffff;
    /* User requested white */
    margin-top: -4px;
    /* Pull closer to digits */
    margin-right: 2px;
    /* Optical alignment */
    line-height: 1;
    opacity: 0.8;
    /* Keep opacity for hierarchy but base color is white */
}

/* Timer Digits - Centered vertically with button */
body.mini-mode #main-timer {
    font-size: 2.8rem;
    /* Larger, bolder */
    font-weight: 600;
    /* Bolder as per image */
    line-height: 1;
    /* Tight line height */
    letter-spacing: -0.03em;
    color: #ffffff;
    /* User requested white */
    text-shadow: none;
    /* Cleaner look */

    position: static;
    transform: none;
    width: auto;
    height: auto;
    margin-bottom: 0;
}

/* Action Button - Circular Icon Only */
body.mini-mode .big-play {
    width: 60px;
    /* Back to circular */
    height: 60px;
    padding: 0;
    min-width: 0;
    border-radius: 50%;
    background: var(--btn-primary-bg);
    box-shadow:
        0 8px 20px rgba(14, 165, 233, 0.4),
        inset 0 2px 5px rgba(255, 255, 255, 0.3);

    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
}

body.mini-mode .big-play ion-icon {
    font-size: 2rem;
    /* Larger icon again */
    margin: 0;
    margin-left: 4px;
    /* Optical center fix */
}

/* Action Text - Hidden */
body.mini-mode #action-text {
    display: none !important;
}

/* Hover effects for Micro UI */
body.mini-mode .big-play:hover {
    transform: scale(1.05);
    box-shadow:
        0 0 20px rgba(14, 165, 233, 0.6),
        inset 0 2px 5px rgba(255, 255, 255, 0.3);
}

body.mini-mode .big-play:active {
    transform: scale(0.95);
}

/* Exit Button - Overlay on hover of the whole capsule? 
   Or maybe a tiny x outside? 
   User asked primarily for digits + button. 
   I'll add a tiny exit button that appears on hover of the container to keep it clean.
*/
body.mini-mode #exit-mini-mode-btn-internal {
    display: flex;
    /* We'll use a new internal button or restyle the existing one if we move it */
}

/* Actually, let's keep it simple. The user didn't ask for an exit button in the prompt, 
   but we need one. I will make a tiny absolute one. */

/* Since I am styling .app-container as the capsule, I can put the exit button absolute to it? 
   No, it's safer to have it separate. 
   But wait, I hid #exit-mini-mode-btn above. 
   Let's Un-hide it but style it differently.
*/

/* Exit Button - Default Hidden in Main Mode */
#exit-mini-mode-btn {
    display: none;
}

/* Exit Button - Visible in Micro-UI specifically */
/* Exit Button - Visible in Micro-UI specifically */
/* Exit Button - Visible in Micro-UI specifically */
body.mini-mode #exit-mini-mode-btn {
    display: flex !important;
    position: absolute;
    top: -12px;
    left: -12px;
    width: 32px;
    height: 32px;
    font-size: 16px;

    /* High Visibility Design */
    background: rgba(40, 40, 40, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #fff;

    cursor: pointer;
    align-items: center;
    justify-content: center;

    opacity: 1;
    /* Always visible per user request */
    transform: none;
    /* Removed scale(0.85) to match reset button size */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Hover effects for the button itself */
body.mini-mode #exit-mini-mode-btn:hover {
    background: #ef4444;
    /* Red for exit */
    border-color: transparent;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Header */
/* Header */
.header {
    width: 100%;
    display: flex;
    justify-content: center;
    /* Center the wrapper horizontally */
    padding-top: max(env(safe-area-inset-top), 5px);
    /* Minimal top padding */
    z-index: 10;
}

.header-content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    /* Align logo and controls to the left relative to each other */
    gap: 1rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    /* Removed padding to let it align naturally with start of controls */
}

.header-logo {
    height: 2.7rem;
    width: auto;
    object-fit: contain;
    border-radius: 20px;
}

.logo-area h1 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: #3b82f6;
    text-align: left;
    letter-spacing: -0.02em;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
}

.session-info {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* Timer Ring */
.timer-wrapper {
    position: relative;
    width: 75vmin;
    height: 75vmin;
    max-width: 320px;
    max-height: 320px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.progress-ring {
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 10px rgba(45, 212, 191, 0.2));
    /* Subtle glow */
}

.progress-ring__circle-bg {
    stroke: var(--glass-border);
    transition: stroke 0.5s ease;
}

.progress-ring__circle {
    stroke-dasharray: 880;
    stroke-dashoffset: 880;
    transition: stroke-dashoffset 0.5s linear, stroke 0.3s ease;
    stroke-linecap: round;
}

.timer-content {
    position: absolute;
    text-align: center;
    z-index: 10;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 2.5rem;
    border-radius: 50%;
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--glass-border);
    width: 160px;
    height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: background 0.5s ease, border-color 0.5s ease;
}

#main-timer {
    font-size: 3.5rem;
    font-weight: 300;
    letter-spacing: -1px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

#timer-status {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
}

/* Controls Footer */
.controls-bar {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    padding-bottom: 2rem;
    z-index: 10;
}

.btn-circle {
    border: none;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    background: var(--btn-secondary-bg);
    color: var(--text-primary);
    /* Fixed icon color in light mode */
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--glass-shadow);
    flex-shrink: 0;
}

body.light-theme .btn-circle:not(.big-play) {
    color: var(--text-primary);
}

.btn-sm {
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
}

.btn-theme-toggle {
    border: none;
    border-radius: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    background: var(--btn-secondary-bg);
    color: var(--text-primary);
    border: 1px solid transparent;
    /* No border per design, or subtle */
    /* backdrop-filter: blur(8px); - Design looks opaque/solid light grey in light mode */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    /* Flat design */
    padding: 0.6rem 1rem;
    /* Reduced padding */
    gap: 0.5rem;
    font-family: inherit;
    font-size: 0.9rem;
    /* Reduced font size */
    font-weight: 500;
    white-space: nowrap;
    /* Prevent text wrap */
}

.btn-theme-toggle.btn-icon-only {
    padding: 0.8rem;
    width: 48px;
    height: 48px;
    border-radius: 50px;
    /* Pill/Circle */
}

.btn-theme-toggle:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.2);
    /* Lighter on hover for dark mode */
}

body.light-theme .btn-theme-toggle:hover {
    background: #cbd5e1;
}

/* User requested 50% larger icons in header */
.btn-theme-toggle ion-icon {
    font-size: 1.4rem;
    /* ~50% larger than default text size */
}

.btn-secondary {
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
}

.btn-circle:hover {
    transform: translateY(-2px);
    background: var(--glass-bg);
}

.big-play {
    width: auto;
    min-width: 180px;
    height: 60px;
    padding: 0 2rem;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: var(--btn-primary-bg);
    color: white !important;
    border: none;
    border-radius: 50px;
    box-shadow: 0 10px 25px -5px rgba(14, 165, 233, 0.4);
    display: flex;
    gap: 0.8rem;
    text-transform: uppercase;
}

.big-play ion-icon {
    font-size: 1.4rem;
}

.big-play:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px -10px rgba(14, 165, 233, 0.5);
    background: var(--btn-primary-bg);
    /* Fix: Override btn-circle:hover background */
}

.big-play:active {
    transform: translateY(-1px);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

body.light-theme .modal {
    background: rgba(241, 245, 249, 0.6);
}

.modal:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 2rem;
    border-radius: 20px;
    width: 85%;
    max-width: 320px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.glass-panel h2 {
    margin-top: 0;
    text-align: center;
    font-weight: 500;
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 0.8rem;
    background: rgba(128, 128, 128, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
    text-align: center;
    box-sizing: border-box;
    font-family: inherit;
}

.form-group input:focus {
    outline: none;
    border-color: var(--ring-set);
    background: rgba(128, 128, 128, 0.05);
}

/* Checkbox Group Styling */
.checkbox-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(128, 128, 128, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 0.8rem 1rem;
    margin: 0;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    width: 100%;
    box-sizing: border-box;
    color: var(--text-primary);
    /* Ensure text is primary color, not label secondary */
    margin-top: 1rem;
    /* Match spacing of other inputs if needed, or rely on form-group margin */
}

/* Actually, the user asked for interval "like between top blocks". 
   Top blocks use .form-group which normally has margin-bottom. 
   But .checkbox-group is also a .form-group.
   Let's check .form-group definition again.
   It has margin-bottom: 0.5rem on the label, but no margin on the group itself?
   Wait, lines 622-628: 
   .form-group label { margin-bottom: 0.5rem; }
   
   I don't see a margin-bottom on .form-group itself in the file!
   Ah, I missed it? 
   No, I see .glass-panel h2 has margin-bottom 1.5rem.
   And .modal-actions has margin-top 1.5rem.
   
   If .form-group doesn't have margin, then the inputs are jumping against each other? 
   Let's look at index.html structure.
   
   <div class="form-group">
       <label>...</label>
       <input>
   </div>
   
   If .form-group has no margin, they are tight. 
   But the user says "like between top blocks". 
   
   I will implicitly add margin-bottom to .form-group to separate them.
*/

.form-group {
    margin-bottom: 1rem;
}

.checkbox-group label:hover {
    background: rgba(128, 128, 128, 0.15);
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--ring-set);
    /* Use theme color for checkbox */
    cursor: pointer;
}

.checkbox-group span {
    font-size: 1rem;
    font-weight: 500;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn-pill {
    flex: 1;
    padding: 0.8rem;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: opacity 0.2s;
}

.btn-pill:hover {
    opacity: 0.9;
}

.btn-pill.btn-primary {
    background: var(--btn-primary-bg);
    color: white;
}

.btn-pill.btn-secondary {
    background: var(--glass-border);
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 380px) {
    #main-timer {
        font-size: 3rem;
    }

    .timer-content {
        width: 140px;
        height: 140px;
    }

    .big-play {
        width: 72px;
        height: 72px;
        font-size: 2rem;
    }
}