:root {
    --bg-dark: #0f172a;
    --bg-panel: #1e293b;
    --bg-input: #334155;
    --accent: #38bdf8;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --bubble-me: #1e3a8a;
    --bubble-them: #334155;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: system-ui, sans-serif;
    /* dvh (Dynamic Viewport Height) prevents mobile browser address bars from cutting off content */
    height: 100vh;
    height: 100dvh; 
    display: flex;
    overflow: hidden;
}

/* --- Universal Passcode Screen --- */
#login-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--bg-dark);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000;
}
.login-box {
    background-color: var(--bg-panel);
    padding: 30px; border-radius: 12px; border: 1px solid #475569;
    text-align: center; max-width: 90%; width: 340px;
}
.login-box h2 { margin-bottom: 15px; color: var(--accent); }
.login-box input { width: 100%; margin-bottom: 15px; text-align: center; font-size: 1.1rem; padding: 14px; }
.error-msg { color: #f87171; font-size: 0.85rem; margin-top: -10px; margin-bottom: 15px; display: none; }

/* --- Responsive App Layout Shell --- */
#dashboard-layout {
    display: none; 
    width: 100%;
    height: 100%;
    flex-direction: row;
    position: relative;
}

/* Left Sidebar - Desktop Layout default rules */
#sidebar {
    width: 260px;
    background-color: #0b0f19;
    border-right: 1px solid #334155;
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
    gap: 8px;
    z-index: 1000;
    transition: transform 0.25s ease-in-out;
}
.sidebar-header {
    padding: 10px; font-size: 0.8rem; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-muted); font-weight: 700; margin-bottom: 10px;
}
.tab-btn {
    background: none; border: none; color: var(--text-muted);
    padding: 14px 16px; border-radius: 8px; text-align: left;
    font-size: 1rem; font-weight: 600; cursor: pointer;
    display: flex; align-items: center; gap: 10px;
}
.tab-btn:hover { background-color: #1e293b; color: var(--text-main); }
.tab-btn.active { background-color: var(--accent); color: #0f172a; }

/* Right Active Content Panel Viewport */
#main-viewport {
    flex: 1;
    background-color: var(--bg-panel);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* Mobile Top Navigation Header Bar */
#mobile-header {
    display: none; /* Hidden on Desktop */
    background-color: #0b0f19;
    padding: 12px 16px;
    border-bottom: 1px solid #334155;
    align-items: center;
    gap: 15px;
    height: 56px;
}
.menu-toggle-btn {
    background: none; border: none; color: var(--text-main);
    font-size: 1.5rem; cursor: pointer; padding: 4px 8px;
}
#mobile-title { font-weight: bold; font-size: 1.1rem; color: var(--text-main); }

/* --- Mobile Responsive Rules Breakpoint (Screens under 768px wide) --- */
@media (max-width: 768px) {
    #mobile-header { display: flex; } /* Show Top Header Bar */

    /* Turn Sidebar into a Slide-out Drawer */
    #sidebar {
        position: absolute;
        top: 0; left: 0;
        height: 100%;
        width: 270px;
        transform: translateX(-100%); /* Slide completely out of view off-screen left */
        box-shadow: 20px 0 30px rgba(0,0,0,0.5);
    }
    
    /* Active class toggled via JavaScript to slide sidebar open */
    #sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Dim background overlay when drawer is open */
    #sidebar-overlay {
        display: none;
        position: absolute;
        top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0, 0, 0, 0.6);
        z-index: 999;
    }
    #sidebar-overlay.active { display: block; }
}

