/**
 * WhyWorry — Styles
 * Calming CBT visualization app
 * Mobile-first, GPU-accelerated, Capacitor-ready
 */

/* ═══════════════════════════════════════════════
   DESIGN TOKENS
   ═══════════════════════════════════════════════ */
:root {
    /* Sky */
    --sky-top: #dceefb;
    --sky-mid: #b3d9ef;
    --sky-bottom: #87ceeb;
    --sky-breath: rgba(135, 206, 235, 0.25);

    /* Cloud */
    --cloud-fill-1: #FFFFFF;
    --cloud-fill-2: #FFFEF5;
    --cloud-fill-3: #FFFFF8;
    --cloud-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    /* Softer, deeper shadow */
    --cloud-glow: 0 0 20px rgba(255, 255, 255, 0.6);

    /* UI */
    --ui-primary: #4A90A4;
    --ui-primary-hover: #3d7d90;
    --ui-primary-glow: rgba(74, 144, 164, 0.25);
    --ui-text: #2c3e50;
    --ui-text-mid: #546E7A;
    --ui-text-light: #78909C;
    --ui-surface: rgba(255, 255, 255, 0.96);
    --ui-surface-solid: #f8fbfd;
    --ui-border: rgba(74, 144, 164, 0.12);
    --ui-input-bg: #ffffff;
    --ui-error: #D32F2F;
    --ui-error-bg: #FFEBEE;

    /* Spacing */
    --sp-xs: 4px;
    --sp-sm: 8px;
    --sp-md: 16px;
    --sp-lg: 24px;
    --sp-xl: 32px;
    --sp-2xl: 48px;

    /* Radius */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 20px;
    --r-xl: 28px;
    --r-pill: 999px;

    /* Transitions */
    --t-fast: 0.15s ease;
    --t-base: 0.25s ease;
    --t-slow: 0.4s ease;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
    --shadow-up: 0 -4px 20px rgba(0, 0, 0, 0.06);

    /* Safe areas (Capacitor) */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    /* Animation */
    --float-duration: 12s;
    /* Slower default float */
}


/* ═══════════════════════════════════════════════
   RESET
   ═══════════════════════════════════════════════ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.5;
    color: var(--ui-text);
    background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 50%, var(--sky-bottom) 100%);
    background-attachment: fixed;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
}


/* ═══════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════ */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}


/* ═══════════════════════════════════════════════
   PAGE SYSTEM
   ═══════════════════════════════════════════════ */
.page {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1;
}

.page.active {
    display: flex;
    flex-direction: column;
    animation: pageFadeIn 0.3s ease;
}

@keyframes pageFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}


/* ═══════════════════════════════════════════════
   MAIN APP PAGE
   ═══════════════════════════════════════════════ */
.page-app {
    padding-bottom: var(--safe-bottom);
}


/* ═══════════════════════════════════════════════
   SKY
   ═══════════════════════════════════════════════ */
.sky {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

.sky-breath {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 80%, var(--sky-breath) 0%, transparent 65%);
    animation: breathe 10s ease-in-out infinite;
    pointer-events: none;
}

@keyframes breathe {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}

.sky-breath-guide {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.15) 0%, transparent 60%);
    opacity: 0;
    transform: scale(0.8);
    /* 4-7-8 Rhythm: 4s inhale + 7s hold + 8s exhale = 19s total */
    animation: breatheGuide 19s ease-in-out infinite;
}

@keyframes breatheGuide {

    /* Inhale (4s / 19s ~= 21%) */
    0% {
        opacity: 0;
        transform: scale(0.8);
    }

    21% {
        opacity: 0.6;
        transform: scale(1.2);
    }

    /* Hold (7s / 19s ~= 37% -> 21+37 = 58%) */
    58% {
        opacity: 0.6;
        transform: scale(1.2);
    }

    /* Exhale (8s / 19s ~= 42% -> 58+42 = 100%) */
    100% {
        opacity: 0;
        transform: scale(0.8);
    }
}

.sky-breath-guide {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.15) 0%, transparent 60%);
    opacity: 0;
    transform: scale(0.8);
    /* 4-7-8 Rhythm: 4s inhale + 7s hold + 8s exhale = 19s total */
    animation: breatheGuide 19s ease-in-out infinite;
}

