:root {
    --danger: #e02424;
    --danger-rgb: 224, 36, 36;
    --transition: all 0.2s ease;
    --sidebar-width: 200px;
    --shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.03);
    --shadow-dropdown: 0 10px 40px rgba(0, 0, 0, 0.08);
}


.sidebar-toggle { display: none; background: transparent; border: none; color: var(--text-main); cursor: pointer; padding: 0.5rem; margin-right: 0.5rem; border-radius: 6px; }
.sidebar-overlay { 
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; 
    background: rgba(0,0,0,0.3); z-index: 1500; opacity: 0; visibility: hidden; 
    transition: all 0.3s ease; backdrop-filter: blur(2px);
}
.sidebar-overlay.active { opacity: 1; visibility: visible; }

.toast-container {
    position: fixed; top: 2rem; right: 2rem; z-index: 10000;
    display: flex; flex-direction: column; gap: 0.75rem;
    pointer-events: none;
}

.toast {
    background: var(--card-bg); border: 1px solid var(--border-color);
    padding: 1rem 1.5rem; border-radius: 12px;
    box-shadow: var(--shadow-dropdown); pointer-events: auto;
    width: 320px; animation: slideInX 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    display: flex; flex-direction: column; gap: 0.25rem;
}

.toast h4 { font-size: 0.9rem; font-weight: 600; color: var(--text-main); margin: 0; }
.toast p { font-size: 0.85rem; color: var(--text-muted); margin: 0; }

@keyframes slideInX {
    from { transform: translateX(100%) scale(0.9); opacity: 0; }
    to { transform: translateX(0) scale(1); opacity: 1; }
}

@keyframes slideOut {
    to { transform: translateX(100%); opacity: 0; }
}

.toast-exit { animation: slideOut 0.3s ease-in forwards; }

/* --- ZENITH 9 THEMES --- */
body[data-theme="light"] {
    --bg-main: #ffffff;
    --bg-sidebar: #fcfcfc;
    --card-bg: #ffffff;
    --sidebar-text: #111;
    --text-main: #111;
    --text-muted: #666;
    --text-ghost: #999;
    --border-color: rgba(0,0,0,0.06);
    --primary: #111;
    --primary-rgb: 17,17,17;
}

body[data-theme="solar"] {
    --bg-main: #fdf6e3;
    --bg-sidebar: #eee8d5;
    --card-bg: #fdf6e3;
    --sidebar-text: #657b83;
    --text-main: #586e75;
    --text-muted: #839496;
    --text-ghost: #93a1a1;
    --border-color: rgba(0,0,0,0.08);
    --primary: #b58900;
    --primary-rgb: 181,137,0;
}

body[data-theme="frost"] {
    --bg-main: #f0f7f9;
    --bg-sidebar: #e1edf2;
    --card-bg: #ffffff;
    --sidebar-text: #2c3e50;
    --text-main: #2c3e50;
    --text-muted: #7f8c8d;
    --text-ghost: #bdc3c7;
    --border-color: rgba(52,152,219,0.1);
    --primary: #3498db;
    --primary-rgb: 52,152,219;
}

body[data-theme="rose"] {
    --bg-main: #fffcfc;
    --bg-sidebar: #fff5f5;
    --card-bg: #ffffff;
    --text-main: #4a3737;
    --text-muted: #8c7676;
    --text-ghost: #b3a1a1;
    --border-color: rgba(229,115,115,0.1);
    --primary: #e57373;
    --primary-rgb: 229,115,115;
}

body[data-theme="matcha"] {
    --bg-main: #fcfdfa;
    --bg-sidebar: #f4f6f0;
    --card-bg: #ffffff;
    --text-main: #2d332d;
    --text-muted: #6a736a;
    --text-ghost: #a0a6a0;
    --border-color: rgba(122,158,116,0.15);
    --primary: #7a9e74;
    --primary-rgb: 122,158,116;
}

body[data-theme="midnight"] {
    --bg-main: #000000;
    --bg-sidebar: #050505;
    --card-bg: #0a0a0a;
    --sidebar-text: #fff;
    --text-main: #fff;
    --text-muted: #888;
    --text-ghost: #555;
    --border-color: rgba(255,255,255,0.08);
    --primary: #ffffff;
    --primary-rgb: 255,255,255;
}

body[data-theme="nordic"] {
    --bg-main: #0f172a;
    --bg-sidebar: #0b1222;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-ghost: #64748b;
    --border-color: rgba(255,255,255,0.05);
    --primary: #38bdf8;
    --primary-rgb: 56,189,248;
}

body[data-theme="obsidian"] {
    --bg-main: #1c1917;
    --bg-sidebar: #171717;
    --card-bg: #262626;
    --text-main: #e7dfd5;
    --text-muted: #a8a29e;
    --text-ghost: #57534e;
    --border-color: rgba(255,255,255,0.05);
    --primary: #d6d3d1;
    --primary-rgb: 214,211,209;
}

body[data-theme="cyber"] {
    --bg-main: #020617;
    --bg-sidebar: #0f172a;
    --card-bg: #1e1b4b;
    --text-main: #e0e7ff;
    --text-muted: #818cf8;
    --text-ghost: #4338ca;
    --border-color: rgba(139,92,246,0.2);
    --primary: #c084fc;
    --primary-rgb: 192,132,252;
}



* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    scrollbar-width: none;
    -ms-overflow-style: none;
}

*::-webkit-scrollbar {
    display: none;
}

body {
    font-family: 'Miranda Sans', sans-serif; background-color: var(--bg-main); color: var(--text-main);
    min-height: 100vh; display: flex; flex-direction: column; align-items: center;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.top-nav {
    width: 100%; max-width: 1100px; margin: 0 auto; display: flex;
    justify-content: space-between; align-items: center; padding: 0 1.5rem;
    height: 70px;
    border-bottom: 1px solid var(--border-color); position: sticky; top: 0; background: var(--bg-main); z-index: 3000;
}

.theme-grid {
    display: flex; gap: 0.75rem; flex-wrap: wrap;
}
.theme-swatch {
    width: 48px; height: 48px; border-radius: 12px; cursor: pointer;
    display: flex; align-items: flex-end; justify-content: flex-end;
    padding: 6px; position: relative; transition: var(--transition);
    border: 2px solid transparent;
}
.theme-swatch:hover { transform: translateY(-3px); }
.theme-swatch.active { border-color: var(--primary); }
.theme-swatch.active::after {
    content: '✓'; position: absolute; top: -8px; right: -8px;
    background: var(--primary); color: var(--card-bg); width: 20px; height: 20px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 800; border: 2px solid var(--bg-main);
}
.swatch-accent { width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid rgba(255,255,255,0.1); }
.nav-brand { 
    font-weight: 700; 
    font-size: 1.25rem; 
    cursor: pointer; 
    letter-spacing: -0.02em; 
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-main);
}

.app-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
}
    object-fit: contain;
}

body[data-theme="midnight"] .app-logo,
body[data-theme="nordic"] .app-logo,
body[data-theme="obsidian"] .app-logo,
body[data-theme="cyber"] .app-logo {
    filter: invert(1);
}

.nav-links { display: flex; gap: 1rem; align-items: center; }

.nav-btn {
    background: transparent; border: none; font-family: inherit; font-size: 0.95rem; font-weight: 500;
    color: var(--text-muted); cursor: pointer; transition: var(--transition);
}
.nav-btn:hover { color: var(--text-main); }
.nav-btn.outline { border: 1px solid var(--border-color); padding: 0.5rem 1rem; border-radius: 6px; font-size: 0.85rem; }
.nav-btn.outline:hover { border-color: var(--text-main); }
.nav-btn.solid { background: var(--primary); color: var(--card-bg); padding: 0.5rem 1rem; border-radius: 6px; font-size: 0.85rem; }
.nav-btn.solid:hover { background: var(--primary-hover); }

/* Navigation Profile & Hover Menu */
.navbar-profile { 
    display: flex; align-items: center; gap: 0.85rem; position: relative; cursor: pointer; 
    padding: 0.6rem 0.75rem; border-radius: 12px; transition: var(--transition); border: 1px solid transparent; 
}
.navbar-profile:hover { background: rgba(var(--primary-rgb), 0.05); border-color: rgba(var(--primary-rgb), 0.1); }
.profile-avatar { 
    width: 32px; height: 32px; background: var(--primary); color: var(--card-bg); border-radius: 50%; 
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; 
    letter-spacing: 0.05em; background-size: cover; background-position: center; border: 1.5px solid rgba(128,128,128,0.1);
}
.profile-info { text-align: left; }
.profile-name { font-weight: 700; font-size: 0.92rem; letter-spacing: -0.015em; color: var(--text-main); }
.profile-tz { color: var(--text-muted); font-size: 0.72rem; font-family: inherit; font-weight: 500; letter-spacing: 0.01em; margin-top: 1px; opacity: 0.8; }

