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

/* ═══════════════════════════════════════════════
   FONT (Nunito variable — weights 300-600)
   ═══════════════════════════════════════════════ */
@font-face {
    font-family: 'Nunito';
    src: url('fonts/nunito-latin-ext.woff2') format('woff2');
    font-weight: 300 600;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Nunito';
    src: url('fonts/nunito-latin.woff2') format('woff2');
    font-weight: 300 600;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ═══════════════════════════════════════════════
   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: 'Nunito', -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;
}


/* ═══════════════════════════════════════════════
   SKIP LINK (accessibility)
   ═══════════════════════════════════════════════ */
.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    padding: 8px 16px;
    background: var(--ui-surface-solid);
    color: var(--ui-primary);
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-lg);
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 8px;
}

/* ═══════════════════════════════════════════════
   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-particles {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 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);
    }
}


/* ═══════════════════════════════════════════════
   CATEGORY DROP ZONES
   ═══════════════════════════════════════════════ */
.category-zones {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    padding-top: calc(12px + var(--safe-top));
    z-index: 20;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.category-zones.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.category-zone {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: rgba(255, 255, 255, 0.85);
    border-radius: var(--r-md);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.category-zone:hover,
.category-zone.active {
    transform: scale(1.15);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.category-zone.active {
    background: rgba(74, 144, 164, 0.2);
}

.category-zone.drop-hover {
    transform: scale(1.2);
    background: rgba(74, 144, 164, 0.3);
    box-shadow: 0 0 20px rgba(74, 144, 164, 0.4);
}

body.evening .category-zone {
    background: rgba(30, 50, 70, 0.85);
}

body.evening .category-zone.active,
body.evening .category-zone.drop-hover {
    background: rgba(126, 184, 201, 0.3);
}


/* ═══════════════════════════════════════════════
   CLOUD
   ═══════════════════════════════════════════════ */
.cloud {
    position: absolute;
    bottom: -150px;
    transform: translateX(-50%);
    pointer-events: auto;
    will-change: transform, opacity;
    contain: layout style paint;
    z-index: 1;
    /* Random sway params to be set by JS */
    --sway-duration: 4s;
    --sway-delay: 0s;
    --bob-duration: 3s;
    --bob-delay: 0s;
    --drift-x: 0px;
    --drift-x-mid-1: 0px;
    --drift-x-mid-2: 0px;
    --drift-x-mid-3: 0px;
    --drift-x-mid-4: 0px;
    --drift-y-wobble: 0px;
    --rotate-mid: 0deg;
    --drift-x-docked: 0px;
    --cloud-opacity: 1;
    --cloud-blur: 1px;
    --depth-scale: 1;
    --depth-opacity: 1;
    --depth-blur: 0px;
    opacity: calc(var(--cloud-opacity) * var(--depth-opacity));
    filter: blur(var(--depth-blur));
}

/* Depth layers */
.cloud[data-depth="1"] {
    z-index: 1;
}

.cloud[data-depth="2"] {
    z-index: 2;
}

.cloud[data-depth="3"] {
    z-index: 3;
}

.cloud-shape {
    position: absolute;
    inset: 0;
    filter:
        drop-shadow(0 14px 32px rgba(0, 0, 0, 0.1))
        drop-shadow(0 6px 16px rgba(255, 255, 255, 0.45))
        drop-shadow(0 -3px 10px rgba(255, 255, 255, 0.35))
        drop-shadow(var(--cloud-shadow));
    animation: cloudBob var(--bob-duration) ease-in-out infinite;
    animation-delay: var(--bob-delay);
}

.cloud-shape svg {
    width: 100%;
    height: 100%;
    display: block;
    filter:
        blur(var(--cloud-blur))
        drop-shadow(0 0 18px rgba(255, 255, 255, 0.55))
        drop-shadow(0 0 35px rgba(255, 255, 255, 0.3))
        drop-shadow(0 3px 12px rgba(0, 0, 0, 0.06))
        drop-shadow(var(--cloud-glow));
}

.cloud-text {
    position: absolute;
    top: 46%;
    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);
}

/* Multi-worry cloud text layout */
.cloud-worry-item {
    display: block;
}

.cloud-text-divider {
    display: block;
    width: 30%;
    height: 1px;
    background: rgba(0, 0, 0, 0.1);
    margin: 3px auto;
}

/* Category badge on clouds */
.cloud-category-badge {
    position: absolute;
    bottom: 4px;
    right: 4px;
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: 3;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.cloud:hover .cloud-category-badge,
.cloud[data-category="unsorted"] .cloud-category-badge {
    opacity: 0.6;
}

.cloud[data-category="unsorted"] .cloud-category-badge {
    opacity: 0.4;
}

.cloud[data-category="unsorted"]:hover .cloud-category-badge {
    opacity: 0.8;
}

/* Merge pulse animation */
@keyframes cloudMergePulse {
    0% { transform: translateX(-50%) scale(1); }
    40% { transform: translateX(-50%) scale(1.06); }
    100% { transform: translateX(-50%) scale(1); }
}

.cloud.cloud-merge-pulse {
    animation: cloudMergePulse 0.6s ease !important;
}

/* Drag-and-drop states */
.cloud.docked {
    cursor: grab;
}

.cloud.dragging {
    z-index: 50 !important;
    cursor: grabbing;
    opacity: 0.85;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.2));
    transition: none;
}

.cloud.drop-target.merge-ready {
    filter: drop-shadow(0 0 12px rgba(0, 200, 180, 0.6)) drop-shadow(0 0 24px rgba(0, 200, 180, 0.3));
}

.cloud.drop-target.merge-full {
    filter: drop-shadow(0 0 12px rgba(220, 50, 50, 0.5)) drop-shadow(0 0 24px rgba(220, 50, 50, 0.2));
}


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

    60% {
        transform: translateX(-50%) scale(calc(1.04 * var(--depth-scale, 1))) translateY(-4px);
    }

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

@keyframes cloudFloat {
    0% {
        transform: translateX(-50%) translateY(0) scale(var(--depth-scale)) rotate(0deg);
    }

    12% {
        transform: translateX(calc(-50% + var(--drift-x-mid-1) * 0.5)) translateY(calc(-12vh + var(--drift-y-wobble))) scale(var(--depth-scale)) rotate(calc(var(--rotate-mid) * 0.3));
    }

    28% {
        transform: translateX(calc(-50% + var(--drift-x-mid-1))) translateY(calc(-28vh + 15px)) scale(var(--depth-scale)) rotate(calc(var(--rotate-mid) * -0.5));
    }

    42% {
        transform: translateX(calc(-50% + var(--drift-x-mid-3))) translateY(calc(-42vh + var(--drift-y-wobble) * -1)) scale(var(--depth-scale)) rotate(calc(var(--rotate-mid) * 0.7));
    }

    58% {
        transform: translateX(calc(-50% + var(--drift-x-mid-2))) translateY(calc(-58vh + 40px)) scale(var(--depth-scale)) rotate(calc(var(--rotate-mid) * -0.4));
    }

    72% {
        transform: translateX(calc(-50% + var(--drift-x-mid-4))) translateY(calc(-72vh + 60px)) scale(var(--depth-scale)) rotate(calc(var(--rotate-mid) * 0.6));
    }

    88% {
        transform: translateX(calc(-50% + var(--drift-x) * 0.85)) translateY(calc(-88vh + 120px)) scale(var(--depth-scale)) rotate(calc(var(--rotate-mid) * -0.3));
    }

    100% {
        transform: translateX(calc(-50% + var(--drift-x))) translateY(calc(-100vh + 200px)) scale(var(--depth-scale)) rotate(-0.3deg);
    }
}

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

    100% {
        opacity: 0;
        transform: translateX(-50%) scale(calc(0.85 * var(--depth-scale, 1)));
    }
}