@keyframes breatheGuide {

    /* Inhale (4s / 19s ~= 21%) */
    0% {
        opacity: 0;
        transform: scale(0.8);
    }

    21% {
        opacity: 0.6;
        transform: scale(1.2);
    }

    /* Hold (7s / 19s ~= 37% -> 21+37 = 58%) */
    58% {
        opacity: 0.6;
        transform: scale(1.2);
    }

    /* Exhale (8s / 19s ~= 42% -> 58+42 = 100%) */
    100% {
        opacity: 0;
        transform: scale(0.8);
    }
}


/* ═══════════════════════════════════════════════
   CLOUD
   ═══════════════════════════════════════════════ */
.cloud {
    position: absolute;
    bottom: -150px;
    transform: translateX(-50%);
    pointer-events: none;
    will-change: transform, opacity;
    z-index: 1;
    /* Random sway params to be set by JS */
    --sway-duration: 4s;
    --sway-delay: 0s;
    --bob-duration: 3s;
    --bob-delay: 0s;
}

.cloud-shape {
    position: absolute;
    inset: 0;
    filter: drop-shadow(var(--cloud-shadow));
    /* Gentle bobbing even when floating */
    animation: cloudBob var(--bob-duration) ease-in-out infinite;
    animation-delay: var(--bob-delay);
}

.cloud-shape svg {
    width: 100%;
    height: 100%;
    display: block;
    /* Soft internal glow/bloom */
    filter: drop-shadow(var(--cloud-glow));
}

.cloud-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 78%;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--ui-text);
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
    pointer-events: none;
    z-index: 2;
    /* Slight sway for text too to feel organic */
    animation: cloudSway var(--sway-duration) ease-in-out infinite;
    animation-delay: var(--sway-delay);
}


/* ═══════════════════════════════════════════════
   CLOUD ANIMATIONS
   ═══════════════════════════════════════════════ */
@keyframes cloudSpawn {
    0% {
        opacity: 0;
        transform: translateX(-50%) scale(0.7) translateY(30px);
    }

    60% {
        transform: translateX(-50%) scale(1.04) translateY(-4px);
    }

    100% {
        opacity: 1;
        transform: translateX(-50%) scale(1) translateY(0);
    }
}

@keyframes cloudFloat {
    0% {
        transform: translateX(-50%) translateY(0);
    }

    100% {
        transform: translateX(-50%) translateY(calc(-100vh + 200px));
    }
}

@keyframes cloudFastFade {
    0% {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateX(-50%) scale(0.85);
    }
}

@keyframes cloudBob {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-4px);
    }

    /* Reduced from -6px for subtlety */
}

@keyframes cloudSway {

    0%,
    100% {
        transform: rotate(-0.5deg);
    }

    /* Reduced from 1deg */
    50% {
        transform: rotate(0.5deg);
    }
}

@keyframes cloudDockedFloat {

    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(-3px);
    }

    /* Reduced from -4px */
}

.cloud.spawning {
    animation: cloudSpawn 0.6s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}

.cloud.floating {
    /* Ease-out makes it slow down as it rises, feeling more buoyant */
    animation: cloudFloat var(--float-duration, 8s) cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
}

.cloud.at-top {
    /* Stop the floating animation but keep position */
    animation: none;
    transition: top 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* Bouncy positioning */
}

/* New class for when it's settled at top */
.cloud.docked {
    animation: cloudDockedFloat 6s ease-in-out infinite;
    animation-delay: var(--bob-delay);
}

.cloud.fast-fade {
    animation: cloudFastFade 0.5s ease-in forwards !important;
}

.cloud.mist {
    animation: cloudMist 2s ease-out forwards !important;
    pointer-events: none;
}

@keyframes cloudMist {
    0% {
        opacity: 1;
        transform: translateX(-50%) scale(1);
        filter: blur(0px);
    }

    100% {
        opacity: 0;
        transform: translateX(-50%) scale(2);
        filter: blur(20px);
    }
}


/* ═══════════════════════════════════════════════
   CONTROLS
   ═══════════════════════════════════════════════ */