.dropdown-menu {
    position: absolute; top: calc(100% + 0.5rem); right: 0; width: 220px;
    background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: 12px; box-shadow: var(--shadow-dropdown); overflow: hidden; z-index: 100;    
    visibility: hidden; opacity: 0; transform: translateY(-10px);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.navbar-profile:hover .dropdown-menu,
.dropdown-menu.active { visibility: visible; opacity: 1; transform: translateY(0); }
.dropdown-item { width: 100%; text-align: left; background: transparent; border: none; padding: 0.75rem 1rem; font-family: inherit; font-size: 0.9rem; color: var(--text-muted); cursor: pointer; transition: var(--transition); font-weight: 500; }
.dropdown-item:hover { background: rgba(128,128,128,0.05); color: var(--text-main); }
.dropdown-item.danger { color: var(--danger); }

/* Layouts */
.app-container { width: 100%; max-width: 800px; margin: 0 auto; padding: 0 1.5rem 3rem 1.5rem; animation: fadeInUp 0.5s ease-out forwards; }
.app-layout { 
    width: 100%; 
    max-width: 1100px; 
    margin: 0 auto;
    display: grid; 
    grid-template-columns: var(--sidebar-width) 1fr; 
    gap: 1.5rem; 
    padding: 1.5rem; 
    min-height: calc(100vh - 70px); 
}
.app-content { flex: 1; min-width: 0; }
.hidden { display: none !important; }

/* Sidebar */
.sidebar { 
    display: flex; 
    flex-direction: column; 
    gap: 0.75rem; 
    position: sticky; 
    top: calc(70px + 1.5rem); 
    height: calc(100vh - 70px - 3rem); 
    overflow-y: auto;
}
.sidebar-section { margin-top: 2rem; }
.sidebar-section:first-child { margin-top: 0.75rem; }
.sidebar-section h3 { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: var(--text-ghost); opacity: 0.9; letter-spacing: 0.1em; margin-bottom: 0.75rem; padding-left: 0.5rem; }
.sidebar-item {
    width: 100%; display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.6rem;
    border: none; background: transparent; color: var(--text-muted); font-family: inherit;
    font-size: 0.9rem; font-weight: 500; cursor: pointer; border-radius: 6px; transition: var(--transition); border: 1px solid transparent;
}
.sidebar-item:hover { background: rgba(128,128,128,0.05); color: var(--text-main); }
.sidebar-item.active { background: rgba(var(--primary-rgb), 0.1); color: var(--primary); font-weight: 600; }
.sidebar-item.tag-item.active { background: var(--tag-bg); color: var(--tag-fg); }

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding: 0 0.5rem;
    margin-top: 1.5rem;
}

.sidebar-header h3 {
    margin: 0 !important;
    padding: 0 !important;
}

.sidebar-action-btn {
    background: transparent;
    border: none;
    color: var(--text-ghost);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: var(--transition);
}

.sidebar-action-btn:hover {
    background: rgba(128,128,128,0.1);
    color: var(--text-main);
}

.tag-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.sidebar-item .tag-dot { margin-right: 0.25rem; }
.ghost-text-btn {
    background: transparent; border: none; color: var(--text-muted); 
    font-family: inherit; font-size: 0.85rem; cursor: pointer; padding: 0.25rem 0.5rem;
    transition: var(--transition); border-radius: 4px; font-weight: 500;
}
.ghost-text-btn:hover { background: rgba(128,128,128,0.05); color: var(--text-main); }

/* Main Content */
.app-main { display: flex; flex-direction: column; gap: 1.5rem; animation: fadeInUp 0.5s ease-out forwards; }
.list-header { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0 1.5rem 0; gap: 1rem; flex-wrap: wrap; }
.header-left, .header-right { display: flex; align-items: center; gap: 1rem; }
.header-right { margin-left: auto; }

.search-container { 
    display: flex; align-items: center; position: relative; 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent; border-radius: 50px;
    height: 38px;
}
.search-container.active { 
    background: rgba(128,128,128,0.06); 
    width: 100%; min-width: 200px;
    padding: 0 0.5rem;
    border: 1px solid var(--border-color);
}
.search-container input { 
    background: transparent; border: none; outline: none; 
    color: var(--text-main); font-size: 0.9rem; font-family: inherit;
    width: 0; opacity: 0; transition: all 0.3s ease;
    pointer-events: none;
}
.search-container.active input { 
    width: 100%; opacity: 1; padding: 0 0.75rem; 
    pointer-events: auto;
}
.search-trigger {
    background: transparent; border: none; cursor: pointer;
    color: var(--text-ghost); display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 50%; transition: var(--transition);
    flex-shrink: 0;
}
.search-trigger:hover { color: var(--text-main); background: rgba(128,128,128,0.05); }

#header-tools.hidden { display: none !important; }


.sort-dropdown-container { position: relative; }
.sort-trigger {
    background: rgba(var(--primary-rgb), 0.05); border: none; font-family: inherit; font-size: 0.75rem; font-weight: 700;
    color: var(--text-muted); cursor: pointer; display: flex; align-items: center; gap: 0.5rem;
    padding: 0 0.85rem; height: 38px; border-radius: 50px; transition: var(--transition);
    text-transform: uppercase; letter-spacing: 0.03em;
}
.sort-trigger:hover { color: var(--text-main); background: rgba(var(--primary-rgb), 0.1); }

.action-icon-btn {
    background: transparent; border: none; cursor: pointer;
    color: var(--text-ghost); display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 50%; transition: var(--transition);
}
.action-icon-btn:hover { color: var(--text-main); background: rgba(128,128,128,0.05); }
.action-icon-btn.active { color: var(--primary); }

#header-tools.hidden { display: none !important; }

.minimal-btn { 
    background: var(--primary); color: var(--card-bg); font-size: 0.85rem; font-weight: 600; 
    cursor: pointer; padding: 0 1.25rem; border-radius: 50px; transition: var(--transition); border: none;
    box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.2); height: 38px; display: flex; align-items: center;
}
.minimal-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.3); }

/* Hero & Auth */
.hero-section { 
    text-align: center; 
    min-height: calc(85vh - 70px);
    max-width: 900px; 
    margin: 0 auto; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}
.hero-title { 
    font-size: 3.85rem; 
    font-weight: 800; 
    line-height: 1.1; 
    margin-bottom: 2.5rem; 
    letter-spacing: -0.05em; 
    color: var(--text-main);
}
.typewriter-text {
    color: var(--primary);
    position: relative;
    display: inline-block;
    min-width: 2ch;
}
.typewriter-cursor {
    color: var(--primary);
    font-weight: 300;
    margin-left: 2px;
    animation: blink 0.8s infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.hero-subtitle { 
    font-size: 1.35rem; 
    color: var(--text-muted); 
    max-width: 650px; 
    margin: 0 auto 4rem auto; 
    line-height: 1.65; 
    font-weight: 400;
    opacity: 0;
    animation: fadeIn 1s ease-out 0.3s forwards;
}
.hero-cta-group { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 1rem; 
    opacity: 0;
    animation: fadeIn 1s ease-out 0.6s forwards;
    height: 48px;
}
.hero-btn { 
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 2rem; 
    font-size: 1rem; 
    font-weight: 700; 
    border-radius: 12px; 
    letter-spacing: 0.02em;
    box-shadow: 0 10px 30px rgba(var(--primary-rgb), 0.15);
    white-space: nowrap;
}
.hero-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(var(--primary-rgb), 0.25);
}

.hero-google-wrap { 
    height: 48px; 
    display: flex; 
    align-items: center; 
}

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

@media (max-width: 768px) {
    .hero-section { padding: 8rem 1rem 6rem 1rem; }
    .hero-title { font-size: 3rem; }
    .hero-subtitle { font-size: 1.1rem; margin-bottom: 3rem; }
    .hero-cta-group { flex-direction: column; gap: 1.25rem; }
    .hero-btn { width: 100%; border-radius: 12px; }
}

