/* ==================================================
   APP BASE STYLES
   Section Map:
   1) Variables & Theme
   2) Global Resets
   3) Base Elements + Buttons
   4) Sidebar (Left)
   5) Right Sidebar + Canvas
   ================================================== */

@import url('https://fonts.googleapis.com/css2?family=STIX+Two+Text&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/*=============================================
=            Variables & Theming              =
=============================================*/
/* === BASE: Theme Variables === */
:root {
    --primary-red: #e53e3e;
    --primary-red-hover: #c53030;
    --primary-red-dark: #b71c1c;
    --primary-red-light: #ef9a9a;
    --shadow-color: rgba(229, 57, 53, 0.25);
    --red-50: #fef2f2;
    --blue-50: #eff6ff;
    --blue-500: #3b82f6;
    --green-50: #f0fdf4;
    --gray-light: #f5f5f5;
    --gray-medium: #bdbdbd;
    --gray-dark: #424242;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-color: #333333;
    --bg-color: #ffffff;
    --container-bg: #ffffff;
    --card-bg: #ffffff;
    --input-bg: #ffffff;
    --border-color: #ccc;
    --sidebar-bg: #F9FAFB;
    --sidebar-hover: rgba(0, 0, 0, 0.05);
    --sidebar-active: #fa8db3;
    --sidebar-icon: var(--text-primary);
    --sidebar-text: #eae3e3;
    --mcq-bg: #f5f5f5;
    --mcq-header: #222;
    --mcq-link: #222;
    --mcq-scrollbar: #c9c9c9;
    --mcq-border: #ccc;
    --mcq-hover: #e0e0e0;
    --right-sidebar-bg: rgba(255, 255, 255, 0.85);
    --sidebar-active-bg: var(--red-50);
    --sidebar-active-text: var(--primary-red);
    --secondary-btn-bg: #ffffff;
    --secondary-btn-text: var(--text-secondary);
    --secondary-btn-hover-bg: #f9fafb;
}

/* === BASE: Dark Theme Overrides === */
[data-theme="dark"] {
    --primary-red: #e53e3e;
    --primary-red-hover: #c53030;
    --blue-50: #1a2a3a;
    --red-50: #3a1a1a;
    --green-50: #1a3a2a;
    --text-primary: #f7fafc;
    --text-secondary: #a0aec0;
    --text-color: #e0e0e0;
    --bg-color: #1a1a1a;
    --container-bg: #2a2a2a;
    --card-bg: #1e1e1e;
    --input-bg: #333;
    --border-color: #444444;
    --sidebar-bg: #1a1a1a;
    --sidebar-text: #e0e0e0;
    --sidebar-hover: #333333;
    --sidebar-active: #444444;
    --sidebar-icon: #bbbbbb;
    --mcq-bg: #2a2a2a;
    --mcq-header: #f1f1f1;
    --mcq-link: #f1f1f1;
    --mcq-scrollbar: #555;
    --mcq-border: #444;
    --mcq-hover: #3a3a3a;
    --right-sidebar-bg: rgba(30, 30, 30, 0.85);
    --sidebar-active-bg: var(--red-50);
    --sidebar-active-text: var(--primary-red-light);
    --secondary-btn-bg: #374151;
    --secondary-btn-text: var(--text-primary);
    --secondary-btn-hover-bg: #4b5563;
}

/*=============================================
=            Global Styles & Resets           =
=============================================*/

/*
  Disable browser/framework default focus rings so only our component
  styles control focus appearance.

  Note: we intentionally keep specificity at 0 via :where() so any
  component rule (e.g. .sidebar-but:focus-visible) can still override.
*/
/* === BASE: Focus + Reset === */
:where(button, [type="button"], [type="submit"], [type="reset"], a, input, textarea, select):focus {
    outline: none;
    box-shadow: none;
}

:where(button, [type="button"], [type="submit"], [type="reset"], a, input, textarea, select):focus-visible {
    outline: none;
    box-shadow: none;
}

/* Remove mobile tap highlight */
:where(button, a, input, textarea, select) {
    -webkit-tap-highlight-color: transparent;
}


/*=============================================
=        Feature Badge Styling               =
=============================================*/
/* === BASE: Feature Badge === */
.feature-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, var(--primary-red) 0%, var(--primary-red-hover) 100%);
    color: white;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(229, 57, 53, 0.3);
    border: none;
    animation: slideIn 0.3s ease;
}

