/* ============================================
   STUDYVERSE — AMBIENT SPATIAL GLASS UI
   Futuristic · Japanese Zen · Immersive
   ============================================ */

/* ── CSS Variables — Spatial Glass Palette ── */
:root {
    /* Base Backgrounds - Deep & Atmospheric */
    --bg-primary: #050510;
    --bg-secondary: #0a0a1a;
    --bg-deep: #020205;

    /* Glass System - Multi-layered & Frosted */
    --glass-heavy: rgba(20, 20, 35, 0.7);
    --glass-medium: rgba(255, 255, 255, 0.05);
    --glass-light: rgba(255, 255, 255, 0.08);
    --glass-subtle: rgba(255, 255, 255, 0.03);

    /* Borders & Highlights - Rim Lighting */
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-light: rgba(255, 255, 255, 0.15);
    --glass-shine: rgba(255, 255, 255, 0.2);

    /* Typography */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    --font-jp: 'Noto Serif JP', serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Text Colors */
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b0;
    --text-muted: #606075;
    --text-accent: #ffffff;

    /* Accent Palette - Neon & Pastel Fusion */
    --accent-primary: #8b5cf6;
    /* Violet */
    --accent-secondary: #ec4899;
    /* Pink */
    --accent-tertiary: #10b981;
    /* Emerald */
    --accent-quaternary: #f59e0b;
    /* Amber */

    /* Gradients */
    --gradient-main: linear-gradient(135deg, rgba(139, 92, 246, 0.9), rgba(236, 72, 153, 0.9));
    --gradient-glow: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(236, 72, 153, 0.3));
    --gradient-glass: linear-gradient(145deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.01) 100%);
    --gradient-border: linear-gradient(145deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.02) 100%);

    /* Shapes & Spacing */
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 32px;
    --radius-xl: 48px;
    --radius-pill: 9999px;

    /* Spatial Depth Shadows */
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.4), 0 4px 8px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6), 0 8px 16px rgba(0, 0, 0, 0.3);
    --shadow-neon: 0 0 20px rgba(139, 92, 246, 0.4);

    /* Animations */
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);

    /* ── Legacy Compatibility (Aliases) ── */
    --accent-gradient: var(--gradient-main);
    --accent-1: var(--accent-primary);
    --accent-2: rgba(139, 92, 246, 0.6);
    /* Lighter violet */
    --accent-3: var(--accent-tertiary);
    --accent-4: var(--accent-secondary);
    --accent-5: var(--accent-quaternary);
    --sakura: var(--accent-secondary);
    --wisteria: var(--accent-primary);
    --bamboo: var(--accent-tertiary);
    --koi-gold: var(--accent-quaternary);
    --text-primary-jp: var(--text-primary);
}

/* ── Light Mode — Minimal Zen ── */
[data-theme="light"] {
    --bg-primary: #f2f4f8;
    --bg-secondary: #ffffff;
    --bg-deep: #e8ebf2;

    --glass-heavy: rgba(255, 255, 255, 0.85);
    --glass-medium: rgba(255, 255, 255, 0.6);
    --glass-light: rgba(255, 255, 255, 0.8);
    --glass-subtle: rgba(255, 255, 255, 0.4);

    --glass-border: rgba(0, 0, 0, 0.06);
    --glass-border-light: rgba(255, 255, 255, 1);
    --glass-shine: rgba(255, 255, 255, 0.8);

    --text-primary: #1a1a2e;
    --text-secondary: #505065;
    --text-muted: #9090a5;

    --shadow-sm: 0 4px 12px rgba(20, 20, 40, 0.04);
    --shadow-md: 0 12px 32px rgba(20, 20, 40, 0.08);
    --shadow-lg: 0 24px 64px rgba(20, 20, 40, 0.12);
    --shadow-neon: 0 0 20px rgba(139, 92, 246, 0.2);
}

/* ── Global Updates ── */
body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    letter-spacing: -0.01em;
    overflow-x: hidden;
}

/* Enhanced Background Gradient */
.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background:
        radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(236, 72, 153, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.05) 0%, transparent 50%),
        var(--bg-primary);
    filter: blur(80px);
    animation: bgPulse 20s ease-in-out infinite alternate;
}

@keyframes bgPulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    100% {
        transform: scale(1.1);
        opacity: 1;
    }
}

[data-theme="light"] .bg-gradient {
    background:
        radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(236, 72, 153, 0.08) 0%, transparent 40%),
        var(--bg-primary);
}

/* Ambient Kanji Updates */
.ambient-kanji .kanji-float {
    color: var(--text-primary);
    opacity: 0.03;
    font-weight: 800;
    filter: blur(2px);
}

[data-theme="light"] .ambient-kanji .kanji-float {
    color: var(--text-primary);
    opacity: 0.04;
}

/* ── Theme Toggle Button ── */
.theme-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: var(--glass);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.theme-toggle:hover {
    background: rgba(167, 139, 250, 0.15);
    border-color: var(--accent-1);
    transform: rotate(15deg) scale(1.1);
    box-shadow: 0 4px 20px rgba(167, 139, 250, 0.3);
}

.theme-icon {
    font-size: 18px;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: block;
}