.auth-card { 
    background: var(--card-bg); 
    border: 1px solid var(--border-color); 
    border-radius: 24px; 
    padding: 3.5rem 3rem; 
    box-shadow: var(--shadow-subtle); 
    max-width: 420px; 
    text-align: center; 
    margin: 2rem auto; 
}
.auth-card h1 { margin-bottom: 0.75rem; font-weight: 800; }
.auth-card p { margin-bottom: 2.5rem; color: var(--text-muted); }
.auth-form { display: flex; flex-direction: column; gap: 1.25rem; margin-bottom: 2rem; }
.auth-form input, .custom-select { background: transparent; border: 1px solid var(--border-color); padding: 0.8rem 1rem; border-radius: 8px; color: var(--text-main); font-size: 0.95rem; outline: none; transition: var(--transition); }
.auth-form input:focus { border-color: var(--primary); }
.primary-btn { 
    background: var(--primary); 
    color: var(--card-bg); 
    font-weight: 700; 
    font-size: 0.95rem; 
    border: none; 
    padding: 0.8rem 1.5rem; 
    border-radius: 10px; 
    cursor: pointer; 
    transition: var(--transition); 
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.primary-btn:hover { background: var(--primary-hover); transform: translateY(-1px); }

.auth-divider { 
    margin: 2rem 0; 
    position: relative; 
    text-align: center; 
    border-bottom: 1px solid var(--border-color); 
    height: 10px; 
}
.auth-divider span { 
    background: var(--card-bg); 
    padding: 0 1rem; 
    color: var(--text-ghost); 
    font-size: 0.8rem; 
    font-weight: 600; 
    position: relative; 
    top: -2px; 
}
.google-btn-container { margin-bottom: 2.5rem; display: flex; justify-content: center; }
.auth-toggle { 
    margin-top: 2rem; 
    font-size: 0.95rem; 
    color: var(--text-muted); 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 0.5rem; 
}
.auth-toggle span { color: var(--text-ghost); font-size: 0.85rem; }
.auth-toggle .ghost-text-btn { 
    color: var(--primary); 
    font-weight: 700; 
    font-size: 1rem; 
    padding: 0.5rem 1rem; 
    border-radius: 8px; 
}
.auth-toggle .ghost-text-btn:hover { 
    background: rgba(var(--primary-rgb), 0.05); 
    text-decoration: underline; 
}

/* Todo List */
/* Todo List */
.todo-list { list-style: none; display: flex; flex-direction: column; border-top: 1px solid var(--border-color); }
.todo-item { 
    border-bottom: 1px solid var(--border-color); padding: 0.35rem 0.5rem; 
    display: flex; align-items: center; gap: 1rem; 
    transition: var(--transition); cursor: pointer; 
}
.todo-item:hover { background: rgba(128,128,128,0.02); }
.todo-item.completed { opacity: 0.5; }

.checkbox-wrapper { position: relative; width: 18px; height: 18px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.custom-checkbox { 
    appearance: none; width: 18px; height: 18px; flex-shrink: 0;
    background: transparent; border: 2px solid var(--text-muted); 
    border-radius: 50%; cursor: pointer; transition: var(--transition); 
}
.custom-checkbox:checked { background: var(--primary); border-color: var(--primary); }
.checkbox-icon { position: absolute; pointer-events: none; color: var(--card-bg); transform: scale(0); transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.custom-checkbox:checked + .checkbox-icon { transform: scale(0.8); }

.todo-meta { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.todo-header-row { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; line-height: 1.2; }

.todo-text { font-size: 0.95rem; font-weight: 500; color: var(--text-main); transition: var(--transition); line-height: 1.4; }
.todo-item.completed .todo-text { color: var(--text-ghost); text-decoration: line-through; }

.todo-inline-tags { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; }
.tag-badge { 
    font-size: 0.65rem; font-weight: 700; padding: 0.22rem 0.6rem; border-radius: 6px; border: 1px solid transparent; 
    background: rgba(var(--primary-rgb), 0.05); color: var(--text-muted); 
    text-transform: uppercase; letter-spacing: 0.04em; 
    transition: var(--transition);
    display: inline-flex; align-items: center;
}

.todo-submeta-inline { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; color: var(--text-ghost); }
.due-badge { display: flex; align-items: center; gap: 0.3rem; padding: 0.1rem 0.4rem; border-radius: 4px; border: none; background: rgba(128,128,128,0.05); }
.due-badge.overdue { color: var(--danger); background: rgba(var(--danger-rgb), 0.08); }

.todo-secondary-row { font-size: 0.7rem; color: var(--text-ghost); margin-top: 0.1rem; display: flex; align-items: center; gap: 0.5rem; opacity: 0.8; }
.todo-submeta:empty { display: none; }
.due-badge { color: #f59e0b; font-weight: 600; font-size: 0.75rem; display: flex; align-items: center; gap: 0.2rem; }
.due-badge.overdue { color: var(--danger); }
.due-badge svg { margin-top: -1px; }

.delete-btn { background: transparent; border: none; color: var(--text-ghost); cursor: pointer; padding: 6px; border-radius: 6px; transition: var(--transition); opacity: 0; }
.todo-item:hover .delete-btn { opacity: 1; }
.delete-btn:hover { color: var(--danger); background: rgba(224, 36, 36, 0.05); }

.ghost-text-btn { background: transparent; border: none; cursor: pointer; transition: var(--transition); border-radius: 6px; width: 100%; text-align: left; }
.ghost-text-btn:hover { background: rgba(var(--primary-rgb), 0.05); }

/* Visibility Toggle Switch */
.switch-container { 
    display: flex; 
    align-items: center; 
    gap: 0.75rem; 
    cursor: pointer; 
    user-select: none;
    background: rgba(var(--primary-rgb), 0.05);
    padding: 0 0.85rem;
    height: 38px;
    border-radius: 50px;
    transition: var(--transition);
}
.switch-container:hover { background: rgba(var(--primary-rgb), 0.1); }
.switch-label { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--border-color); transition: 0.3s ease; border-radius: 34px;
}
.slider:before {
    position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px;
    background-color: white; transition: 0.3s ease; border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
input:checked + .slider { background-color: #000; } /* Simple Black when ON */
input:checked + .slider:before { transform: translateX(20px); }
.switch:active .slider:before { width: 20px; }

/* Filter Bar */
.filter-bar { display: flex; align-items: center; padding: 0 0 1rem 0; gap: 0.5rem; animation: fadeIn 0.3s ease; }
.filter-bar.hidden { display: none; }

.filter-badge { background: var(--primary); color: var(--card-bg); padding: 0.4rem 0.8rem; border-radius: 50px; display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; font-weight: 600; }
.filter-badge button { background: transparent; border: none; color: inherit; font-size: 1.2rem; cursor: pointer; line-height: 1; }

/* Modals */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; z-index: 5000;
    opacity: 0; visibility: hidden; transition: all 0.2s ease;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-card {
    background: var(--card-bg); width: 100%; max-width: 500px;
    border-radius: 12px; box-shadow: var(--shadow-dropdown);
    border: 1px solid var(--border-color); display: flex; flex-direction: column;
    transform: scale(0.95); transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin: 1rem; max-height: 90vh;
}
.modal-overlay.active .modal-card { transform: scale(1); }

.modal-header { padding: 1.5rem 2rem 0.5rem 2rem; position: relative; }
.close-btn { 
    position: absolute; top: 1.25rem; right: 1.5rem; 
    background: transparent; border: none; font-size: 1.5rem; 
    color: var(--text-ghost); cursor: pointer; display: flex !important; 
    align-items: center; justify-content: center; width: 32px; height: 32px;
    transition: var(--transition);
}
.close-btn:hover { color: var(--text-main); transform: scale(1.1); }
.modal-header h2 { font-size: 1.25rem; font-weight: 700; color: var(--text-main); }
.title-highlighter-wrapper { 
    position: relative; 
    width: 100%; 
    padding: 0; 
}

#modal-title, .title-highlighter {
    display: block !important;
    vertical-align: top !important;
    width: 100% !important; 
    font-size: 1.25rem !important; 
    font-weight: 700 !important; 
    font-family: 'Inter', sans-serif !important;
    line-height: 1.4 !important;
    letter-spacing: -0.01em !important;
    text-transform: none !important;
    text-rendering: optimizeLegibility !important;
    -webkit-font-smoothing: antialiased !important;
    padding: 0.25rem 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
    border: none !important;
}

#modal-title {
    background: transparent !important; 
    color: transparent !important; 
    -webkit-text-fill-color: transparent !important;
    outline: none !important;
    position: relative; 
    z-index: 2; 
    caret-color: var(--text-main);
    resize: none !important;
    overflow: hidden !important;
}

.title-highlighter {
    position: absolute; 
    top: 0; 
    left: 0; 
    right: 0;
    bottom: 0;
    color: var(--text-main); 
    pointer-events: none; 
    overflow: hidden;
    z-index: 1;
}

.title-highlighter mark {
    background: rgba(var(--primary-rgb), 0.15); color: inherit; 
    border-radius: 4px; padding: 1px 0;
}
.title-highlighter .tag-mark {
    color: var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
    padding: 0 4px;
    margin: 0 -2px;
    border-radius: 4px;
    font-weight: 600;
}
.title-highlighter .nlp-mark { 
    color: #f59e0b; 
    font-weight: 600; 
    background: rgba(245, 158, 11, 0.08); 
    padding: 0 4px;
    margin: 0 -2px;
    border-radius: 4px;
}

.suggestions-dropdown {
    position: absolute; top: 100%; left: 1.5rem; right: 1.5rem;
    background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: 8px; box-shadow: var(--shadow-dropdown); z-index: 2000;
    max-height: 200px; overflow-y: auto;
}
.suggestion-item { padding: 0.75rem 1rem; cursor: pointer; font-size: 0.95rem; font-weight: 500; transition: var(--transition); }
.suggestion-item:hover, .suggestion-item.active { background: rgba(128,128,128,0.05); color: var(--primary); }


#modal-desc {
    width: 100%; border: none; background: transparent; color: var(--text-main);
    font-family: inherit; font-size: 0.95rem; resize: none; outline: none; min-height: 50px; line-height: 1.5;
}

.modal-schedule-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0; color: var(--text-muted); }
.custom-date-pill { 
    background: rgba(128,128,128,0.08); border: none; padding: 0.3rem 0.6rem; 
    border-radius: 6px; font-family: inherit; font-size: 0.85rem; color: var(--text-main);
    outline: none; cursor: pointer;
}
.custom-date-pill::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.6; padding: 0; }
.custom-date-pill:focus { background: rgba(128,128,128,0.12); }

.clear-date-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(128,128,128,0.1);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    transition: var(--transition);
}
.clear-date-btn:hover { background: rgba(var(--danger-rgb), 0.1); color: var(--danger); transform: scale(1.1); }