.feature-badge:hover {
    background: linear-gradient(135deg, var(--primary-red-hover) 0%, var(--primary-red-dark) 100%);
    box-shadow: 0 4px 12px rgba(229, 57, 53, 0.4);
    transform: translateY(-2px);
}

.feature-badge i {
    font-size: 14px;
}

.feature-badge-text {
    font-size: 12px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

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


* {
    box-sizing: border-box;
}

/* === BASE: Document Defaults === */
body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

/* Prevent browser zoom/resizing and input color changes */
input,
textarea,
select {
    resize: none !important;
}


body.modal-open {
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
}

th,
td {
    border: 1px solid #444;
    padding: 8px;
}

.hidden {
    display: none;
}

.text-center {
    text-align: center;
}

.text-primary {
    --bs-text-opacity: 1;
    color: rgb(255 0 0) !important;
}

.p-16px {
    padding: 16px;
}


.preview-wrapper {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    width: 100%;
}

.preview-wrapper img {
    width: 70px;
    height: 70px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Sidebar action row buttons */
.sidebar-action-row {
    display: flex;
    gap: 8px;
    justify-content: space-between;
    align-items: center;
    margin: 16px 16px 16px 16px;
}

.sidebar-action-row .mindmap-btn,
.sidebar-action-row .nav-icon-btn {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    border: none;
    text-decoration: none;
    border-radius: 6px;
    background: var(--border-color);
    color: var(--text-color);
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    position: relative;
}

.sidebar-action-row .mindmap-btn span,
.sidebar-action-row .nav-icon-btn span {
    display: none;
}


/* Show tooltip on hover */
.sidebar-action-row .mindmap-btn[title]:hover::after,
.sidebar-action-row .nav-icon-btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0.9;
}

/* Hover effect */
.sidebar-action-row .mindmap-btn:hover,
.sidebar-action-row .nav-icon-btn:hover {
    background: #007bff;
    color: #fff;
    transform: translateY(-2px);
}


#mistake-text {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
    margin-bottom: 0;
}


/* Mobile responsive */
@media (max-width: 600px) {
    .sidebar-action-row {
        flex-wrap: wrap;
        gap: 6px;
    }

    .sidebar-action-row .mindmap-btn,
    .sidebar-action-row .nav-icon-btn {
        flex: 0 0 48%;
        padding: 12px;
    }
}


[data-theme="dark"] .tyu78 {
    background-color: #1e1e1e;
    color: #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7);
    width: 300px;
    max-width: 90%;
    overflow: hidden;
    transform: scale(.8);
    transition: transform .3s, background-color .3s, color .3s;
    user-select: none;
    font-family: Arial, sans-serif;
}

[data-theme="dark"] .tyu78 .bgh56 {
    font-weight: bold;
    font-size: 1.2rem;
    padding: 12px 16px;
    background-color: #2c2c2c;
    border-bottom: 1px solid #444;
    color: #ff4d4d;
}



[data-theme="dark"] .tyu78 .opi12 {
    padding: 16px;
    font-size: 1rem;
    color: #ccc;
}

/* Memory box light mode */
/* Memory box light mode - professional code style */
.memory-box {
    padding: 16px;
    font-size: 1rem;
    font-family: 'Fira Code', monospace;
    color: #333;
    background-color: #f0f0f0;
    border-radius: 8px;
    border: 1px solid #ccc;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    transition: background-color 0.3s, color 0.3s, box-shadow 0.3s;
}

/* Memory box dark mode - professional code style */
[data-theme="dark"] .memory-box {
    padding: 16px;
    font-size: 1rem;
    font-family: 'Fira Code', monospace;
    color: #ccc;
    background-color: #1f1f1f;
    border-radius: 8px;
    border: 1px solid #333;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    transition: background-color 0.3s, color 0.3s, box-shadow 0.3s;
}

[data-theme="dark"] .tyu78 .qwe90 .lmn45 {
    display: block;
    width: 100%;
    padding: 12px;
    border: none;
    background-color: #3f0d0d;
    color: #ffffff;
    font-weight: bold;
    cursor: pointer;
    transition: background-color .3s, transform .2s;
    border-radius: 0 0 12px 12px;
}

