:root {
    --bg-light: #faf9f7;
    --bg-dark: #0b1120;
    --primary: #7c6ff7;
    --primary-soft: rgba(124, 111, 247, 0.08);
    --text-main: #1a1a2e;
    --text-muted: #8b8fa3;
    --text-dark: #e2e8f0;
    --glass: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(255, 255, 255, 0.3);
    --transition-base: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 1s cubic-bezier(0.4, 0, 0.2, 1);

    /* Mode colors */
    --color-pause: #7c6ff7;
    --color-slow: #f0a04b;
    --color-release: #5db9a8;
}

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

body {
    font-family: 'Outfit', 'Noto Serif SC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color var(--transition-slow), color var(--transition-base);
    -webkit-font-smoothing: antialiased;
}

body.mode-pause { background-color: #0b1120; color: #e2e8f0; }
body.mode-slow  { background-color: #1a120b; color: #f5e6d3; }
body.mode-release { background-color: #0a1a17; color: #d3e8e2; }

/* ── Ambient Background ── */
.ambient-layer {
    position: fixed; inset: 0; z-index: -2; overflow: hidden;
    transition: opacity var(--transition-slow);
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.35;
    transition: background 1s ease, opacity 1s ease;
    will-change: transform;
}

.blob-1 { width: 700px; height: 700px; background: #d4c5f9; top: -15%; left: -10%; animation: drift 35s infinite alternate ease-in-out; }
.blob-2 { width: 600px; height: 600px; background: #b8d8f0; bottom: -15%; right: -10%; animation: drift 40s infinite alternate-reverse ease-in-out; }
.blob-3 { width: 500px; height: 500px; background: #f5d0e4; top: 40%; left: 25%; animation: drift 28s infinite alternate ease-in-out; animation-delay: -5s; }
.blob-4 { width: 400px; height: 400px; background: #e0d9fc; bottom: 15%; left: 10%; animation: drift 30s infinite alternate ease-in-out; animation-delay: -12s; }

body.mode-pause .blob-1 { background: #1e1b4b; opacity: 0.25; }
body.mode-pause .blob-2 { background: #172554; opacity: 0.18; }
body.mode-pause .blob-3 { background: #3b0764; opacity: 0.16; }
body.mode-pause .blob-4 { background: #2e1065; opacity: 0.18; }

body.mode-slow .blob-1 { background: #3b2a1a; opacity: 0.25; }
body.mode-slow .blob-2 { background: #4a2c0e; opacity: 0.18; }
body.mode-slow .blob-3 { background: #5c3d1e; opacity: 0.16; }
body.mode-slow .blob-4 { background: #3d2008; opacity: 0.18; }

body.mode-release .blob-1 { background: #0d2a24; opacity: 0.25; }
body.mode-release .blob-2 { background: #0f3d34; opacity: 0.18; }
body.mode-release .blob-3 { background: #1a4a3e; opacity: 0.16; }
body.mode-release .blob-4 { background: #0e3530; opacity: 0.18; }

@keyframes drift {
    0%   { transform: translate(0, 0) scale(1) rotate(0deg); }
    100% { transform: translate(60px, 80px) scale(1.08) rotate(30deg); }
}

/* ── Particle Canvas ── */
#particle-canvas {
    position: fixed; inset: 0; z-index: -1; pointer-events: none;
    transform: translateZ(0);
}

/* ── App Layout ── */
#app {
    width: 100%; max-width: 460px; height: 90dvh;
    position: relative; padding: 1.5rem;
    display: flex; flex-direction: column;
}

.page {
    position: absolute; inset: 0;
    opacity: 0; pointer-events: none;
    transform: translateY(24px) scale(0.97);
    transition: opacity var(--transition-base), transform var(--transition-base);
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    padding: 1.5rem;
    contain: layout style;
}

.page.active {
    opacity: 1; pointer-events: auto;
    transform: translateY(0) scale(1);
}

.page-inner {
    width: 100%;
    display: flex; flex-direction: column;
    align-items: center; text-align: center;
}

/* ── Landing Page ── */
.logo-mark {
    font-size: 2.75rem; color: var(--primary);
    margin-bottom: 1.5rem;
    animation: gentle-pulse 5s infinite ease-in-out;
    opacity: 0.75;
}

.landing-title {
    font-size: 3.25rem; font-weight: 700;
    margin-bottom: 1rem; letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--text-main) 30%, var(--primary));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}

.landing-subtitle {
    font-size: 1.1rem; line-height: 1.7;
    color: var(--text-muted); font-weight: 300;
    margin-bottom: 2.5rem;
}

/* ── Mode Cards ── */
.mode-cards {
    display: flex; flex-direction: column;
    gap: 0.85rem; width: 100%; max-width: 300px;
    margin-bottom: 1.5rem;
}

.mode-card {
    display: flex; align-items: center; gap: 1rem;
    width: 100%; padding: 1rem 1.5rem;
    border-radius: 18px; border: 1.5px solid rgba(0,0,0,0.06);
    background: rgba(255,255,255,0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: pointer;
    transition: all 0.35s ease;
    text-align: left;
    font-family: inherit;
}

.mode-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}

.mode-card:active {
    transform: scale(0.98);
}

.mode-icon {
    width: 44px; height: 44px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; position: relative;
}

/* ── 喘口气 icon: concentric ripple rings ── */
.icon-pause {
    background: rgba(124, 111, 247, 0.08);
    border: 1.5px solid rgba(124, 111, 247, 0.25);
}
.icon-pause::before {
    content: '';
    position: absolute;
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 1.5px solid rgba(124, 111, 247, 0.35);
}
.icon-pause::after {
    content: '';
    position: absolute;
    width: 5px; height: 5px;
    background: rgba(124, 111, 247, 0.7);
    border-radius: 50%;
}

/* ── 慢慢来 icon: compass cross ── */
.icon-slow {
    background: rgba(240, 160, 75, 0.08);
    border: 1.5px solid rgba(240, 160, 75, 0.25);
}
.icon-slow::before {
    content: '';
    position: absolute;
    width: 20px; height: 1px;
    background: rgba(240, 160, 75, 0.4);
}
.icon-slow::after {
    content: '';
    position: absolute;
    width: 1px; height: 20px;
    background: rgba(240, 160, 75, 0.4);
}

/* ── 放下吧 icon: dissolving dots ── */
.icon-release {
    background: rgba(93, 185, 168, 0.08);
    border: 1.5px dashed rgba(93, 185, 168, 0.25);
}
.icon-release::before {
    content: '';
    position: absolute;
    width: 3px; height: 3px;
    background: rgba(93, 185, 168, 0.7);
    border-radius: 50%;
    top: 10px; left: 50%;
    transform: translateX(-50%);
    box-shadow:
        16px 10px 0 rgba(93, 185, 168, 0.5),
        -16px 10px 0 rgba(93, 185, 168, 0.5),
        0 24px 0 rgba(93, 185, 168, 0.4);
}
.icon-release::after {
    content: '';
    position: absolute;
    width: 2px; height: 2px;
    background: rgba(93, 185, 168, 0.6);
    border-radius: 50%;
    top: 16px; left: 12px;
    box-shadow:
        18px 6px 0 rgba(93, 185, 168, 0.4),
        -6px 18px 0 rgba(93, 185, 168, 0.5);
}

.mode-name {
    font-size: 1.1rem; font-weight: 600;
    color: var(--text-main);
}

.mode-hint {
    font-size: 0.8rem; color: var(--text-muted);
    display: block; margin-top: 2px;
}

.mode-card .mode-text {
    display: flex; flex-direction: column;
}

/* ── Buttons ── */
.btn-main {
    padding: 1.1rem 3rem; border-radius: 100px;
    background: var(--primary); color: #fff;
    border: none; font-size: 1.05rem; font-weight: 600;
    cursor: pointer; display: flex; align-items: center;
    gap: 0.75rem;
    transition: all 0.3s ease;
    box-shadow: 0 8px 28px rgba(124, 111, 247, 0.28);
    letter-spacing: 0.02em;
}

.btn-main:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 16px 36px rgba(124, 111, 247, 0.38);
}

.btn-ghost {
    background: transparent; color: var(--text-muted);
    border: 1px solid var(--glass-border);
    padding: 0.7rem 2rem; border-radius: 100px;
    font-size: 0.85rem; cursor: pointer;
    transition: all 0.3s ease; margin-top: 2rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.btn-ghost:hover {
    background: var(--glass); color: var(--text-main);
}

body.mode-pause .btn-ghost { color: #94a3b8; border-color: rgba(255,255,255,0.08); }
body.mode-slow .btn-ghost { color: #b8a088; border-color: rgba(255,255,255,0.08); }
body.mode-release .btn-ghost { color: #8ab8a8; border-color: rgba(255,255,255,0.08); }

/* ── Core Visuals ── */
.core-wrap {
    width: 180px; height: 180px;
    margin-bottom: 3rem;
    display: flex; align-items: center; justify-content: center;
    position: relative;
}

/* ─────────────────────
   喘口气 · 呼吸涟漪
   ───────────────────── */
.core-pause .breath-ripple {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(124, 111, 247, 0.4);
    animation: breath-wave var(--speed-pause, 5s) ease-out infinite;
}

.core-pause .r1 { width: 30px; height: 30px; animation-delay: 0s; }
.core-pause .r2 { width: 30px; height: 30px; animation-delay: 1.2s; }
.core-pause .r3 { width: 30px; height: 30px; animation-delay: 2.4s; }
.core-pause .r4 { width: 30px; height: 30px; animation-delay: 3.6s; }

.core-pause .breath-nucleus {
    position: absolute;
    width: 5px; height: 5px;
    background: rgba(124, 111, 247, 0.8);
    border-radius: 50%;
    animation: nucleus-pulse var(--speed-pause, 5s) ease-in-out infinite;
}

@keyframes breath-wave {
    0%   { width: 20px; height: 20px; opacity: 0.7; }
    100% { width: 160px; height: 160px; opacity: 0; }
}

@keyframes nucleus-pulse {
    0%, 100% { transform: scale(1);   box-shadow: 0 0 8px rgba(124, 111, 247, 0.5); }
    50%      { transform: scale(1.8); box-shadow: 0 0 18px rgba(124, 111, 247, 0.8); }
}

/* ─────────────────────
   慢慢来 · 旋转罗盘
   ───────────────────── */
.core-slow .compass-ring {
    position: absolute;
    width: 130px; height: 130px;
    border-radius: 50%;
    border: 1.5px solid rgba(240, 160, 75, 0.3);
    animation: compass-spin var(--speed-slow, 24s) linear infinite;
}

.core-slow .compass-spoke {
    position: absolute;
    width: 1px; height: 50px;
    background: linear-gradient(to top, rgba(240, 160, 75, 0.5), rgba(240, 160, 75, 0.05));
    transform-origin: bottom center;
    bottom: 50%;
    left: calc(50% - 0.5px);
    opacity: 0;
}

.core-slow .s1 { transform: rotate(0deg);   animation: spoke-fade var(--speed-slow-spoke, 4s) 0s infinite ease-in-out; }
.core-slow .s2 { transform: rotate(60deg);  animation: spoke-fade var(--speed-slow-spoke, 4s) 0.7s infinite ease-in-out; }
.core-slow .s3 { transform: rotate(120deg); animation: spoke-fade var(--speed-slow-spoke, 4s) 1.4s infinite ease-in-out; }
.core-slow .s4 { transform: rotate(180deg); animation: spoke-fade var(--speed-slow-spoke, 4s) 2.1s infinite ease-in-out; }
.core-slow .s5 { transform: rotate(240deg); animation: spoke-fade var(--speed-slow-spoke, 4s) 2.8s infinite ease-in-out; }
.core-slow .s6 { transform: rotate(300deg); animation: spoke-fade var(--speed-slow-spoke, 4s) 3.5s infinite ease-in-out; }

.core-slow .compass-center {
    position: absolute;
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(240, 160, 75, 0.7);
    background: transparent;
    animation: center-glow var(--speed-slow-spoke, 4s) ease-in-out infinite;
    z-index: 2;
}

@keyframes compass-spin {
    to { transform: rotate(360deg); }
}

@keyframes spoke-fade {
    0%, 100% { opacity: 0.15; }
    50%      { opacity: 0.6; }
}

@keyframes center-glow {
    0%, 100% { box-shadow: 0 0 6px rgba(240, 160, 75, 0.2); border-color: rgba(240, 160, 75, 0.4); }
    50%      { box-shadow: 0 0 20px rgba(240, 160, 75, 0.5); border-color: rgba(240, 160, 75, 0.9); }
}

/* ─────────────────────
   放下吧 · 消散星环
   ───────────────────── */
.core-release .dust-ring {
    position: absolute;
    width: 100px; height: 100px;
    border-radius: 50%;
    border: 1px dashed rgba(93, 185, 168, 0.2);
    animation: dust-ring-spin var(--speed-release-ring, 30s) linear infinite;
}

.core-release .dust {
    position: absolute;
    width: 4px; height: 4px;
    background: rgba(93, 185, 168, 0.8);
    border-radius: 50%;
    animation: dust-drift var(--speed-release, 4s) ease-out infinite;
}

/* Scattered around the circle */
.core-release .d1 { top: 35px; left: 50%;  animation-delay: 0s; }
.core-release .d2 { top: 45px; left: 70%;  animation-delay: 0.5s; }
.core-release .d3 { top: 50%;  left: 78%;  animation-delay: 1.0s; }
.core-release .d4 { top: 68%;  left: 68%;  animation-delay: 1.5s; }
.core-release .d5 { top: 75px; left: 50%;  animation-delay: 2.0s; }
.core-release .d6 { top: 68%;  left: 32%;  animation-delay: 2.5s; }
.core-release .d7 { top: 50%;  left: 22%;  animation-delay: 3.0s; }
.core-release .d8 { top: 45px; left: 30%;  animation-delay: 3.5s; }

@keyframes dust-ring-spin {
    to { transform: rotate(360deg); }
}

@keyframes dust-drift {
    0%   { transform: scale(1); opacity: 0.9; }
    100% { transform: scale(0.2); opacity: 0; }
}

/* ── Quotes ── */
.quote-block {
    min-height: 90px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 1.5rem; padding: 0 0.5rem;
}

.quote-text {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.55rem; font-weight: 400;
    line-height: 1.6;
    transition: opacity 0.8s ease;
}

/* ── Timer ── */
.timer-row {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.95rem; margin-bottom: 2rem; opacity: 0.6;
}

.timer-val {
    font-variant-numeric: tabular-nums;
    font-weight: 600; letter-spacing: 0.08em;
}

/* ── Note ── */
.note-section { width: 100%; max-width: 320px; }

.note-toggle {
    background: none; border: none;
    font-size: 0.85rem; cursor: pointer;
    opacity: 0.6; transition: opacity 0.3s ease;
    display: flex; align-items: center; gap: 0.35rem;
    margin: 0 auto 0.75rem;
    font-family: inherit;
}

body.mode-pause .note-toggle { color: #a5b4fc; }
body.mode-slow .note-toggle { color: #f0c088; }
body.mode-release .note-toggle { color: #7ec8b0; }

.note-toggle:hover { opacity: 1; }

.note-area-wrap {
    max-height: 0; overflow: hidden;
    transition: max-height 0.45s ease-out;
}

.note-area-wrap.open { max-height: 180px; }

.note-area-wrap textarea {
    width: 100%; height: 110px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px; padding: 0.9rem;
    color: inherit; font-family: inherit;
    font-size: 0.9rem; resize: none; outline: none;
    transition: border-color 0.3s ease;
}

.note-area-wrap textarea:focus {
    border-color: rgba(255,255,255,0.2);
}

.note-area-wrap textarea::placeholder {
    color: inherit; opacity: 0.35;
}

/* ── Feedback ── */
.feedback-icon {
    width: 80px; height: 80px;
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    position: relative;
    animation: gentle-pulse 5s infinite ease-in-out;
}

.feedback-icon.fb-pause {
    background: rgba(124, 111, 247, 0.1);
    border: 2px solid rgba(124, 111, 247, 0.3);
}
.feedback-icon.fb-pause::before {
    content: '';
    position: absolute; inset: 14px;
    border-radius: 50%;
    border: 2px solid rgba(124, 111, 247, 0.35);
}
.feedback-icon.fb-pause::after {
    content: '';
    position: absolute;
    width: 8px; height: 8px;
    background: rgba(124, 111, 247, 0.7);
    border-radius: 50%;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}

.feedback-icon.fb-slow {
    background: rgba(240, 160, 75, 0.1);
    border: 2px solid rgba(240, 160, 75, 0.3);
}
.feedback-icon.fb-slow::before {
    content: '';
    position: absolute;
    width: 36px; height: 1.5px;
    background: rgba(240, 160, 75, 0.4);
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}
.feedback-icon.fb-slow::after {
    content: '';
    position: absolute;
    width: 1.5px; height: 36px;
    background: rgba(240, 160, 75, 0.4);
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}

.feedback-icon.fb-release {
    background: rgba(93, 185, 168, 0.1);
    border: 2px dashed rgba(93, 185, 168, 0.25);
}
.feedback-icon.fb-release::before {
    content: '';
    position: absolute;
    width: 4px; height: 4px;
    background: rgba(93, 185, 168, 0.7);
    border-radius: 50%;
    top: 18px; left: 50%;
    transform: translateX(-50%);
    box-shadow:
        24px 16px 0 rgba(93, 185, 168, 0.5),
        -24px 16px 0 rgba(93, 185, 168, 0.5),
        0 40px 0 rgba(93, 185, 168, 0.4);
}
.feedback-icon.fb-release::after {
    content: '';
    position: absolute;
    width: 3px; height: 3px;
    background: rgba(93, 185, 168, 0.6);
    border-radius: 50%;
    top: 28px; left: 20px;
    box-shadow:
        30px 8px 0 rgba(93, 185, 168, 0.4),
        -8px 28px 0 rgba(93, 185, 168, 0.5);
}

.feedback-title {
    font-size: 2.25rem; font-weight: 700; margin-bottom: 1rem;
}

.feedback-body {
    font-size: 1.05rem; color: var(--text-muted);
    margin-bottom: 2rem; line-height: 1.75; max-width: 320px;
    min-height: 3.5rem;
    transition: color 0.5s ease;
}

.feedback-body.loading {
    display: flex; align-items: center; justify-content: center;
}

.feedback-body.loading::after {
    content: '';
    width: 20px; height: 20px;
    border: 2px solid var(--primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.stats-row {
    display: flex; gap: 2.5rem; margin-bottom: 2rem;
}

.stat-item { display: flex; flex-direction: column; gap: 0.4rem; }

.stat-val {
    font-size: 1.85rem; font-weight: 700; color: var(--primary);
}

.stat-label {
    font-size: 0.75rem; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--text-muted);
}

.stat-divider { width: 1px; background: var(--glass-border); }

.gentle-remind {
    font-style: italic; margin-bottom: 2rem;
    opacity: 0.55; font-size: 0.95rem;
}

.feedback-actions { display: flex; gap: 1rem; }

/* Reveal button */
.btn-reveal {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid rgba(0,0,0,0.1);
    padding: 0.65rem 1.8rem;
    border-radius: 100px;
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.5s ease, transform 0.3s ease;
    margin-bottom: 1rem;
}

.btn-reveal:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-reveal.fade-out {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
}

/* Stats reveal: blurred → clear */
.stats-reveal {
    filter: blur(12px);
    opacity: 0;
    transition: filter 0.8s ease, opacity 0.8s ease;
}

.stats-reveal.revealed {
    filter: blur(0);
    opacity: 1;
}

.session-hint {
    font-size: 0.8rem; color: var(--text-muted); opacity: 0.55;
}

/* ── Animations ── */
@keyframes gentle-pulse {
    0%, 100% { opacity: 0.55; transform: scale(1); }
    50%      { opacity: 0.85; transform: scale(1.06); }
}

/* ── Mobile ── */
@media (max-width: 480px) {
    #app { padding: 1rem; height: 92dvh; }

    .landing-title { font-size: 2.5rem; }

    .landing-subtitle { font-size: 1rem; margin-bottom: 2rem; }

    .quote-text { font-size: 1.3rem; }

    .core-wrap { width: 150px; height: 150px; margin-bottom: 2.5rem; }

    .core-pause .breath-nucleus { width: 4px; height: 4px; }
    .core-slow .compass-ring { width: 110px; height: 110px; }
    .core-slow .compass-spoke { height: 42px; }
    .core-slow .compass-center { width: 11px; height: 11px; }
    .core-release .dust-ring { width: 80px; height: 80px; }
    .core-release .dust { width: 3px; height: 3px; }

    .mode-cards { max-width: 280px; gap: 0.7rem; }

    .mode-card {
        padding: 0.85rem 1.2rem;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(255,255,255,0.35);
    }

    .btn-ghost {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .blob { filter: none; opacity: 0.15; animation: none; }

    .page { transition: opacity 0.3s ease, transform 0.3s ease; }

    .core-pause .breath-ripple { animation-duration: 7s; }
    .logo-mark, .feedback-icon { animation: none; }
}

@media (max-width: 360px) {
    .landing-title { font-size: 2rem; }
    .quote-text { font-size: 1.15rem; }
    .core-wrap { width: 120px; height: 120px; }
    .core-pause .breath-nucleus { width: 3px; height: 3px; }
    .core-slow .compass-ring { width: 90px; height: 90px; }
    .core-slow .compass-spoke { height: 36px; }
    .core-slow .compass-center { width: 10px; height: 10px; }
    .core-release .dust-ring { width: 70px; height: 70px; }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .blob { animation: none; }
}
