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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    color: #fff;
    overflow-x: hidden;
}

body.modal-open {
    overflow: hidden;
}

.quick-presets {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-chip {
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-radius: 999px;
    padding: 9px 14px;
    font-weight: 600;
    box-shadow: 0 6px 16px rgba(0,0,0,0.18);
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    backdrop-filter: blur(6px);
}

.btn-chip.more {
    background: rgba(0,0,0,0.22);
    border-color: rgba(255,255,255,0.2);
}

.btn-chip:hover,
.btn-chip:focus-visible {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-1px);
}

.btn-chip.more:hover,
.btn-chip.more:focus-visible {
    background: rgba(0,0,0,0.32);
}

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

.main-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 20px;
    padding-bottom: 20px;
}

.current-preset {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 10px;
    text-align: center;
    min-height: 20px;
}

.breathing-graph {
    position: relative;
    width: min(480px, 90vw);
    height: 140px;
    margin-top: 18px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(6px);
}

.breathing-graph canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.breathing-graph-dot {
    position: absolute;
    left: 20%;
    top: 50%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.75), 0 0 24px rgba(255, 200, 160, 0.5);
    transform: translate(-50%, -50%);
    transition: left 0.6s ease;
    pointer-events: none;
}

.breathing-container {
    position: relative;
    width: 300px;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.breathing-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #fff5e6, #ffcc80, #ff9800);
    box-shadow: 
        0 0 60px rgba(255, 183, 77, 0.6),
        0 0 100px rgba(255, 152, 0, 0.4),
        inset 0 0 30px rgba(255, 255, 255, 0.3);
    transition: transform 0.1s ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    position: relative;
}

.breathing-circle.animating {
    transition: none;
}

.glow-ring {
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
}

.glow-ring:nth-child(2) {
    width: 240px;
    height: 240px;
    border-color: rgba(255, 255, 255, 0.2);
}

.glow-ring:nth-child(3) {
    width: 280px;
    height: 280px;
    border-color: rgba(255, 255, 255, 0.1);
}

.phase-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: #5d4037;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    text-align: center;
}

.phase-countdown {
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(93, 64, 55, 0.85);
    letter-spacing: 1px;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.35);
    min-height: 1.1em;
    position: absolute;
    left: 50%;
    top: calc(50% + 1.25rem);
    transform: translateX(-50%);
    width: 100%;
    text-align: center;
}

.timer-row {
    margin-top: 30px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.timer-display {
    font-size: 2.5rem;
    font-weight: 300;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    letter-spacing: 1px;
}

.timer-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    line-height: 1;
    color: #5d4037;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(93, 64, 55, 0.18);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16);
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
    user-select: none;
}

.timer-icon.is-running {
    background: rgba(255, 255, 255, 0.9);
    color: #5d4037;
    border-color: rgba(93, 64, 55, 0.18);
}

.timer-icon:hover {
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

.timer-icon:active {
    transform: scale(0.97);
}

.timer-icon:focus-visible {
    outline: 2px solid #ff9a56;
    outline-offset: 2px;
}

.controls {
    margin-top: 30px;
    display: flex;
    gap: 15px;
}

.btn {
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(135deg, #ff9a56, #ff6b6b);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
}

.notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    color: #5d4037;
    padding: 15px 30px;
    border-radius: 50px;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.5s ease;
    z-index: 1000;
}

.notification.show {
    opacity: 1;
}

/* Floating quick controls */
.floating-actions {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 150;
}

.fab {
    padding: 16px 22px;
    border-radius: 16px;
    font-size: 1rem;
    box-shadow: 0 14px 30px rgba(255, 107, 107, 0.45);
}

.audio-pill {
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.audio-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.22);
}

.sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 300;
}

.sheet-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* Settings Panel as side drawer */
.settings-panel {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: stretch;
    justify-content: flex-end;
    padding: 0;
    pointer-events: none;
    opacity: 0;
    z-index: 310;
    transition: opacity 0.18s ease;
}