.theme-toggle:active .theme-icon {
    transform: rotate(360deg);
}

.login-theme-toggle {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 10;
}

/* ── Reset & Base ── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.7;
    font-size: 15.5px;
    letter-spacing: -0.015em;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-2);
}

/* ── Ambient Floating Kanji ── */
.ambient-kanji {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.kanji-float {
    position: absolute;
    font-family: var(--font-jp);
    font-weight: 700;
    color: rgba(167, 139, 250, 0.035);
    user-select: none;
    animation: kanjiDrift 30s ease-in-out infinite;
}

.k1 {
    font-size: 120px;
    top: 8%;
    left: 5%;
    animation-delay: 0s;
    animation-duration: 35s;
}

.k2 {
    font-size: 90px;
    top: 60%;
    right: 8%;
    animation-delay: -5s;
    animation-duration: 28s;
}

.k3 {
    font-size: 150px;
    bottom: 15%;
    left: 15%;
    animation-delay: -10s;
    animation-duration: 40s;
}

.k4 {
    font-size: 80px;
    top: 25%;
    right: 20%;
    animation-delay: -15s;
    animation-duration: 32s;
}

.k5 {
    font-size: 100px;
    top: 70%;
    left: 60%;
    animation-delay: -8s;
    animation-duration: 36s;
}

.k6 {
    font-size: 70px;
    top: 40%;
    left: 40%;
    animation-delay: -20s;
    animation-duration: 38s;
}

.k7 {
    font-size: 130px;
    bottom: 30%;
    right: 15%;
    animation-delay: -12s;
    animation-duration: 33s;
}

.k8 {
    font-size: 85px;
    top: 5%;
    left: 70%;
    animation-delay: -18s;
    animation-duration: 37s;
}

@keyframes kanjiDrift {

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

    25% {
        transform: translateY(-20px) rotate(3deg);
        opacity: 1;
    }

    50% {
        transform: translateY(10px) rotate(-2deg);
        opacity: 0.7;
    }

    75% {
        transform: translateY(-10px) rotate(1deg);
        opacity: 0.9;
    }
}

/* ── Particle Canvas ── */
#particles-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* ── Animated Background — Aurora Zen ── */
.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background:
        radial-gradient(ellipse at 15% 50%, rgba(167, 139, 250, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 85% 20%, rgba(52, 211, 153, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 40% 80%, rgba(247, 168, 196, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 65%, rgba(99, 102, 241, 0.05) 0%, transparent 40%),
        var(--bg-primary);
    animation: auroraShift 25s ease-in-out infinite alternate;
}

@keyframes auroraShift {
    0% {
        background:
            radial-gradient(ellipse at 15% 50%, rgba(167, 139, 250, 0.1) 0%, transparent 50%),
            radial-gradient(ellipse at 85% 20%, rgba(52, 211, 153, 0.06) 0%, transparent 50%),
            radial-gradient(ellipse at 40% 80%, rgba(247, 168, 196, 0.06) 0%, transparent 50%),
            radial-gradient(ellipse at 70% 65%, rgba(99, 102, 241, 0.05) 0%, transparent 40%),
            var(--bg-primary);
    }

    50% {
        background:
            radial-gradient(ellipse at 60% 30%, rgba(247, 168, 196, 0.08) 0%, transparent 50%),
            radial-gradient(ellipse at 20% 70%, rgba(167, 139, 250, 0.08) 0%, transparent 50%),
            radial-gradient(ellipse at 80% 55%, rgba(52, 211, 153, 0.07) 0%, transparent 50%),
            radial-gradient(ellipse at 45% 40%, rgba(251, 191, 36, 0.04) 0%, transparent 40%),
            var(--bg-primary);
    }

    100% {
        background:
            radial-gradient(ellipse at 40% 60%, rgba(167, 139, 250, 0.12) 0%, transparent 50%),
            radial-gradient(ellipse at 75% 35%, rgba(247, 168, 196, 0.07) 0%, transparent 50%),
            radial-gradient(ellipse at 25% 25%, rgba(52, 211, 153, 0.08) 0%, transparent 50%),
            radial-gradient(ellipse at 60% 80%, rgba(99, 102, 241, 0.05) 0%, transparent 40%),
            var(--bg-primary);
    }
}

.app-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--glass-heavy);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-top: 1px solid var(--glass-border-light);
    border-radius: var(--radius-xl);
    padding: 64px 48px;
    max-width: 480px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg), var(--shadow-neon);
    animation: cardFloat 6s ease-in-out infinite alternate;
    position: relative;
    overflow: hidden;
    transform-style: preserve-3d;
}

.login-card::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: var(--accent-gradient);
    border-radius: var(--radius-xl);
    z-index: -1;
    opacity: 0;
    transition: opacity var(--transition-smooth);
}

.login-card:hover::before {
    opacity: 0.25;
}

.card-wave-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    color: var(--accent-1);
}

.card-wave-top svg {
    width: 100%;
    height: 40px;
    display: block;
}

@keyframes cardFloat {
    0% {
        transform: translateY(0px) rotateX(0deg);
    }

    100% {
        transform: translateY(-20px) rotateX(2deg);
    }
}

