@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&family=Raleway:wght@400;500&display=swap");


* {
    box-sizing: border-box;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

:root {
    /* Extension Size Variables (Dynamic) */
    --extension-width: 480px;
    --extension-height: 550px;
    --border-radius: 8px;

    /* Popup Size Customization */
    --popup-width: 420px;
    --popup-max-width: 90%;

    /* Colors */
    --note-blue: #3b82f6;
    --note-purple: #8b5cf6;
    --note-yellow: #facc15;
    --note-green: #22c55e;
    --note-red: #ef4444;

    /* Classic Blue Light Theme (Default) */
    --bg-primary: #F8FAFC;
    --bg-secondary: #FFFFFF;
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --border-color: #CBD5E1;
    --accent-color: #3B82F6;
    --accent-text: #ffffff;
    --sidebar-bg: #1E293B;
}

.theme-dark {
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --border-color: #374151;
    --accent-color: #60a5fa;
    --accent-text: #111827;
    --sidebar-bg: #1f2937;
}

.theme-classic {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --accent-color: #4F46E5;
    /* Indigo 600 - Visual Identity Update */
    --accent-hover: #4338ca;
    --accent-text: #ffffff;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --sidebar-bg: #2C3E50;
}

.classic-mode {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --accent-color: #3b82f6;
    --accent-text: #ffffff;
    --sidebar-bg: #2C3E50;
}

.theme-nord {
    --bg-primary: #2E3440;
    --bg-secondary: #3B4252;
    --text-primary: #ECEFF4;
    --text-secondary: #D8DEE9;
    --border-color: #4C566A;
    --accent-color: #88C0D0;
    --accent-text: #2E3440;
    --sidebar-bg: #3B4252;
}

.theme-ocean {
    --bg-primary: #222e50;
    --bg-secondary: #2f3e66;
    --text-primary: #c3e5f4;
    --text-secondary: #a2c2d3;
    --border-color: #3f5180;
    --accent-color: #66d9ef;
    --accent-text: #222e50;
    --sidebar-bg: #1d263b;
}

.theme-pink {
    --bg-primary: #fff0f5;
    --bg-secondary: #ffffff;
    --text-primary: #831843;
    --text-secondary: #be185d;
    --border-color: #fbcfe8;
    --accent-color: #e11d48;
    --accent-text: #ffffff;
    --sidebar-bg: #be185d;
}

.theme-solarized-light {
    --bg-primary: #fdf6e3;
    --bg-secondary: #eee8d5;
    --text-primary: #586e75;
    --text-secondary: #839496;
    --border-color: #93a1a1;
    --accent-color: #268bd2;
    --accent-text: #fdf6e3;
    --sidebar-bg: #eee8d5;
}

.theme-solarized-dark {
    --bg-primary: #002b36;
    --bg-secondary: #073642;
    --text-primary: #93a1a1;
    --text-secondary: #586e75;
    --border-color: #586e75;
    --accent-color: #268bd2;
    --accent-text: #002b36;
    --sidebar-bg: #073642;
}


/* Base Styles */
body {
    width: var(--extension-width);
    height: var(--extension-height);
    font-family: var(--font-sans, 'Inter', sans-serif);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    padding-top: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
}

input,
button,
select,
textarea,
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: inherit;
}

/* Sidebar mode (flexible) */
body:not(.popup-mode) {
    width: 100% !important;
    height: 100vh !important;
    padding-top: 0;
}

/* Override for popup mode - horizontal layout */
/* Main Content Generic */
.main-content {
    display: flex;
    flex-direction: column;
    padding-top: 0;
    margin-top: 0;
}

/* Override for popup mode - horizontal layout */
html.popup-mode,
/* Start helper for chrome extension popup sizing */
html:has(body.popup-mode) {
    width: var(--extension-width) !important;
    height: var(--extension-height) !important;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body.popup-mode {
    display: flex !important;
    flex-direction: row !important;
    width: var(--extension-width) !important;
    height: var(--extension-height) !important;
    min-width: var(--extension-width) !important;
    min-height: var(--extension-height) !important;
    padding: 0;
    margin: 0;
    overflow: hidden;
    background: var(--bg-primary);
    border: 2px solid rgba(71, 85, 105, 0.45);
    border-radius: 12px;
    box-sizing: border-box;
    /* Ensure background is set */
}

body.popup-mode .main-content {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    right: 4px;
    border-radius: 8px;
    margin: 0 !important;
    width: auto !important;
    height: auto !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: left 0.25s ease;
}

body.popup-mode .main-content.sidebar-expanded {
    left: 64px;
}

body.popup-mode nav.sidebar-nav {
    top: 4px;
    bottom: 4px;
    left: 4px;
    height: calc(100% - 8px);
    max-height: calc(100% - 8px);
    border-radius: 8px 0 0 8px;
}

body.popup-mode .sidebar-toggle {
    left: 4px;
}

body.popup-mode .sidebar-toggle.expanded {
    left: 64px;
}

/* Sidebar Navigation - Fixed on Left */
nav.sidebar-nav {
    position: fixed;
    left: 0;
    top: 0;
    width: 60px;
    height: 100vh;
    max-height: 100vh;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 16px 0;
    gap: 12px;
    z-index: 900;
    overflow-y: auto;
    box-sizing: border-box;
}

/* Sidebar Navigation Icons */
nav.sidebar-nav .nav-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

nav.sidebar-nav .nav-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.95);
    transform: translateY(-2px);
}

nav.sidebar-nav .nav-icon.active {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}

/* AI Circle Badge in Sidebar */
nav.sidebar-nav .ai-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: white;
    letter-spacing: 0.5px;
}

/* Spacer to push last icon to bottom */
nav.sidebar-nav>.nav-spacer {
    flex-grow: 1;
    min-height: 0;
}

/* Sidebar — collapsed by default, expanded via .expanded class */
nav.sidebar-nav {
    width: 0;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: width 0.25s ease, transform 0.25s ease, opacity 0.2s ease;
}
nav.sidebar-nav.expanded {
    width: 60px;
    padding: 16px 0;
    overflow-y: auto;
    opacity: 1;
    pointer-events: auto;
}