[data-theme="dark"] .tyu78 .qwe90 .lmn45:hover {
    background-color: #3f0d0d;
    transform: scale(1.05);
}

/*=============================================
=                  Animations                 =
=============================================*/

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

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

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

@keyframes bounce {

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

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

@keyframes functionAdded {
    0% {
        background-color: #e8f0fe;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    20% {
        background-color: #d2e3fc;
        box-shadow: 0 4px 12px rgba(26, 115, 232, 0.2);
        transform: translateY(-2px);
    }

    40% {
        background-color: #aecbfa;
    }

    100% {
        background-color: #e8f0fe;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }
}

@keyframes checkmarkAppear {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }

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

/*=============================================
=              Layout & Structure             =
=============================================*/

.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    position: relative;
}

.main-content {
    flex: 1;
    background-color: rgb(255, 255, 255);
    background-size: 20px 20px;
    height: 100%;
    position: relative;
    overflow: auto;
    transition: margin-left 0.3s ease, margin-right 0.35s ease;
}

.content {
    flex-grow: 1;
    padding: 20px;
    width: 100%;
    transition: width 0.3s ease;
}

.sidebar:not(.hidden)~.main-content .sidebar-icon-btn#toggleSidebar {
    display: none;
}

.sidebar.hidden~.main-content .content {
    width: 100%;
}

.right-sidebar-active .main-content {
    margin-right: 420px;
}

.chat-area-wrapper {
    height: calc(100dvh - 64px);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    position: relative;
    background: var(--bg-color);
}

.chat-area-wrapper.empty-state {
    justify-content: center;
    padding-top: 0;
}

.chat-area-wrapper.empty-state {
    transform: none;
    padding-bottom: 6vh;
}

.chat-area-wrapper.empty-state .chat-start-container {
    flex: 0 0 auto;
    padding-top: 0;
    padding-bottom: 0;
}

.chat-area-wrapper.empty-state .chat-wrapper {
    flex: 0 0 auto;
    width: 100%;
    padding-top: 0;
    padding-bottom: 0;
}

.chat-area-wrapper.empty-state .chat-input-container {
    margin-top: 5px;
    max-width: 760px;
}


.chat-area-wrapper.has-messages {
    justify-content: flex-start;
}

.chat-area-wrapper .messages-container {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
    margin: 0;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    padding: 32px calc((100% - min(960px, 100% - 32px)) / 2) 16px;
    gap: 12px;
    box-sizing: border-box;
}

.chat-area-wrapper .chat-start-container {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.y-overflow-auto {
    overflow-y: auto;
}

.question-sheet-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}




/*=============================================
=                   Navbar                    =
=============================================*/

/* Main navbar styles consolidated in ENHANCED NAVBAR section */

.model-switcher {
    display: flex;
    gap: 12px;
    align-items: center;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.dropdown {
    position: relative;
}

.model-switcher-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    background: var(--container-bg);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 10px;
    color: var(--text-secondary);
}

.model-switcher-btn:hover {
    background: var(--gray-light);
    border-color: var(--primary-red);
    color: var(--primary-red);
}

.model-switcher-btn.open {
    background: var(--primary-red);
    border-color: var(--primary-red);
    color: white;
}

/* Model Dropdown Menu - Clean Enterprise Design */
.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--container-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
    display: none;
    min-width: 180px;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.dropdown-menu.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* Dropdown Menu Items */