.settings-panel.open {
    pointer-events: auto;
    opacity: 1;
}

.settings-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px;
    cursor: pointer;
    color: #5d4037;
    font-weight: 600;
    user-select: none;
}

.settings-toggle svg {
    transition: transform 0.3s ease;
}

.settings-panel.open .settings-toggle svg {
    transform: rotate(180deg);
}


.presets-sheet {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 14px;
    color: #333;
    background: #ffffff;
    border-radius: 14px 0 0 14px;
    padding: 18px 18px 22px;
    width: min(420px, 80vw);
    max-height: calc(100vh - 24px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.26);
    overflow: hidden;
    backdrop-filter: blur(8px);
    border-left: 1px solid rgba(0,0,0,0.06);
}

.side-drawer {
    transform: translateX(100%);
    transition: transform 0.22s ease;
}

.settings-panel.open .side-drawer {
    transform: translateX(0);
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding-right: 8px;
}

.sheet-title h3 {
    color: #5d4037;
    font-size: 1.2rem;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.75rem;
    color: #aa6a2c;
}

.sheet-handle {
    width: 52px;
    height: 6px;
    border-radius: 999px;
    background: rgba(0,0,0,0.12);
    margin: 0 auto 12px;
}

.sheet-actions {
    display: flex;
    gap: 12px;
    margin-top: 4px;
    flex-wrap: nowrap;
    justify-content: space-between;
}

.sheet-actions button {
    flex: 1 1 0;
    min-width: 0;
    padding: 12px 14px;
    font-size: 0.95rem;
    letter-spacing: 0;
    text-transform: none;
}

.sheet-actions .btn-secondary {
    background: #ffe8d6;
    color: #7a2f00;
    border: 1px solid #f08c42;
    box-shadow: 0 4px 12px rgba(240, 140, 66, 0.25);
}

.sheet-actions .btn-secondary:hover {
    background: #ffd9b8;
}

.close-btn {
    background: rgba(0, 0, 0, 0.05);
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    color: #5d4037;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.presets-sheet .close-btn {
    position: static;
    background: transparent;
    box-shadow: none;
}

.presets-sheet .close-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 400;
}

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

.modal-card {
    background: #ffffff;
    color: #333;
    border-radius: 20px;
    padding: 22px;
    width: min(520px, 90vw);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: translateY(20px);
    transition: transform 0.25s ease;
}