.login-icon {
    width: 90px;
    height: 90px;
    margin: 0 auto 20px;
    background: var(--accent-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    animation: iconPulse 3s ease-in-out infinite;
    box-shadow: 0 0 40px rgba(167, 139, 250, 0.35), 0 0 80px rgba(167, 139, 250, 0.1);
}

@keyframes iconPulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 40px rgba(167, 139, 250, 0.35);
    }

    50% {
        transform: scale(1.06);
        box-shadow: 0 0 60px rgba(167, 139, 250, 0.5);
    }
}

.login-title {
    font-family: var(--font-heading);
    font-size: 34px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--accent-primary);
    letter-spacing: -0.03em;
    text-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
}

.login-subtitle-jp {
    font-family: var(--font-jp);
    font-size: 14px;
    color: var(--accent-2);
    margin-bottom: 8px;
    letter-spacing: 0.3em;
    font-weight: 400;
    opacity: 0.8;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 36px;
    line-height: 1.6;
}

.google-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 15px 36px;
    background: white;
    color: #333;
    border: none;
    border-radius: 50px;
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-smooth);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.google-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition-smooth);
    border-radius: 50px;
}

.google-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(167, 139, 250, 0.25);
}

.google-btn:hover::after {
    opacity: 0.1;
}

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

.google-btn img {
    width: 24px;
    height: 24px;
}

.login-footer {
    margin-top: 28px;
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 500;
    opacity: 0.9;
}

.login-credits {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
}

.credits-text {
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    letter-spacing: 0.3px;
    font-weight: 500;
    opacity: 0.9;
}

.credits-text strong {
    color: var(--accent-1);
    font-weight: 700;
}

.credits-links {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.credit-link {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    text-decoration: none;
    transition: all var(--transition-smooth);
}

/* Social icon base */
.social-icon {
    transition: all var(--transition-smooth);
}

/* ── GitHub — Official mark ── */
.github-icon {
    fill: #e6edf3;
}

.credit-github:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 24px rgba(255, 255, 255, 0.12);
}

.credit-github:hover .github-icon {
    fill: #ffffff;
}

/* ── Email / Gmail — Official red ── */
.email-icon {
    fill: #EA4335;
}

.credit-email:hover {
    background: rgba(234, 67, 53, 0.12);
    border-color: rgba(234, 67, 53, 0.35);
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 24px rgba(234, 67, 53, 0.25);
}

.credit-email:hover .email-icon {
    fill: #ff5145;
}

/* ── LinkedIn — Official blue ── */
.linkedin-icon {
    fill: #0A66C2;
}

.credit-linkedin:hover {
    background: rgba(10, 102, 194, 0.12);
    border-color: rgba(10, 102, 194, 0.35);
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 24px rgba(10, 102, 194, 0.25);
}

.credit-linkedin:hover .linkedin-icon {
    fill: #1a90ff;
}

/* ── Light mode social icon overrides ── */
[data-theme="light"] .github-icon {
    fill: #24292f;
}

[data-theme="light"] .credit-github:hover {
    background: rgba(36, 41, 47, 0.08);
    border-color: rgba(36, 41, 47, 0.2);
    box-shadow: 0 8px 24px rgba(36, 41, 47, 0.15);
}

[data-theme="light"] .credit-github:hover .github-icon {
    fill: #000000;
}

[data-theme="light"] .email-icon {
    fill: #EA4335;
}

[data-theme="light"] .credit-email:hover {
    background: rgba(234, 67, 53, 0.08);
    box-shadow: 0 8px 24px rgba(234, 67, 53, 0.15);
}

[data-theme="light"] .linkedin-icon {
    fill: #0A66C2;
}

[data-theme="light"] .credit-linkedin:hover {
    background: rgba(10, 102, 194, 0.08);
    box-shadow: 0 8px 24px rgba(10, 102, 194, 0.15);
}

/* ============================================
   DASHBOARD
   ============================================ */
.dashboard {
    display: none;
    min-height: 100vh;
    padding-bottom: 40px;
}