.dropdown-menu li {
    list-style: none;
    padding: 10px 14px;
    margin: 2px 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dropdown-menu li:hover {
    background: var(--gray-light);
    color: var(--text-primary);
}

.dropdown-menu li.selected {
    background: var(--primary-red);
    color: white;
    font-weight: 600;
}

.dropdown-menu li.selected:hover {
    background: var(--primary-red-hover);
}


/*=============================================
=                 Sidebars                    =
=============================================*/

/* === BASE: Left Sidebar === */
/* --- Left Sidebar --- */
.sidebar {
    background-color: var(--sidebar-bg);
    width: 260px;
    min-width: 260px;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
        width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
        min-width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    overflow: hidden;
    position: relative;
    z-index: 9997;
    border-right: 1px solid var(--border-color);
}

/* Desktop: minimized sidebar (70px with icons) */
@media (min-width: 956px) {
    .sidebar.hidden {
        width: 70px;
        min-width: 70px;
    }

    .sidebar.hidden .sidebar-but-text,
    .sidebar.hidden .sidebar-but-shortcut {
        display: none;
    }

    .sidebar.hidden .sidebar-but {
        justify-content: center;
        padding: 10px;
        position: relative;
    }

    .sidebar.hidden .sidebar-but:hover::after {
        content: attr(title);
        position: absolute;
        left: calc(100% + 12px);
        top: 50%;
        transform: translateY(-50%);
        padding: 8px 14px;
        background: rgba(0, 0, 0, 0.9);
        color: white;
        border-radius: 8px;
        white-space: nowrap;
        font-size: 14px;
        font-weight: 500;
        z-index: 10000;
        pointer-events: none;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        animation: tooltipFadeIn 0.2s ease;
    }

    @keyframes tooltipFadeIn {
        from {
            opacity: 0;
            transform: translateY(-50%) translateX(-5px);
        }

        to {
            opacity: 1;
            transform: translateY(-50%) translateX(0);
        }
    }

    .sidebar.hidden .sidebar-but:hover::before {
        content: '';
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        margin-left: 6px;
        width: 0;
        height: 0;
        border-style: solid;
        border-width: 5px 6px 5px 0;
        border-color: transparent rgba(0, 0, 0, 0.9) transparent transparent;
        z-index: 10000;
        pointer-events: none;
    }

    .sidebar.hidden .user-details {
        display: none;
    }

    .sidebar.hidden .sidebar-footer-userinfo {
        justify-content: center;
        padding: 6px;
    }

    .sidebar.hidden~.main-content {
        margin-left: 70px;
    }
}

/* Mobile: completely hide sidebar */
@media (max-width: 955px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100dvh;
        width: min(84vw, 320px);
        min-width: 0;
        transform: translate3d(-100%, 0, 0);
        transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform;
        contain: layout paint;
        z-index: 9997;
    }

    .sidebar.hidden {
        transform: translate3d(-100%, 0, 0);
    }

    .sidebar:not(.hidden) {
        transform: translate3d(0, 0, 0);
    }

    .sidebar.hidden~.main-content {
        margin-left: 0;
    }
}

.sidebar-header {
    padding: 16px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    min-height: 56px;
}

.sidebar-icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-icon-btn svg {
    stroke: currentColor;
}

.sidebar-icon-btn:hover {
    background: var(--sidebar-hover);
    color: var(--primary-red);
    transform: scale(1.05);
}

/* Mobile: always show toggle button on the left */
@media (max-width: 955px) {
    .navbar-left .sidebar-icon-btn {
        display: flex !important;
    }
}