.subtasks-section { border-top: 1px solid var(--border-color); padding-top: 1rem; }
.modal-st-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.modal-st-input { flex: 1; border: none; background: transparent; color: var(--text-main); font-family: inherit; outline: none; font-size: 0.9rem; }
.modal-st-input.st-done { text-decoration: line-through; color: var(--text-ghost); }
#modal-subtask-input { width: 100%; border: none; background: transparent; color: var(--text-main); font-size: 0.9rem; outline: none; padding-left: 2rem; }

/* Tag Management */
.tag-manage-row { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 0.5rem 0.25rem; 
    border-bottom: 1px solid var(--border-color); 
}
.tag-manage-row:last-child { border-bottom: none; }
.tag-manage-info { display: flex; align-items: center; gap: 0.75rem; }
.star-btn { background: transparent; border: none; cursor: pointer; color: var(--text-ghost); transition: var(--transition); display: flex; align-items: center; }
.star-btn.starred { color: #f59e0b; }
.star-btn:hover { transform: scale(1.2); }

/* Task Modal Tabs */
.modal-tags-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.modal-tags-row:empty { display: none; }
.modal-tag-pill { 
    display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.2rem 0.6rem; 
    font-size: 0.75rem; font-weight: 600; border-radius: 50px; border: 1px solid var(--border-color); 
    background: rgba(128,128,128,0.05); transition: var(--transition);
}
.modal-tag-pill button { 
    background: transparent; border: none; color: inherit; cursor: pointer; 
    font-size: 1.1rem; line-height: 1; padding: 0 0 1px 2px; opacity: 0.6; display: flex; align-items: center;
}
.modal-tag-pill button:hover { opacity: 1; }

.modal-tabs { 
    display: flex; 
    border-bottom: 1px solid var(--border-color); 
    margin-bottom: 0.75rem; 
    padding: 0 2rem; 
    gap: 1.5rem;
}
.modal-tab-btn {
    background: transparent; border: none; font-family: inherit;
    padding: 0.75rem 0; font-size: 0.85rem; font-weight: 600;
    color: var(--text-ghost); cursor: pointer; position: relative;
    transition: var(--transition);
}
.modal-tab-btn:hover { color: var(--text-main); }
.modal-tab-btn.active { color: var(--primary); }
.modal-tab-btn.active::after {
    content: ""; position: absolute; bottom: -1px; left: 0; right: 0;
    height: 2px; background: var(--primary);
}
.modal-body { padding: 1rem 2rem 2rem 2rem; display: flex; flex-direction: column; gap: 0.75rem; overflow-y: auto; flex: 1; }
.modal-panel { display: flex; flex-direction: column; gap: 0.75rem; animation: fadeIn 0.2s ease; flex: 1; }

/* Activity Section inside Panel */
.comments-list { display: flex; flex-direction: column; gap: 0.75rem; overflow-y: auto; padding-right: 0.5rem; margin-top: 0.5rem; flex: 1; }
.comment-bubble { background: rgba(128,128,128,0.05); padding: 0.75rem 1rem; border-radius: 12px; font-size: 0.9rem; position: relative; }
.comment-meta { font-size: 0.7rem; color: var(--text-ghost); margin-bottom: 0.25rem; display: flex; justify-content: space-between; }
.comment-text { line-height: 1.4; color: var(--text-main); }

.attachments-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.upload-error-msg { 
    background: rgba(var(--danger-rgb), 0.1); color: var(--danger); 
    padding: 0.75rem 1rem; border-radius: 8px; font-size: 0.85rem; 
    font-weight: 600; margin-bottom: 1rem; border-left: 4px solid var(--danger);
    width: 100%;
}
.upload-error-msg.hidden { display: none; }
.attachment-pill { 
    background: var(--card-bg); border: 1px solid var(--border-color); 
    padding: 0.4rem 0.75rem; border-radius: 50px; font-size: 0.8rem;
    display: flex; align-items: center; gap: 0.5rem; transition: var(--transition);
    text-decoration: none; color: var(--text-main);
}
.attachment-pill:hover { border-color: var(--primary); background: rgba(128,128,128,0.02); }
.attachment-pill svg { color: var(--text-muted); }
.attachment-pill .delete-att { margin-left: auto; color: var(--text-ghost); cursor: pointer; display: flex; align-items: center; padding: 2px; border-radius: 50%; transition: var(--transition); }
.attachment-pill .delete-att:hover { background: rgba(var(--danger-rgb), 0.1); color: var(--danger); }

.comment-bubble .comment-actions { position: absolute; top: 0.5rem; right: 0.5rem; display: flex; gap: 0.5rem; opacity: 0; transition: var(--transition); }
.comment-bubble:hover .comment-actions { opacity: 1; }
.comment-action { background: rgba(128,128,128,0.1); border: none; padding: 4px; border-radius: 4px; cursor: pointer; color: var(--text-muted); display: flex; align-items: center; transition: var(--transition); }
.comment-action:hover { background: rgba(128,128,128,0.2); color: var(--text-main); }
.comment-action.danger:hover { color: var(--danger); background: rgba(224,36,36,0.1); }

.comment-input-row { display: flex; align-items: center; gap: 0.75rem; background: var(--bg-main); padding: 0.5rem; border-radius: 10px; border: 1px solid var(--border-color); }
.comment-input-row input { flex: 1; border: none; background: transparent; color: var(--text-main); font-family: inherit; font-size: 0.9rem; outline: none; }
.attach-btn { color: var(--text-muted); cursor: pointer; display: flex; align-items: center; transition: var(--transition); padding: 0.4rem; border-radius: 6px; }
.attach-btn:hover { color: var(--primary); background: rgba(128,128,128,0.1); }

.modal-footer { 
    padding: 1.25rem 2rem; 
    border-top: 1px solid var(--border-color); 
    display: flex; 
    justify-content: flex-end; 
    gap: 1rem; 
    align-items: center; 
}
.modal-footer button {
    height: 42px;
    padding: 0 1.5rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 100px;
}

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

/* Settings Modal Specifics */
.settings-tabs { display: flex; gap: 1rem; border-bottom: 1px solid var(--border-color); margin: 0.5rem 0 1rem 0; padding-bottom: 0.5rem; overflow-x: auto; }
.tab-btn { background: transparent; border: none; color: var(--text-muted); font-family: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; padding: 0.5rem 0.75rem; border-radius: 6px; position: relative; transition: var(--transition); white-space: nowrap; }
.tab-btn:hover { color: var(--text-main); background: rgba(128,128,128,0.05); }
.tab-btn.active { color: var(--primary); }
.tab-btn.active::after { content: ""; position: absolute; bottom: -0.5rem; left: 0; right: 0; height: 2px; background: var(--primary); }

.settings-panel { animation: fadeIn 0.3s ease; display: flex; flex-direction: column; gap: 1rem; min-height: 250px; }
.settings-group { display: flex; flex-direction: column; gap: 0.4rem; }
.settings-group label { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.8; margin-bottom: 0.2rem; }
.settings-row { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
.settings-row strong { font-size: 0.85rem; font-weight: 600; color: var(--text-main); }

/* Premium Input Styling */
.settings-group input:not([type="checkbox"]), 
.settings-group .custom-select-trigger {
    background: rgba(var(--primary-rgb), 0.04);
    border: 1.5px solid var(--border-color);
    padding: 0.85rem 1rem;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-main);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    width: 100%;
}

.settings-group input:focus,
.settings-group .custom-select-container.active .custom-select-trigger {
    background: rgba(var(--primary-rgb), 0.02);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.1);
}