@keyframes cloudBob {

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

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

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

@keyframes cloudSway {

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

    50% {
        transform: translate(-50%, -50%) rotate(0.5deg);
    }
}

.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, 10s) cubic-bezier(0.33, 0.02, 0.18, 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);
}

/* Docked clouds are driven by JS Perlin wind — no CSS animation */
.cloud.docked {
    will-change: transform;
}

/* Cloud focus states */
.cloud.docked:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ui-primary-glow),
                0 0 20px rgba(255, 255, 255, 0.6);
}

/* High contrast mode support */
@media (forced-colors: active) {
    .cloud:focus-visible {
        outline: 2px solid CanvasText;
    }
}

.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) translateY(0);
        filter: blur(0px) brightness(1);
    }

    25% {
        opacity: 0.9;
        transform: translateX(-50%) scale(1.08) translateY(-8px);
        filter: blur(1px) brightness(1.15);
    }

    50% {
        opacity: 0.5;
        transform: translateX(-50%) scale(1.3) translateY(-18px);
        filter: blur(6px) brightness(1.3);
    }

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


/* ═══════════════════════════════════════════════
   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: 12px 12px;
    padding-left: calc(12px + var(--safe-left));
    padding-right: calc(12px + var(--safe-right));
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}


/* ═══════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════ */
.app-header {
    text-align: center;
    margin-bottom: 8px;
}

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