.sidebar-sections {
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-section {
    padding-bottom: 8px;
    padding-top: 0px;
}

.sidebar-header-toggle {
    font-size: 12px;
    color: #888;
    padding: 0 16px;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

.scrollable-chat-list {
    max-height: calc(100vh - 250px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #444 transparent;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    padding: 10px 0 16px 0;
    box-sizing: border-box;
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #666;
    padding: 4px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}


.scrollable-chat-list::-webkit-scrollbar {
    width: 6px;
}

.scrollable-chat-list::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}

.sidebar-item-wrapper {
    position: relative;
    border-radius: 6px;
    margin: 2px 0;
}

.sidebar-item-wrapper.is-active a span {
    font-weight: 600;
}

.sidebar-item-wrapper.is-active .sidebar-conv-link span {
    font-weight: 600;
}

.sidebar-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: 6px;
    transition: all 0.3s ease;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    text-decoration: none;
    gap: 12px;
    color: var(--sidebar-text);
    margin-bottom: 4px;
}

.sidebar-item.active {
    background-color: var(--sidebar-active);
    color: #f9fffd;
}

.sidebar-item:hover a {
    color: red;
}

.sidebar-item:hover .sidebar-conv-link {
    color: red;
}

.sidebar-item a {
    text-decoration: none;
    color: #737373;
    font-size: 14px;
    flex-grow: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.sidebar-item .sidebar-conv-link {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: #737373;
    font-size: 14px;
    flex-grow: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-align: left;
    cursor: pointer;
}

.sidebar-footer {
    position: relative;
    width: 100%;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    margin-top: auto;
    background-color: var(--sidebar-bg);
    transition: opacity 0.3s ease, padding 0.25s ease;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
}

.sidebar.hidden .sidebar-footer {
    padding: 16px 8px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.sidebar-minimize-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
}

.sidebar-minimize-btn:hover {
    background: var(--sidebar-hover);
    color: var(--primary-red);
    border-color: var(--primary-red);
}

.sidebar-minimize-btn svg {
    flex-shrink: 0;
}

.sidebar.hidden .sidebar-minimize-btn {
    display: none;
}

/* Desktop: clicking minimized sidebar should have pointer cursor */
@media (min-width: 956px) {
    .sidebar.hidden {
        cursor: pointer;
    }

    .sidebar.hidden .sidebar-but {
        cursor: pointer;
    }
}

.sidebar-footer-userinfo {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background-color: #f9fafb;
    color: #333;
    border-radius: 0;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-size: 0.875rem;
    line-height: 1.1;
}

.sidebar-footer-userinfo .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-footer-userinfo .user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-footer-userinfo .user-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.sidebar-footer-userinfo .user-name {
    font-weight: 500;
    font-size: 0.875rem;
    color: #000;
    margin: 0;
}

.sidebar-footer-userinfo .user-credit-text {
    font-size: 0.75rem;
    color: #555;
    margin: 2px 0 0 0;
}

.sidebar-footer-userinfo .credit-bar-container {
    background-color: #fee2e2;
    height: 4px;
    width: 100%;
    max-width: 150px;
    overflow: hidden;
    margin-top: 4px;
    border-radius: 0;
}

.sidebar-footer-userinfo .credit-bar-fill {
    background-color: #ef4444;
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 0;
}

.sidebar-backn {
    background: none;
    border: none;
    display: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #333;
}

/* === BASE: Right Sidebar === */
/* --- Right Sidebar --- */
.right-sidebar {
    position: fixed;
    top: 0;
    right: -420px;
    width: 420px;
    height: 100vh;
    background: var(--right-sidebar-bg);
    backdrop-filter: blur(12px);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 999;
    transition: right 0.35s ease;
    overflow-y: auto;
    padding: 24px;
    box-sizing: border-box;
    border-left: 1px solid rgba(255, 255, 255, 0.25);
}

.right-sidebar.active {
    right: 0;
}

.right-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.right-sidebar-header h4 {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0;
    color: #2c3e50;
}

.right-sidebar-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #333;
    transition: color 0.2s;
}

.right-sidebar-close:hover {
    color: #ff4d4d;
}

.right-sidebar::-webkit-scrollbar {
    width: 6px;
}

.right-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.right-sidebar::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}


/* === BASE: Right Sidebar 2 / Canvas === */
/* --- Right Sidebar 2 --- */
#rightsidebar2 {
    position: fixed;
    right: -420px;
    top: 0;
    width: 420px;
    height: 100vh;
    background: var(--container-bg);
    box-shadow: -8px 0 24px rgba(15, 23, 42, 0.08);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
    display: flex;
    flex-direction: column;
    will-change: transform;
    border-left: 1px solid var(--border-color);
}

/* =============================
   Canvas sidebar (rightsidebar2)
   ============================= */
#rightsidebar2.canvas-sidebar {
    background: var(--container-bg);
}

#rightsidebar2 .canvas-header-actions {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

#rightsidebar2 .canvas-header-btn {
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.25);
    color: #000;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 10px;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background 0.2s ease;
}

#rightsidebar2 .canvas-header-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

#rightsidebar2 .canvas-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 12px 14px;
    background: var(--container-bg);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    position: sticky;
    top: 64px;
    z-index: 2;
}

#rightsidebar2 .canvas-toolbar-group {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

#rightsidebar2 .canvas-toolbar-separator {
    width: 1px;
    height: 28px;
    background: var(--border-color);
}

#rightsidebar2 .canvas-tool-btn {
    border: 1px solid var(--border-color);
    background: var(--secondary-btn-bg);
    color: var(--secondary-btn-text);
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
}

#rightsidebar2 .canvas-tool-btn:hover {
    transform: translateY(-1px);
}

#rightsidebar2 .canvas-page-size,
#rightsidebar2 .canvas-font-size {
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--secondary-btn-bg);
    color: var(--secondary-btn-text);
    padding: 0 10px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
}

#rightsidebar2 .canvas-page-size:focus-visible,
#rightsidebar2 .canvas-font-size:focus-visible {
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.15);
}