/* Custom Dropdown / Select */
.custom-select-container { position: relative; width: 100%; }
.custom-select-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    text-align: left;
}
.custom-select-trigger::after {
    content: ""; width: 8px; height: 8px;
    border-right: 2px solid var(--text-ghost);
    border-bottom: 2px solid var(--text-ghost);
    transform: rotate(45deg) translateY(-2px);
    transition: transform 0.3s ease;
    margin-right: 2px;
}
.custom-select-container.active .custom-select-trigger::after {
    transform: rotate(-135deg) translateY(-2px);
    border-color: var(--primary);
}

.custom-select-menu {
    position: absolute; top: calc(100% + 8px); left: 0; right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.25);
    z-index: 6000;
    max-height: 250px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 0.5rem;
}

.custom-select-container.active .custom-select-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-select-item {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
}
.custom-select-item:hover {
    background: rgba(var(--primary-rgb), 0.08);
    color: var(--text-main);
}
.custom-select-item.selected {
    background: var(--primary);
    color: white;
}

/* Custom Scrollbar for Dropdown */
.custom-select-menu::-webkit-scrollbar { width: 5px; }
.custom-select-menu::-webkit-scrollbar-track { background: transparent; }
.custom-select-menu::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
.custom-select-menu::-webkit-scrollbar-thumb:hover { background: var(--text-ghost); }

.error-badge { background: #fee2e2; color: #b91c1c; padding: 0.75rem; border-radius: 8px; border: 1px solid #f87171; margin-bottom: 1rem; font-size: 0.85rem; }
.success-badge { background: #d1fae5; color: #047857; padding: 0.75rem; border-radius: 8px; border: 1px solid #10b981; margin-bottom: 1rem; font-size: 0.85rem; }

/* Pricing Cards */
.pricing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-top: 1rem; }
.pricing-card {
    background: var(--card-bg); border: 1px solid var(--border-color); 
    padding: 2rem; border-radius: 16px; display: flex; flex-direction: column; 
    transition: var(--transition); position: relative;
}
.pricing-card.pro { 
    border-color: var(--primary); 
    box-shadow: 0 10px 30px rgba(var(--primary-rgb), 0.15);
    background: linear-gradient(135deg, var(--card-bg) 0%, rgba(var(--primary-rgb), 0.05) 100%);
}
.pro-badge { 
    position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
    background: var(--primary); color: white; font-size: 0.65rem; font-weight: 800;
    padding: 4px 12px; border-radius: 50px; letter-spacing: 0.05em;
}
.plan-header { margin-bottom: 2rem; }
.plan-name { font-size: 1.1rem; font-weight: 600; color: var(--text-muted); display: block; margin-bottom: 0.5rem; }
.plan-price { font-size: 2.5rem; font-weight: 700; color: var(--text-main); }
.plan-price span { font-size: 1rem; color: var(--text-muted); font-weight: 400; }

.plan-features { list-style: none; padding: 0; margin: 0 0 2rem 0; display: flex; flex-direction: column; gap: 0.75rem; }
.plan-features li { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; color: var(--text-main); }
.plan-features li svg { color: #10b981; flex-shrink: 0; }
.pricing-card:not(.pro) .plan-features li svg { color: var(--text-muted); }

/* Notifications & Setup Guide */
.settings-card.premium {
    background: rgba(var(--primary-rgb), 0.03);
    border: 1.5px solid rgba(var(--primary-rgb), 0.1);
    padding: 1.25rem; /* Tighter all-around padding */
    border-radius: 16px;
    position: relative;
    overflow: visible !important;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.settings-card.premium::before {
    content: ""; position: absolute; top: -40px; right: -40px; width: 120px; height: 120px;
    background: var(--primary); opacity: 0.04; border-radius: 50%; filter: blur(50px);
    pointer-events: none;
}

.setup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.setup-card {
    background: var(--card-bg);
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: var(--transition);
}
.setup-card:hover { border-color: var(--text-ghost); transform: translateY(-2px); }
.setup-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-main);
}

/* Compact Alerts Layout */
.mobile-guide-compact { margin-top: 2rem; padding: 0 0.5rem; }
.setup-grid-compact { display: flex; flex-direction: column; gap: 1rem; }
.setup-list {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(128,128,128,0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.8rem;
}
.setup-list-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    color: var(--text-main);
}
.setup-list span { color: var(--text-muted); font-size: 0.75rem; }
.setup-list strong { color: var(--primary); }
.setup-header svg { color: var(--primary); }
.setup-steps {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.setup-steps .step {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}
.setup-steps .step strong { color: var(--text-main); font-weight: 700; }

.pwa-info-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(var(--primary-rgb), 0.05);
    color: var(--primary);
    padding: 0.6rem 1rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
}

.upgrade-btn { 
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    border: none; box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.3);
}
.upgrade-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.4); }

/* Mobile FAB */
.mobile-fab { 
    display: none; position: fixed; bottom: 2rem; right: 1.5rem; width: 56px; height: 56px; 
    background: var(--primary); color: var(--card-bg); border: none; border-radius: 50%;
    box-shadow: 0 10px 30px rgba(var(--primary-rgb), 0.4); z-index: 1000;
    cursor: pointer; align-items: center; justify-content: center; transition: var(--transition);
}
.mobile-fab:active { transform: scale(0.9); }

@media (max-width: 800px) {
    .mobile-fab { display: flex; }
    /* Hide FAB when modal is active to prevent clashing UI */
    .modal-overlay.active ~ .mobile-fab { display: none !important; }
    
    .minimal-btn { display: none; } /* Hide the old button on mobile */

    /* Anti-zoom for iOS/Android (16px minimum) */
    input, textarea, select, .ql-editor, [contenteditable] {
        font-size: 16px !important;
    }

    .list-header { flex-direction: column; align-items: stretch; gap: 0.75rem; padding-bottom: 0.5rem; }
    .header-left, .search-container { max-width: 100%; width: 100%; height: 42px; }
    .header-right { margin-left: 0; justify-content: space-between; width: 100%; gap: 0.75rem; align-items: center; }
    
    .sort-dropdown-container { flex: 1; }
    .sort-trigger { width: 100%; height: 42px; justify-content: space-between; background: rgba(128,128,128,0.05); border-radius: 8px; }
    
    .sidebar-toggle { display: flex; align-items: center; }
    .sidebar { 
        position: fixed; left: 0; top: 0; bottom: 0; z-index: 2000;
        background: var(--bg-main); border-right: 1px solid var(--border-color);
        transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex; /* Override display:none cases if any */
    }
    .sidebar.active { transform: translateX(0); box-shadow: 20px 0 50px rgba(0,0,0,0.1); }
    
    .app-layout { grid-template-columns: 1fr; padding: 0; }
    .top-nav { padding: 0 1rem; }
    .app-main { padding: 1rem; }
    
    /* Bottom Sheet Modals */
    .modal-card { 
        position: fixed; bottom: 0; left: 0; right: 0; margin: 0; 
        max-width: 100%; border-radius: 20px 20px 0 0; 
        max-height: 85vh; transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
    .modal-overlay.active .modal-card { transform: translateY(0); }
    
    .pricing-grid { grid-template-columns: 1fr; gap: 1rem; }
    .todo-item { padding: 0.7rem 0.5rem; }
    
    .list-header { 
        flex-direction: row !important; 
        align-items: center !important; 
        gap: 0.5rem !important; 
        padding: 0.5rem 0 !important;
    }
    /* Hide sort/completed when search is active on mobile */
    .list-header:has(.search-container.active) .header-right { display: none !important; }
    .list-header:has(.search-container.active) .header-left { flex: 1; width: 100%; }
    .header-left { flex: 1; min-width: 0; }
    .search-container { width: 100% !important; height: 38px !important; }
    #todo-search { padding-left: 2.5rem !important; font-size: 0.85rem !important; }
    .header-right { width: auto !important; margin: 0 !important; }
    .sort-trigger { padding: 0 0.85rem !important; height: 38px !important; font-size: 0.75rem !important; min-width: 80px; }
    #current-sort-label { display: none; } /* Hide label on mobile to save space, icon only or compact */
    .sort-trigger::after { content: "Sort"; margin-left: 4px; }

    .notebook-covers-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
        padding: 1rem 0 !important;
    }

    .modal-tabs { padding: 0 1.5rem; }
    .modal-body { min-height: auto; padding: 0 1.5rem 1.5rem; }
    .modal-footer { padding: 1.25rem 1.5rem; flex-direction: row; gap: 0.75rem; }
    .modal-footer button { flex: 1; height: 42px; font-size: 0.85rem; }

    /* Profile Refinement */
    .profile-info { display: none; }
    .navbar-profile { gap: 0; padding-left: 0.5rem; }

    /* Sidebar Spacing Refinement */
    .sidebar { padding: 1.5rem 1rem; gap: 2rem; }
    .sidebar-section h3 { margin-bottom: 0.75rem; font-size: 0.75rem; }
    .sidebar-item { padding: 0.75rem 0.75rem; gap: 0.8rem; font-size: 0.95rem; }
}