.dashboard.active {
    display: block;
    animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ── Navbar ── */
/* ── Navbar ── */
.navbar {
    position: sticky;
    top: 20px;
    z-index: 100;
    margin: 0 24px 20px;
    background: var(--glass-heavy);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-bottom: 1px solid var(--glass-border);
    border-radius: var(--radius-pill);
    padding: 12px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideDown 0.8s var(--ease-out-back);
    box-shadow: var(--shadow-md);
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

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

.nav-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.nav-brand-icon {
    width: 44px;
    height: 44px;
    background: var(--accent-gradient);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 16px rgba(167, 139, 250, 0.3);
    transition: all var(--transition-smooth);
}

.nav-brand-icon:hover {
    transform: rotate(-5deg) scale(1.08);
    box-shadow: 0 6px 24px rgba(167, 139, 250, 0.4);
}

.nav-brand-text-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.nav-brand-text {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
    text-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
}

.nav-brand-jp {
    font-family: var(--font-jp);
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.15em;
    line-height: 1;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-user-info {
    text-align: right;
}

.nav-user-name {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.nav-user-email {
    font-size: 11px;
    color: var(--text-muted);
}

.nav-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid var(--accent-1);
    object-fit: cover;
    transition: all var(--transition-smooth);
}

.nav-avatar:hover {
    border-color: var(--accent-3);
    box-shadow: 0 0 24px rgba(52, 211, 153, 0.4);
    transform: scale(1.05);
}

.btn-signout {
    padding: 8px 22px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    font-family: var(--font-body);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-smooth);
}

.btn-signout:hover {
    background: rgba(247, 168, 196, 0.12);
    border-color: var(--accent-4);
    color: var(--accent-4);
}

/* ── Main Content ── */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* ── Japanese Section Labels ── */
.section-label-jp {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    margin-top: 8px;
}

.section-label-jp .label-kanji {
    font-family: var(--font-jp);
    font-size: 42px;
    font-weight: 700;
    color: rgba(167, 139, 250, 0.08);
    line-height: 1;
    user-select: none;
}

.section-label-jp .label-text {
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--text-muted);
}

.section-label-jp .label-line {
    flex: 1;
    height: 1px;
    background: var(--glass-border);
}

/* ── Stats Row ── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 36px;
}

.stat-card {
    background: var(--glass-subtle);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-top: 1px solid var(--glass-border-light);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-smooth);
    animation: staggerIn 0.6s var(--ease-out-back) both;
    box-shadow: var(--shadow-sm);
}

.stat-card:nth-child(1) {
    animation-delay: 0.1s;
}

.stat-card:nth-child(2) {
    animation-delay: 0.2s;
}

.stat-card:nth-child(3) {
    animation-delay: 0.3s;
}

.stat-card:nth-child(4) {
    animation-delay: 0.4s;
}

@keyframes staggerIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

.stat-card:hover {
    transform: translateY(-6px);
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-glow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    border-color: rgba(167, 139, 250, 0.25);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 3px 3px 0 0;
}

.stat-card:nth-child(1)::after {
    background: var(--accent-gradient);
}

.stat-card:nth-child(2)::after {
    background: linear-gradient(90deg, var(--accent-3), #6ee7b7);
}

.stat-card:nth-child(3)::after {
    background: var(--accent-gradient-warm);
}

.stat-card:nth-child(4)::after {
    background: linear-gradient(90deg, var(--accent-5), #f97316);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 16px;
}

.stat-card:nth-child(1) .stat-icon {
    background: rgba(167, 139, 250, 0.15);
}

.stat-card:nth-child(2) .stat-icon {
    background: rgba(52, 211, 153, 0.15);
}

.stat-card:nth-child(3) .stat-icon {
    background: rgba(247, 168, 196, 0.15);
}

.stat-card:nth-child(4) .stat-icon {
    background: rgba(251, 191, 36, 0.15);
}

.stat-value {
    font-family: var(--font-body);
    font-size: 34px;
    font-weight: 800;
    margin-bottom: 4px;
    color: var(--accent-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    text-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

/* ── Section Header ── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: -0.02em;
}

.section-title .icon {
    font-size: 28px;
}

/* ── Add Entry Button ── */
.btn-add {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: 50px;
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-smooth);
    box-shadow: 0 4px 24px rgba(167, 139, 250, 0.35);
    position: relative;
    overflow: hidden;
}

.btn-add::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
    opacity: 0;
    transition: opacity var(--transition-smooth);
}

.btn-add:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 36px rgba(167, 139, 250, 0.5);
}

.btn-add:hover::before {
    opacity: 1;
}

.btn-add:active {
    transform: translateY(0) scale(0.97);
}

/* ── Progress Bar ── */
.progress-section {
    background: var(--glass-subtle);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-top: 1px solid var(--glass-border-light);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 40px;
    animation: staggerIn 0.6s var(--ease-out-back) 0.3s both;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.progress-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glass-shine), transparent);
    opacity: 0.5;
}

.progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.progress-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-percentage {
    font-family: var(--font-body);
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-3);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.progress-bar-container {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: var(--gradient-main);
    border-radius: 50px;
    transition: width 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    box-shadow: 0 0 16px rgba(139, 92, 246, 0.5);
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.progress-details {
    display: flex;
    gap: 24px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.progress-detail {
    font-size: 13px;
    color: var(--text-secondary);
}

.progress-detail span {
    color: var(--accent-2);
    font-weight: 600;
}

/* ── Entries Feed ── */
.entries-feed {
    display: grid;
    gap: 20px;
}

.entry-card {
    background: var(--glass-subtle);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-top: 1px solid var(--glass-border-light);
    border-radius: var(--radius-lg);
    padding: 32px;
    transition: all var(--transition-smooth);
    animation: entrySlideIn 0.6s var(--ease-out-back) both;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

@keyframes entrySlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

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

.entry-card:hover {
    transform: translateY(-6px) scale(1.01);
    background: var(--glass-light);
    box-shadow: var(--shadow-md), var(--shadow-neon);
    border-color: rgba(139, 92, 246, 0.3);
    z-index: 1;
}

.entry-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--gradient-main);
    opacity: 0.8;
}

.entry-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.entry-date {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--accent-2);
    font-weight: 600;
}