.app-title {
    font-size: 1.2rem;
    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.75rem;
    color: var(--ui-text-light);
    font-weight: 400;
    margin-top: 2px;
}


/* ═══════════════════════════════════════════════
   FORM
   ═══════════════════════════════════════════════ */
.worry-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group {
    position: relative;
}

.worry-input {
    width: 100%;
    min-height: 40px;
    padding: 10px 14px;
    padding-right: 56px;
    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: #607D8B;
}

.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;
}


/* ═══════════════════════════════════════════════
   CATEGORY CHIPS
   ═══════════════════════════════════════════════ */
.category-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-bottom: 8px;
}

.category-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    font-size: 1.1rem;
    background: var(--ui-input-bg);
    border: 1.5px solid var(--ui-border);
    border-radius: var(--r-pill);
    cursor: pointer;
    transition: all var(--t-fast);
    -webkit-tap-highlight-color: transparent;
}

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

.category-chip[aria-checked="true"] {
    background: var(--ui-primary);
    border-color: var(--ui-primary);
    box-shadow: 0 2px 8px rgba(74, 144, 164, 0.3);
}

.category-chip:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ui-primary-glow);
}


/* ═══════════════════════════════════════════════
   DISTORTION SECTION
   ═══════════════════════════════════════════════ */
.distortion-section {
    margin-bottom: 8px;
}

.distortion-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-family: inherit;
    color: var(--ui-text-light);
    background: transparent;
    border: 1px dashed var(--ui-border);
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: all var(--t-fast);
    -webkit-tap-highlight-color: transparent;
}

.distortion-toggle:hover {
    color: var(--ui-text-mid);
    border-color: var(--ui-text-light);
}

.distortion-toggle[aria-expanded="true"] .distortion-toggle-icon {
    transform: rotate(180deg);
}

.distortion-toggle-icon {
    transition: transform var(--t-fast);
}

.distortion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    padding: 8px;
    background: rgba(74, 144, 164, 0.03);
    border-radius: var(--r-sm);
}

.distortion-chips[hidden] {
    display: none;
}

.distortion-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    font-size: 0.6875rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--ui-text-mid);
    background: var(--ui-input-bg);
    border: 1px solid var(--ui-border);
    border-radius: var(--r-pill);
    cursor: pointer;
    transition: all var(--t-fast);
    -webkit-tap-highlight-color: transparent;
}

.distortion-chip:hover {
    border-color: var(--ui-primary);
    color: var(--ui-primary);
}

.distortion-chip[aria-checked="true"] {
    background: rgba(74, 144, 164, 0.12);
    border-color: var(--ui-primary);
    color: var(--ui-primary);
}

.distortion-chip:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--ui-primary-glow);
}


/* ═══════════════════════════════════════════════
   FORM ROW
   ═══════════════════════════════════════════════ */
.form-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
}

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

.category-select {
    width: 100%;
    height: 40px;
    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);
    min-height: 44px;
    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: 8px;
    padding-top: 6px;
    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 {
    min-height: 44px;
    padding: 8px 16px;
    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;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 6px 8px;
    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: 44px;
    height: 44px;
    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);
}

.custom-categories-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: var(--sp-md);
}

.custom-category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-sm) 0;
    border-bottom: 1px solid var(--ui-border);
}

.custom-category-item:last-child {
    border-bottom: none;
}