/* Notes Module Styles */
.notes-grid {
    padding: 1.5rem 0;
    width: 100%;
    transition: var(--transition);
}

.notes-grid.masonry {
    display: block;
    column-count: 4;
    column-gap: 1rem;
}

.notes-grid.masonry .note-card {
    display: inline-block;
    width: 100%;
    margin-bottom: 1rem;
    break-inside: avoid;
    aspect-ratio: auto !important; /* Allow content to dictate height */
}

@media (max-width: 1100px) { .notes-grid.masonry { column-count: 3; } }
@media (max-width: 900px) { .notes-grid.masonry { column-count: 2; } }
@media (max-width: 650px) { .notes-grid.masonry { column-count: 1; } }

/* Notebooks Hub */
.hub-container {
    padding: 0.5rem 0;
    animation: fadeIn 0.5s ease-out;
}
.hub-section {
    margin-bottom: 3.5rem;
}
.hub-section h3 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-ghost);
    margin-bottom: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    opacity: 0.8;
}

.notebook-covers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
    padding-bottom: 2rem;
}

.notebook-cover {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.25rem;
    aspect-ratio: 4/3;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.notebook-cover::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    bottom: 0;
    background: var(--nb-color, var(--primary));
    opacity: 0.8;
}

.notebook-cover:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.08);
    border-color: var(--primary);
}

.notebook-cover:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-dropdown);
    border-color: var(--primary);
}

.notebook-cover h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
    z-index: 1;
}
.nb-cover-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    align-self: flex-end;
    box-shadow: 0 0 0 4px var(--card-bg), 0 0 0 5px var(--border-color);
    z-index: 1;
}
.notebook-cover::after {
    content: '';
    position: absolute;
    bottom: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    opacity: 0.03;
    transition: opacity 0.3s;
}
.notebook-cover.with-image {
    position: relative;
    border: none !important;
    overflow: hidden;
}

.notebook-cover.with-image::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0) 20%, rgba(0,0,0,0.7) 100%);
    z-index: 1;
    opacity: 1;
    transition: var(--transition);
}
.notebook-cover.with-image:hover::after {
    background: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,0.8) 100%);
}

.notebook-cover.with-image > * {
    position: relative;
    z-index: 2;
}

.notebook-cover.with-image h4 { color: white !important; text-shadow: 0 2px 4px rgba(0,0,0,0.3); }
.notebook-cover.with-image p { color: rgba(255,255,255,0.9) !important; font-weight: 500; }
.notebook-cover.with-image .nb-cover-dot { border: 2px solid rgba(255,255,255,0.3); }

.notebook-cover.create-nb-card {
    border: 2px dashed var(--border-color);
    background: transparent;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    box-shadow: none;
}
.notebook-cover.create-nb-card:hover {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.02);
    transform: translateY(-5px);
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }/* Legacy grid refs cleaned */
}

.notes-grid, .notebook-hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
}

@media (max-width: 1100px) {
    .notes-grid, .notebook-hub-grid { 
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); 
        gap: 1.25rem; 
    }
}

@media (max-width: 900px) {
    .notes-grid, .notebook-hub-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 1rem; }
}

@media (max-width: 500px) {
    .notes-grid, .notebook-hub-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 0.75rem; }
    .notebook-card .notebook-title { font-size: 0.85rem; }
}

.notes-grid .note-card.white-page {
    background: var(--card-bg) !important;
    aspect-ratio: 1 / 1.4;
    padding: 1rem 1.25rem;
    border: 1px solid rgba(0,0,0,0.08); /* Subtle page edge */
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}

body.dark-theme .notes-grid .note-card.white-page {
    background: var(--card-bg) !important;
    border-color: rgba(255,255,255,0.1);
}

.note-card-content h3.small-text {
    font-size: 0.925rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    letter-spacing: -0.01em;
    overflow-wrap: break-word;
    word-break: break-word;
}

.note-card-content p.small-text.excerpt {
    font-size: 0.75rem;
    line-height: 1.6;
    color: var(--text-muted);
    /* Limit lines to keep masonry balanced but allow some variation */
    display: -webkit-box;
    -webkit-line-clamp: 12; 
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Shared Minimalist List Row (No Formatting, Just Dividers) */
.note-card.list-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0.5rem;
    gap: 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    box-shadow: none;
    transition: var(--transition);
}

.note-card.list-row:hover {
    background: rgba(var(--primary-rgb), 0.02);
}

.list-row-left {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex: 1;
    min-width: 0;
}

.page-icon {
    flex-shrink: 0;
    opacity: 0.7;
    display: flex;
    align-items: center;
}

.list-row-info {
    display: flex;
    align-items: baseline;
    gap: 1.5rem;
    flex: 1;
    min-width: 0;
}

.list-row-info h3.note-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    min-width: 80px;
    flex: 0 1 auto;
}

.note-excerpt {
    font-size: 0.8rem;
    color: var(--text-ghost);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

@media (max-width: 700px) {
    .note-excerpt {
        display: none;
    }
    .list-row-info {
        gap: 0.5rem;
    }
}

.list-row-right {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.note-time {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted); /* Using muted instead of ghost for better readability on varied themes */
}

.note-card {
    background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: 16px; padding: 1.5rem; transition: var(--transition);
    cursor: pointer; position: relative; display: flex;
    flex-direction: column; gap: 0.75rem; box-shadow: var(--shadow-subtle);
}

.note-card:hover { transform: translateY(-4px); box-shadow: 0 10px 30px rgba(0,0,0,0.08); }
.note-card.pinned { border: 1px solid var(--primary); }

.pinned-indicator {
    position: absolute; top: 1.25rem; right: 1.25rem;
    color: var(--primary); opacity: 0.8;
}

.note-card h3 {
    font-size: 1.15rem; font-weight: 700; margin: 0;
    padding-right: 1.5rem; color: var(--text-main);
}

.note-card p {
    font-size: 0.95rem; color: var(--text-muted); line-height: 1.6;
    margin: 0; white-space: pre-wrap; word-break: break-word;
    display: -webkit-box; -webkit-line-clamp: 10; -webkit-box-orient: vertical; overflow: hidden;
}

.note-card .note-footer {
    margin-top: auto; display: flex;
    align-items: center; gap: 0.5rem; padding-top: 1rem; font-size: 0.75rem;
    color: var(--text-ghost);
}

/* Color Picker & Options */
.note-options-row {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border-color);
}

.color-picker { display: flex; gap: 0.6rem; }
.color-swatch {
    width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border-color);
    cursor: pointer; transition: var(--transition); padding: 0;
}
.color-swatch:hover { transform: scale(1.2); }
.color-swatch.active { border: 2px solid var(--primary); transform: scale(1.2); box-shadow: 0 0 0 2px var(--bg-main); }

body.dark-theme .note-card { background: #1a1a1a; }
body.dark-theme .note-card p { color: #bbbbbb; }

#sidebar-footer-archive {
    position: sticky;
    bottom: 0;
    background: var(--bg-main);
    z-index: 10;
}

#sidebar-footer-archive .sidebar-item:hover {
    background: rgba(var(--primary-rgb), 0.08);
    opacity: 1 !important;
}

/* Undo Bar Styling */
#sidebar-undo-bar {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    background: var(--text-ghost);
    color: var(--card-bg);
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: var(--shadow-modal);
    z-index: 2000;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: translateY(150%);
}
#sidebar-undo-bar.active { transform: translateY(0); }
#sidebar-undo-bar button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.8rem;
    transition: var(--transition);
}
#sidebar-undo-bar button:hover { transform: scale(1.05); filter: brightness(1.1); }

/* Notebooks Hub Styles */
.notebook-covers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

.notebook-book-card {
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
    user-select: none;
}

.notebook-cover-box {
    aspect-ratio: 3 / 4;
    width: 100%;
    border-radius: 4px 12px 12px 4px;
    background: var(--card-bg);
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.4), inset 18px 0 20px -10px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1.5rem 1.25rem;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.05);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.notebook-cover-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.2) 60%, transparent 100%);
    z-index: 0;
}

/* Spine effect markup */
.notebook-cover-box::before {
    content: "";
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 20px;
    background: rgba(0,0,0,0.12);
    box-shadow: inset -5px 0 10px -5px rgba(0,0,0,0.2);
    border-right: 1px solid rgba(255,255,255,0.08);
}