/* Sidebar Toggle Arrow — starts at left:0 (collapsed position) */
.sidebar-toggle {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 901;
    width: 18px;
    height: 40px;
    background: var(--sidebar-bg, #1e293b);
    border: none;
    border-radius: 0 8px 8px 0;
    color: rgba(255,255,255,0.6);
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: left 0.25s ease, background 0.15s, color 0.15s;
    padding: 0;
}
.sidebar-toggle:hover {
    background: var(--accent-primary, #3b82f6);
    color: #fff;
}
.sidebar-toggle i {
    transform: rotate(180deg);
    transition: transform 0.25s ease;
}
.sidebar-toggle.expanded {
    left: 60px;
}
.sidebar-toggle.expanded i {
    transform: rotate(0deg);
}

/* Main Content Area — starts at left:4px (collapsed position) */
body.popup-mode .main-content {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    right: 4px;
    border-radius: 8px;
    margin: 0 !important;
    width: auto !important;
    height: auto !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: left 0.25s ease;
}
body.popup-mode .main-content.sidebar-expanded {
    left: 64px;
}


/* ===== CONTENT VIEW SWITCHING ===== */
/* Hide all views by default, show only active view */
.content-view {
    display: none !important;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    flex: 1;
}

.content-view.active {
    display: flex !important;
    flex: 1;
    overflow-y: auto;
}

/* Ensure proper layout for active views in popup mode */
body.popup-mode .content-view.active {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    /* height removed to rely on flex scaling relative to absolute parent */
    min-height: 0;
    overflow: hidden;
}

/* View Content Wrapper */
.view-content {
    padding: 20px 20px 60px 20px;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.view-content::-webkit-scrollbar {
    display: none;
}

/* Content Header for Views */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* Compact header for popup mode */
/* Ensure proper layout for active views in popup mode */
body.popup-mode .content-view.active {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    /* Enable main scrollbar here */
    overflow-x: hidden;
}

/* Compact header for popup mode */
body.popup-mode .content-header h1 {
    display: block;
    font-size: 18px;
    margin: 12px 0 6px 0;
    /* Add margin to H1 instead of container padding */
}

body.popup-mode .content-header {
    padding: 0 20px;
    /* Zero top padding on container */
    height: auto;
    border: none;
    overflow: visible;
    flex-shrink: 0;
}

.content-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

.container {
    padding: 0 20px 20px 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* When sidepanel header is fixed, offset the container */
body.has-fixed-header .container {
    padding-top: 50px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    background-color: var(--sidebar-bg) !important;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: white !important;
    transition: background-color 0.3s ease;
}

.header .nav-icon {
    color: rgba(255, 255, 255, 0.7) !important;
    transition: all 0.2s ease;
}

.header .nav-icon:hover {
    color: white !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
}

.header .nav-icon.active {
    color: white !important;
    background-color: rgba(255, 255, 255, 0.2) !important;
    box-shadow: none;
}

/* AI View Redesign Styles */
.ai-redesign-header {
    flex-direction: row !important;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px !important;
    gap: 8px !important;
}

.ai-plan-info-compact {
    display: flex;
    align-items: center;
    gap: 8px;
}

.plan-badge.micro-badge {
    padding: 3px 8px;
    font-size: 10px;
    border-radius: 12px;
}

.credits-count.small-text {
    font-size: 12px;
}

.header-action-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.icon-btn-small {
    background: var(--bg-surface-2, rgba(255,255,255,0.1));
    border: 1px solid var(--border-subtle, rgba(255,255,255,0.15));
    color: var(--text-secondary, #94a3b8);
    border-radius: 8px;
    padding: 6px 8px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.icon-btn-small:hover {
    background: var(--bg-surface-3, rgba(255,255,255,0.15));
    color: var(--text-primary, #fff);
}

.credits-bar-container.compact-bar {
    height: 3px;
    margin: 0;
}

.ai-view-header {
    padding: 20px;
    background: var(--bg-surface-1);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 16px;
    color: var(--text-primary);
}

.ai-plan-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
}

.plan-badge {
    color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.plan-badge.pro {
    color: #fff;
    background: linear-gradient(135deg, #10b981, #059669);
}

.plan-badge.free {
    color: #fff;
    background: linear-gradient(135deg, #6b7280, #9ca3af);
}

.credits-count {
    color: var(--accent-success);
    /* Use success color for credits as per mockup aesthetic */
    font-size: 13px;
    font-weight: 700;
}

.credits-bar-container {
    height: 6px;
    background: var(--bg-surface-1);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    width: 100%;
}

.credits-bar {
    height: 100%;
    background: linear-gradient(90deg, #3B82F6, #8B5CF6);
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.dashboard-link-btn {
    width: 100%;
    padding: 14px;
    background: var(--bg-surface-2);
    border: 1px dashed var(--accent-primary);
    border-radius: 12px;
    color: var(--accent-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
}

.dashboard-link-btn:hover {
    background: var(--bg-surface-3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.dashboard-link-btn i {
    font-size: 14px;
}

/* ===========================
   AI VIEW MAIN STYLES
   =========================== */

.ai-view-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-app);
}

/* Messages Area */
.ai-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background-color: var(--bg-app);
    /* Dynamic theme background */
}

/* Dark mode override */
.theme-dark .ai-messages-area,
.theme-ocean .ai-messages-area {
    background-color: var(--bg-app);
}

.ai-message {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.ai-message.assistant .ai-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
}

.ai-bubble {
    background: var(--bg-surface-1);
    padding: 18px 22px;
    border-radius: 4px 18px 18px 18px;
    /* Rounded consistent with reference */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    max-width: 88%;
    border: 1px solid var(--border-subtle);
}

.theme-dark .ai-bubble {
    background: var(--bg-surface-1);
    border-color: var(--border-subtle);
}

/* Input Area */
.ai-input-area {
    padding: 16px 20px 24px 20px;
    background: var(--bg-surface-1);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ai-suggestions {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
}

.ai-suggestions::-webkit-scrollbar {
    display: none;
}

.suggestion-chip {
    padding: 8px 16px;
    border-radius: 20px;
    background: var(--bg-surface-1);
    border: 1px solid var(--border-default);
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    font-weight: 500;
}

.suggestion-chip:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: rgba(59, 130, 246, 0.05);
    transform: translateY(-1px);
}

.theme-dark .suggestion-chip {
    background: var(--bg-surface-1);
}

.ai-input-wrapper {
    display: flex;
    align-items: center;
    background: white;
    border: 1px solid var(--border-subtle);
    border-radius: 28px;
    /* Pill shape */
    padding: 4px 6px 4px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    transition: all 0.2s;
}

.theme-dark .ai-input-wrapper {
    background: var(--bg-surface-1);
}

.ai-input-wrapper:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.15);
}

.ai-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    background: transparent;
    color: var(--text-primary);
    padding: 10px 0;
    min-height: 24px;
    resize: none;
    font-family: inherit;
}

.ai-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    margin-left: 8px;
}

.ai-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.4);
}

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

.header h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

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

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
}

.icon-btn:hover {
    background-color: var(--accent-color);
    color: var(--accent-text);
}

/* Stat Grid for Popup Features */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 16px;
}

.stat-box {
    text-align: center;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 12px;
}

.theme-dark .stat-box {
    background: var(--bg-surface-1);
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

/* Search Box */
.search-box {
    position: relative;
    margin-top: 0;
    /* Removed space for smooth scrolling */
    padding: 0;
    flex-shrink: 0;
    min-height: 50px;
    /* Increased slightly to accommodate button visual */
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    overflow: visible;
    /* Important for button to stick out */
}

/* Search Box Sticky in Popup */
body.popup-mode .search-box {
    margin-left: 0;
    width: 100%;
    box-sizing: border-box;
    margin-top: 0;
    padding: 8px 0;
    /* Use padding for spacing to include in sticky bg */
    min-height: auto;
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--bg-primary);
}

/* Disable inner scroll in popup mode */
body.popup-mode .notes-container {
    overflow: visible;
    flex: none;
    height: auto;
}



/* Show search add button in sidebar mode */
body:not(.popup-mode) #searchAddBtn {
    display: flex;
}

.search-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: var(--accent-text);
    border: 1px solid transparent;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 20px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.search-add-btn:hover {
    opacity: 0.9;
    background-color: color-mix(in srgb, var(--accent-color), black 10%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Floating Add Button (FAB) */
.floating-add-btn {
    position: absolute;
    top: 20px;
    right: 16px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
}

.floating-add-btn:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.5);
}

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



.search-icon {
    position: absolute;
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
    color: rgba(0, 0, 0, 0.4);
    font-size: 16px;
    z-index: 2;
    pointer-events: none;
}

#searchInput {
    flex-grow: 1;
    width: auto;
    padding: 12px 60px 12px 40px;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    box-sizing: border-box;
    height: 44px;
    transition: all 0.2s ease;
}

#searchInput:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Notes Container */
.notes-container {
    flex: 1 1 0;
    /* Important: Use 0 basis to force proper scrolling calculation */
    min-height: 0;
    /* Critical for flexbox scrolling nested in flex container */
    overflow-y: auto;
    margin-top: 16px;
    padding-right: 0;
    width: 100%;
    padding-bottom: 20px;
}

#notesList {
    list-style: none;
    padding: 0 0 60px 0;
    /* Huge bottom padding to force scrollability */
    margin: 0;
    width: 100%;
}