.entry-date .icon {
    font-size: 18px;
}

.entry-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 38px;
    height: 38px;
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: rgba(247, 168, 196, 0.12);
    border-color: var(--accent-4);
    color: var(--accent-4);
}

.btn-icon.edit:hover {
    background: rgba(167, 139, 250, 0.12);
    border-color: var(--accent-1);
    color: var(--accent-1);
}

.entry-body {
    margin-bottom: 12px;
}

.entry-text {
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.7;
    white-space: pre-wrap;
}

.entry-images {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.entry-image {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-md);
    object-fit: cover;
    border: 2px solid var(--glass-border);
    cursor: pointer;
    transition: all var(--transition-smooth);
}

.entry-image:hover {
    transform: scale(1.06);
    border-color: var(--accent-1);
    box-shadow: 0 0 24px rgba(167, 139, 250, 0.35);
}

.entry-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.entry-tag {
    font-family: var(--font-body);
    padding: 4px 14px;
    background: rgba(167, 139, 250, 0.12);
    color: var(--accent-2);
    border-radius: 50px;
    font-size: 12px;
    font-weight: 500;
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    animation: fadeIn 0.8s ease-out;
}

.empty-icon {
    font-size: 72px;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

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

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

.empty-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-text {
    color: var(--text-secondary);
    font-size: 15px;
    max-width: 400px;
    margin: 0 auto;
}

/* ── Footer ── */
.footer-wave {
    position: relative;
    color: var(--accent-1);
    margin-top: 40px;
}

.footer-wave svg {
    width: 100%;
    height: 60px;
    display: block;
}

.footer-text {
    text-align: center;
    font-family: var(--font-jp);
    font-size: 13px;
    color: var(--text-muted);
    padding: 12px 0 24px;
    letter-spacing: 0.15em;
    opacity: 0.6;
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    background: var(--glass-heavy);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-top: 1px solid var(--glass-border-light);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg), var(--shadow-neon);
    animation: modalSlideUp 0.6s var(--ease-out-back);
    position: relative;
    transform-style: preserve-3d;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.95);
    }

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px 0;
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.02em;
}

.btn-close {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.btn-close:hover {
    background: rgba(247, 168, 196, 0.15);
    color: var(--accent-4);
    border-color: var(--accent-4);
}

.modal-body {
    padding: 24px 28px;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    font-family: var(--font-heading);
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15);
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

.form-textarea {
    min-height: 140px;
    resize: vertical;
    line-height: 1.6;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a0a0c0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
}

.form-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Image Upload */
.upload-area {
    border: 2px dashed var(--glass-border);
    border-radius: var(--radius-md);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-smooth);
    position: relative;
}

.upload-area:hover {
    border-color: var(--accent-1);
    background: rgba(167, 139, 250, 0.04);
}

.upload-area.dragover {
    border-color: var(--accent-3);
    background: rgba(52, 211, 153, 0.04);
    transform: scale(1.01);
}

.upload-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.upload-text {
    font-size: 14px;
    color: var(--text-secondary);
}

.upload-text span {
    color: var(--accent-2);
    font-weight: 600;
}