.controls {
    background: var(--ui-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    box-shadow: var(--shadow-up);
    padding: var(--sp-lg) var(--sp-md);
    padding-left: calc(var(--sp-md) + var(--safe-left));
    padding-right: calc(var(--sp-md) + var(--safe-right));
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}


/* ═══════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════ */
.app-header {
    text-align: center;
    margin-bottom: var(--sp-md);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.app-title {
    font-size: 1.4rem;
    font-weight: 300;
    color: var(--ui-primary);
    letter-spacing: -0.02em;
}

.header-top .icon-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.app-subtitle {
    font-size: 0.8125rem;
    color: var(--ui-text-light);
    font-weight: 400;
    margin-top: 2px;
}


/* ═══════════════════════════════════════════════
   FORM
   ═══════════════════════════════════════════════ */
.worry-form {
    display: flex;
    flex-direction: column;
    gap: var(--sp-sm);
}

.input-group {
    position: relative;
}

.worry-input {
    width: 100%;
    min-height: 52px;
    padding: var(--sp-md) var(--sp-lg);
    padding-right: 60px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--ui-text);
    background: var(--ui-input-bg);
    border: 1.5px solid var(--ui-border);
    border-radius: var(--r-xl);
    resize: none;
    outline: none;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.worry-input::placeholder {
    color: #90A4AE;
}

.worry-input:focus {
    border-color: var(--ui-primary);
    box-shadow: 0 0 0 3px var(--ui-primary-glow);
}

.worry-input.near-limit {
    border-color: #FFB74D;
}

.worry-input.near-limit:focus {
    box-shadow: 0 0 0 3px rgba(255, 183, 77, 0.2);
}

.worry-input.at-limit {
    border-color: #ef5350;
}

.char-count {
    position: absolute;
    right: var(--sp-md);
    bottom: var(--sp-sm);
    font-size: 0.6875rem;
    color: var(--ui-text-light);
    opacity: 0.6;
    pointer-events: none;
    transition: color var(--t-fast), opacity var(--t-fast);
}

.char-count.warn {
    color: #FF9800;
    opacity: 1;
}

.char-count.full {
    color: #ef5350;
    opacity: 1;
}


/* ═══════════════════════════════════════════════
   FORM ROW
   ═══════════════════════════════════════════════ */
.form-row {
    display: flex;
    gap: var(--sp-sm);
    align-items: stretch;
}

.select-wrap {
    flex: 1;
    min-width: 0;
}

.category-select {
    width: 100%;
    height: 46px;
    padding: 0 36px 0 var(--sp-md);
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--ui-text);
    background: var(--ui-input-bg);
    border: 1.5px solid var(--ui-border);
    border-radius: var(--r-lg);
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%234A90A4' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.category-select:focus {
    border-color: var(--ui-primary);
    box-shadow: 0 0 0 3px var(--ui-primary-glow);
}


/* ═══════════════════════════════════════════════
   RELEASE BUTTON
   ═══════════════════════════════════════════════ */
.release-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-sm);
    height: 46px;
    padding: 0 var(--sp-lg);
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: linear-gradient(135deg, var(--ui-primary) 0%, var(--ui-primary-hover) 100%);
    border: none;
    border-radius: var(--r-lg);
    cursor: pointer;
    outline: none;
    white-space: nowrap;
    transition: transform var(--t-fast), box-shadow var(--t-fast);
    -webkit-tap-highlight-color: transparent;
}

.release-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(74, 144, 164, 0.35);
}

.release-btn:active {
    transform: translateY(0) scale(0.98);
}

.release-btn:focus-visible {
    box-shadow: 0 0 0 3px var(--ui-primary-glow);
}

.btn-icon {
    font-size: 1rem;
}


/* ═══════════════════════════════════════════════
   CONTROLS FOOTER (Stats + Clear)
   ═══════════════════════════════════════════════ */
.controls-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: var(--sp-md);
    padding-top: var(--sp-sm);
    border-top: 1px solid var(--ui-border);
}

.stats {
    display: flex;
    align-items: center;
    gap: var(--sp-xs);
    font-size: 0.8125rem;
    color: var(--ui-text-light);
}