.disclaimer-modal {
    width: min(720px, 94vw);
    max-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.disclaimer-content {
    background: #f8f4f0;
    border-radius: 14px;
    padding: 16px 18px;
    color: #3a2c27;
    overflow-y: auto;
    flex: 1;
    min-height: 240px;
    max-height: calc(100vh - 220px);
    box-shadow: inset 0 1px 4px rgba(0,0,0,0.08);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.disclaimer-content h1,
.disclaimer-content h2,
.disclaimer-content h3,
.disclaimer-content h4 {
    color: #4a342f;
    margin-top: 14px;
}

.disclaimer-content p,
.disclaimer-content li {
    color: #3a2c27;
}

.disclaimer-content ul {
    margin-left: 18px;
    list-style: disc;
}

.disclaimer-actions {
    justify-content: center;
    gap: 10px;
    position: sticky;
    bottom: 0;
    padding: 12px 0 4px;
    background: #ffffff;
    border-top: 1px solid rgba(0,0,0,0.06);
}

.disclaimer-snooze {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #3a2c27;
    font-weight: 600;
    padding: 8px 4px 0;
    user-select: none;
}

.disclaimer-snooze input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #4a90e2;
}

.modal-backdrop.open .modal-card {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.ratio-readonly .setting-value {
    color: #5d4037;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
}

.setting-group {
    background: #f8f4f0;
    padding: 20px;
    border-radius: 15px;
}

.setting-group h3 {
    color: #5d4037;
    margin-bottom: 15px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.setting-item {
    margin-bottom: 15px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.preset-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.presets-scroll {
    overflow-y: auto;
    padding-right: 4px;
    margin-right: -4px;
    flex: 1 1 auto;
    min-height: 0;
}

.settings-bottom {
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.86) 0%, #fff 38%);
    padding-top: 10px;
    margin-top: 6px;
    border-top: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 -8px 18px rgba(0,0,0,0.06);
}

.preset-buttons .preset-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
    /* Override generic secondary button styling for better contrast
       inside the light settings card */
    background: #ffffff;
    color: #5d4037;
    border: 1px solid rgba(255, 152, 0, 0.4);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: none;
}

.preset-buttons .preset-btn.selected {
    background: #ff7b42;
    color: #ffffff;
    border: 1px solid #e36524;
    box-shadow: 0 0 0 3px rgba(255, 123, 66, 0.25), 0 6px 12px rgba(0, 0, 0, 0.08);
}

.preset-buttons .preset-btn.selected .preset-info-icon {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.preset-buttons .preset-btn:hover {
    background: #ffe7d0;
}

/* Tooltip for preset descriptions */
.preset-btn {
    position: relative;
}

.preset-label {
    flex: 1;
    text-align: left;
}

.preset-tooltip {
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.97); /* very dark slate for strong contrast */
    color: #f9fafb;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    line-height: 1.2;
    max-width: 320px;
    text-transform: none;
    letter-spacing: normal;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease-out, transform 0.15s ease-out;
    z-index: 20;
}

.preset-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: rgba(15, 23, 42, 0.97) transparent transparent transparent;
}

.preset-btn:hover .preset-tooltip,
.preset-btn:focus-visible .preset-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -4px);
}

.preset-btn.show-tooltip .preset-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -4px);
}

.preset-info-icon {
    border: none;
    background: rgba(255, 152, 0, 0.12);
    color: #aa6a2c;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease, color 0.2s ease;
}

.preset-info-icon:hover,
.preset-info-icon:focus-visible {
    background: rgba(255, 152, 0, 0.22);
    color: #8b4f1a;
    outline: none;
}

.preset-category-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.preset-category-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #aa6a2c;
}

.preset-category-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.setting-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #666;
    font-size: 0.9rem;
}

.setting-item input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

.bpm-setting {
    margin-bottom: 6px;
}

.bpm-setting input[type="range"] {
    width: calc(100% + 30px);
    margin-left: -15px;
    margin-right: -15px;
}

.rhythm-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.rhythm-inline label {
    margin-bottom: 0;
}

.rhythm-inline .setting-value {
    margin-top: 0;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff9a56, #ff6b6b);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(255, 107, 107, 0.4);
}

.setting-value {
    text-align: right;
    font-weight: 600;
    color: #ff6b6b;
    font-size: 0.9rem;
    margin-top: 5px;
}

.toggle-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    width: 50px;
    height: 26px;
    background: #ddd;
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #ff9a56, #ff6b6b);
}

.toggle-switch input:checked + .toggle-slider::after {
    transform: translateX(24px);
}

.instruction-text {
    margin-top: 20px;
    text-align: center;
    opacity: 0.9;
    font-size: 1rem;
    max-width: 400px;
}

@media (max-width: 600px) {
    .breathing-container {
        width: 250px;
        height: 250px;
    }

    .breathing-circle {
        width: 120px;
        height: 120px;
    }

    .glow-ring {
        width: 160px;
        height: 160px;
    }

    .glow-ring:nth-child(2) {
        width: 190px;
        height: 190px;
    }

    .glow-ring:nth-child(3) {
        width: 220px;
        height: 220px;
    }

    .timer-display {
        font-size: 2rem;
    }

    .settings-content {
        padding: 0 15px 20px;
    }

    .setting-group {
        padding: 15px;
    }
}