.notebook-book-card:hover { transform: translateY(-10px); }
.notebook-book-card:hover .notebook-cover-box {
    box-shadow: 0 25px 50px -15px rgba(0,0,0,0.4);
}

.notebook-book-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
    margin-bottom: 0.35rem;
    z-index: 1;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.notebook-book-stats {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.9);
    font-weight: 600;
    z-index: 1;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* List View in Hub */
.notebook-hub-list {
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--border-color);
    gap: 0;
}

.notebook-list-item {
    /* Utilizing shared .note-card.list-row minimalist styles */
    border-top: none; /* Ensure no double borders */
}

.notebook-list-item h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notebook-list-item p {
    margin: 4px 0 0 0;
    font-size: 0.85rem;
    color: var(--text-ghost);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notebook-thumb {
    width: 32px;
    height: 42px;
    border-radius: 4px;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.1);
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
}

@media (max-width: 500px) {
    .notebook-list-item {
        padding: 1rem 1.25rem;
        gap: 1rem;
    }
    .notebook-list-item > svg {
        display: none;
    }
}
    position: relative;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
}
.notebook-thumb::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: rgba(0,0,0,0.15); border-radius: 4px 0 0 4px;
}

.notes-list-view {
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--border-color);
    gap: 0;
}
/* Quill Formatting Bar Customization */
.ql-toolbar.ql-snow {
    border: 1px solid var(--border-color) !important;
    background: rgba(128,128,128,0.03) !important;
    border-radius: 12px !important;
    margin-bottom: 0.75rem !important;
    display: flex !important;
    flex-wrap: wrap;
    align-items: center !important;
    justify-content: flex-start !important;
    padding: 0.5rem 0.75rem !important;
    gap: 0.25rem !important;
}

.ql-toolbar.ql-snow .ql-formats {
    margin-right: 0.5rem !important;
}
.ql-container.ql-snow {
    border: none !important;
    font-family: inherit !important;
    font-size: 1.05rem !important;
    color: var(--text-main) !important;
}
.ql-editor.ql-blank::before {
    color: var(--text-ghost) !important;
    font-style: normal !important;
    opacity: 0.6;
}
.notes-list-view .note-card {
    border: none;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 0.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    background: transparent !important;
    transition: var(--transition);
    border-radius: 0;
    box-shadow: none !important;
    width: 100%;
}
.notes-list-view .note-card:hover { background: rgba(128,128,128,0.03) !important; }
.notes-list-view .note-card h3 { 
    margin: 0; 
    font-size: 0.95rem; 
    font-weight: 500; 
    color: var(--text-main) !important; 
    flex: 1;
}
.notes-list-view .note-card p { display: none; }
.notes-list-view .note-card .note-footer {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-ghost);
    opacity: 0.8;
}

body.writing-focus-mode {
    overflow: hidden !important;
    background-color: var(--bg-main) !important;
}


body.writing-focus-mode .modal-overlay.active {
    background: var(--bg-main) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 20px 0 !important;
    display: block !important;
    overflow-y: auto !important;
    overflow-x: visible !important; /* Allow side float */
    position: fixed !important;
    top: 0 !important; /* Start at the top: Navbar is hidden */
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 2500; 
}
body.writing-focus-mode.dark-theme .modal-overlay.active {
    background: var(--bg-main) !important;
}

body.writing-focus-mode .top-nav {
    display: none !important;
}

body.writing-focus-mode.dark-theme .top-nav {
    display: none !important;
}


/* Ensure navbar is always on top but sidebar/main are gone */
body.writing-focus-mode .sidebar, 
body.writing-focus-mode .app-main,
body.writing-focus-mode #app-view,
body.writing-focus-mode #sidebar-overlay {
    display: none !important;
}

.immersive-editor-card {
    background: var(--card-bg) !important; 
    width: 95% !important;
    max-width: 820px !important; /* Standard "Page" width */
    min-height: 1000px !important; /* Blank page feel */
    height: auto !important;
    max-height: none !important;
    border: none !important;
    border-radius: 24px !important; /* Premium curves */
    box-shadow: 0 10px 60px rgba(0,0,0,0.12) !important;
    margin: 20px auto 120px auto !important;
    transform: none !important;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: visible !important;
}


.editor-header-sticky-group {
    position: relative; /* Non-sticky: scrolls with the page */
    top: 0;
    z-index: 5100;
    background: var(--card-bg) !important;
    border-bottom: 1px solid var(--border-color);
    border-top-left-radius: inherit;
    border-top-right-radius: inherit;
}

.editor-header {
    padding: 1.5rem 1.75rem 1rem 1.75rem !important; /* Balanced for wider area + toolbar room */
    border: none !important;
    background: transparent !important;
    display: flex !important;
    align-items: center !important;
    overflow: visible !important;
}

@media (max-width: 800px) {
    /* Library Hub Header */
    #notebook-list-header {
        flex-direction: column !important;
        align-items: center !important;
        gap: 1.25rem !important;
        padding-bottom: 2rem !important;
        text-align: center;
    }

    /* Internal Notebook View Header (The Cluttered one) */
    #notebook-view-header {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 0.75rem !important; /* Reduced from 1.25rem */
        padding: 0.5rem 1rem 1rem 1rem !important; /* Tightened top spacing */
    }

    #notebook-view-header #notebook-view-title {
        width: 100% !important;
        text-align: center !important;
        font-size: 1.6rem !important; /* Slightly smaller to feel tighter */
        margin-top: 0.5rem !important;
        margin-bottom: 0.25rem !important; /* Reduced from 0.5rem */
    }

    #notebook-view-header .header-left {
        width: auto !important;
        flex: 1 !important;
        justify-content: flex-start !important;
    }

    #notebook-view-header .header-right {
        width: auto !important;
        flex: 1 !important;
        justify-content: flex-end !important;
        margin-top: 0 !important;
    }

    /* Hide text labels on mobile to save space */
    #current-note-sort-label {
        display: none !important;
    }

    .note-sort-dropdown button {
        padding: 0 0.5rem !important;
        height: 38px;
    }

    /* Adjust Grid Cards for Mobile Height */
    .notes-grid .note-card.white-page {
        aspect-ratio: auto !important; /* Remove tall forced ratio */
        min-height: 180px;
        padding: 1rem !important;
    }
}

.editor-back-btn {
    flex-shrink: 0;
    width: auto;
    display: flex;
    align-items: center;
    color: var(--text-ghost);
    transition: var(--transition);
}
.editor-back-btn:hover { color: var(--text-main); transform: translateX(-2px); }

.editor-title-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-left: 1.5rem;
}

#note-modal-title {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    width: 100%;
    padding: 0.15rem 0 0 0;
    outline: none;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    line-height: 1.4;
    resize: none;
    overflow: hidden;
    vertical-align: top;
    display: block;
}
#note-modal-title:hover { opacity: 0.8; }

.editor-utility-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.editor-breadcrumb {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-ghost);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    display: block;
    margin-bottom: 0.1rem;
}

.editor-status-row, .toolbar-row { display: none !important; }

.autosave-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: var(--transition);
}
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: 'Outfit', sans-serif;
    box-sizing: border-box;
}

.autosave-status svg {
    stroke: currentColor;
    flex-shrink: 0;
}

.autosave-idle   { color: #16a34a; background: rgba(34,  197, 94,  0.12); }
.autosave-saving { color: #b45309; background: rgba(245, 158, 11,  0.12); }
.autosave-offline{ color: #dc2626; background: rgba(239, 68,  68,  0.12); }

/* Cleaned up legacy toolbar refs */


.immersive-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 !important; /* Managed by the editor inside */
    height: auto !important; 
}

/* Flatten Quill so it doesn't have its own scrollbar */
.writing-focus-mode #editor-container {
    height: auto !important;
    min-height: 600px;
}

.writing-focus-mode .ql-container.ql-snow {
    border: none !important;
    height: auto !important;
}

.writing-focus-mode .ql-editor {
    height: auto !important;
    overflow-y: visible !important; 
    min-height: 800px;
    padding: 3rem 6rem 20rem 6rem !important; /* Luxurious side margins and massive bottom clearance */
}

#editor-container {
    border: none !important;
    font-family: 'Outfit', sans-serif !important;
    position: relative !important;
    display: block !important;
    width: 100% !important;
}

.ql-container.ql-bubble {
    font-family: inherit !important;
    font-size: inherit !important;
    position: relative !important;
    border: none !important;
}

.ql-editor {
    position: relative !important;
    padding: 3rem 5.125rem 4rem 5.625rem !important; /* Increased top padding (1.5 -> 3) for bubble space */
    font-size: 16px !important;
    line-height: 1.7 !important;
    color: var(--text-main) !important;
    min-height: 300px;
    outline: none !important;
}