.stats-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding: 0 var(--sp-sm);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ui-primary);
    background: rgba(74, 144, 164, 0.08);
    border-radius: var(--r-pill);
    transition: transform 0.2s ease;
}

.stats-count.count-pulse {
    animation: countPulse 0.3s ease;
}

@keyframes countPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

.clear-btn {
    padding: var(--sp-xs) var(--sp-md);
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--ui-text-light);
    background: transparent;
    border: 1px solid var(--ui-border);
    border-radius: var(--r-sm);
    cursor: pointer;
    outline: none;
    transition: all var(--t-fast);
    -webkit-tap-highlight-color: transparent;
}

.clear-btn:hover {
    color: var(--ui-primary);
    border-color: var(--ui-primary);
    background: rgba(74, 144, 164, 0.04);
}

.clear-btn:focus-visible {
    box-shadow: 0 0 0 2px var(--ui-primary-glow);
}


/* ═══════════════════════════════════════════════
   BOTTOM NAV
   ═══════════════════════════════════════════════ */
.bottom-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-sm);
    padding: var(--sp-sm) var(--sp-md);
    padding-bottom: calc(var(--sp-sm) + var(--safe-bottom));
    background: rgba(0, 0, 0, 0.04);
    flex-shrink: 0;
    z-index: 10;
}

.nav-link {
    font-size: 0.6875rem;
    color: var(--ui-text-light);
    text-decoration: none;
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
    padding: 2px 0;
    transition: color var(--t-fast);
    -webkit-tap-highlight-color: transparent;
}

.nav-link:hover {
    color: var(--ui-primary);
}

.nav-support {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.nav-dot {
    font-size: 0.6875rem;
    color: var(--ui-text-light);
    opacity: 0.4;
}


/* ═══════════════════════════════════════════════
   TEXT PAGES (Privacy, Disclaimer, Contact, Thanks)
   ═══════════════════════════════════════════════ */
.page-text {
    background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 50%, var(--sky-bottom) 100%);
    background-attachment: fixed;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--sp-xl) var(--sp-md);
    padding-top: calc(var(--sp-xl) + var(--safe-top));
    padding-bottom: calc(var(--sp-xl) + var(--safe-bottom));
}

.page-card {
    max-width: 520px;
    width: 100%;
    margin: 0 auto;
    background: var(--ui-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--r-lg);
    padding: var(--sp-lg);
    box-shadow: var(--shadow-md);
}

.page-card--centered {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-sm);
}

.back-link {
    display: inline-block;
    font-size: 0.8125rem;
    color: var(--ui-primary);
    text-decoration: none;
    margin-bottom: var(--sp-md);
    transition: opacity var(--t-fast);
}

.back-link:hover {
    opacity: 0.7;
}

.page-card h2 {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--ui-text);
    margin-bottom: var(--sp-md);
}

.page-body {
    font-size: 0.9375rem;
    line-height: 1.65;
    color: var(--ui-text-mid);
}

.page-body p {
    margin-bottom: var(--sp-md);
}

.page-body p:last-child {
    margin-bottom: 0;
}

.page-body ul {
    margin: var(--sp-sm) 0 var(--sp-md) var(--sp-lg);
}

.page-body li {
    margin-bottom: var(--sp-xs);
}

.page-body a {
    color: var(--ui-primary);
    text-decoration: none;
}

.page-body a:hover {
    text-decoration: underline;
}

.page-body strong {
    color: var(--ui-text);
    font-weight: 600;
}

/* Contact specifics */
.contact-block {
    margin-bottom: var(--sp-md);
}

.contact-block:last-child {
    margin-bottom: 0;
}

.contact-name {
    font-weight: 600;
    color: var(--ui-text);
    font-size: 1rem;
}

/* Page footer nav */
.page-footer-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-sm);
    margin-top: var(--sp-lg);
    font-size: 0.75rem;
}

.page-footer-nav a {
    color: var(--ui-text-light);
    text-decoration: none;
    transition: color var(--t-fast);
}

.page-footer-nav a:hover {
    color: var(--ui-primary);
}

.page-footer-nav span {
    color: var(--ui-text-light);
    opacity: 0.4;
}