/* --- Global Controls Upgrades for Mobile Touch --- */
input, textarea, button {
    font-size: 16px !important; /* Prevents iOS Safari from automatically zooming in on focus */
}
input, textarea { background-color: var(--bg-input); border: none; color: var(--text-main); padding: 12px; border-radius: 8px; outline: none; }
button { background-color: var(--accent); color: #0f172a; border: none; padding: 12px 20px; border-radius: 8px; font-weight: bold; cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* --- Note Image Attachment Thumbnails --- */
.note-images-strip { display: flex; flex-wrap: wrap; gap: 10px; }
.note-thumb {
    position: relative;
    width: 84px; height: 84px;
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--bg-input);
    border: 1px solid #475569;
}
.note-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; display: block; }
.note-thumb-remove {
    position: absolute; top: 2px; right: 2px;
    width: 22px; height: 22px;
    padding: 0 !important;
    border-radius: 50%;
    background-color: rgba(15, 23, 42, 0.85);
    color: #f87171;
    font-size: 14px !important;
    line-height: 1;
    display: flex; align-items: center; justify-content: center;
}
.note-thumb-remove:hover { background-color: #f87171; color: #0f172a; }

/* --- Full-screen Image Viewer (Lightbox) --- */
.img-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.img-lightbox.open { display: flex; }
.img-lightbox img {
    /* Scale down to fit the screen on phones; never upscale past native size */
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
}
.img-lightbox-close {
    position: fixed;
    top: 12px; right: 12px;
    width: 44px; height: 44px;
    padding: 0 !important;
    border-radius: 50%;
    background-color: rgba(30, 41, 59, 0.9);
    color: var(--text-main);
    font-size: 26px !important;
    line-height: 1;
    display: flex; align-items: center; justify-content: center;
    z-index: 3001;
}

/* --- Directional Chat Bubbles Rules --- */
.msg-row { display: flex; flex-direction: column; width: 100%; margin-bottom: 2px; }
.msg-row.me { align-items: flex-end; }
.msg-row.them { align-items: flex-start; }
.msg-meta { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 2px; padding: 0 4px; }
.msg-text { padding: 10px 14px; border-radius: 16px; max-width: 80%; word-wrap: break-word; line-height: 1.4; font-size: 0.95rem; display: inline-block; }
.me .msg-text { background-color: var(--bubble-me); border-bottom-right-radius: 4px; }
.them .msg-text { background-color: var(--bubble-them); border-bottom-left-radius: 4px; }

/* ==========================================================================
   🌸 UNIFIED BOTANICAL COMPONENT CLASS HOOKS (DEEP SPACE THEME CONVERGENCE)
   ========================================================================== */

#flower-viewport-wrapper {
    background-color: var(--bg-panel) !important;
    width: 100%;
    height: 100%;
}

#flower-content-card {
    background-color: var(--bg-dark);
    border: 1px solid #334155;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

#flower-zh-name {
    color: var(--text-main) !important;
    font-weight: 700;
    letter-spacing: -0.02em;
}

#flower-en-name {
    color: var(--accent) !important;
    font-weight: 500;
    letter-spacing: 0.02em;
}

#flower-img {
    border: 1px solid #475569;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s;
}

#flower-img:hover {
    transform: scale(1.015);
    border-color: var(--accent);
}

#flower-viewport-wrapper [style*="background: rgba(0,0,0,0.03)"] {
    background-color: var(--bg-input) !important;
    border-left-color: var(--accent) !important;
    color: var(--text-main);
    border: 1px solid #475569;
    border-left-width: 4px;
}

#flower-meta-text {
    color: var(--accent) !important;
    font-weight: 600;
}

#flower-story-text {
    color: var(--text-main) !important;
    font-size: 0.98rem !important;
    line-height: 1.65;
}

#flower-loading-spinner {
    color: var(--text-muted) !important;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* --- Workspace Fluid Note Modal Transitions --- */
.modal-overlay-layer {
    animation: fadeInModal 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-content-card {
    animation: scaleUpModal 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleUpModal {
    from { transform: scale(0.94); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* --- The Streak of Light Pulsing Core --- */
.pulse-glow-layer {
    animation: pulseGlowAnimation 2.5s infinite alternate ease-in-out;
}

@keyframes pulseGlowAnimation {
    0% {
        box-shadow: 0 0 15px rgba(56, 189, 248, 0.3), 0 0 5px rgba(56, 189, 248, 0.2);
    }
    100% {
        box-shadow: 0 0 28px rgba(56, 189, 248, 0.65), 0 0 12px rgba(56, 189, 248, 0.4);
        transform: scale(1.03);
    }
}

/* ==========================================================================
   🏡 SHARED GARDEN & BOTANICAL GREENHOUSE UTILITIES
   ========================================================================== */

/* Progress Bar Track Fill Transitions */
.garden-progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--bg-dark);
    border-radius: 9999px;
    overflow: hidden;
    border: 1px solid #475569;
}
.garden-progress-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Garden Grid Card Hover Effects */
.garden-vault-card {
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s;
}
.garden-vault-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent) !important;
}

/* Action Feeding Buttons Micro-interactions */
#feed-sun-btn, #feed-water-btn, #evolve-plant-btn, #harvest-plant-btn {
    transition: transform 0.15s ease, opacity 0.2s, filter 0.2s;
}
#feed-sun-btn:active, #feed-water-btn:active, #evolve-plant-btn:active, #harvest-plant-btn:active {
    transform: scale(0.96);
}
#feed-sun-btn:hover:not([disabled]) {
    filter: brightness(1.1);
    box-shadow: 0 0 12px rgba(250, 204, 21, 0.2);
}
#feed-water-btn:hover:not([disabled]) {
    filter: brightness(1.1);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}

/* Smooth Canvas Fade for State Swapping */
#incubation-canvas {
    animation: plantStageFadeIn 0.35s ease-out forwards;
}

@keyframes plantStageFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}