#rightsidebar2 .canvas-color-picker {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--secondary-btn-bg);
    padding: 4px;
    cursor: pointer;
}

#rightsidebar2 .canvas-tool-btn.is-active {
    border-color: var(--primary-red);
    color: var(--primary-red);
    background: var(--sidebar-active-bg);
}

#rightsidebar2 .canvas-stage {
    position: relative;
    flex: 1;
    overflow: auto;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.9), rgba(248, 250, 252, 0.6));
    padding: 18px 16px 28px;
}

#rightsidebar2 .canvas-status-bar {
    background: var(--container-bg);
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -10px 24px rgba(15, 23, 42, 0.08);
    z-index: 100000;
}

[data-theme="dark"] #rightsidebar2 .canvas-status-bar {
    background: #0b1220;
    color: #cbd5f5;
    border-top-color: #1f2937;
}

#rightsidebar2 .canvas-stage.canvas-ruler-visible::before,
#rightsidebar2 .canvas-stage.canvas-ruler-visible::after {
    content: "";
    position: sticky;
    left: 0;
    top: 0;
    background: repeating-linear-gradient(
        to right,
        rgba(148, 163, 184, 0.4),
        rgba(148, 163, 184, 0.4) 1px,
        transparent 1px,
        transparent 24px
    );
    height: 18px;
    width: 100%;
    display: block;
    z-index: 2;
}

#rightsidebar2 .canvas-stage.canvas-ruler-visible::after {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 18px;
    background: repeating-linear-gradient(
        to bottom,
        rgba(148, 163, 184, 0.4),
        rgba(148, 163, 184, 0.4) 1px,
        transparent 1px,
        transparent 24px
    );
}

#rightsidebar2 .canvas-doc {
    position: relative;
    margin: 0 auto;
    width: min(100%, 820px);
    min-height: 70vh;
    padding: 24px 28px;
    outline: none;
    color: var(--text-primary);
    background: var(--container-bg);
    line-height: 1.7;
    font-size: 16px;
    white-space: pre-wrap;
    word-break: break-word;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
    display: block;
    text-align: left;
}

#rightsidebar2 .canvas-doc,
#rightsidebar2 .canvas-doc *,
#rightsidebar2 .canvas-page,
#rightsidebar2 .canvas-page * {
    text-align: left;
}

#rightsidebar2 .canvas-doc,
#rightsidebar2 .canvas-page {
    caret-color: var(--text-primary);
}

#rightsidebar2 .canvas-doc:focus,
#rightsidebar2 .canvas-page:focus {
    caret-color: var(--text-primary);
}

#rightsidebar2 .canvas-page p,
#rightsidebar2 .canvas-page div,
#rightsidebar2 .canvas-page ul,
#rightsidebar2 .canvas-page ol,
#rightsidebar2 .canvas-page h1,
#rightsidebar2 .canvas-page h2,
#rightsidebar2 .canvas-page h3,
#rightsidebar2 .canvas-page h4,
#rightsidebar2 .canvas-page h5,
#rightsidebar2 .canvas-page h6 {
    margin: 0 0 0.6em 0;
}


#rightsidebar2[data-page-size="A4"] .canvas-doc { max-width: 780px; min-height: 1100px; }
#rightsidebar2[data-page-size="Letter"] .canvas-doc { max-width: 816px; min-height: 1056px; }
#rightsidebar2[data-page-size="Legal"] .canvas-doc { max-width: 816px; min-height: 1344px; }
#rightsidebar2[data-page-size="A3"] .canvas-doc { max-width: 1100px; min-height: 1560px; }

#rightsidebar2 .canvas-doc:empty::before {
    content: "Write anything…";
    color: var(--text-secondary);
}

#rightsidebar2 .canvas-empty-hint {
    position: absolute;
    left: 50%;
    top: 54%;
    transform: translate(-50%, -50%);
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px dashed var(--border-color);
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.8);
    pointer-events: none;
    font-weight: 600;
    font-size: 12px;
}

#rightsidebar2 .canvas-text-editor {
    position: absolute;
    z-index: 3;
    min-width: 160px;
    max-width: 85%;
    min-height: 38px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--container-bg);
    color: var(--text-primary);
    outline: none;
    resize: both;
    font: inherit;
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.08);
}