/* Thanks page */
.thanks-cloud {
    font-size: 3rem;
    margin-bottom: var(--sp-sm);
    animation: floatGentle 4s ease-in-out infinite;
}

@keyframes floatGentle {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.thanks-sub {
    color: var(--ui-text-light);
    font-size: 0.875rem;
    margin-bottom: var(--sp-lg);
}


/* ═══════════════════════════════════════════════
   BUTTONS (shared)
   ═══════════════════════════════════════════════ */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: linear-gradient(135deg, var(--ui-primary), var(--ui-primary-hover));
    border: none;
    border-radius: var(--r-lg);
    cursor: pointer;
    text-decoration: none;
    transition: transform var(--t-fast), box-shadow var(--t-fast);
    -webkit-tap-highlight-color: transparent;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(74, 144, 164, 0.35);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--ui-primary);
    background: transparent;
    border: 1.5px solid var(--ui-border);
    border-radius: var(--r-lg);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--t-fast);
    -webkit-tap-highlight-color: transparent;
}

.btn-secondary:hover {
    border-color: var(--ui-primary);
    background: rgba(74, 144, 164, 0.04);
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 0.875rem;
    font-weight: 400;
    font-family: inherit;
    color: var(--ui-text-light);
    background: transparent;
    border: none;
    border-radius: var(--r-lg);
    cursor: pointer;
    transition: color var(--t-fast);
    -webkit-tap-highlight-color: transparent;
}

.btn-ghost:hover {
    color: var(--ui-text-mid);
}

.btn-block {
    width: 100%;
}

.btn-small {
    padding: 6px 14px;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--ui-primary);
    background: rgba(74, 144, 164, 0.06);
    border: 1px solid var(--ui-border);
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: all var(--t-fast);
    -webkit-tap-highlight-color: transparent;
}

.btn-small:hover {
    background: rgba(74, 144, 164, 0.1);
    border-color: var(--ui-primary);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: var(--r-sm);
    color: var(--ui-text-light);
    cursor: pointer;
    transition: all var(--t-fast);
    -webkit-tap-highlight-color: transparent;
}

.icon-btn:hover {
    background: rgba(74, 144, 164, 0.06);
    color: var(--ui-primary);
}


/* ═══════════════════════════════════════════════
   SUPPORT MODAL
   ═══════════════════════════════════════════════ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: flex-end;
    justify-content: center;
}

.modal.open {
    display: flex;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-card {
    position: relative;
    max-width: 420px;
    width: 100%;
    margin: var(--sp-md);
    margin-bottom: calc(var(--sp-md) + var(--safe-bottom));
    background: var(--ui-surface-solid);
    border-radius: var(--r-lg);
    padding: var(--sp-lg);
    box-shadow: var(--shadow-lg);
    animation: modalSlideUp 0.35s cubic-bezier(0.22, 0.68, 0.31, 1);
    z-index: 1;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(40px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    top: var(--sp-md);
    right: var(--sp-md);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    color: var(--ui-text-light);
    cursor: pointer;
    border-radius: var(--r-sm);
    transition: all var(--t-fast);
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--ui-text);
}

.modal-card h2 {
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: var(--sp-sm);
    padding-right: 32px;
}

.modal-desc {
    font-size: 0.875rem;
    color: var(--ui-text-mid);
    line-height: 1.55;
    margin-bottom: var(--sp-lg);
}

.modal-btns {
    display: flex;
    flex-direction: column;
    gap: var(--sp-sm);
}

.modal-fine {
    margin-top: var(--sp-md);
    font-size: 0.6875rem;
    color: var(--ui-text-light);
    text-align: center;
    line-height: 1.4;
}


/* ═══════════════════════════════════════════════
   SETTINGS PANEL
   ═══════════════════════════════════════════════ */
.settings-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
}

.settings-overlay.open {
    display: block;
}

.settings-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.settings-drawer {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 85vw);
    background: var(--ui-surface-solid);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.3s cubic-bezier(0.22, 0.68, 0.31, 1);
    padding-top: var(--safe-top);
    padding-right: var(--safe-right);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-lg) var(--sp-lg) var(--sp-md);
}