.custom-category-name {
    font-size: 0.8125rem;
    color: var(--ui-text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.custom-category-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-size: 0.875rem;
    color: var(--ui-text-light);
    background: transparent;
    border: none;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: all var(--t-fast);
}

.custom-category-delete:hover {
    color: var(--ui-error);
    background: var(--ui-error-bg);
}

body.evening .distortion-chips {
    background: rgba(126, 184, 201, 0.05);
}

body.evening .distortion-chip[aria-checked="true"] {
    background: rgba(126, 184, 201, 0.15);
    border-color: var(--ui-primary);
    color: var(--ui-primary);
}

.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");
}

body.evening .cloud-text-divider {
    background: rgba(255, 255, 255, 0.15);
}

body.evening .cloud-category-badge {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

body.evening .cloud.drop-target.merge-ready {
    filter: drop-shadow(0 0 12px rgba(100, 220, 220, 0.5)) drop-shadow(0 0 24px rgba(100, 220, 220, 0.25));
}

body.evening .cloud.drop-target.merge-full {
    filter: drop-shadow(0 0 12px rgba(255, 100, 100, 0.5)) drop-shadow(0 0 24px rgba(255, 100, 100, 0.2));
}

body.evening .bottom-nav {
    background: rgba(0, 0, 0, 0.25);
}

body.evening .nav-link {
    color: rgba(255, 255, 255, 0.7);
}

body.evening .nav-link:hover {
    color: #7eb8c9;
}

body.evening .nav-dot {
    color: rgba(255, 255, 255, 0.35);
}


/* ═══════════════════════════════════════════════
   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;
    }

    .bottom-nav {
        background: rgba(0, 0, 0, 0.15);
    }

    .nav-link {
        color: #B0BEC5;
    }

    .nav-dot {
        color: #78909C;
    }
}


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

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

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

    .worry-input {
        font-size: 1rem;
        min-height: 44px;
    }

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

    .release-btn {
        padding: 0 18px;
        font-size: 0.95rem;
    }

    .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: 18px 24px;
    }
}

@media (max-width: 480px) {
    .app-subtitle {
        display: none;
    }
}

@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;
    }

    .cloud.drop-target.merge-ready {
        filter: none;
        outline: 2px solid rgba(0, 200, 180, 0.8);
        outline-offset: 4px;
    }

    .cloud.drop-target.merge-full {
        filter: none;
        outline: 2px solid rgba(220, 50, 50, 0.7);
        outline-offset: 4px;
    }

    .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 — layer 1 */
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;
}

/* Stars — layer 2 (larger tile, different offsets) */
body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    background-image:
        radial-gradient(1px 1px at 5% 45%, #fff, transparent),
        radial-gradient(2px 2px at 15% 75%, #eee, transparent),
        radial-gradient(1.5px 1.5px at 25% 55%, #fff, transparent),
        radial-gradient(1px 1px at 35% 15%, #fff, transparent),
        radial-gradient(2px 2px at 45% 85%, #ddd, transparent),
        radial-gradient(1.5px 1.5px at 55% 35%, #fff, transparent),
        radial-gradient(1px 1px at 65% 65%, #fff, transparent),
        radial-gradient(2px 2px at 75% 25%, #eee, transparent),
        radial-gradient(1.5px 1.5px at 85% 50%, #fff, transparent),
        radial-gradient(1px 1px at 92% 80%, #fff, transparent);
    background-size: 700px 700px;
    opacity: 0;
    transition: opacity 3s ease;
}

@keyframes starTwinkle1 {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 0.3; }
}

@keyframes starTwinkle2 {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.9; }
}

body.evening::before {
    opacity: 0.7;
    animation: starTwinkle1 8s ease-in-out infinite;
}

body.evening::after {
    opacity: 0.5;
    animation: starTwinkle2 12s ease-in-out infinite;
}

/* ═════════════════════════════════════════════
   ONBOARDING HINT
   ═════════════════════════════════════════════ */

.onboarding-hint {
    padding: var(--sp-sm) var(--sp-md);
    margin-bottom: var(--sp-sm);
    background: rgba(74, 144, 164, 0.08);
    border-radius: var(--r-md);
    text-align: center;
    font-size: 0.8125rem;
    color: var(--ui-text-mid);
    line-height: 1.5;
    animation: hintFadeIn 0.5s ease;
}

.onboarding-hint p {
    margin: 0;
}

.onboarding-hint.hidden {
    display: none;
}

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