#rightsidebar2 .canvas-cursors {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

#rightsidebar2 .canvas-cursor-label {
    position: absolute;
    transform: translate(10px, 10px);
    font-size: 12px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--container-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    white-space: nowrap;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

#rightsidebar2.fullscreen {
    right: 0;
    width: 100vw;
    max-width: 100vw;
    z-index: 99999;
}

#rightsidebar2.fullscreen.active~.main-content,
#rightsidebar2.fullscreen.active+.main-content {
    margin-right: 0;
}

#rightsidebar2.active {
    right: 0;
}

#rightsidebar2.active~.main-content,
#rightsidebar2.active+.main-content {
    margin-right: 420px;
    transition: margin-right 0.3s ease;
}

#rightsidebar2 .sidebar-header {
    padding: 16px 18px;
    background: transparent;
    color: #000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: none;
    border-radius: 0 0 18px 18px;
    font-family: "STIX Two Text", Georgia, serif;
    font-weight: 700;
    letter-spacing: 0.4px;
    font-size: 1.1rem;
    user-select: none;
}

#rightsidebar2 .sidebar-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: #000;
}

#rightsidebar2 .close-sidebar2,
#rightsidebar2 .canvas-close-btn {
    background: none;
    border: none;
    color: #000;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
    transition: all 0.2s ease;
    line-height: 1;
}

#rightsidebar2 .close-sidebar2:hover,
#rightsidebar2 .canvas-close-btn:hover {
    transform: scale(1.1);
    opacity: 0.9;
}

#rightsidebar2 .sidebar-tabs {
    display: flex;
    background: #f8f9fa;
}

#rightsidebar2 .tab-button {
    flex: 1;
    padding: 14px 0;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 500;
    color: #5f6368;
    transition: all 0.2s ease;
    position: relative;
    font-size: 0.95rem;
}

#rightsidebar2 .tab-button.active {
    color: #4285f4;
    font-weight: 600;
}

#rightsidebar2 .tab-button.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 20%;
    right: 20%;
    height: 3px;
    background: #4285f4;
    border-radius: 3px 3px 0 0;
}

#rightsidebar2 .tab-button:hover:not(.active) {
    background: rgba(66, 133, 244, 0.08);
    color: #4285f4;
}

#rightsidebar2 .sidebar-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
}

#rightsidebar2 .tab-content {
    display: none;
    flex: 1;
    padding: 0;
    overflow-y: auto;
}

#rightsidebar2 .tab-content.active {
    display: flex;
    flex-direction: column;
}

#rightsidebar2 #blankSheetTextarea {
    flex: 1;
    padding: 20px;
    border: none;
    resize: none;
    font-family: 'Roboto', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    background: #fff;
    color: #202124;
}

#rightsidebar2 #blankSheetTextarea:focus {
    outline: none;
    background: #f8f9fa;
}

#rightsidebar2 #analyzeWithGemini {
    padding: 14px 28px;
    margin: 20px;
    background: #ff2e63;
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 12px rgba(255, 46, 99, 0.4);
    font-size: 1rem;
    align-self: flex-end;
    letter-spacing: 0.5px;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.2);
}

#rightsidebar2 #analyzeWithGemini:hover {
    background: #e60045;
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 0 18px rgba(255, 46, 99, 0.6);
}

#rightsidebar2 #analyzeWithGemini:active {
    transform: translateY(0);
    box-shadow: 0 0 10px rgba(255, 46, 99, 0.3);
}

#rightsidebar2 #generatedQuestions {
    padding: 20px;
    flex: 1;
}

#rightsidebar2 .generated-question {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 16px 20px 16px 40px;
    color: black;
    margin-bottom: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    border-left: 4px solid #4285f4;
    position: relative;
    animation: fadeIn 0.4s ease forwards;
}

#rightsidebar2 .generated-question:hover {
    background: #e8f0fe;
    transform: translateX(4px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#rightsidebar2 .generated-question::before {
    content: 'Q';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    background: #4285f4;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

#rightsidebar2 .loading {
    padding: 24px;
    text-align: center;
    color: #5f6368;
    font-style: italic;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

#rightsidebar2 .loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(66, 133, 244, 0.2);
    border-radius: 50%;
    border-top-color: #4285f4;
    animation: spin 1s ease-in-out infinite;
}