.settings-header h3 {
    font-size: 1rem;
    font-weight: 500;
}

.settings-body {
    flex: 1;
    padding: 0 var(--sp-lg);
    overflow-y: auto;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-md);
    padding: var(--sp-md) 0;
    cursor: pointer;
}

.setting-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.setting-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ui-text);
}

.setting-hint {
    font-size: 0.75rem;
    color: var(--ui-text-light);
}

.setting-divider {
    height: 1px;
    background: var(--ui-border);
}

.setting-btns {
    display: flex;
    gap: var(--sp-sm);
}

.settings-footer {
    padding: var(--sp-lg);
    padding-bottom: calc(var(--sp-lg) + var(--safe-bottom));
    text-align: center;
    font-size: 0.6875rem;
    color: var(--ui-text-light);
    line-height: 1.5;
}


/* ═══════════════════════════════════════════════
   TOGGLE SWITCH
   ═══════════════════════════════════════════════ */
.toggle {
    position: relative;
    flex-shrink: 0;
}

.toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    display: block;
    width: 44px;
    height: 24px;
    background: #cfd8dc;
    border-radius: 12px;
    position: relative;
    transition: background var(--t-base);
    cursor: pointer;
}

.toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    transition: transform var(--t-base);
}

.toggle-input:checked+.toggle-track {
    background: var(--ui-primary);
}

.toggle-input:checked+.toggle-track .toggle-thumb {
    transform: translateX(20px);
}

.toggle-input:focus-visible+.toggle-track {
    box-shadow: 0 0 0 3px var(--ui-primary-glow);
}


/* ═══════════════════════════════════════════════
   TOAST NOTIFICATION
   ═══════════════════════════════════════════════ */
.toast-container {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 90;
    width: calc(100% - 32px);
    max-width: 420px;
    pointer-events: none;
}

.toast {
    background: var(--ui-surface-solid);
    border-radius: var(--r-md);
    padding: var(--sp-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-md);
    pointer-events: auto;
    animation: toastIn 0.4s cubic-bezier(0.22, 0.68, 0.31, 1);
}

.toast.leaving {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes toastOut {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(20px);
        opacity: 0;
    }
}

.toast-text {
    font-size: 0.8125rem;
    color: var(--ui-text-mid);
    line-height: 1.4;
}

.toast-actions {
    display: flex;
    gap: var(--sp-sm);
    align-items: center;
    flex-shrink: 0;
}

.toast-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
    color: #fff;
    background: var(--ui-primary);
    border: none;
    border-radius: var(--r-sm);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: opacity var(--t-fast);
}

.toast-btn:hover {
    opacity: 0.85;
}

.toast-close {
    background: transparent;
    border: none;
    color: var(--ui-text-light);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}


/* ═══════════════════════════════════════════════
   ERROR MESSAGE
   ═══════════════════════════════════════════════ */
.error-message {
    padding: var(--sp-sm) var(--sp-md);
    margin-bottom: var(--sp-sm);
    font-size: 0.8125rem;
    color: var(--ui-error);
    background: var(--ui-error-bg);
    border: 1px solid #FFCDD2;
    border-radius: var(--r-sm);
    animation: slideDown 0.25s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body.evening .sky-breath {
    animation-duration: 14s;
}

body.evening .cloud-text {
    color: #1a2634;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.3);
}

body.evening .category-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%237eb8c9' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
}


/* ═══════════════════════════════════════════════
   DARK MODE (system preference — overridden by evening mode)
   ═══════════════════════════════════════════════ */
@media (prefers-color-scheme: dark) {
    :root {
        --sky-top: #1a2634;
        --sky-mid: #243447;
        --sky-bottom: #2d3e50;
        --sky-breath: rgba(74, 144, 164, 0.1);

        --ui-text: #ECEFF1;
        --ui-text-mid: #B0BEC5;
        --ui-text-light: #78909C;
        --ui-surface: rgba(38, 50, 56, 0.95);
        --ui-surface-solid: #263238;
        --ui-border: rgba(255, 255, 255, 0.08);
        --ui-input-bg: #37474F;
    }

    .worry-input::placeholder {
        color: #78909C;
    }

    .category-select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%234A90A4' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
    }

    .cloud-text {
        color: #263238;
    }
}