.upload-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.image-previews {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.image-preview {
    position: relative;
    width: 90px;
    height: 90px;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--glass-border);
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: rgba(247, 168, 196, 0.9);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.image-preview:hover .remove-btn {
    opacity: 1;
}

.modal-footer {
    padding: 0 28px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn-cancel {
    padding: 12px 24px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.btn-save {
    padding: 12px 32px;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: 50px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-smooth);
    box-shadow: 0 4px 20px rgba(167, 139, 250, 0.3);
}

.btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(167, 139, 250, 0.45);
}

.btn-save:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── Image Lightbox ── */
.lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(12px);
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.lightbox-overlay.active {
    display: flex;
    animation: modalFadeIn 0.3s ease-out;
}

.lightbox-overlay img {
    max-width: 90%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

/* ── Toast ── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    backdrop-filter: blur(16px);
}

.toast.success {
    border-left: 4px solid var(--accent-3);
}

.toast.error {
    border-left: 4px solid var(--accent-4);
}

.toast.info {
    border-left: 4px solid var(--accent-1);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(60px);
    }

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

.toast.removing {
    animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(60px);
    }
}

/* ── Loading Spinner ── */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(10, 10, 26, 0.92);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(167, 139, 250, 0.15);
    border-top: 3px solid var(--accent-1);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ── Streak Fire ── */
.streak-fire {
    display: inline-block;
    animation: fireFlicker 0.5s ease-in-out infinite alternate;
}

@keyframes fireFlicker {
    from {
        transform: scale(1) rotate(-2deg);
    }

    to {
        transform: scale(1.1) rotate(2deg);
    }
}

/* ── Entry Type Toggle ── */
.entry-type-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    padding: 4px;
    margin-bottom: 24px;
    position: relative;
}

.toggle-option {
    flex: 1;
    padding: 10px 20px;
    text-align: center;
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 50px;
    transition: all var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    user-select: none;
    z-index: 1;
}

.toggle-option:hover {
    color: var(--text-secondary);
}

.toggle-option.active {
    color: white;
    background: var(--accent-gradient);
    box-shadow: 0 4px 16px rgba(167, 139, 250, 0.3);
}

.toggle-option.active.life {
    background: var(--accent-gradient-warm);
    box-shadow: 0 4px 16px rgba(247, 168, 196, 0.3);
}

.toggle-option .toggle-emoji {
    font-size: 16px;
}

.daily-life-fields {
    display: none;
}

.daily-life-fields.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

.study-fields {
    display: none;
}

.study-fields.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

/* Daily Life Card */
.entry-card.life-entry::before {
    background: var(--accent-gradient-warm);
}

.entry-card.life-entry .entry-date {
    color: var(--accent-4);
}

.entry-card.life-entry .entry-tag.type-tag {
    background: rgba(247, 168, 196, 0.12);
    color: var(--accent-4);
}

.entry-tag.type-tag {
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Mood Selector */
.mood-selector {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mood-option {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.mood-option:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent-4);
}

.mood-option.selected {
    background: rgba(247, 168, 196, 0.15);
    border-color: var(--accent-4);
    color: var(--accent-4);
    box-shadow: 0 0 16px rgba(247, 168, 196, 0.15);
}

.mood-option input {
    display: none;
}

/* Tabs */
.section-tabs {
    display: flex;
    gap: 8px;
}

.section-tab {
    padding: 8px 20px;
    background: transparent;
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.section-tab:hover {
    color: var(--text-secondary);
    border-color: rgba(255, 255, 255, 0.15);
}

.section-tab.active {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
    box-shadow: 0 2px 14px rgba(167, 139, 250, 0.3);
}

.section-tab.active.life {
    background: var(--accent-gradient-warm);
    box-shadow: 0 2px 14px rgba(247, 168, 196, 0.3);
}

/* ============================================
   TWEMOJI — iOS-style emoji sizing
   ============================================ */
img.emoji {
    height: 1.2em;
    width: 1.2em;
    margin: 0 0.05em 0 0.1em;
    vertical-align: -0.15em;
    display: inline-block;
    pointer-events: none;
}

.stat-icon img.emoji {
    height: 1.6em;
    width: 1.6em;
}

.login-icon img.emoji {
    height: 1.4em;
    width: 1.4em;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
}

.empty-icon img.emoji {
    height: 1em;
    width: 1em;
}

.mood-option img.emoji {
    height: 1.3em;
    width: 1.3em;
}

.toggle-emoji img.emoji {
    height: 1.2em;
    width: 1.2em;
}

.section-title .icon img.emoji {
    height: 1.1em;
    width: 1.1em;
}

/* ============================================
   MOBILE TOUCH OPTIMIZATIONS
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    * {
        -webkit-tap-highlight-color: transparent;
    }

    button,
    a,
    .mood-option,
    .toggle-option,
    .section-tab,
    .stat-card {
        touch-action: manipulation;
    }

    /* Remove hover effects that cause sticky states on mobile */
    .stat-card:hover {
        transform: none;
    }

    .entry-card:hover {
        transform: none;
    }

    /* Make tappable items respond with active instead */
    .stat-card:active {
        transform: scale(0.97);
        background: var(--bg-card-hover);
    }

    .entry-card:active {
        transform: scale(0.99);
        background: var(--bg-card-hover);
    }

    .btn-add:active {
        transform: scale(0.95);
    }

    .google-btn:active {
        transform: scale(0.97);
    }
}

/* ============================================
   RESPONSIVE — TABLET (768px)
   ============================================ */
@media (max-width: 768px) {

    /* -- Navbar: compact mobile bar -- */
    .navbar {
        padding: 10px 16px;
        gap: 8px;
    }

    .nav-brand {
        gap: 10px;
    }

    .nav-brand-icon {
        width: 38px;
        height: 38px;
        font-size: 18px;
        border-radius: 12px;
    }

    .nav-brand-text {
        font-size: 16px;
    }

    .nav-brand-jp {
        font-size: 8px;
    }

    .nav-user-info {
        display: none;
    }

    .nav-user {
        gap: 10px;
    }

    .theme-toggle {
        width: 38px;
        height: 38px;
    }

    .nav-avatar {
        width: 36px;
        height: 36px;
    }

    .btn-signout {
        padding: 7px 16px;
        font-size: 12px;
    }

    /* -- Main Content -- */
    .main-content {
        padding: 16px 14px;
    }

    /* -- Stats Row: 2-column grid -- */
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 24px;
    }

    .stat-card {
        padding: 18px 14px;
        border-radius: var(--radius-md);
    }

    .stat-icon {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        font-size: 22px;
        margin-bottom: 12px;
    }

    .stat-value {
        font-size: 26px;
        margin-bottom: 2px;
    }

    .stat-label {
        font-size: 10px;
        letter-spacing: 1px;
    }

    /* -- Progress Section -- */
    .progress-section {
        padding: 20px 16px;
        margin-bottom: 24px;
        border-radius: var(--radius-md);
    }

    .progress-title {
        font-size: 14px;
    }

    .progress-percentage {
        font-size: 18px;
    }

    /* -- Section Labels -- */
    .section-label-jp {
        margin-bottom: 14px;
        gap: 12px;
    }

    .section-label-jp .label-kanji {
        font-size: 32px;
    }

    .section-label-jp .label-text {
        font-size: 11px;
        letter-spacing: 2px;
    }

    /* -- Section Header & Tabs -- */
    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 18px;
    }

    .section-title {
        font-size: 20px;
    }

    .section-title .icon {
        font-size: 22px;
    }

    .section-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-bottom: 4px;
        gap: 6px;
    }

    .section-tabs::-webkit-scrollbar {
        display: none;
    }

    .section-tab {
        padding: 8px 16px;
        font-size: 12px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .btn-add {
        justify-content: center;
        font-size: 14px;
        padding: 12px 24px;
    }

    /* -- Entry Cards -- */
    .entries-feed {
        gap: 14px;
    }

    .entry-card {
        padding: 18px 16px;
        border-radius: var(--radius-md);
    }

    .entry-header {
        margin-bottom: 12px;
    }

    .entry-date {
        font-size: 13px;
    }

    .entry-text {
        font-size: 14px;
        line-height: 1.65;
    }

    .entry-images {
        gap: 8px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }

    .entry-images::-webkit-scrollbar {
        display: none;
    }

    .entry-image {
        width: 100px;
        height: 100px;
        flex-shrink: 0;
        border-radius: 12px;
    }

    .entry-tags {
        gap: 6px;
    }

    .entry-tag {
        padding: 3px 10px;
        font-size: 11px;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
        border-radius: 10px;
        font-size: 15px;
    }

    /* -- Modal: iOS-style bottom sheet -- */
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal {
        max-width: 100%;
        max-height: 92vh;
        border-radius: 24px 24px 0 0;
        animation: modalSheetUp 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    }

    @keyframes modalSheetUp {
        from {
            opacity: 0;
            transform: translateY(100%);
        }

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

    .modal::before {
        content: '';
        display: block;
        width: 40px;
        height: 5px;
        background: rgba(255, 255, 255, 0.15);
        border-radius: 3px;
        margin: 12px auto 0;
    }

    .modal-header {
        padding: 16px 20px 0;
    }

    .modal-title {
        font-size: 18px;
    }

    .modal-body {
        padding: 18px 20px;
    }

    .form-input,
    .form-textarea,
    .form-select {
        padding: 14px 16px;
        font-size: 16px;
        /* prevents iOS zoom on focus */
        border-radius: 14px;
    }

    .form-textarea {
        min-height: 120px;
    }

    .form-label {
        font-size: 11px;
        margin-bottom: 6px;
    }

    .form-group {
        margin-bottom: 16px;
    }

    /* Mood Selector — 3 column grid */
    .mood-selector {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .mood-option {
        padding: 10px 8px;
        font-size: 12px;
        justify-content: center;
        border-radius: 14px;
        flex-direction: column;
        gap: 4px;
        text-align: center;
    }

    .mood-option span {
        font-size: 20px;
    }

    /* Entry Type Toggle */
    .entry-type-toggle {
        margin-bottom: 18px;
    }

    .toggle-option {
        padding: 10px 14px;
        font-size: 12px;
    }

    /* Upload Area */
    .upload-area {
        padding: 22px 16px;
    }

    .upload-icon {
        font-size: 32px;
        margin-bottom: 8px;
    }

    .upload-text {
        font-size: 13px;
    }

    .modal-footer {
        padding: 0 20px 20px;
        /* Add safe area padding for iPhones */
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    }

    .btn-cancel,
    .btn-save {
        padding: 14px 24px;
        font-size: 15px;
        flex: 1;
        justify-content: center;
        text-align: center;
    }

    /* -- Login Card -- */
    .login-card {
        padding: 44px 24px 36px;
        border-radius: var(--radius-lg);
        max-width: 100%;
        margin: 0 12px;
    }

    .login-icon {
        width: 76px;
        height: 76px;
        font-size: 34px;
        margin-bottom: 16px;
    }

    .login-title {
        font-size: 26px;
    }

    .login-subtitle-jp {
        font-size: 12px;
    }

    .login-subtitle {
        font-size: 13px;
        margin-bottom: 28px;
    }

    .google-btn {
        padding: 14px 28px;
        font-size: 15px;
        width: 100%;
        justify-content: center;
    }

    .login-footer {
        font-size: 11.5px;
        margin-top: 22px;
        color: var(--text-secondary);
        font-weight: 500;
        opacity: 0.9;
    }

    .credits-text {
        font-size: 11.5px;
        color: var(--text-secondary);
        font-weight: 500;
        opacity: 0.9;
    }

    .login-credits {
        margin-top: 24px;
        padding-top: 16px;
    }

    .credit-link {
        width: 40px;
        height: 40px;
        border-radius: 12px;
    }

    .login-theme-toggle {
        top: 16px;
        right: 16px;
    }

    /* -- Toast: bottom centered on mobile -- */
    .toast-container {
        top: auto;
        bottom: 24px;
        right: 16px;
        left: 16px;
        align-items: stretch;
    }

    .toast {
        min-width: unset;
        width: 100%;
        border-radius: 14px;
        padding: 14px 18px;
        font-size: 13px;
    }

    /* -- Lightbox -- */
    .lightbox-overlay img {
        max-width: 95%;
        border-radius: var(--radius-md);
    }

    /* -- Empty State -- */
    .empty-state {
        padding: 50px 16px;
    }

    .empty-icon {
        font-size: 56px;
    }

    .empty-title {
        font-size: 18px;
    }

    .empty-text {
        font-size: 13px;
    }

    /* -- Footer -- */
    .footer-text {
        font-size: 11px;
        padding: 8px 0 20px;
    }

    /* -- Ambient elements: less on mobile for perf -- */
    .ambient-kanji .kanji-float {
        font-size: 50px !important;
        opacity: 0.5;
    }

    .k3,
    .k5,
    .k6,
    .k8 {
        display: none;
    }
}

/* ============================================
   RESPONSIVE — SMALL PHONE (480px)
   ============================================ */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .stat-card {
        padding: 16px 12px;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
        margin-bottom: 10px;
    }

    .stat-value {
        font-size: 22px;
        font-family: var(--font-body);
        font-variant-numeric: tabular-nums;
    }

    .stat-label {
        font-size: 9px;
    }

    .nav-brand-text {
        font-size: 14px;
    }

    .nav-brand-jp {
        display: none;
    }

    .nav-brand-icon {
        width: 34px;
        height: 34px;
        font-size: 16px;
        border-radius: 10px;
    }

    .progress-details {
        flex-direction: column;
        gap: 6px;
    }

    .progress-detail {
        font-size: 12px;
    }

    .section-title {
        font-size: 18px;
    }

    .modal-header {
        padding: 12px 16px 0;
    }

    .modal-body {
        padding: 14px 16px;
    }

    .modal-footer {
        padding: 0 16px 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }

    /* Mood grid: 2 columns on very small screens */
    .mood-selector {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .mood-option {
        padding: 10px 6px;
        font-size: 11px;
    }

    .entry-image {
        width: 80px;
        height: 80px;
    }

    .login-card {
        padding: 36px 18px 28px;
        margin: 0 8px;
    }

    .login-icon {
        width: 64px;
        height: 64px;
        font-size: 28px;
    }

    .login-title {
        font-size: 22px;
    }

    .google-btn {
        padding: 13px 24px;
        font-size: 14px;
    }
}

/* ============================================
   SAFE AREA — Notched phones
   ============================================ */
@supports (padding: env(safe-area-inset-top)) {
    .navbar {
        padding-top: max(10px, env(safe-area-inset-top));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .main-content {
        padding-left: max(14px, env(safe-area-inset-left));
        padding-right: max(14px, env(safe-area-inset-right));
    }
}

/* ── Utility Animations ── */
.animate-in {
    animation: staggerIn 0.5s ease-out both;
}

.scale-in {
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   APPLE EMOJI — iPhone-style emoji rendering
   ============================================ */
img.apple-emoji {
    height: 1.2em;
    width: 1.2em;
    margin: 0 0.05em 0 0.1em;
    vertical-align: -0.15em;
    display: inline;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}

/* Larger emojis in stat icons */
.stat-icon img.apple-emoji {
    height: 1.6em;
    width: 1.6em;
    vertical-align: middle;
    margin: 0;
}

/* Emojis in login icon area */
.login-icon img.apple-emoji {
    height: 1em;
    width: 1em;
    vertical-align: middle;
    margin: 0;
}

/* Emojis in nav brand icon */
.nav-brand-icon img.apple-emoji {
    height: 1em;
    width: 1em;
    vertical-align: middle;
    margin: 0;
}

/* Emojis inside buttons and tabs */
.section-tab img.apple-emoji,
.toggle-option img.apple-emoji,
.mood-option img.apple-emoji {
    height: 1.15em;
    width: 1.15em;
    vertical-align: -0.1em;
}

/* Emojis in select dropdown */
.form-select img.apple-emoji,
select img.apple-emoji,
option img.apple-emoji {
    height: 1em;
    width: 1em;
}

/* Emojis in empty state */
.empty-icon img.apple-emoji {
    height: 1em;
    width: 1em;
    margin: 0;
}

/* Emojis in the upload area */
.upload-icon img.apple-emoji {
    height: 1em;
    width: 1em;
    margin: 0;
}

/* Emojis in progress title */
.progress-title img.apple-emoji {
    height: 1.1em;
    width: 1.1em;
    vertical-align: -0.1em;
}

/* Emojis in modal title */
.modal-title img.apple-emoji {
    height: 1.1em;
    width: 1.1em;
    vertical-align: -0.1em;
}

/* Theme toggle emoji sizing */
.theme-icon img.apple-emoji {
    height: 1em;
    width: 1em;
    vertical-align: middle;
    margin: 0;
}

/* Emojis in entry card badges/tags */
.entry-tag img.apple-emoji,
.entry-badge img.apple-emoji,
.entry-mood img.apple-emoji {
    height: 1.1em;
    width: 1.1em;
    vertical-align: -0.1em;
}

/* Emojis in toast notifications */
.toast img.apple-emoji {
    height: 1.2em;
    width: 1.2em;
    vertical-align: -0.1em;
}