.ql-editor a {
    cursor: pointer !important;
    text-decoration: underline;
}

.ql-editor h1 { font-size: 1.5rem !important; margin-bottom: 0.5rem !important; font-weight: 700; }
.ql-editor h2 { font-size: 1.25rem !important; margin-bottom: 0.4rem !important; font-weight: 700; }
.ql-editor p { font-size: 1rem !important; margin-bottom: 0.75rem !important; }

.ql-editor.ql-blank::before {
    left: 5.625rem !important;
    right: 5.125rem !important;
    font-style: normal !important;
    font-weight: 400 !important;
    color: var(--text-ghost) !important;
    opacity: 0.5 !important;
    pointer-events: none !important;
}


/* Custom Dropdown for Move To */
.dropdown-trigger-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.8rem;
    background: rgba(128,128,128,0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}
.dropdown-trigger-btn:hover { background: var(--border-color); color: var(--text-main); }

/* Horizontal Scroll for Unsplash */
.unsplash-suggestions-grid {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    gap: 1rem;
    padding-bottom: 0.75rem;
    scrollbar-width: thin;
}
.unsplash-suggestions-grid::-webkit-scrollbar { height: 4px; }
.unsplash-suggestions-grid::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }

.suggestion-card {
    flex: 0 0 120px; /* Fixed width for horizontal scroll */
    aspect-ratio: 3 / 4;
}

/* Archive Tabs Scroll */
.archive-tabs-scroll {
    display: flex;
    overflow-x: auto;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    padding-bottom: 0.25rem;
    scrollbar-width: none;
}
.archive-tabs-scroll::-webkit-scrollbar { display: none; }

.archive-tab {
    white-space: nowrap;
    padding: 0.75rem 1rem !important;
    border-radius: 0 !important;
    border-bottom: 2px solid transparent !important;
    font-size: 0.85rem;
}
.archive-tab.active {
    border-bottom: 2px solid var(--primary) !important;
    color: var(--primary);
    font-weight: 600;
}

#editor-container {
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    font-size: 1rem !important;
    border: none !important;
    overflow: visible !important; /* Essential for bubble theme */
}

.ql-container.ql-snow, .ql-container.ql-bubble {
    border: none !important;
    overflow: visible !important;
}

.ql-editor, .ql-editor * {
    overflow-wrap: break-word !important;
    word-break: break-all !important;
    white-space: pre-wrap !important; 
}

.ql-editor {
    padding: 1rem 4.5rem 10rem 4.5rem !important; 
    overflow-y: visible !important; 
    height: auto !important;
    min-height: 500px;
    line-height: 1.7 !important;
    color: #333;
}


.ql-toolbar.ql-snow {
    border: none !important;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--card-bg);
    padding: 0 0.75rem !important;
    height: 32px !important;
    margin: 0 !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    box-sizing: border-box;
}

.editor-footer {
    padding: 1.5rem 3rem !important;
    background: var(--bg-main);
    border-top: 1px solid var(--border-color);
}

.suggestion-card {
    aspect-ratio: 3 / 4;
    border-radius: 6px;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.suggestion-card:hover { transform: scale(1.03); }
.suggestion-card.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.2);
}

.suggestion-card.selected::after {
    content: "✓";
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--primary);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
}

/* --- Unified Library Hub Dashboard --- */
.notebook-hub-dashboard {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.hub-section {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.hub-section-header {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.hub-section-header h3 {
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-ghost);
    margin: 0;
}

.hub-section-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-ghost);
    opacity: 0.5;
}

/* Slim Task-like Recent List */
.hub-recent-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hub-recent-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.hub-recent-row:hover {
    background: rgba(var(--primary-rgb), 0.05);
}

.hub-recent-row .row-left {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex: 1;
}

.hub-recent-row .note-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hub-recent-row .note-time {
    font-size: 0.8rem;
    color: var(--text-ghost);
    white-space: nowrap;
    font-weight: 500;
}

/* My Notebooks Grid (3:4 Portrait) */
/* Notebooks Hub Grid Styles synced with notes-grid above */
.notebook-hub-grid {
    /* Styles now inherited/shared with .notes-grid */
}

.notebook-hub-card {
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: var(--transition);
}

.notebook-hub-card:hover { transform: translateY(-4px); }

.notebook-hub-cover {
    aspect-ratio: 1 / 1.4; /* Slightly taller for book look */
    border-radius: 4px 12px 12px 4px; /* Notebook spine look */
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
    box-shadow: 8px 10px 25px rgba(0,0,0,0.15);
    border-left: 5px solid rgba(0,0,0,0.15); /* Physical spine effect */
    transition: var(--transition);
}

.notebook-hub-cover::before {
    content: "";
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(255,255,255,0.1);
    z-index: 2;
}

.notebook-hub-stats {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: rgba(255,255,255,0.95);
    color: #000;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    z-index: 4;
}

.notebook-hub-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,0.6));
}

.notebook-hub-info-inside {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.25rem 1rem 1rem 1.25rem; /* More left padding for spine gap */
    z-index: 3;
}

.notebook-hub-name {
    font-size: 0.95rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.2;
}

.notebook-hub-meta {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}


/* Dashboard List View */
.notebook-hub-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* --- Quill Bubble Theme Zenith Polish --- */
.ql-bubble .ql-tooltip {
    background-color: var(--card-bg) !important;
    color: var(--text-main) !important;
    border: 1px solid rgba(0,0,0,0.1) !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2) !important;
    padding: 8px 12px !important;
    z-index: 20000 !important; 
}

.ql-bubble .ql-toolbar {
    display: flex !important;
    flex-wrap: nowrap !important; /* Force all options onto a single line */
    align-items: center !important;
    gap: 0.25rem !important;
    white-space: nowrap !important;
    width: max-content !important;
}

.ql-bubble .ql-toolbar button {
    color: var(--text-ghost) !important;
}

.ql-bubble .ql-toolbar button:hover,
.ql-bubble .ql-toolbar button.ql-active {
    color: var(--primary) !important;
}

.ql-bubble .ql-stroke {
    stroke: currentColor !important;
}

.ql-bubble .ql-fill {
    fill: currentColor !important;
}

/* Mobile Tweaks for Note Editor */
@media (max-width: 768px) {
    body.writing-focus-mode .modal-overlay.active {
        padding: 0 !important; /* Start flush after navbar */
    }

    .immersive-editor-card {
        width: 100% !important;
        height: 100% !important;
        height: 100dvh !important; /* Uses dynamic viewport height to fill gaps */
        border-radius: 20px !important; /* Maintain premium curves on mobile/tablet */
        max-width: none !important;
        box-shadow: none !important; /* Remove card physicality for flush look */
        margin: 0 !important;
    }
    
    .editor-header, .editor-status-row, .immersive-body {
        padding-left: 1.25rem !important;
        padding-right: 1.25rem !important;
    }

    .editor-header {
        padding-top: 2.25rem !important; /* Extra space below navbar/top edge */
    }
    
    .ql-editor {
        padding-left: 1.25rem !important;
        padding-right: 1.25rem !important;
    }

    #note-modal-title {
        font-size: 1.5rem;
    }

    #autosave-label {
        display: none !important;
    }

    .autosave-status {
        padding: 0.4rem !important; /* Circular look for mobile */
        width: 28px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Fixed Mobile List View */
    .notes-list-view .note-card.list-row {
        padding: 0.75rem 1rem !important;
        gap: 0.75rem !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .list-row-left {
        gap: 0 !important;
    }

    .list-row-left .page-icon, 
    .list-row-left .note-excerpt {
        display: none !important;
    }

    .list-row-info {
        gap: 0 !important;
    }

    .list-row-info h3.note-title {
        min-width: 0 !important;
        font-size: 0.9rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .list-row-right .note-time {
        font-size: 0.7rem !important;
        opacity: 0.6;
        white-space: nowrap;
    }
}

.ql-editor {
    font-family: 'Inter', sans-serif !important;
}

/* Move Page Functionality */
.move-destination-item {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.65rem 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border-color);
}

.move-destination-item:last-child {
    border-bottom: none;
}

.move-destination-item:hover {
    background: rgba(var(--primary-rgb), 0.04);
}

.move-destination-item .mini-cover {
    width: 32px;
    height: 44px;
    border-radius: 4px;
    background-size: cover;
    background-position: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.move-destination-item span {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
}

.move-btn {
    opacity: 0;
    transition: var(--transition);
    width: 20px; /* Reduced from 24px for 'tiny' look */
    height: 20px;
    border-radius: 50%;
    color: var(--text-ghost);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--primary-rgb), 0.04);
    flex-shrink: 0;
}

.note-card:hover .move-btn,
.list-row:hover .move-btn {
    opacity: 1;
}

.move-btn:hover {
    color: var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
}