/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */
@media (min-width: 640px) {
    .controls {
        padding: var(--sp-xl) var(--sp-lg);
        border-radius: var(--r-lg) var(--r-lg) 0 0;
    }

    .app-title {
        font-size: 1.6rem;
    }

    .app-subtitle {
        font-size: 0.875rem;
    }

    .worry-input {
        font-size: 1.0625rem;
        min-height: 58px;
    }

    .category-select,
    .release-btn {
        height: 52px;
    }

    .release-btn {
        padding: 0 var(--sp-xl);
        font-size: 1rem;
    }

    .cloud-text {
        font-size: 14px;
    }
}

@media (min-width: 768px) {
    .page-app {
        max-width: 780px;
        margin: 0 auto;
        border-left: 1px solid rgba(0, 0, 0, 0.04);
        border-right: 1px solid rgba(0, 0, 0, 0.04);
    }

    .controls {
        padding: var(--sp-xl) var(--sp-2xl);
    }
}

@media (min-width: 1024px) {
    .cloud-text {
        font-size: 15px;
    }
}


/* ═══════════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .cloud.floating {
        animation: none;
        opacity: 0;
    }

    .cloud.spawning {
        animation: none;
        opacity: 1;
    }

    .sky-breath {
        animation: none;
        opacity: 0.5;
    }
}


/* ═══════════════════════════════════════════════
   LANDSCAPE + SMALL HEIGHT
   ═══════════════════════════════════════════════ */
@media (max-height: 500px) and (orientation: landscape) {
    .app-header {
        margin-bottom: var(--sp-sm);
    }

    .app-title {
        font-size: 1.125rem;
    }

    .app-subtitle {
        display: none;
    }

    .controls {
        padding: var(--sp-md);
    }

    .controls-footer {
        margin-top: var(--sp-sm);
        padding-top: var(--sp-xs);
    }
}

/* ═══════════════════════════════════════════════
   EVENING MODE
   ═══════════════════════════════════════════════ */
body.evening {
    --sky-top: #0B1026;
    --sky-mid: #2B32B2;
    --sky-bottom: #1488CC;
    --sky-breath: rgba(255, 255, 255, 0.05);

    --cloud-fill-1: #E0E0E0;
    --cloud-fill-2: #F5F5F5;
    --cloud-fill-3: #ECECEC;
    --cloud-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --cloud-glow: 0 0 15px rgba(255, 255, 255, 0.3);

    --ui-primary: #7eb8c9;
    --ui-primary-hover: #6aa8bb;
    --ui-primary-glow: rgba(126, 184, 201, 0.2);
    --ui-text: #e0e7ed;
    --ui-text-mid: #9fb3bf;
    --ui-text-light: #6d8594;
    --ui-surface: rgba(13, 27, 42, 0.95);
    --ui-surface-solid: #0f1f30;
    --ui-border: rgba(126, 184, 201, 0.1);
    --ui-input-bg: #142536;
    --ui-error: #ef9a9a;
    --ui-error-bg: rgba(239, 154, 154, 0.1);
}

/* Stars */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    background-image:
        radial-gradient(1.5px 1.5px at 10% 10%, #fff, transparent),
        radial-gradient(1px 1px at 20% 30%, #fff, transparent),
        radial-gradient(2px 2px at 30% 10%, #ddd, transparent),
        radial-gradient(1.5px 1.5px at 40% 40%, #fff, transparent),
        radial-gradient(1px 1px at 50% 20%, #fff, transparent),
        radial-gradient(2px 2px at 60% 80%, #ddd, transparent),
        radial-gradient(1.5px 1.5px at 70% 50%, #fff, transparent),
        radial-gradient(1px 1px at 80% 90%, #fff, transparent),
        radial-gradient(2px 2px at 90% 15%, #ddd, transparent),
        radial-gradient(1px 1px at 95% 60%, #fff, transparent);
    background-size: 550px 550px;
    opacity: 0;
    transition: opacity 3s ease;
}

body.evening::before {
    opacity: 0.7;
}