/* Note Item Layout */
.note {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    transition: box-shadow 0.2s, transform 0.2s;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    gap: 8px;
}

.note:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

/* Note Header for Actions */
.note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.note-actions-left,
.note-actions-right {
    display: flex;
    gap: 4px;
    align-items: center;
}

.note-header button {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.note-header button:hover {
    color: var(--text-primary);
    background-color: var(--border-color);
}

.note-header .pin-btn.pinned {
    color: var(--note-yellow);
}

.note-header .pin-btn.pinned:hover {
    color: #eab308;
}

.note-body {
    cursor: pointer;
}

.note-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px 0;
    word-break: break-all;
}

.note-preview {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
    max-height: 4.5em;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

/* ── Admin Banners ─────────────────────────── */

/* Promo Banner */
.promo-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    border-radius: 8px;
    margin: 8px 12px 4px;
    flex-wrap: wrap;
}
.promo-banner-msg { flex: 1; min-width: 100px; }
.promo-banner-code {
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.5px;
}
.promo-banner-code:hover { background: rgba(255,255,255,0.35); }
.promo-banner-discount {
    font-weight: 700;
    color: #fde68a;
}

/* Popup Banner Modal */
.admin-popup-banner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.admin-popup-banner {
    background: var(--bg-card, #fff);
    border-radius: 16px;
    padding: 28px 24px 22px;
    max-width: 380px;
    width: 100%;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
    animation: popupBannerIn 0.25s ease-out;
}
@keyframes popupBannerIn {
    from { opacity: 0; transform: scale(0.9) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.admin-popup-banner-close {
    position: absolute;
    top: 10px; right: 14px;
    background: none; border: none;
    font-size: 22px; cursor: pointer;
    color: var(--text-muted, #999);
    line-height: 1;
}
.admin-popup-banner-close:hover { color: var(--text-primary, #333); }
.admin-popup-banner-title {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 10px;
    color: var(--text-primary, #1e293b);
}
.admin-popup-banner-msg {
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--text-secondary, #64748b);
    margin: 0 0 14px;
}
.admin-popup-banner-link {
    display: inline-block;
    padding: 8px 20px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff !important;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.2s;
}
.admin-popup-banner-link:hover { opacity: 0.85; }

/* Top Banner (dashboard only) */
.admin-top-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    border-radius: 0;
    min-height: 34px;
}
.admin-top-banner.banner-info    { background: #3b82f6; }
.admin-top-banner.banner-success { background: #22c55e; }
.admin-top-banner.banner-warning { background: #f59e0b; color: #1e293b; }
.admin-top-banner.banner-danger  { background: #ef4444; }
.admin-top-banner-text { flex: 1; text-align: center; }
.admin-top-banner-dismiss {
    background: none; border: none;
    color: inherit; font-size: 18px;
    cursor: pointer; opacity: 0.7;
    line-height: 1;
}
.admin-top-banner-dismiss:hover { opacity: 1; }

/* ── Category Filter Bar ───────────────────── */
.category-filter-bar {
    display: flex;
    gap: 6px;
    padding: 6px 12px;
    overflow-x: auto;
    scrollbar-width: none;
    align-items: center;
    flex-wrap: nowrap;
    min-height: 38px;
    border-bottom: 1px solid var(--border-subtle, #e2e8f0);
}
.popup-mode .category-filter-bar {
    min-height: 46px;
    padding: 10px 12px;
    gap: 8px;
}
.category-filter-bar::-webkit-scrollbar { display: none; }

.category-chip {
    white-space: nowrap;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border-default, #cbd5e1);
    background: var(--bg-surface-2, #f1f5f9);
    color: var(--text-secondary, #64748b);
    transition: all 0.2s;
    font-family: inherit;
}
.popup-mode .category-chip {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 18px;
}
.category-chip:hover {
    background: var(--bg-surface-3, #e2e8f0);
    color: var(--text-primary, #1e293b);
}
.category-chip.active {
    background: var(--accent-primary, #3b82f6);
    color: #fff;
    border-color: var(--accent-primary, #3b82f6);
}
.add-category-chip {
    padding: 4px 10px;
    font-size: 11px;
    color: var(--accent-primary, #3b82f6);
    border-style: dashed;
    background: transparent;
}
.popup-mode .add-category-chip {
    padding: 6px 12px;
    font-size: 12px;
}
.add-category-chip:hover {
    background: var(--accent-primary, #3b82f6);
    color: #fff;
}

/* ── Add/Edit Category Modal ─────────────── */
.category-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

#categoryModalOverlay {
    z-index: 10010;
}
.category-modal {
    background: var(--bg-surface, var(--bg-surface-1, #fff));
    border-radius: 14px;
    width: 280px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    overflow: hidden;
    border: 1px solid var(--border-color, var(--border-default, #e2e8f0));
    animation: catModalIn 0.18s ease-out;
}
@keyframes catModalIn {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.category-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border-subtle, #e2e8f0);
}
.category-modal-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
}
.category-modal-close {
    background: none;
    border: none;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 6px;
    transition: all 0.15s;
}
.category-modal-close:hover {
    background: var(--bg-surface-2, #f1f5f9);
    color: var(--text-primary, #1e293b);
}
.category-modal-body {
    padding: 14px 16px;
}
.category-modal-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border-color, var(--border-default, #cbd5e1));
    border-radius: 10px;
    font-size: 13px;
    background: var(--bg-surface-2, #f8fafc);
    color: var(--text-primary, #1e293b);
    outline: none;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color 0.15s;
}
.category-modal-input:focus {
    border-color: var(--accent-primary, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.category-modal-hint {
    font-size: 11px;
    color: #ef4444;
    margin-top: 6px;
    min-height: 16px;
}
.category-modal-footer {
    display: flex;
    gap: 8px;
    padding: 10px 16px 14px;
    justify-content: flex-end;
}
.category-modal-btn {
    padding: 7px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    font-family: inherit;
}
.category-modal-btn.cancel {
    background: var(--bg-surface-2, #f1f5f9);
    color: var(--text-secondary, #64748b);
    border: 1px solid var(--border-color, var(--border-default, #e2e8f0));
}
.category-modal-btn.cancel:hover {
    background: var(--bg-surface-3, #e2e8f0);
}
.category-modal-btn.confirm {
    background: var(--accent-primary, #3b82f6);
    color: #fff;
}
.category-modal-btn.confirm:hover {
    filter: brightness(1.1);
}

/* ── Manage Categories Popup ─────────────── */
.manage-categories-popup {
    width: 300px;
    max-height: 380px;
    display: flex;
    flex-direction: column;
}
.manage-categories-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 240px;
}
.manage-categories-body::-webkit-scrollbar { width: 4px; }
.manage-categories-body::-webkit-scrollbar-thumb { background: var(--border-color, var(--border-default, #cbd5e1)); border-radius: 4px; }
.manage-categories-footer {
    padding: 10px 12px 12px;
    border-top: 1px solid var(--border-subtle, #e2e8f0);
}
.category-manage-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    border-radius: 10px;
    background: var(--bg-surface-2, #f8fafc);
    border: 1px solid var(--border-subtle, #e2e8f0);
    gap: 8px;
    transition: background 0.15s;
}
.category-manage-item:hover {
    background: var(--bg-surface-3, #f1f5f9);
}
.category-manage-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary, #1e293b);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.category-manage-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}
.category-manage-btn {
    background: none;
    border: none;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    font-size: 12px;
    padding: 5px 7px;
    border-radius: 6px;
    transition: all 0.15s;
}
.category-manage-btn:hover {
    background: var(--bg-surface-3, #e2e8f0);
    color: var(--text-primary, #1e293b);
}
.category-manage-btn.delete:hover {
    background: rgba(239,68,68,0.1);
    color: #ef4444;
}
.category-manage-empty {
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
    text-align: center;
    padding: 24px 12px;
}
.manage-cat-add-row {
    display: flex;
    gap: 6px;
    align-items: center;
}
.manage-cat-add-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: var(--accent-primary, #3b82f6);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.15s;
    flex-shrink: 0;
}
.manage-cat-add-btn:hover {
    filter: brightness(1.1);
}
/* Settings Manage button */
.setting-action-btn {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--accent-primary, #3b82f6);
    background: transparent;
    color: var(--accent-primary, #3b82f6);
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
}
.setting-action-btn:hover {
    background: var(--accent-primary, #3b82f6);
    color: #fff;
}

/* ── Category Badge on Notes ──────────────── */
.note-category-badge {
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--bg-surface-3, #e2e8f0);
    color: var(--text-muted, #94a3b8);
    font-weight: 500;
    white-space: nowrap;
    line-height: 1.3;
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    height: 18px;
}

/* ── Category Picker in Popup ─────────────── */
.category-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}
.category-picker span {
    font-size: 13px;
    color: var(--text-secondary, #64748b);
    font-weight: 500;
}
.category-picker select {
    flex: 1;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-default, #cbd5e1);
    background: var(--bg-input, #fff);
    color: var(--text-primary, #1e293b);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
}

/* Drag & Drop Styling */
#notesList li.dragging {
    opacity: 0.5;
    background: var(--border-color);
}

/* Note Colors */
/* Note Colors - Both Sides */
.note.white {
    border-left-color: #d1d5db;
    border-right-color: #d1d5db;
}

.note.blue {
    border-left-color: var(--note-blue);
    border-right-color: var(--note-blue);
}

.note.purple {
    border-left-color: var(--note-purple);
    border-right-color: var(--note-purple);
}

.note.yellow {
    border-left-color: var(--note-yellow);
    border-right-color: var(--note-yellow);
}

.note.green {
    border-left-color: var(--note-green);
    border-right-color: var(--note-green);
}

.note.red {
    border-left-color: var(--note-red);
    border-right-color: var(--note-red);
}

/* Empty State & Scrollbar */
.empty-notes-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.notes-container::-webkit-scrollbar {
    width: 6px;
}

.notes-container::-webkit-scrollbar-track {
    background: transparent;
}

.notes-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* Popup & Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: none;
    backdrop-filter: blur(4px);
}

/* In popup mode, overlay should not cover the sidebar if it's expanded */
body.popup-mode .overlay {
    left: 0;
    width: 100vw;
    transition: left 0.25s ease, width 0.25s ease;
}

body.popup-mode.sidebar-expanded .overlay {
    left: 60px;
    width: calc(100vw - 60px);
}

body.show-overlay .overlay {
    display: block;
}

.popup-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--bg-primary);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: var(--popup-max-width);
    max-width: var(--popup-width);
    max-height: 90vh;
    overflow-y: auto;
    z-index: 10001;
    border-radius: 12px;
    display: none;
    flex-direction: column;
}

/* In popup mode, adjust popup position to account for sidebar if expanded */
body.popup-mode .popup-box {
    left: 50%;
    margin-left: 0 !important;
    transition: left 0.25s ease;
}

body.popup-mode.sidebar-expanded .popup-box {
    left: calc(50% + 30px);
    /* Center it relative to the main content area (50% + half sidebar width) */
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.popup-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.popup-header .close-icon,
.settings-close,
.faq-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

.popup-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.popup-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Form Styles */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#titleTag,
.settings-form select {
    width: 100%;
    padding: 10px 14px;
    font-size: 16px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    box-sizing: border-box;
}

.editor-container {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

#editor {
    min-height: 150px;
    max-height: 250px;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg-secondary);
    outline: none;
    font-size: var(--text-body);
    font-family: 'Inter', sans-serif;
    /* Default editor font */
}

/* Plain Text Mode Styling */
#editor[data-plaintext="true"],
.note-full-desc[data-plaintext="true"] {
    font-family: var(--font-plaintext, 'Courier New', monospace) !important;
    font-size: var(--size-plaintext, 14px) !important;
    white-space: pre-wrap !important;
}

/* Ensure list view is compact but uses the font */
.note-body[data-plaintext="true"] .note-preview {
    font-family: var(--font-plaintext, 'Courier New', monospace) !important;
    font-size: var(--size-plaintext, 14px) !important;
    /* Retain original overflow behavior for compact view */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Force readable font for editing */
/* Editor Specific Override */
#editor[data-plaintext="true"] {
    font-family: var(--font-plaintext, 'Courier New', monospace) !important;
    white-space: pre-wrap !important;
}

.plain-text-row {
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Button Styles */
.btn-main,
.btn-alt {
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 500;
    border-radius: var(--border-radius);
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color 0.2s, opacity 0.2s;
    text-decoration: none;
}

.btn-main {
    background-color: var(--accent-color);
    color: var(--accent-text);
}

.btn-main:hover {
    opacity: 0.9;
}

.btn-alt {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-alt:hover {
    background-color: var(--border-color);
}

.custom-file-upload {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.custom-file-upload input[type="file"] {
    display: none;
}

/* Color Bar Picker */
.color-bar-picker {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-bar-options {
    display: flex;
    gap: 8px;
}

.color-bar {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    cursor: pointer;
    border-radius: 50%;
    transition: transform 0.2s, border-color 0.2s;
}

.color-bar.selected {
    border-color: var(--accent-color);
    transform: scale(1.1);
}

.color-bar.white {
    background: #e5e5e5;
}

.color-bar.blue {
    background: var(--note-blue);
}

.color-bar.purple {
    background: var(--note-purple);
}

.color-bar.yellow {
    background: var(--note-yellow);
}

.color-bar.green {
    background: var(--note-green);
}

.color-bar.red {
    background: var(--note-red);
}

/* Settings Popup */
/* Settings Popup */
.settings-form {
    width: 100%;
    /* Ensure full width */
}

.settings-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-form label {
    font-weight: 500;
    font-size: 14px;
}

.settings-form .toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.settings-form .backup-container {
    display: flex;
    gap: 12px;
}

/* Settings Actions */
.settings-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}


/* FAQ & Settings Donate Sections */
.faq-donate-section,
.settings-donate-section {
    padding: 12px;
    background-color: color-mix(in srgb, var(--accent-color) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent-color) 25%, transparent);
    border-radius: var(--border-radius);
    text-align: center;
}

.settings-donate-section {
    margin-top: 10px;
}

.faq-donate-section {
    margin: -10px -10px 15px -10px;
}

.faq-donate-section p,
.settings-donate-section p {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 500;
}

.donate-btn {
    width: auto;
    background-color: var(--accent-color);
    color: var(--accent-text) !important;
}

.donate-btn .fa-heart {
    color: #ef4444;
}

/* FAQ Details */
.faq-content {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding-right: 10px;
}

/* Also make FAQ scrollable */
.faq-content details {
    border-bottom: 1px solid var(--border-color);
    padding: 14px 4px;
    font-size: 14px;
}

.faq-content summary {
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    position: relative;
    padding-right: 20px;
}

.faq-content summary::after {
    content: '+';
    position: absolute;
    right: 0;
    font-size: 20px;
    color: var(--text-secondary);
}

.faq-content details[open] summary::after {
    content: '−';
}

.faq-content p {
    margin: 12px 0 0;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Classic Mode */
body.classic-mode {
    background: #f0f8ff;
    color: #333;
}

.classic-mode .header h1 {
    color: #3d8dca;
}

.classic-mode .note {
    border: 1px solid #ddd;
    background: #f9f9f9;
}

.classic-mode .note-header button:hover {
    background: #ddd;
}

.classic-mode .note-title {
    color: #3d8dca;
}

.classic-mode #colorBarPicker {
    display: none;
}

/* === AI ASSISTANT STYLES === */

.pro-feature {
    position: relative;
}

.pro-feature::after {
    content: 'PRO';
    position: absolute;
    top: -4px;
    right: -4px;
    background: linear-gradient(135deg, #8B5CF6, #A78BFA);
    color: white;
    font-size: 8px;
    font-weight: 700;
    padding: 2px 4px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

#aiPopup .popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.credits-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: #8B5CF6;
}

.ai-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.ai-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    font-weight: 500;
}

.ai-action-btn:hover {
    background: var(--border-color);
    border-color: #8B5CF6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
}

.ai-action-btn i {
    font-size: 24px;
    color: #8B5CF6;
}

.pricing-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.pricing-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    position: relative;
}

.pricing-card.featured {
    border-color: #8B5CF6;
}

.pricing-badge {
    position: absolute;
    top: -10px;
    right: 12px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #1a1a1a;
    font-size: 10px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
}

.pricing-price {
    font-size: 32px;
    font-weight: 700;
    color: #8B5CF6;
    margin-bottom: 16px;
}

.pricing-features {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
}

.pricing-features li::before {
    content: '?';
    color: #4CAF50;
    font-weight: 700;
    margin-right: 8px;
}

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

/* ===== POPUP MODE LAYOUT (Dark Left Sidebar) ===== */
body.popup-mode {
    width: 640px;

    /* Also make FAQ scrollable */
    .faq-content details {
        border-bottom: 1px solid var(--border-color);
        padding: 14px 4px;
        font-size: 14px;
    }

    .faq-content summary {
        font-weight: 600;
        cursor: pointer;
        list-style: none;
        position: relative;
        padding-right: 20px;
    }

    .faq-content summary::after {
        content: '+';
        position: absolute;
        right: 0;
        font-size: 20px;
        color: var(--text-secondary);
    }

    .faq-content details[open] summary::after {
        content: '−';
    }

    .faq-content p {
        margin: 12px 0 0;
        line-height: 1.6;
        color: var(--text-secondary);
    }

    /* Classic Mode */
    body.classic-mode {
        background: #f0f8ff;
        color: #333;
        font-family: 'Raleway', sans-serif;
    }

    .classic-mode .header h1 {
        color: #3d8dca;
    }

    .classic-mode .note {
        border: 1px solid #ddd;
        background: #f9f9f9;
    }

    .classic-mode .note-header button:hover {
        background: #ddd;
    }

    .classic-mode .note-title {
        color: #3d8dca;
    }

    .classic-mode #colorBarPicker {
        display: none;
    }

    /* === AI ASSISTANT STYLES === */

    .pro-feature {
        position: relative;
    }

    .pro-feature::after {
        content: 'PRO';
        position: absolute;
        top: -4px;
        right: -4px;
        background: linear-gradient(135deg, #8B5CF6, #A78BFA);
        color: white;
        font-size: 8px;
        font-weight: 700;
        padding: 2px 4px;
        border-radius: 3px;
        letter-spacing: 0.5px;
    }

    #aiPopup .popup-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
    }

    .credits-badge {
        display: flex;
        align-items: center;
        gap: 6px;
        background: rgba(139, 92, 246, 0.1);
        border: 1px solid rgba(139, 92, 246, 0.3);
        padding: 6px 12px;
        border-radius: 20px;
        font-size: 13px;
        font-weight: 600;
        color: #8B5CF6;
    }

    .ai-actions-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 24px;
    }

    .ai-action-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding: 16px;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s ease;
        font-size: 13px;
        font-weight: 500;
    }

    .ai-action-btn:hover {
        background: var(--border-color);
        border-color: #8B5CF6;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
    }

    .ai-action-btn i {
        font-size: 24px;
        color: #8B5CF6;
    }

    .pricing-options {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .pricing-card {
        background: var(--bg-secondary);
        border: 2px solid var(--border-color);
        border-radius: 12px;
        padding: 20px;
        position: relative;
    }

    .pricing-card.featured {
        border-color: #8B5CF6;
    }

    .pricing-badge {
        position: absolute;
        top: -10px;
        right: 12px;
        background: linear-gradient(135deg, #FFD700, #FFA500);
        color: #1a1a1a;
        font-size: 10px;
        font-weight: 700;
        padding: 4px 8px;
        border-radius: 4px;
    }

    .pricing-price {
        font-size: 32px;
        font-weight: 700;
        color: #8B5CF6;
        margin-bottom: 16px;
    }

    .pricing-features {
        list-style: none;
        padding: 0;
        margin: 0 0 20px 0;
    }

    .pricing-features li::before {
        content: '?';
        color: #4CAF50;
        align-items: center;
        padding: 12px 24px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        font-weight: 500;
    }

    .credits-info {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .credits-info i {
        font-size: 18px;
    }

    .btn-sm {
        padding: 6px 12px;
        font-size: 13px;
    }

    .ai-search-container {
        padding: 24px;
    }

    .ai-search-box {
        position: relative;
        margin-bottom: 24px;
    }

    .ai-search-input-wrapper {
        display: flex;
        align-items: center;
        background: var(--bg-secondary);
        border: 2px solid var(--border-color);
        border-radius: 12px;
        padding: 12px 16px;
        transition: all 0.3s ease;
    }

    .ai-search-input-wrapper:focus-within {
        border-color: #667eea;
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    }

    .ai-search-icon {
        color: #667eea;
        font-size: 18px;
        margin-right: 12px;
    }

    .ai-search-input {
        flex: 1;
        border: none;
        background: none;
        font-size: 15px;
        color: var(--text-primary);
        outline: none;
    }

    .ai-search-input::placeholder {
        color: var(--text-secondary);
    }

    .ai-tone-selector {
        margin-left: 12px;
    }

    .ai-tone-select {
        padding: 6px 12px;
        border: 1px solid var(--border-color);
        border-radius: 6px;
        background: var(--bg-primary);
        color: var(--text-primary);
        font-size: 13px;
        cursor: pointer;
    }

    .ai-search-suggestions {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        margin-top: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        z-index: 10;
    }

    .suggestion-item {
        padding: 12px 16px;
        cursor: pointer;
        transition: background 0.2s;
        border-bottom: 1px solid var(--border-color);
    }

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

    .suggestion-item:hover {
        background: var(--bg-primary);
    }

    .ai-response-area {
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 16px;
        margin-bottom: 24px;
    }

    .ai-response-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 12px;
    }

    .ai-response-label {
        font-weight: 600;
        color: var(--text-primary);
    }

    .ai-response-content {
        padding: 12px;
        background: var(--bg-primary);
        border-radius: 6px;
        min-height: 100px;
        max-height: 300px;
        overflow-y: auto;
        white-space: pre-wrap;
        line-height: 1.6;
    }

    .ai-history {
        margin-top: 24px;
    }

    .ai-history-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 12px;
        padding-bottom: 8px;
        border-bottom: 1px solid var(--border-color);
    }

    .ai-history-header span {
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 13px;
        text-transform: uppercase;
    }

    .btn-link {
        background: none;
        border: none;
        color: var(--accent-color);
        cursor: pointer;
        font-size: 13px;
        padding: 0;
    }

    .btn-link:hover {
        text-decoration: underline;
    }

    .ai-history-list {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .history-item {
        padding: 10px 12px;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: 6px;
        cursor: pointer;
        transition: all 0.2s;
        font-size: 14px;
    }

    .history-item:hover {
        border-color: var(--accent-color);
        transform: translateX(4px);
    }

    .history-item-text {
        color: var(--text-primary);
        margin-bottom: 4px;
    }

    .history-item-meta {
        font-size: 12px;
        color: var(--text-secondary);
    }

    /* Search Add Button */
    .search-add-btn {
        position: absolute;
        right: 24px;
        bottom: -20px;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border: none;
        color: white;
        font-size: 20px;
        cursor: pointer;
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
        transition: all 0.3s ease;
        z-index: 10;
    }

    .search-add-btn:hover {
        transform: scale(1.1);
        box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
    }

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

    /* Adjust notes container to account for floating button */
    body.popup-mode .notes-container {
        padding: 24px 24px 24px 24px;
    }
}

/* ===== SIDEBAR MODE LAYOUT (Horizontal Header) ===== */
/* Only apply these styles when NOT in popup mode */
body:not(.popup-mode) .container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

body:not(.popup-mode) .container .header {
    flex-shrink: 0;
    padding: 8px 12px;
    background: #2C3E50;
    border-bottom: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body:not(.popup-mode) .container .header .actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Remove spacer - let icons wrap naturally */
body:not(.popup-mode) .container .header .header-spacer {
    display: none;
}

/* Compact nav-icon styles for header */
body:not(.popup-mode) .header .nav-icon {
    width: 40px;
    height: 40px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 18px;
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

body:not(.popup-mode) .header .nav-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.95);
    transform: translateY(-2px);
}

body:not(.popup-mode) .header .nav-icon.active {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}

/* Compact AI Circle Badge in Header */
body:not(.popup-mode) .header .ai-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: white;
    letter-spacing: 0.5px;
}

/* Ensure content-view fills remaining space in sidebar mode */
body:not(.popup-mode) .container .content-view.active {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

body:not(.popup-mode) .container .content-view.active::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

/* Sidepanel: compact content-header and view-content */
body:not(.popup-mode) .content-header {
    padding: 12px 20px;
    justify-content: center;
}

body:not(.popup-mode):not(.dashboard-mode) .content-header h1 {
    font-size: 18px;
    text-align: center;
}

body:not(.popup-mode):not(.dashboard-mode) .view-content {
    padding: 0 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

body:not(.popup-mode):not(.dashboard-mode) .view-content > * {
    width: 100%;
    max-width: 400px;
}

/* Hide redundant header in sidebar mode */
/* content-header visible for Add Note button */
body:not(.popup-mode):not(.dashboard-mode) .container #notesView .content-header {
    display: flex;
    justify-content: center;
    /* Center the button if desired, or leave default */
    border-bottom: none;
    /* Optional: remove border if it looks cleaner */
    padding-bottom: 0;
}

#addNoteBtn {
    width: 100%;
    justify-content: center;
}

/* ===== RESPONSIVE HEADER FOR NARROW WIDTHS ===== */
@media (max-width: 300px) {
    body:not(.popup-mode) .header .nav-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    body:not(.popup-mode) .header .ai-circle {
        width: 24px;
        height: 24px;
        font-size: 9px;
    }

    body:not(.popup-mode) .container .header {
        padding: 6px 8px;
        gap: 6px;
    }

    body:not(.popup-mode) .container .header .actions {
        gap: 6px;
    }
}

/* =========================================
   AI VIEW STYLES
   ========================================= */
.ai-credits-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.dashboard-notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* =========================================
   DASHBOARD SEARCH FIX & ADVANCED AI
   ========================================= */

.dashboard-search-wrapper {
    max-width: 600px;
    margin: 0 auto 32px auto;
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-surface-2);
    border-radius: 12px;
    padding: 4px;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.dashboard-search-wrapper i.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--text-secondary);
    z-index: 2;
}

.dashboard-search-input {
    width: 100%;
    height: 48px;
    border: none;
    background: transparent;
    padding: 0 60px 0 48px;
    font-size: 16px;
    color: var(--text-primary);
    outline: none;
}

.dashboard-add-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--accent-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-right: 4px;
}

.dashboard-add-btn:hover {
    background: color-mix(in srgb, var(--accent-color), black 10%);
    transform: scale(1.05);
}

/* AI Dashboard Layout */
.ai-dashboard-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
    height: calc(100vh - 140px);
    /* Fill remaining height */
}

.ai-chat-panel {
    background: var(--bg-surface-2);
    border-radius: 16px;
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-controls-panel {
    background: var(--bg-surface-1);
    border-radius: 16px;
    border: 1px solid var(--border-subtle);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-label {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.option-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.option-btn {
    padding: 8px 12px;
    border: 1px solid var(--border-default);
    background: var(--bg-surface-1);
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    color: var(--text-primary);
}

.option-btn:hover {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.05);
}

.option-btn.selected {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.ai-dash-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.ai-dash-input-area {
    padding: 16px;
    background: var(--bg-surface-1);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: 12px;
}

.ai-dash-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-default);
    border-radius: 24px;
    background: var(--bg-surface-2);
    color: var(--text-primary);
    outline: none;
    font-size: 15px;
}

.ai-dash-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}


.credits-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
}

.credits-info i {
    color: #f59e0b;
}

.ai-search-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-search-box {
    position: relative;
    z-index: 10;
}

.ai-search-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.ai-search-input-wrapper:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.ai-search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 15px;
    color: var(--text-primary);
    outline: none;
    margin: 0 12px;
    min-width: 0;
}

.ai-tone-selector select {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    outline: none;
}

.ai-history {
    margin-top: 10px;
}

.ai-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.ai-history-header span {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.ai-history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover {
    border-color: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.history-item-text {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-weight: 500;
}

.history-item-meta {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Modern AI Interface */
.ai-view-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.ai-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.05) 0%, transparent 100%);
}

.ai-message {
    display: flex;
    gap: 12px;
    max-width: 85%;
}

.ai-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-message.assistant {
    align-self: flex-start;
}

.ai-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.ai-message.user .ai-avatar {
    background-color: var(--border-color);
    color: var(--text-secondary);
}

.ai-message.assistant .ai-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.ai-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.ai-message.user .ai-bubble {
    background-color: var(--accent-color);
    color: var(--accent-text);
    border-bottom-right-radius: 2px;
}

.ai-message.assistant .ai-bubble {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 2px;
}

.ai-input-area {
    padding: 16px;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 8px 16px;
    transition: box-shadow 0.2s;
}

.ai-input-wrapper:focus-within {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
    border-color: var(--accent-color);
}

.ai-input {
    flex: 1;
    border: none;
    background: none;
    resize: none;
    max-height: 100px;
    padding: 8px 0;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    color: var(--text-primary);
}

.ai-send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.ai-send-btn:hover {
    transform: scale(1.05);
}

.ai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-credits-pill {
    position: absolute;
    top: 16px;
    right: 16px;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-color);
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Suggestions */
.ai-suggestions {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
}

.ai-suggestions::-webkit-scrollbar {
    display: none;
}

.suggestion-chip {
    white-space: nowrap;
    padding: 6px 12px;
    border-radius: 16px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-chip:hover {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Force Theme-Specific Header Colors (Fix for Variable Scope Issues) */
body.theme-light .header {
    background-color: #2C3E50 !important;
}

body.theme-dark .header {
    background-color: #1f2937 !important;
}

body.theme-classic .header,
body.classic-mode .header {
    background-color: #2C3E50 !important;
}

body.theme-nord .header {
    background-color: #3B4252 !important;
}

body.theme-ocean .header {
    background-color: #1d263b !important;
}

body.theme-pink .header {
    background-color: #be185d !important;
}

body.theme-solarized-light .header {
    background-color: #eee8d5 !important;
    color: #586e75 !important;
}

/* Fix contrast for light header */
body.theme-solarized-dark .header {
    background-color: #073642 !important;
}

/* Ensure nav icons in light header (Solarized Light) are dark */
body.theme-solarized-light .header .nav-icon {
    color: rgba(88, 110, 117, 0.7) !important;
}

body.theme-solarized-light .header .nav-icon:hover {
    color: #586e75 !important;
    background-color: rgba(0, 0, 0, 0.05) !important;
}

body.theme-solarized-light .header .nav-icon.active {
    color: #268bd2 !important;
    background-color: rgba(0, 0, 0, 0.1) !important;
}

/* ========== THEME GALLERY ========== */

.theme-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
}

.theme-card-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.theme-card-btn:hover {
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.theme-card-btn.active {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px var(--accent-color);
}

.tc-preview {
    width: 100%;
    aspect-ratio: 4/3;
    border-radius: 4px;
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tc-bar {
    height: 6px;
    border-radius: 2px;
    border: 1px solid;
}

.tc-accent {
    height: 5px;
    width: 50%;
    border-radius: 2px;
}

.tc-text {
    height: 3px;
    width: 75%;
    border-radius: 1px;
    opacity: 0.6;
}

.tc-text-s {
    height: 3px;
    width: 50%;
    border-radius: 1px;
    opacity: 0.35;
}

.tc-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.tc-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: none;
    background: #ef4444;
    color: white;
    font-size: 9px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    line-height: 1;
}

.theme-card-btn:hover .tc-delete {
    opacity: 1;
}

/* ========== THEME EDITOR ========== */

.theme-editor-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.te-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.te-row>span {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 50px;
}

.te-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
}

.te-toggle {
    display: flex;
    gap: 4px;
}

.te-mode {
    padding: 4px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.te-mode.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.te-colors {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.te-color-field {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.te-color-field input[type="color"] {
    width: 34px;
    height: 34px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    padding: 1px;
    background: var(--bg-primary);
}

.te-color-field input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.te-color-field input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

.te-color-field>span {
    font-size: 9px;
    color: var(--text-secondary);
}

.te-preview {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    transition: all 0.2s;
}

.te-preview-header {
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 600;
    border-bottom: 1px solid;
}

.te-preview-body {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.te-preview-text {
    font-size: 12px;
}

.te-preview-btn {
    align-self: flex-start;
    padding: 4px 14px;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: default;
}

.te-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--accent-color);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--accent-color);
}

input:checked+.slider:before {
    -webkit-transform: translateX(20px);
    -ms-transform: translateX(20px);
    transform: translateX(20px);
}

/* Rounded sliders by default */
.slider {
    border-radius: 34px;
}

.slider:before {
    border-radius: 50%;
}

/* Settings View Redesign (Clean Layout) */
.settings-section-container {
    margin-bottom: 32px;
}

.settings-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding-left: 4px;
}

.settings-card {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

/* Individual setting row */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-row:hover {
    background: var(--bg-surface-3);
    /* Slight hover effect */
}

.setting-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 16px;
    flex: 1;
}

.setting-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.setting-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.setting-control {
    flex-shrink: 0;
}

/* Specific inputs in settings */
.setting-select {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    cursor: pointer;
    min-width: 140px;
}

.setting-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.setting-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-number-input {
    width: 60px;
    padding: 6px;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* Section specific overrides */
.expandable-content {
    background: var(--bg-surface-1);
    border-top: 1px solid var(--border-color);
    padding: 16px;
    display: none;
    /* controlled by JS */
}

.expandable-content.active {
    display: block;
}

/* ========== AI LOCK OVERLAY ========== */
.ai-lock-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 0;
    padding: 24px;
    box-sizing: border-box;
}

.ai-lock-card {
    background: var(--bg-surface-2, #1e293b);
    border: 1px solid rgba(139, 92, 246, 0.35);
    border-radius: 16px;
    padding: 28px 24px;
    text-align: center;
    max-width: 280px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: fadeInUp 0.25s ease-out;
}

.ai-lock-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(59, 130, 246, 0.25));
    border: 1px solid rgba(139, 92, 246, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    font-size: 22px;
    color: #a78bfa;
}

.ai-lock-card h3 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 700;
    color: #f1f5f9;
}

.ai-lock-card p {
    margin: 0 0 18px;
    font-size: 13px;
    color: var(--text-secondary, #94a3b8);
    line-height: 1.5;
}