/* ========================================================================
   1. GLOBAL STYLES (Variables, Body, Fonts, Resets)
   ======================================================================== */

:root {
    --sharpbru-primary-color: #4F46E5;
    --sharpbru-primary-hover-color: #4338CA;
    --sharpbru-secondary-color: #f5f5f5;
    --sharpbru-text-color: #333;
    --sharpbru-border-radius: 8px;
    --sharpbru-font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    --sharpbru-error-color: #e74c3c;
    --sharpbru-typing-indicator-color: #aaa;
    --sidebar-width: 250px;
    --sidebar-overhang-width: 50px;
    --header-height: 70px;
    --logo-area-background: #f8f9fa;
    --sharpbru-dark-bg-page: #121212;
    --dark-logo-area-background: #2C2C2C;
    --sharpbru-dark-bg-sidebar: #2C2C2C;
    --sharpbru-dark-bg-sidebar-overhang: #3A3A3A;
    --sharpbru-dark-bg-display: #222222;
    --sharpbru-dark-border-color: #444444;
    --sharpbru-dark-bot-bg: #3A3A3A;
    --sharpbru-dark-bot-text: #e0e0e0;
    --sharpbru-dark-user-bg: #4F46E5;
    --sharpbru-dark-user-text: #e0e7ff;
    --sharpbru-dark-input-bg: #333333;
    --sharpbru-dark-input-border: var(--sharpbru-dark-border-color);
    --sharpbru-dark-input-focus-border: #0EA5E9;
    --sharpbru-dark-button-bg: #4F46E5;
    --sharpbru-dark-button-hover-bg: #4338CA;
    --sharpbru-dark-button-icon: #e0e7ff;
    --sharpbru-dark-text-primary: #f0f0f0;
    --sharpbru-dark-text-secondary: #b0b0b0;
    --sharpbru-dark-text-error-content: #fca5a5;
    --sharpbru-dark-bg-error-content: #991b1b;
    --sharpbru-dark-muted-text: #888;
    --desktop-panel-width: 320px;
    --desktop-panel-bg-light: #f8f9fa;
    --desktop-panel-border-light: #e0e0e0;
    --desktop-panel-bg-dark: #282828;
    --desktop-panel-border-dark: var(--sharpbru-dark-border-color);
    --desktop-tab-hover-bg-light: #e9ecef;
    --desktop-tab-active-bg-light: #ffffff;
    --desktop-tab-hover-bg-dark: #3a3a3a;
    --desktop-tab-active-bg-dark: var(--sharpbru-dark-bg-display);
    --subtle-text-color: #6c757d; /* Added for dropdown arrow */
}

html {
    box-sizing: border-box;
    height: 100%;
    background-color: #ccc;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--sharpbru-font-family, Arial, sans-serif);
    height: 100%;
    overflow: hidden;
    background-color: #ccc;
}

/* ========================================================================
   2. LAYOUT STYLES (Main App Structure)
   ======================================================================== */

.app-container {
    display: flex;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    position: relative;
    background-color: #fff;
    transition: background-color 0.3s ease;
}

#app-header {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: var(--header-height);
    background-color: var(--logo-area-background);
    display: flex;
    align-items: center;
    padding: 10px;
    z-index: 1001;
    border-bottom: 1px solid #ccc;
    transition: width 0.3s ease-in-out, background-color 0.3s ease, border-bottom-color 0.3s ease;
}

#top-app-bar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--header-height);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    background-color: #fff;
    z-index: 1000;
    transition: left 0.3s ease-in-out, background-color 0.3s ease;
}

.chat-area {
    flex-grow: 1;
    margin-top: var(--header-height);
    margin-left: var(--sidebar-width);
    height: calc(100dvh - var(--header-height));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    transition: margin-left 0.3s ease-in-out, background-color 0.3s ease, margin-right 0.3s ease-in-out;
    background-color: #fff;
    overflow: auto;
    padding: 0;
}

.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100dvh - var(--header-height));
    background-color: #f8f9fa;
    transition: width 0.3s ease-in-out, background-color 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

#sharpbru-chat-container {
    background-color: transparent; /* Changed from #fff */
    border: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    font-family: var(--sharpbru-font-family);
    overflow: hidden;
    width: 100%;
    max-width: 750px;
    height: 100%;
    padding: 0 10px;
}

#auth-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100vw;
    background-color: #e9ecef;
    padding: 20px;
    position: relative;
    top: 0;
    left: 0;
    z-index: 1500;
}

#desktop-panel {
    position: fixed;
    top: var(--header-height);
    right: 0;
    width: var(--desktop-panel-width);
    height: calc(100dvh - var(--header-height));
    background-color: var(--desktop-panel-bg-light);
    border-left: 1px solid var(--desktop-panel-border-light);
    box-shadow: -3px 0 8px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    z-index: 990;
    display: flex;
    flex-direction: column;
}

#desktop-panel.desktop-panel-visible {
    transform: translateX(0);
}

.desktop-panel-inner-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#desktop-panel-header {
    flex-shrink: 0;
    border-bottom: 1px solid var(--desktop-panel-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px 5px 10px;
}

#desktop-panel-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#desktop-panel-resizer-handle {
    position: absolute;
    left: 0;
    top: 0;
    width: 10px;
    height: 100%;
    cursor: col-resize;
    transform: translateX(-50%);
    z-index: 100;
    background-color: transparent;
}

.chat-area.chat-area-desktop-open {
    margin-right: var(--desktop-panel-width);
}

/* Desktop Panel Tabs */
#desktop-tabs {
    display: flex;
    gap: 4px;
}

.desktop-tab-button {
    padding: 6px 10px;
    border: none;
    background-color: transparent;
    cursor: pointer;
    font-family: var(--sharpbru-font-family);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--sharpbru-text-color);
    border-radius: calc(var(--sharpbru-border-radius) - 4px);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.desktop-tab-button:hover {
    background-color: var(--desktop-tab-hover-bg-light);
}

.desktop-tab-button.active-tab {
    background-color: var(--desktop-tab-active-bg-light);
    font-weight: 600;
    color: var(--sharpbru-primary-color);
}

.desktop-tab-content {
    display: none;
}

.desktop-tab-content.active-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
    padding: 10px;
    box-sizing: border-box;
}

#desktop-panel-close-button {
    background: none;
    border: none;
    font-size: 1.6rem;
    color: var(--sharpbru-text-color);
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
}

#desktop-panel-close-button:hover {
    color: var(--sharpbru-error-color);
}

/* Notepad editor wrapper - contains editor + word count strip */
#notepad-editor-wrapper {
    flex-grow: 1;
    min-height: 0;
    margin-bottom: 10px;
    border-radius: var(--sharpbru-border-radius);
    position: relative;
    display: flex;
    flex-direction: column;
}

#notepad-editor {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
    width: 100%;
    padding: 10px;
    border: 1px solid var(--desktop-panel-border-light);
    border-radius: var(--sharpbru-border-radius);
    font-family: var(--sharpbru-font-family);
    font-size: 1em;
    line-height: 1.5;
    color: var(--sharpbru-text-color);
    outline: none;
}

#notepad-editor:focus {
    border-color: var(--sharpbru-primary-color);
    box-shadow: 0 0 0 2px rgba(78, 69, 220, 0.15);
}

#notepad-editor:empty::before {
    content: "Unleash your ideas! Add notes for your agents, embed images, or save YouTube links for later. Your digital canvas awaits.";
    color: #999;
    pointer-events: none;
    display: block;
}

/* Word count strip below the editor border */
#notepad-word-count {
    text-align: right;
    padding: 2px 8px 0;
    font-size: 0.7rem;
    color: #aaa;
    pointer-events: none;
    flex-shrink: 0;
}

/* Preview mode: read-only rendered markdown */
#notepad-editor.preview-mode {
    contenteditable: false;
    background-color: rgba(128, 128, 128, 0.04);
    cursor: default;
}

#notepad-editor.preview-mode:empty::before {
    content: none;
}

/* Preview toggle active state */
#preview-toggle-button.active {
    background-color: var(--sharpbru-primary-color);
    color: white;
}

/* Thread link in notepad */
.thread-link {
    padding: 8px 12px;
    margin: 4px 0;
    background-color: rgba(79, 70, 229, 0.08);
    border: 1px solid rgba(79, 70, 229, 0.2);
    border-radius: var(--sharpbru-border-radius);
    cursor: pointer;
    color: var(--sharpbru-primary-color);
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.thread-link:hover {
    background-color: rgba(79, 70, 229, 0.15);
}

#notepad-textarea {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
    width: 100%;
    margin-bottom: 10px;
    border: 1px solid var(--desktop-panel-border-light);
    border-radius: var(--sharpbru-border-radius);
    padding: 10px;
    resize: none;
    font-family: var(--sharpbru-font-family);
    font-size: 1em;
    line-height: 1.5;
    color: var(--sharpbru-text-color);
}

#notepad-textarea:focus {
    outline: none;
    border-color: var(--sharpbru-primary-color);
    box-shadow: 0 0 0 2px rgba(78, 69, 220, 0.15);
}

.desktop-content-footer {
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 10px;
    border-top: 1px solid var(--desktop-panel-border-light);
    font-size: 0.8rem;
    color: #777;
    gap: 10px;
}

#todo-item-count {
    margin-right: auto;
}

/* --- To-Do List Styles --- */
#todo-list-container {
    flex-grow: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#todo-list {
    list-style: none;
    margin: 0 0 10px 0;
    padding: 0;
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
}

#todo-add-container {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 8px;
    margin-bottom: 5px;
    border-radius: var(--sharpbru-border-radius);
    border: 1px solid var(--desktop-panel-border-light);
    background-color: var(--sharpbru-input-bg, #fff);
}

#todo-add-container input[type="text"] {
    flex-grow: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.9rem;
    color: var(--sharpbru-text-color);
}

#todo-add-container input[type="text"]:focus {
    outline: none;
}

.dark-mode #todo-add-container {
    border-color: var(--desktop-panel-border-dark);
    background-color: var(--sharpbru-dark-input-bg, #2a2a2a);
}

.dark-mode #todo-add-container input[type="text"] {
    color: var(--sharpbru-dark-text-primary, #e0e0e0);
}

.todo-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: calc(var(--sharpbru-border-radius) - 4px);
    transition: background-color 0.15s ease;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}

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

.todo-item:hover {
    background-color: rgba(0,0,0,0.03);
}

.todo-checkbox {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--sharpbru-primary-color);
}

.todo-text {
    flex-grow: 1;
    cursor: pointer;
    font-size: 0.95em;
    line-height: 1.4;
    color: var(--sharpbru-text-color);
    word-break: break-word;
    padding: 2px 0;
    transition: color 0.2s ease, text-decoration 0.2s ease;
}

.todo-item.completed .todo-text {
    text-decoration: line-through;
    color: #999;
}

.todo-delete {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.todo-item:hover .todo-delete {
    opacity: 1;
}

.todo-delete:hover {
    color: var(--sharpbru-error-color);
    background-color: rgba(231, 76, 60, 0.1);
}

.todo-edit-input {
    flex-grow: 1;
    border: 1px solid var(--sharpbru-primary-color);
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 0.95em;
    font-family: var(--sharpbru-font-family);
    color: var(--sharpbru-text-color);
    background-color: #fff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(78, 69, 220, 0.1);
}

/* To-Do add row — input sits borderless inside #todo-add-container */
#todo-add-input {
    flex-grow: 1;
    padding: 6px 8px;
    border: none;
    background: transparent;
    font-family: var(--sharpbru-font-family);
    font-size: 0.9em;
    color: var(--sharpbru-text-color);
    outline: none;
}

#todo-add-input::placeholder {
    color: #aaa;
}

#todo-add-button {
    flex-shrink: 0;
    background-color: var(--sharpbru-primary-color);
    color: white;
    border: none;
    border-radius: calc(var(--sharpbru-border-radius) - 4px);
    padding: 6px 14px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.2s ease;
}

#todo-add-button:hover {
    background-color: var(--sharpbru-primary-hover-color);
}

/* ========================================================================
   SCHEDULE / AUTOMATIONS TAB STYLES
   ======================================================================== */

#schedule-view {
    display: none;
}

#schedule-view.active-content {
    display: flex;
    flex-direction: column;
}

#automation-list-wrapper {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#automation-add-btn {
    flex-shrink: 0;
    background-color: var(--sharpbru-primary-color);
    color: white;
    border: none;
    border-radius: var(--sharpbru-border-radius);
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--sharpbru-font-family);
    margin-bottom: 10px;
    transition: background-color 0.2s ease;
}

#automation-add-btn:hover {
    background-color: var(--sharpbru-primary-hover-color);
}

#automation-list {
    list-style: none;
    margin: 0;
    padding: 0;
    flex-grow: 1;
}

.automation-item {
    background-color: #fff;
    border: 1px solid var(--desktop-panel-border-light);
    border-radius: var(--sharpbru-border-radius);
    padding: 10px 12px;
    margin-bottom: 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.automation-item:hover {
    border-color: var(--sharpbru-primary-color);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.automation-item.inactive {
    opacity: 0.55;
}

.automation-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
}

.automation-item-prompt {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--sharpbru-text-color);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
}

.automation-status {
    flex-shrink: 0;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 10px;
}

.automation-status.active {
    background-color: rgba(34, 197, 94, 0.15);
    color: #16a34a;
}

.automation-status.inactive {
    background-color: rgba(234, 179, 8, 0.15);
    color: #ca8a04;
}

.automation-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 0.72rem;
    color: #777;
    margin-bottom: 4px;
}

.automation-delivery {
    font-style: italic;
}

.automation-item-next {
    font-size: 0.7rem;
    color: #999;
    margin-bottom: 8px;
}

.automation-item-next strong {
    color: #666;
}

.automation-item-actions {
    display: flex;
    gap: 6px;
}

.automation-item-actions button {
    background: none;
    border: 1px solid var(--desktop-panel-border-light);
    border-radius: calc(var(--sharpbru-border-radius) - 4px);
    padding: 4px 10px;
    font-size: 0.72rem;
    cursor: pointer;
    font-family: var(--sharpbru-font-family);
    color: var(--sharpbru-text-color);
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.automation-item-actions button:hover {
    background-color: var(--sharpbru-primary-color);
    color: white;
    border-color: var(--sharpbru-primary-color);
}

.automation-toggle-btn:hover {
    background-color: #6b7280 !important;
    border-color: #6b7280 !important;
}

.automation-delete-btn:hover {
    background-color: var(--sharpbru-error-color) !important;
    border-color: var(--sharpbru-error-color) !important;
}

/* Automation Form */
#automation-form-wrapper {
    display: none;
    flex-direction: column;
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
}

#automation-form-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 12px 0;
    color: var(--sharpbru-text-color);
}

#automation-prompt-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--desktop-panel-border-light);
    border-radius: var(--sharpbru-border-radius);
    font-family: var(--sharpbru-font-family);
    font-size: 0.9rem;
    color: var(--sharpbru-text-color);
    background-color: #fff;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    resize: vertical;
    min-height: 80px;
    margin-bottom: 12px;
    line-height: 1.5;
}

#automation-prompt-input:focus {
    border-color: var(--sharpbru-primary-color);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.automation-form-row {
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.automation-form-row label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.automation-form-row select,
.automation-form-row input[type="date"],
.automation-form-row input[type="time"] {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--desktop-panel-border-light);
    border-radius: calc(var(--sharpbru-border-radius) - 2px);
    font-family: var(--sharpbru-font-family);
    font-size: 0.85rem;
    color: var(--sharpbru-text-color);
    background-color: #fff;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.automation-form-row select:focus,
.automation-form-row input:focus {
    border-color: var(--sharpbru-primary-color);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.automation-day-row,
.automation-date-row {
    display: none;
}

.automation-day-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.automation-day-grid input[type="checkbox"] {
    display: none;
}

.automation-day-grid label {
    font-size: 0.65rem;
    font-weight: 600;
    text-align: center;
    padding: 6px 2px;
    border: 1px solid var(--desktop-panel-border-light);
    border-radius: calc(var(--sharpbru-border-radius) - 4px);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0;
    color: #777;
    transition: all 0.15s ease;
    user-select: none;
}

.automation-day-grid input[type="checkbox"]:checked + label {
    background-color: var(--sharpbru-primary-color);
    color: white;
    border-color: var(--sharpbru-primary-color);
}

.automation-day-grid label:hover {
    border-color: var(--sharpbru-primary-color);
}

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

#automation-file {
    flex-grow: 1;
    min-width: 0;
    font-size: 0.8rem;
    padding: 4px 0;
    border: 1px solid var(--desktop-panel-border-light);
    border-radius: calc(var(--sharpbru-border-radius) - 2px);
    background-color: #fff;
    color: var(--sharpbru-text-color);
    cursor: pointer;
}

#automation-file::-webkit-file-upload-button {
    background-color: var(--sharpbru-primary-color);
    color: #fff;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    margin-right: 8px;
}

#automation-file::file-selector-button {
    background-color: var(--sharpbru-primary-color);
    color: #fff;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    margin-right: 8px;
}

.dark-mode #automation-file {
    background-color: var(--sharpbru-dark-input-bg, #333);
    border-color: var(--desktop-panel-border-dark);
    color: var(--sharpbru-dark-text-primary, #e0e0e0);
}

.automation-file-clear-btn {
    flex-shrink: 0;
    padding: 5px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: calc(var(--sharpbru-border-radius) - 2px);
    border: 1px solid var(--desktop-panel-border-light);
    background-color: #f5f5f5;
    color: var(--sharpbru-text-color);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.automation-file-clear-btn:hover {
    background-color: var(--sharpbru-error-color);
    color: #fff;
    border-color: var(--sharpbru-error-color);
}

#automation-file-hint {
    color: #777;
    font-size: 0.72rem;
    display: block;
    margin-top: 4px;
    line-height: 1.4;
}

.dark-mode #automation-file-hint {
    color: var(--sharpbru-dark-text-secondary, #b0b0b0) !important;
}

.automation-form-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--desktop-panel-border-light);
}

#automation-save-btn {
    flex-grow: 1;
    background-color: var(--sharpbru-primary-color);
    color: white;
    border: none;
    border-radius: var(--sharpbru-border-radius);
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--sharpbru-font-family);
    transition: background-color 0.2s ease;
}

#automation-save-btn:hover {
    background-color: var(--sharpbru-primary-hover-color);
}

#automation-save-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#automation-cancel-btn {
    background: none;
    border: 1px solid var(--desktop-panel-border-light);
    border-radius: var(--sharpbru-border-radius);
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: var(--sharpbru-font-family);
    color: var(--sharpbru-text-color);
    transition: background-color 0.2s ease;
}

#automation-cancel-btn:hover {
    background-color: var(--desktop-tab-hover-bg-light);
}

/* --- Dark Mode: Automations --- */
.dark-mode .automation-item {
    background-color: var(--sharpbru-dark-bg-display, #222);
    border-color: var(--desktop-panel-border-dark);
}

.dark-mode .automation-item-prompt {
    color: var(--sharpbru-dark-text-primary, #e0e0e0);
}

.dark-mode .automation-item-next,
.dark-mode .automation-item-meta {
    color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

.dark-mode .automation-item-next strong {
    color: var(--sharpbru-dark-text-primary, #e0e0e0);
}

.dark-mode .automation-item-actions button {
    border-color: var(--desktop-panel-border-dark);
    color: var(--sharpbru-dark-text-primary, #e0e0e0);
}

.dark-mode .automation-form-row label {
    color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

.dark-mode .automation-form-row select,
.dark-mode .automation-form-row input[type="date"],
.dark-mode .automation-form-row input[type="time"] {
    background-color: var(--sharpbru-dark-input-bg, #333);
    border-color: var(--desktop-panel-border-dark);
    color: var(--sharpbru-dark-text-primary, #e0e0e0);
    color-scheme: dark; /* Forces browser native elements (arrows, pickers) into dark mode styles */
}

/* ========================================================================
   BULLETPROOF DARK MODE CALENDAR & TIME PICKER FIX
   Hardened with html.dark-mode prefix, ID targeting & !important to
   guarantee native picker assets render correctly in dark mode.
   ======================================================================== */

/* 1. Force the browser layout engine to natively render dark picker assets */
html.dark-mode #automation-date,
html.dark-mode #automation-time,
html.dark-mode .automation-form-row input[type="date"],
html.dark-mode .automation-form-row input[type="time"] {
    color-scheme: dark !important;
    color: var(--sharpbru-dark-text-primary, #e0e0e0) !important;
    background-color: var(--sharpbru-dark-input-bg, #333) !important;
    border-color: var(--desktop-panel-border-dark) !important;
}

/* 2. WebKit/Blink Shadow-DOM Fallback: Hard-invert the icon assets to clean white */
html.dark-mode #automation-date::-webkit-calendar-picker-indicator,
html.dark-mode #automation-time::-webkit-calendar-picker-indicator,
html.dark-mode .automation-form-row input[type="date"]::-webkit-calendar-picker-indicator,
html.dark-mode .automation-form-row input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1) brightness(1) !important;
    opacity: 0.8 !important;
    cursor: pointer !important;
}

/* 3. Hover state for clean visual feedback */
html.dark-mode #automation-date::-webkit-calendar-picker-indicator:hover,
html.dark-mode #automation-time::-webkit-calendar-picker-indicator:hover,
html.dark-mode .automation-form-row input[type="date"]::-webkit-calendar-picker-indicator:hover,
html.dark-mode .automation-form-row input[type="time"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1 !important;
}

.dark-mode #automation-form-title {
    color: var(--sharpbru-dark-text-primary, #f0f0f0);
}

.dark-mode #automation-prompt-input {
    background-color: var(--sharpbru-dark-input-bg, #333);
    border-color: var(--desktop-panel-border-dark);
    color: var(--sharpbru-dark-text-primary, #f0f0f0);
}

.dark-mode #automation-prompt-input::placeholder {
    color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

/* --- Dark Mode: Automation File Input & Hint --- */
.dark-mode #automation-file {
    color: var(--sharpbru-dark-text-primary, #e0e0e0);
}
.dark-mode #automation-file::-webkit-file-upload-button {
    background-color: var(--sharpbru-primary-color);
    color: #fff;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
}
.dark-mode #automation-file::file-selector-button {
    background-color: var(--sharpbru-primary-color);
    color: #fff;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
}
.dark-mode #automation-file-hint {
    color: var(--sharpbru-dark-text-secondary, #b0b0b0) !important;
}
.dark-mode #automation-file-hint strong {
    color: var(--sharpbru-dark-text-primary, #e0e0e0);
}
.dark-mode .automation-file-clear-btn {
    background-color: var(--sharpbru-dark-input-bg, #333) !important;
    border-color: var(--desktop-panel-border-dark) !important;
    color: var(--sharpbru-dark-text-primary, #e0e0e0) !important;
}

.dark-mode .automation-form-actions {
    border-top-color: var(--desktop-panel-border-dark);
}

.dark-mode .automation-day-grid label {
    border-color: var(--desktop-panel-border-dark);
    color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

.dark-mode .automation-day-grid input[type="checkbox"]:checked + label {
    background-color: var(--sharpbru-primary-color);
    color: white;
    border-color: var(--sharpbru-primary-color);
}

.dark-mode #automation-cancel-btn {
    border-color: var(--desktop-panel-border-dark);
    color: var(--sharpbru-dark-text-primary, #e0e0e0);
}

.dark-mode #automation-cancel-btn:hover {
    background-color: var(--desktop-tab-hover-bg-dark);
}

/* --- Pinned Threads (Nudge Chat) --- */
#chat-history-list li.is-pinned {
    background-color: rgba(79, 70, 229, 0.06);
    border-left: 3px solid var(--sharpbru-primary-color);
    padding-left: 6px;
}

.dark-mode #chat-history-list li.is-pinned {
    background-color: rgba(79, 70, 229, 0.15);
}

#chat-history-list li.is-pinned.active-chat {
    background-color: rgba(79, 70, 229, 0.15);
}

.dark-mode #chat-history-list li.is-pinned.active-chat {
    background-color: rgba(79, 70, 229, 0.25);
}

.thread-pin-indicator {
    flex-shrink: 0;
    color: var(--sharpbru-primary-color);
    font-size: 0.85rem;
    margin-right: 2px;
}

#desktop-panel-resizer-handle:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

#desktop-panel-resizer-handle:hover::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    background-color: var(--sharpbru-primary-color, #5a42f3);
    transform: translateX(-50%);
}

/* Sidebar Resizer Handle */
#sidebar-resizer-handle {
    position: absolute;
    right: 0;
    top: 0;
    width: 10px;
    height: 100%;
    cursor: col-resize;
    transform: translateX(50%);
    z-index: 100;
    background-color: transparent;
}

#sidebar-resizer-handle:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

#sidebar-resizer-handle:hover::after {
    content: '';
    position: absolute;
    right: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    background-color: var(--sharpbru-primary-color, #5a42f3);
    transform: translateX(50%);
}

.sidebar.collapsed #sidebar-resizer-handle {
    display: none;
}

.dark-mode #sidebar-resizer-handle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.dark-mode #sidebar-resizer-handle:hover::after {
    background-color: var(--sharpbru-dark-input-focus-border);
}

#welcome-message-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    padding-bottom: 15vh;
    box-sizing: border-box; /* <--- THIS FIXES THE SHIFT */
    opacity: 1;
    transition: opacity 0.4s ease-in-out, visibility 0.4s;
    visibility: visible;
    z-index: 10;
    pointer-events: none;
}

.app-container.sidebar-collapsed #app-header {
    width: var(--sidebar-overhang-width);
}

.app-container.sidebar-collapsed #top-app-bar {
    left: var(--sidebar-overhang-width);
}

.app-container.sidebar-collapsed .chat-area {
    margin-left: var(--sidebar-overhang-width);
}

.sidebar.collapsed {
    width: var(--sidebar-overhang-width);
}

.sidebar.collapsed #hamburger-menu {
    background-color: #e9ecef;
    border-color: #dee2e6;
    right: 0;
    top: 0;
    width: 100%;
    height: var(--header-height);
    border-radius: 0;
    border-left: none;
    border-top: none;
    border-bottom: 1px solid #dee2e6;
}

.sidebar.collapsed #new-chat-icon-collapsed {
    display: flex;
}

.sidebar.collapsed .sidebar-content {
    opacity: 0;
    transform: translateX(-100%);
    pointer-events: none;
}

.app-container.sidebar-collapsed #app-logo {
    opacity: 0;
    max-width: 0;
    pointer-events: none;
}

.app-container.sidebar-collapsed #app-logo-collapsed {
    opacity: 1;
}

.chat-area.chat-active #welcome-message-container {
    opacity: 0;
    visibility: hidden;
}

@media (max-width: 767px) {
    #top-app-bar {
        padding-left: 10px;
        padding-right: 10px;
    }

    .app-container.sidebar-collapsed #top-app-bar {
        padding-left: 60px;
    }

    #auth-logo {
        display: block;
        width: 200px;               
        max-width: 100%;           
        height: auto;               
        margin: 0 auto 30px auto; 
    }

    #welcome-message-text {
        font-size: 1.6rem;
    }
}

@media (max-width: 1024px) {
    #auth-logo {
        max-width: 200px;
        margin-bottom: 25px;
    }
}

/* ========================================================================
   3. COMPONENT STYLES (Reusable Pieces of UI)
   ======================================================================== */

#app-logo-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

#app-logo {
    max-height: calc(var(--header-height) - 30px);
    max-width: calc(var(--sidebar-width) - var(--sidebar-overhang-width) - 20px);
    display: block;
    opacity: 1;
    transition: opacity 0.2s ease-in-out, max-width 0.3s ease-in-out;
}

#app-logo-collapsed {
    max-height: calc(var(--header-height) - 30px);
    max-width: calc(var(--sidebar-overhang-width) - 10px);
    display: block;
    opacity: 0;
    position: absolute;
    transition: opacity 0.2s ease-in-out 0.1s;
}

#hamburger-menu {
    position: absolute;
    top: 10px;
    right: 7px;
    width: calc(var(--sidebar-overhang-width) - 14px);
    height: 40px;
    background-color: transparent;
    border: 1px solid transparent;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sharpbru-text-color);
    z-index: 10;
    border-radius: var(--sharpbru-border-radius);
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, top 0.3s ease, right 0.3s ease, width 0.3s ease, height 0.3s ease, border-radius 0.3s ease;
}

#hamburger-menu:hover {
    background-color: #d1d5db;
}

#new-chat-icon-collapsed {
    display: none;
    position: absolute;
    top: calc(var(--header-height) + 10px);
    left: 50%;
    transform: translateX(-50%);
    width: calc(var(--sidebar-overhang-width) - 20px);
    height: calc(var(--sidebar-overhang-width) - 20px);
    padding: 5px;
    background-color: var(--sharpbru-primary-color);
    color: white;
    border: none;
    border-radius: var(--sharpbru-border-radius);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, opacity 0.3s ease;
    z-index: 5;
}

#new-chat-icon-collapsed svg {
    width: 20px;
    height: 20px;
}

#new-chat-icon-collapsed:hover {
    background-color: var(--sharpbru-primary-hover-color);
}

.sidebar-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 60px 10px 15px 10px;
    overflow-y: auto;
    background-color: #f8f9fa;
    transition: opacity 0.2s ease-in-out 0.1s, transform 0.3s ease-in-out, background-color 0.3s ease;
    transform: translateX(0);
}

.sidebar-content h2 {
    font-family: var(--sharpbru-font-family);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--sharpbru-text-color);
    margin-top: 0;
    margin-bottom: 15px;
    letter-spacing: 0.5px;
    transition: color 0.3s ease;
}

#new-chat-button {
    width: 100%;
    background-color: var(--sharpbru-primary-color);
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: var(--sharpbru-border-radius);
    text-align: left;
    cursor: pointer;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    font-family: var(--sharpbru-font-family);
    font-size: 0.9rem;
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

#new-chat-button svg {
    margin-right: 8px;
    fill: currentColor;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

#new-chat-button:hover {
    background-color: var(--sharpbru-primary-hover-color);
}

#chat-history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1;
    overflow-y: auto;
}

#chat-history-list li {
    position: relative; /* Needed for menu positioning */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 30px 8px 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: var(--sharpbru-font-family);
    transition: background-color 0.2s ease, color 0.2s ease;
    color: var(--sharpbru-text-color);
    border-radius: 6px; /* Add a subtle radius for better spacing */
    margin-bottom: 2px; /* Add a small margin between items */
}

.thread-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
    padding: 5px 0; /* Add some padding for better clickability */
}

.thread-title-input {
    width: 100%;
    flex-grow: 1;
    border: 1px solid var(--sharpbru-primary-color);
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 0.9rem;
    font-family: var(--sharpbru-font-family);
    outline: none;
}

.thread-menu-button {
    position: absolute;       /* CHANGE: Pulls it out of flex flow */
    right: 6px;               /* CHANGE: Anchors to the right edge */
    top: 50%;                 /* CHANGE: Centers vertically */
    transform: translateY(-50%); /* CHANGE: Perfect vertical alignment alignment */
    
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 2px 6px;         /* SLIGHT CHANGE: Compact padding for better alignment */
    font-size: 1.2rem;
    line-height: 1;
    opacity: 0;               /* Hidden by default */
    transition: opacity 0.2s, background-color 0.2s;
    z-index: 2;               /* Keeps it hovering cleanly on top */
}

#chat-history-list li:hover .thread-menu-button,
.thread-menu-button:focus {
    opacity: 1; /* Show on hover/focus */
}

.thread-menu-button:hover {
    background-color: rgba(0,0,0,0.1);
}

.thread-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: var(--sharpbru-border-radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 10;
    padding: 5px;
    min-width: 120px;
}

.thread-menu.visible {
    display: block;
}

.thread-menu-item {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
}

.thread-menu-item:hover {
    background-color: #f0f0f0;
}

.thread-menu-item.delete:hover {
    background-color: var(--sharpbru-error-color);
    color: white;
}


#chat-history-list li:hover {
    background-color: #efefef;
}

#chat-history-list li.active-chat {
    background-color: #e0e0e0;
    font-weight: bold;
}

.settings-area {
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid #dee2e6;
    flex-shrink: 0;
    transition: border-top-color 0.3s ease;
}

.settings-area h3 {
    font-family: var(--sharpbru-font-family);
    font-size: 1rem;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--sharpbru-text-color);
    transition: color 0.3s ease;
}

.theme-toggle-container {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

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

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

.slider.round {
    border-radius: 24px;
}

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

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

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

input:checked+.slider.round::before {
    transform: translateX(26px);
}

.toggle-label {
    font-family: var(--sharpbru-font-family);
    font-size: 0.9rem;
    margin-left: 8px;
    vertical-align: middle;
    color: var(--sharpbru-text-color);
    transition: color 0.3s ease;
}

#sharpbru-chat-display {
    flex-grow: 1;
    overflow-y: auto;
    color: var(--sharpbru-text-color);
    background-color: transparent;
    border: none;
    transition: color 0.3s ease;
    padding-right: 5px;
}

.sharpbru-message {
    margin-bottom: 24px;
    padding: 10px 15px;
    border-radius: var(--sharpbru-border-radius);
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    white-space: pre-line;
    text-align: left !important;
}

/* --- Timestamp on each message (small, non-intrusive) --- */
.message-timestamp {
    font-size: 0.68rem;
    color: var(--sharpbru-dark-muted-text, #999);
    margin-bottom: 3px;
    opacity: 0.85;
    user-select: none;
    font-variant-numeric: tabular-nums;
}

/* User messages: timestamp sits on the right (aligned with right-aligned bubble) */
.message-timestamp.user {
    text-align: right;
    margin-top: 0;
    padding-right: 15px; /* Align with text inside user bubble (which has 15px padding) */
}

/* Bot messages: timestamp sits on the left (aligned with left-aligned bubble) */
.message-timestamp.bot {
    text-align: left;
    margin-top: 0;
}

/* Dark mode tweak for readability */
.app-container.dark-mode .message-timestamp {
    color: var(--sharpbru-dark-muted-text, #888);
    opacity: 0.7;
}

/* --- Date separator (WhatsApp-style "Today", "Yesterday", etc.) --- */
.date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 16px 0 12px;
    user-select: none;
}

.date-separator span {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--subtle-text-color, #6c757d);
    background-color: rgba(0, 0, 0, 0.04);
    padding: 3px 12px;
    border-radius: 12px;
    letter-spacing: 0.2px;
}

.app-container.dark-mode .date-separator span {
    background-color: rgba(255, 255, 255, 0.06);
    color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

.sharpbru-message.bot {
    background-color: #fff !important;
    color: var(--sharpbru-text-color);
    margin-right: auto;
    max-width: 95%;
    border-bottom-left-radius: 2px;
    border: none !important;
    box-shadow: none !important;
    padding: 10px 0; /* Override horizontal padding so text left-aligns with timestamp */
}

.sharpbru-message.user {
    background-color: #F1F5F9;
    color: #0F172A;
    margin-left: auto;
    border-bottom-right-radius: 2px;
}

.sharpbru-message.error {
    background-color: var(--sharpbru-error-color);
    color: white;
    font-weight: bold;
    text-align: left;
}

.sharpbru-message strong {
    font-weight: 600;
}

.sharpbru-message p {
    margin-top: 0;
    margin-bottom: 0.2em;
}

.sharpbru-message p:last-child {
    margin-bottom: 0;
}

.code-block-wrapper {
    position: relative;
    margin: 1em 0 0.5em 0; /* Reduced bottom margin */
}

/* Strip the default browser margins off the pre tag inside it */
.code-block-wrapper pre {
    margin: 0 !important;
}

.copy-code-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #4f555e;
    color: #e0e0e0;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.8em;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 1;
}

.code-block-wrapper:hover .copy-code-btn {
    opacity: 1;
}

.copy-code-btn:hover {
    background-color: #686e77;
}

.copy-code-btn.copied {
    background-color: #28a745;
    color: white;
}

/* Notepad Copy Button - header icon button */
#notepad-copy-btn {
    background: transparent;
    border: none;
    color: var(--sharpbru-text-color);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.2s ease;
    display: none;
    align-items: center;
    justify-content: center;
    margin-right: 2px;
}

#notepad-copy-btn:hover {
    color: var(--sharpbru-primary-color);
}

#notepad-copy-btn.copied {
    color: #28a745;
}

#notepad-copy-btn.visible {
    display: inline-flex;
}

/* Notepad Share Button - header icon button */
#share-note-editor-button {
    background: transparent;
    border: none;
    color: var(--sharpbru-text-color);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.2s ease;
    display: none;
    align-items: center;
    justify-content: center;
    margin-right: 2px;
}

#share-note-editor-button:hover {
    color: var(--sharpbru-primary-color);
}

#share-note-editor-button.visible {
    display: inline-flex;
}

.sharpbru-message pre {
    background-color: #2d2d2d;
    color: #f8f8f2;
    padding: 15px;
    border-radius: calc(var(--sharpbru-border-radius) - 4px);
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    margin: 0;
    text-align: left;
    white-space: pre; /* Preserve formatting exactly — scroll instead of wrapping */
    overflow-wrap: normal; /* Override inherited break-word from .sharpbru-message */
}

.sharpbru-message code:not(pre code) {
    background-color: #e0e0e0;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    text-align: left;
}

#sharpbru-form {
    display: flex;
    align-items: flex-end; /* Align to bottom for stable resizing */
    gap: 10px;
    padding-top: 15px;
    background-color: transparent;
    border-top: 1px solid #dee2e6;
    transition: border-top-color 0.3s ease;
    position: relative; /* Positioning context for the drag-and-drop overlay */
}

/* ========================================================================
   DRAG-AND-DROP FILE OVERLAY
   ======================================================================== */
#file-drop-overlay {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background-color: rgba(78, 69, 220, 0.08);
    border: 2px dashed var(--sharpbru-primary-color, #4e45dc);
    border-radius: var(--sharpbru-border-radius, 8px);
    color: var(--sharpbru-primary-color, #4e45dc);
    font-size: 0.95rem;
    font-weight: 600;
    z-index: 50;
    pointer-events: none; /* Overlay shouldn't intercept pointer events */
    animation: file-drop-fade-in 0.15s ease-out;
}

@keyframes file-drop-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.app-container.dark-mode #file-drop-overlay {
    background-color: rgba(120, 110, 255, 0.12);
    border-color: var(--sharpbru-dark-input-focus-border, #7a6dff);
    color: var(--sharpbru-dark-input-focus-border, #7a6dff);
}

#file-upload-container {
    flex-shrink: 0;
}

#sharpbru-input {
    flex-grow: 1;
    min-width: 0; /* Allow the textarea to shrink indefinitely */
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: var(--sharpbru-border-radius);
    font-size: 1em;
    font-family: var(--sharpbru-font-family);
    line-height: 1.5;
    resize: none; /* Hide default resize handle */
    overflow-y: hidden; /* Hide scrollbar until max-height */
    transition: border-color 0.2s, background-color 0.3s ease, color 0.3s ease;
    color: var(--sharpbru-text-color);
}

#sharpbru-form button[type="submit"] {
    flex-shrink: 0;
}


#sharpbru-input:focus {
    outline: none;
    border-color: var(--sharpbru-primary-color);
    box-shadow: 0 0 0 2px rgba(78, 69, 220, 0.2);
}

#sharpbru-input::placeholder {
    color: #999;
    transition: color 0.3s ease;
}

#sharpbru-form button {
    padding: 10px;
    background-color: var(--sharpbru-primary-color);
    color: white;
    border: none;
    border-radius: var(--sharpbru-border-radius);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#sharpbru-form button[type="submit"] svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

#sharpbru-form button:hover {
    background-color: var(--sharpbru-primary-hover-color);
}

#sharpbru-form button:disabled {
    background-color: #b0c4de;
    cursor: not-allowed;
}

.sharpbru-typing-indicator {
    padding: 0 15px 10px 15px;
    font-style: italic;
    color: var(--sharpbru-typing-indicator-color);
    font-size: 0.9em;
    display: none;
    transition: color 0.3s ease;
    text-align: left;
}

.sharpbru-message.thinking {
    background-color: #f0f0f0;
    color: #b0b0b0;
    font-style: italic;
    opacity: 0.9;
}

.sharpbru-message.thinking span {
    animation: sharpbru_blink 1.4s infinite both;
    font-weight: bold;
}

.sharpbru-message.thinking span:nth-child(1) {
    animation-delay: 0s;
}

.sharpbru-message.thinking span:nth-child(2) {
    animation-delay: 0.2s;
}

.sharpbru-message.thinking span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes sharpbru_blink {
    0% {
        opacity: .2;
    }

    20% {
        opacity: 1;
    }

    100% {
        opacity: .2;
    }
}

#sharpbru-chat-display::-webkit-scrollbar,
#chat-history-list::-webkit-scrollbar {
    width: 8px;
}

#sharpbru-chat-display::-webkit-scrollbar-track,
#chat-history-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: var(--sharpbru-border-radius);
}

#sharpbru-chat-display::-webkit-scrollbar-thumb,
#chat-history-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: var(--sharpbru-border-radius);
}

#sharpbru-chat-display::-webkit-scrollbar-thumb:hover,
#chat-history-list::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

#privacy-statement {
    font-size: 0.75rem;
    color: #6c757d;
    text-align: center;
    padding: 8px 15px 0px 15px;
    margin-top: 5px;
    transition: color 0.3s ease;
    line-height: 1.3;
}

.sidebar-content #user-info-container {
    margin-top: 20px;
    padding: 15px;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    transition: border-top-color 0.3s ease;
}

.sidebar-content #user-display-name {
    font-size: 0.9rem;
    color: var(--sharpbru-text-color);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
    transition: color 0.3s ease;
    cursor: pointer;
}

#logout-button {
    background: none;
    border: none;
    color: var(--sharpbru-text-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    transition: color 0.2s ease, transform 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#logout-button svg {
    width: 1em;
    height: 1em;
    stroke: currentColor;
}

#logout-button:hover {
    color: var(--sharpbru-primary-color);
    transform: scale(1.1);
}

#auth-logo {
    display: block;
    max-width: 400px;
    height: auto;
    margin: 0 auto 30px auto;
}

.auth-form-card {
    background-color: #ffffff;
    padding: 35px 45px;
    border-radius: var(--sharpbru-border-radius, 8px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 420px;
    text-align: center;
    transition: background-color 0.3s ease, box-shadow 0.3s ease, color 0.3s ease;
    z-index: 1;
    position: relative;
}

.auth-form-card h2 {
    margin-top: 0;
    margin-bottom: 30px;
    color: var(--sharpbru-text-color, #333);
    font-size: 2rem;
    font-weight: 600;
}

.auth-form-card form div {
    margin-bottom: 20px;
    text-align: left;
}

.auth-form-card form label {
    display: block;
    margin-bottom: 8px;
    color: var(--sharpbru-text-color, #555);
    font-weight: 500;
    font-size: 0.9rem;
}

#registration-terms-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #e9ecef;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2500;
    padding: 20px;
    box-sizing: border-box;
}

#registration-terms-modal-content {
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.15);
    max-width: 750px;
    width: 100%;
    position: relative;
    text-align: left;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 20px;
}

#registration-terms-modal-content .modal-close-button {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2.2rem;
    font-weight: normal;
    color: #aaa;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
    padding: 5px;
}

#registration-terms-modal-content .modal-close-button:hover {
    color: #777;
}

#registration-notice-container {
    background-color: transparent;
    border: none;
    padding: 0;
    margin-bottom: 15px;
    font-size: 0.85rem;
    color: #444;
    overflow-y: auto;
    flex-grow: 1;
}

#registration-notice-container h2 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--sharpbru-text-color, #333);
}

#registration-notice-container p {
    margin-top: 0;
    margin-bottom: 10px;
    line-height: 1.5;
}

#registration-notice-container ul {
    padding-left: 20px;
    margin-top: 0;
    margin-bottom: 0;
    list-style-type: disc;
}

#registration-notice-container li {
    margin-bottom: 10px;
    line-height: 1.5;
}

#registration-notice-container li:last-child {
    margin-bottom: 0;
}

#registration-notice-container strong {
    font-weight: 600;
    color: var(--sharpbru-text-color, #333);
}

#accept-terms-modal-container {
    display: flex;
    align-items: flex-start;
    margin-top: 0;
    margin-bottom: 15px;
    padding-top: 15px;
    padding-bottom: 15px;
    text-align: left;
    border-top: 1px solid #d0d0d0;
}

#accept-terms-modal-container input[type="checkbox"]#reg-accept-terms-modal {
    margin-right: 10px;
    margin-top: 3px;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

#accept-terms-modal-container label[for="reg-accept-terms-modal"] {
    font-size: 0.9rem;
    font-weight: normal;
    color: var(--sharpbru-text-color, #444);
    line-height: 1.5;
    margin-bottom: 0;
    cursor: pointer;
}

#proceed-to-register-button {
    width: 100%;
    padding: 12px 15px;
    background-color: var(--sharpbru-primary-color, #4e45dc);
    color: white;
    border: none;
    border-radius: var(--sharpbru-border-radius, 6px);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, opacity 0.2s ease-in-out;
    margin-top: 0;
}

#proceed-to-register-button:hover:not(:disabled) {
    background-color: var(--sharpbru-primary-hover-color, #3a33a3);
}

#proceed-to-register-button:disabled {
    background-color: #cccccc;
    color: #888888;
    cursor: not-allowed;
    opacity: 0.7;
}

#modal-accept-message.auth-message {
    margin-top: 10px;
    margin-bottom: 0;
    min-height: 1.2em;
}

.auth-form-card form input[type="email"],
.auth-form-card form input[type="password"],
.auth-form-card form input[type="text"] {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #d1d5db;
    border-radius: var(--sharpbru-border-radius, 6px);
    font-size: 1rem;
    color: var(--sharpbru-text-color, #333);
    background-color: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.3s ease, color 0.3s ease;
}

.auth-form-card form input:focus {
    outline: none;
    border-color: var(--sharpbru-primary-color, #4e45dc);
    box-shadow: 0 0 0 3px rgba(78, 69, 220, 0.15);
}

.auth-form-card form button[type="submit"] {
    width: 100%;
    padding: 12px 15px;
    background-color: var(--sharpbru-primary-color, #4e45dc);
    color: white;
    border: none;
    border-radius: var(--sharpbru-border-radius, 6px);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, transform 0.1s ease, color 0.2s ease;
    margin-top: 15px;
    margin-bottom: 10px;
}

.auth-form-card form button[type="submit"]:hover {
    background-color: var(--sharpbru-primary-hover-color, #3a33a3);
}

.auth-form-card form button[type="submit"]:active {
    transform: translateY(1px);
}

.auth-form-card .auth-message {
    margin-top: 15px;
    font-size: 0.85rem;
    min-height: 1.2em;
    font-weight: 500;
}

.auth-form-card .auth-message.error,
#modal-accept-message.error {
    color: var(--sharpbru-error-color, #e74c3c);
}

.auth-form-card .auth-message.success {
    color: #22c55e;
}

.auth-form-card p {
    margin-top: 25px;
    font-size: 0.9rem;
    color: var(--sharpbru-text-color, #555);
}

.auth-form-card p a {
    color: var(--sharpbru-primary-color, #4e45dc);
    text-decoration: none;
    font-weight: 600;
}

.auth-form-card p a:hover {
    text-decoration: underline;
}

.sharpbru-message em {
    font-style: italic;
}

.sharpbru-message h1,
.sharpbru-message h2,
.sharpbru-message h3,
.sharpbru-message h4,
.sharpbru-message h5,
.sharpbru-message h6 {
    margin-top: 0.4em;
    margin-bottom: 0.2em;
    line-height: 1.2;
    font-weight: 600;
    text-align: left;
}

.sharpbru-message h1 {
    font-size: 1.6em;
}

.sharpbru-message h2 {
    font-size: 1.4em;
}

.sharpbru-message h3 {
    font-size: 1.2em;
}

.sharpbru-message h4 {
    font-size: 1.1em;
}

.sharpbru-message h5 {
    font-size: 1.0em;
}

.sharpbru-message h6 {
    font-size: 0.9em;
}

.sharpbru-message ul,
.sharpbru-message ol {
    padding-left: 25px;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
    text-align: left;
}

.sharpbru-message li {
    margin-bottom: 0.75em;
    line-height: 1.6;
}

.sharpbru-message li:last-child {
    margin-bottom: 0;
}

/* Unified Chat & Notepad Link Styles */
.sharpbru-message a,
#notepad-editor a {
    color: var(--sharpbru-primary-color);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    font-weight: 500;
    padding: 0 2px;
    background-color: transparent;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.sharpbru-message a:hover,
#notepad-editor a:hover {
    text-decoration-thickness: 2px;
    color: var(--sharpbru-primary-hover-color); 
}

/* FIX: Ensure visited links stay on-brand */
.sharpbru-message a:visited,
#notepad-editor a:visited {
    color: var(--sharpbru-primary-color);
}

.sharpbru-message a:active,
#notepad-editor a:active {
    transform: translateY(0px);
    background-color: rgba(79, 70, 229, 0.1); /* Subtler active state */
}

#model-selector-container {
    position: relative;
    display: inline-block;
}

.tier-status-display {
    padding: 6px 12px;
    font-size: .85em;
    font-weight: 600;
    border-radius: 15px;
    transition: background-color .3s ease, color .3s ease, border-color .3s ease;
    text-align: center;
    display: block;
    white-space: nowrap;
}

.tier-status-display.tier-free {
    background-color: #e9ecef;
    border: 1px solid #ced4da;
    text-transform: capitalize;
}

.tier-status-display.tier-free a.tier-upgrade-link {
    color: inherit;
    text-decoration: none;
    font-weight: inherit;
}

#user-tier-status.model-selector-active {
    background-color: var(--sharpbru-primary-color, #4e45dc);
    color: white;
    border: 1px solid transparent;
    cursor: pointer;
    padding-right: 30px;
    position: relative;
}

#user-tier-status.model-selector-active:hover {
    background-color: var(--sharpbru-primary-hover-color);
}

.model-selector-active::after {
    content: '▼';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%) scale(0.8);
    color: rgba(255, 255, 255, 0.7);
    pointer-events: none;
    transition: color .3s ease;
}

#model-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    width: auto;
    min-width: 100%;
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: var(--sharpbru-border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1100;
    overflow: hidden;
    padding: 4px;
}

.model-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--sharpbru-text-color);
    white-space: nowrap;
    border-radius: calc(var(--sharpbru-border-radius) - 4px);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.model-item:hover {
    background-color: #e9ecef;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
    box-sizing: border-box;
}

#profile-settings-modal-content.auth-form-card {
    max-width: 600px;
    padding: 25px 35px;
    text-align: left;
    margin-top: 0;
}

#profile-settings-modal-content h2 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.profile-section {
    margin-bottom: 20px;
}

.profile-section:last-child {
    margin-bottom: 5px;
}

.profile-section h3 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--sharpbru-text-color, #333);
    border-bottom: none;
    padding-bottom: 0;
}

#profile-settings-modal-content form div {
    margin-bottom: 12px;
}

#profile-settings-modal-content form label {
    display: block;
    margin-bottom: 5px;
    color: var(--sharpbru-text-color, #555);
    font-weight: 500;
    font-size: 0.85rem;
}

#profile-settings-modal-content form input[type="text"],
#profile-settings-modal-content form input[type="password"],
#profile-settings-modal-content form textarea {
    padding: 10px 12px;
    font-size: 0.95rem;
    width: 100%;
}

#profile-settings-modal-content form button[type="submit"] {
    margin-top: 10px;
    margin-bottom: 8px;
    padding: 10px 15px;
}

#profile-settings-modal-content p.auth-message {
    margin-top: 10px;
    min-height: 1em;
    font-size: 0.8rem;
    margin-bottom: 0;
}

#profile-tab .profile-section {
    max-width: 450px;
    margin-left: auto;
    margin-right: auto;
}

#profile-settings-modal-content .modal-close-button {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
}

.desktop-tab-content {
    display: none;
}

.desktop-tab-content.active-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
    padding: 10px;
    box-sizing: border-box;
}

#notepad-textarea {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
    width: 100%;
    margin-bottom: 10px;
    border: 1px solid var(--desktop-panel-border-light);
    border-radius: var(--sharpbru-border-radius);
    padding: 10px;
    resize: none;
    font-family: var(--sharpbru-font-family);
    font-size: 1em;
    line-height: 1.5;
    color: var(--sharpbru-text-color);
}

body.dark-mode #notepad-editor {
    color: var(--sharpbru-dark-text-primary);
}

#notepad-editor:empty::before {
    content: "Unleash your ideas! Add notes for your agents, embed images, or save YouTube links for later. Your digital canvas awaits.";
    color: #999;
    pointer-events: none;
    display: block;
}


.desktop-content-footer {
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 10px;
    border-top: 1px solid var(--desktop-panel-border-light);
    font-size: 0.8rem;
    color: #777;
    gap: 10px;
}

#todo-item-count {
    margin-right: auto;
}

#desktop-toggle-button {
    background-color: #e9ecef;
    border: 1px solid #ced4da;
    color: #495057;
    padding: 4px 8px;
    border-radius: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    visibility: hidden;
}

.app-container.user-logged-in #desktop-toggle-button {
    visibility: visible;
}

#desktop-toggle-button svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
}

#desktop-toggle-button:hover {
    background-color: #d1d5db;
    border-color: #b8bdc1;
}

#desktop-panel-resizer-handle:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

#desktop-panel-resizer-handle:hover::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    background-color: var(--sharpbru-primary-color, #5a42f3);
    transform: translateX(-50%);
}

#desktop-tabs {
    display: flex;
    gap: 2px;
}

.desktop-tab-button {
    padding: 6px 8px;
    border: none;
    background-color: transparent;
    cursor: pointer;
    font-family: var(--sharpbru-font-family);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--sharpbru-text-color);
    border-radius: calc(var(--sharpbru-border-radius) - 4px);
    transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.desktop-tab-button:hover {
    background-color: var(--desktop-tab-hover-bg-light);
}

.desktop-tab-button.active-tab {
    background-color: var(--desktop-tab-active-bg-light);
    font-weight: 600;
    color: var(--sharpbru-primary-color);
}

#desktop-panel-close-button {
    background: none;
    border: none;
    font-size: 1.6rem;
    color: var(--sharpbru-text-color);
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
}

#desktop-panel-close-button:hover {
    color: var(--sharpbru-error-color);
}

#notepad-textarea:focus {
    outline: none;
    border-color: var(--sharpbru-primary-color);
    box-shadow: 0 0 0 2px rgba(78, 69, 220, 0.15);
}

.desktop-save-button {
    padding: 6px 12px;
    background-color: var(--sharpbru-primary-color);
    color: white;
    border: none;
    border-radius: var(--sharpbru-border-radius);
    cursor: pointer;
    font-size: 0.85rem;
    transition: background-color 0.2s ease;
    height: 29px; /* Enforce consistent height */
    display: inline-flex; /* Align icon and text */
    align-items: center;
    justify-content: center;
}

.desktop-save-button:hover {
    background-color: var(--sharpbru-primary-hover-color);
}

.delete-note-button:hover {
    background-color: var(--sharpbru-error-color);
}

#welcome-message-text {
    font-family: var(--sharpbru-font-family);
    font-size: 2.2rem;
    line-height: 1.4;
    font-weight: 500;
    color: #b0b0b0;
    transition: color 0.3s ease;
    max-width: 80%;
}

.modal-tab-nav {
    display: flex;
    border-bottom: 1px solid var(--sharpbru-dark-border-color);
    margin-bottom: 20px;
}

.modal-tab-button {
    padding: 10px 20px;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--sharpbru-text-color);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.modal-tab-button.active {
    color: var(--sharpbru-primary-color);
    border-bottom-color: var(--sharpbru-primary-color);
    font-weight: 600;
}

.modal-tab-button:hover {
    background-color: #efefef;
}

.modal-tab-content {
    height: 400px;
    overflow-y: auto;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.logo-upload-section,
.note-sharing-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--sharpbru-dark-border-color);
}

.dark-mode #logo-upload-input {
    color: var(--sharpbru-dark-text-primary);
}

.dark-mode #admin-user-list-container label,
.dark-mode #admin-agent-management-container h3,
.dark-mode .section-description,
.dark-mode #global-agent-form label,
.dark-mode #edit-user-form label,
.dark-mode .note-sharing-section .toggle-label {
    color: var(--sharpbru-dark-text-primary);
}

.styled-select {
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: var(--sharpbru-border-radius);
    font-size: 1em;
    background-color: #fff;
    color: var(--sharpbru-text-color);
    transition: border-color 0.2s, box-shadow 0.2s;
    height: 41px; /* Match button height */
}

.dark-mode .styled-select {
    background-color: var(--sharpbru-dark-input-bg);
    border-color: var(--sharpbru-dark-border-color);
    color: var(--sharpbru-dark-text-primary);
}

#global-agent-form textarea {
    width: 100%;
    box-sizing: border-box;
}



.section-description {
    font-size: 0.9rem;
    color: var(--sharpbru-text-color);
    margin-bottom: 20px;
}

#add-new-agent-button,
.sharpbru-button {
    background-color: var(--sharpbru-primary-color);
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

#add-new-agent-button:hover,
.sharpbru-button:hover {
    background-color: var(--sharpbru-primary-hover-color);
}

#agent-list-container {
    margin-top: 20px;
    max-height: 250px;
    overflow-y: auto;
}

.agent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    border: 1px solid var(--sharpbru-dark-border-color);
    border-radius: 5px;
    margin-bottom: 10px;
}

.agent-item-name {
    font-weight: 600;
}

body.dark-mode #profile-settings-modal-content .agent-item-name {
    color: var(--sharpbru-dark-text-primary);
}

.agent-item-actions button {
    margin-left: 10px;
    background: none;
    border: 1px solid var(--sharpbru-dark-border-color);
    border-radius: 5px;
    padding: 5px 10px;
    cursor: pointer;
}

.agent-item-actions button:hover {
    background-color: #efefef;
    border-color: var(--sharpbru-primary-color);
}

#add-agent-form input[type="text"],
#add-agent-form input[type="url"],
#add-agent-form textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    color: var(--text-color);
    background-color: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#add-agent-form input[type="text"]:focus,
#add-agent-form input[type="url"]:focus,
#add-agent-form textarea:focus {
    outline: none;
    border-color: var(--sharpbru-primary-color);
    box-shadow: 0 0 0 3px rgba(78, 69, 220, 0.15);
}

#add-agent-modal-content input[type="text"],
#add-agent-modal-content input[type="url"],
#add-agent-modal-content textarea {
    border: 1px solid #d1d5db;
}

button.tab-button-disabled {
    color: #999 !important;
    opacity: 0.6;
    cursor: not-allowed !important;
}

button.tab-button-disabled:hover {
    cursor: not-allowed !important;
}

.desktop-tab-content textarea {
    flex-grow: 1;
}

@media (max-width: 767px) {
    .auth-form-card {
        padding: 25px 20px;
    }

    #registration-terms-modal-content h2 {
        font-size: 1.3rem;
    }

    #registration-notice-container {
        font-size: 0.75rem;
    }

    #accept-terms-modal-container label[for="reg-accept-terms-modal"] {
        font-size: 0.8rem;
    }
}


/* ========================================================================
   4. RICH MEDIA STYLES (YouTube, Image Previews, Lightbox)
   ======================================================================== */

.media-previews-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.youtube-preview-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    max-width: 440px;
    cursor: pointer;
    overflow: hidden;
    border: 1px solid var(--sharpbru-border-color, #e0e0e0);
    border-radius: 10px;
    transition: background-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.youtube-preview-card:hover {
    background-color: var(--sharpbru-hover-color, #f5f5fa);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.youtube-preview-thumbnail-wrapper {
    position: relative;
    width: 130px;
    flex-shrink: 0;
    aspect-ratio: 16 / 9;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
}

.youtube-preview-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.youtube-preview-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s ease;
}

.youtube-preview-play-icon::after {
    content: '';
    border-style: solid;
    border-width: 6px 0 6px 10px;
    border-color: transparent transparent transparent #ffffff;
    margin-left: 3px;
}

.youtube-preview-card:hover .youtube-preview-play-icon {
    transform: translate(-50%, -50%) scale(1.1);
}

.youtube-preview-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.youtube-preview-source {
    font-size: 0.8rem;
    color: var(--sharpbru-secondary-text-color, #666);
    margin: 0 0 4px 0;
    font-weight: 500;
}

.youtube-preview-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--sharpbru-primary-text-color, #333);
    margin: 0;
    line-height: 1.35;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.youtube-preview-card .media-delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 2;
}

.youtube-preview-card:hover .media-delete-btn {
    opacity: 1;
}

.youtube-preview-card .media-delete-btn:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.image-thumbnail {
    max-width: 500px;
    max-width: 100%;
    max-height: auto;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity 0.2s ease;
    border: 1px solid var(--sharpbru-border-color, #e0e0e0);
}

.image-preview-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

/* ========================================================================
   5. NOTE SHARING & NOTIFICATION STYLES
   ======================================================================== */

/* --- Modal Overlay & General Content --- */
#share-note-modal-overlay,
#new-shared-note-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.65);
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 3000;
    padding: 20px;
    backdrop-filter: blur(3px);
}

#share-note-modal-content,
#new-shared-note-modal-content {
    background-color: #fff;
    border-radius: var(--sharpbru-border-radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    position: relative;
    max-height: 90vh;
    border: 1px solid #ddd;
}

#share-note-modal-header,
#new-shared-note-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

#share-note-modal-title,
#new-shared-note-modal-title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--sharpbru-text-color);
}

#share-note-modal-body,
#new-shared-note-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

#share-note-modal-footer,
#new-shared-note-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    background-color: #f8f9fa;
    border-bottom-left-radius: var(--sharpbru-border-radius);
    border-bottom-right-radius: var(--sharpbru-border-radius);
    flex-shrink: 0;
}

/* --- Share Modal Specific Controls --- */
#share-user-search {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: var(--sharpbru-border-radius);
    font-size: 1rem;
    margin-bottom: 10px;
    box-sizing: border-box;
}

#share-note-user-list {
    flex-grow: 1;
    min-height: 150px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: var(--sharpbru-border-radius);
    padding: 8px;
    margin-bottom: 15px;
    background-color: #fff;
}

.share-user-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.share-user-item:hover {
    background-color: #f0f0f0;
}

.share-user-item input[type="checkbox"] {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--sharpbru-primary-color);
}

.share-user-item label {
    font-size: 0.95rem;
    color: var(--sharpbru-text-color);
    cursor: pointer;
    flex-grow: 1;
}

.share-controls-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-container label {
    font-size: 0.9rem;
    color: var(--sharpbru-text-color);
    cursor: pointer;
}

.checkbox-container input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--sharpbru-primary-color);
}

#share-note-button {
    background-color: var(--sharpbru-primary-color);
    color: white;
}

#share-note-button:hover {
    background-color: var(--sharpbru-primary-hover-color);
}

/* --- New Shared Note Notification --- */
#new-shared-note-modal-text {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--sharpbru-text-color);
    margin-bottom: 20px;
}

#new-shared-note-modal-text b {
    font-weight: 600;
    color: var(--sharpbru-primary-color);
}

/* --- General Modal Components --- */
.sharpbru-modal-button {
    padding: 10px 18px;
    border: none;
    border-radius: var(--sharpbru-border-radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.sharpbru-modal-button.secondary {
    background-color: #e9ecef;
    color: var(--sharpbru-text-color);
    border: 1px solid #ced4da;
}

.sharpbru-modal-button.secondary:hover {
    background-color: #d1d5db;
}

#close-share-note-modal {
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 2rem;
    font-weight: 300;
    color: #aaa;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
    padding: 5px;
}

#close-share-note-modal:hover {
    color: #777;
}

/* --- Dark Mode Styles --- */
body.dark-mode #share-note-modal-content,
body.dark-mode #new-shared-note-modal-content {
    background-color: var(--desktop-panel-bg-dark);
    border-color: var(--sharpbru-dark-border-color);
}

body.dark-mode #share-note-modal-header,
body.dark-mode #new-shared-note-modal-header,
body.dark-mode #share-note-modal-footer,
body.dark-mode #new-shared-note-modal-footer {
    border-color: var(--sharpbru-dark-border-color);
}

body.dark-mode #share-note-modal-title,
body.dark-mode #new-shared-note-modal-title,
body.dark-mode #new-shared-note-modal-text,
body.dark-mode .share-user-item label,
body.dark-mode .checkbox-container label {
    color: var(--sharpbru-dark-text-primary);
}

body.dark-mode #share-user-search {
    background-color: var(--sharpbru-dark-input-bg);
    border-color: var(--sharpbru-dark-input-border);
    color: var(--sharpbru-dark-text-primary);
}

body.dark-mode #share-note-user-list {
    background-color: var(--sharpbru-dark-bg-display);
    border-color: var(--sharpbru-dark-border-color);
}

body.dark-mode .share-user-item:hover {
    background-color: var(--desktop-tab-hover-bg-dark);
}

body.dark-mode .sharpbru-modal-button.secondary {
    background-color: #4a4a4a;
    color: var(--sharpbru-dark-text-primary);
    border-color: #5a5a5a;
}

body.dark-mode .sharpbru-modal-button.secondary:hover {
    background-color: #5a5a5a;
}

body.dark-mode #close-share-note-modal {
    color: var(--sharpbru-dark-text-secondary);
}

/* --- Spinner --- */
.content-spinner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    border-radius: var(--sharpbru-border-radius);
}

body.dark-mode .content-spinner-overlay {
    background: rgba(0,0,0,0.5);
}

.content-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--sharpbru-primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


#notes-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    padding: 10px;
    overflow-y: auto;
    flex-grow: 1;
}

.note-card {
    position: relative;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: box-shadow 0.2s ease;
}

.note-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.note-card-title {
    font-weight: bold;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-card-preview {
    flex-grow: 1;
    font-size: 0.9rem;
    color: #666;
}


.note-card-delete {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 2px 5px;
    border-radius: 4px;
    transition: color 0.2s, background-color 0.2s;
}

.note-card-delete:hover {
    color: var(--sharpbru-error-color);
    background-color: rgba(231, 76, 60, 0.1);
}

.notes-grid-error {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    text-align: center;
    color: var(--sharpbru-text-color);
}

#retry-notes-load {
    margin-top: 15px;
}

#share-note-modal-content {
    max-width: 450px;
    text-align: left;
}

#share-note-modal-title {
    text-align: center;
    margin-bottom: 20px;
}

#share-note-user-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
    border: 1px solid var(--desktop-panel-border-light);
    border-radius: var(--sharpbru-border-radius);
    padding: 10px;
}

.share-user-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.share-user-item:hover {
    background-color: #f0f0f0;
}

.share-user-item input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
}

.share-user-item label {
    cursor: pointer;
    flex-grow: 1;
}

#share-note-button {
    width: 100%;
}

#share-note-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

#share-user-search {
    width: 70%;
    padding: 8px 10px;
    border: 1px solid var(--desktop-panel-border-light);
    border-radius: var(--sharpbru-border-radius);
}

.share-select-all-container {
    display: flex;
    align-items: center;
}

.dark-mode #share-note-modal-content {
    background-color: var(--desktop-panel-bg-dark);
    color: var(--sharpbru-dark-text-primary);
}

.dark-mode #share-note-user-list {
    border-color: var(--sharpbru-dark-border-color);
}

.dark-mode .share-user-item:hover {
    background-color: var(--desktop-tab-hover-bg-dark);
}

.dark-mode #share-user-search {
    background-color: var(--sharpbru-dark-input-bg);
    border-color: var(--sharpbru-dark-border-color);
    color: var(--sharpbru-dark-text-primary);
}

/* --- Note Card Icon Layout (Improved Version) --- */

/* This container will now span the bottom of the card and space out its children */
.note-card-icons {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 8px;           /* Vertically aligns them in the middle */
}

/* Base styles for ALL icons to remove default browser weirdness */
.note-card-icons > button {
  padding: 4px;
  background: none;
  border: none; /* This removes the "ugly border" from the share button */
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Copy icon on note cards */
.note-card-copy {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}
.note-card-copy svg {
  width: 16px;
  height: 16px;
  color: #888;
  transition: color 0.2s ease;
}
.note-card-copy:hover svg {
  color: var(--sharpbru-primary-color);
}
.note-card-copy.copied svg {
  color: #28a745;
}

/* Share/Export icon on note cards - pushes to the far right */
.note-card-share-export {
  margin-left: auto;
}
.note-card-share-export svg {
  width: 18px;
  height: 18px;
  color: #888;
  transition: color 0.2s ease;
}
.note-card-share-export:hover svg {
  color: var(--sharpbru-primary-color);
}

/* Dropdown menu on note cards */
.note-dropdown-menu {
  display: none;
  position: absolute;
  bottom: 36px;
  right: 8px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: var(--sharpbru-border-radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 20;
  min-width: 160px;
  padding: 4px 0;
}
.note-dropdown-menu.active {
  display: block;
}
.note-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--sharpbru-text-color);
  transition: background-color 0.15s ease;
  white-space: nowrap;
}
.note-dropdown-item:hover {
  background-color: #f0f0f0;
}
.note-dropdown-item svg {
  flex-shrink: 0;
}

/* Editor share/export dropdown */
#editor-share-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: var(--sharpbru-border-radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 20;
  min-width: 170px;
  padding: 4px 0;
  margin-top: 4px;
}
#editor-share-dropdown.active {
  display: block;
}
.editor-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--sharpbru-text-color);
  transition: background-color 0.15s ease;
  white-space: nowrap;
}
.editor-dropdown-item:hover {
  background-color: #f0f0f0;
}
.editor-dropdown-item svg {
  flex-shrink: 0;
}

/* Style for the Media Icon */
.note-card-media-icon {
  width: 24px;
  height: 24px;
  background-color: var(--sharpbru-primary-color);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Flex order for note card icons: media | copy | share/export */
.note-card-media-icon {
    order: 1;
}
.note-card-copy {
    order: 2;
}
.note-card-share-export {
    order: 3;
}

#share-note-user-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.share-user-item {
    display: flex;
    align-items: center;
    padding: 5px;
}

.share-user-item input {
    margin-right: 10px;
}

.thread-link {
    background-color: #eef2ff;
    color: #4338ca;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s ease;
    display: inline-block;
    margin: 4px 0;
    position: relative;
}

.thread-link:hover {
    background-color: #e0e7ff;
}

.thread-link:visited {
    color: var(--sharpbru-primary-color); /* Keeps it uniform */
}

.dark-mode .thread-link {
    background-color: #312e75;
    color: #93C5FD;
}

.dark-mode .thread-link:hover {
    background-color: #37308d;
}

.dark-mode .thread-link:visited {
    color: #60A5FA;
}

.media-delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.youtube-preview-card:hover .media-delete-btn,
.image-preview-wrapper:hover .media-delete-btn,
.thread-link:hover .media-delete-btn {
    opacity: 1;
}

.media-delete-btn:hover {
    background-color: rgba(231, 76, 60, 0.9);
}


/* --- NEW: Note Card Media Icon --- */
.note-card {
    position: relative; /* Ensure the icon is positioned relative to the card */
}


/* --- NEW: Video Player Close Button --- */
#desktop-video-player-container {
    position: relative; /* Needed for positioning the close button */
}

#desktop-video-close-button {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
    z-index: 10;
    transition: background-color 0.2s;
}

#desktop-video-close-button:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

/* --- NEW: Notes Grid Error Styling --- */
.notes-grid-error {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    height: 100%;
    color: var(--sharpbru-text-color);
}

.notes-grid-error p {
    margin-bottom: 15px;
}

.dark-mode .notes-grid-error {
    color: var(--sharpbru-dark-text-primary);
}


.add-to-note-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 1; /* Always visible */
    transition: background-color 0.2s ease-in-out;
    z-index: 5;
}

.add-to-note-btn:hover {
    background-color: var(--sharpbru-primary-hover-color);
}


.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    display: block;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

/* ========================================================================
   5. NOTE-SPECIFIC STYLES (Notes Grid, Cards, etc.)
   ======================================================================== */

#notes-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    padding: 10px;
    flex-grow: 1;
    overflow-y: auto;
    align-content: flex-start;
}

.note-card {
    position: relative;
    background-color: var(--desktop-tab-active-bg-light);
    border: 1px solid var(--desktop-panel-border-light);
    border-radius: var(--sharpbru-border-radius);
    padding: 12px;
    cursor: pointer;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    height: 150px;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevents content from spilling out */
}

.note-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    border-color: var(--sharpbru-primary-color);
}

.note-card.active-note {
    border-color: var(--sharpbru-primary-color);
    box-shadow: 0 0 0 2px rgba(78, 69, 220, 0.3);
}

.note-card-title {
    font-weight: 600;
    font-size: 1rem;
    margin: 0 0 8px 0;
    color: var(--sharpbru-text-color);
    overflow-wrap: break-word; /* Fix: Wrap long text */
    word-break: break-all; /* Fix: Break long URLs */
}

.note-card-preview {
    font-size: 0.85rem;
    color: var(--subtle-text-color);
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow-wrap: break-word; /* Fix: Wrap long text */
}

.note-card-delete {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    background-color: rgba(0,0,0,0.1);
    color: #666;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s;
}

.note-card:hover .note-card-delete {
    opacity: 1;
}

.note-card-delete:hover {
    background-color: var(--sharpbru-error-color);
    color: white;
}

#add-note-button {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 300;
    color: var(--subtle-text-color);
    border: 2px dashed var(--desktop-panel-border-light);
    background-color: transparent;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

#add-note-button:hover {
    border-color: var(--sharpbru-primary-color);
    color: var(--sharpbru-primary-color);
}

.lightbox-close:hover {
    color: #ccc;
}

#desktop-video-player-container {
    display: none;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: #000;
    flex-shrink: 0;
}

#desktop-video-player-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ========================================================================
   5. DARK MODE STYLES
   ======================================================================== */

html.dark-mode,
body.dark-mode {
    background-color: var(--sharpbru-dark-bg-page, #121212);
}

.app-container.dark-mode {
    background-color: var(--sharpbru-dark-bg-page, #121212);
}

.app-container.dark-mode #app-header {
    background-color: var(--dark-logo-area-background, #2C2C2C);
    border-bottom-color: var(--sharpbru-dark-border-color, #444);
}

.app-container.dark-mode #top-app-bar {
    background-color: var(--sharpbru-dark-bg-display, #222222);
}

.app-container.dark-mode .chat-area {
    background-color: var(--sharpbru-dark-bg-display, #222222);
}

.app-container.dark-mode .sidebar {
    background-color: var(--sharpbru-dark-bg-sidebar, #2C2C2C);
}

.app-container.dark-mode .sidebar.collapsed {
    background-color: var(--sharpbru-dark-bg-sidebar-overhang, #3A3A3A);
}

.app-container.dark-mode .sidebar.collapsed #hamburger-menu {
    background-color: var(--sharpbru-dark-bg-sidebar-overhang, #3A3A3A);
    border-color: var(--sharpbru-dark-border-color, #444);
    color: var(--sharpbru-dark-text-primary, #f0f0f0);
}

.app-container.dark-mode .sidebar.collapsed #hamburger-menu:hover {
    background-color: #4a4a4a;
}

.app-container.dark-mode .sidebar-content {
    background-color: var(--sharpbru-dark-bg-sidebar, #2C2C2C);
}

.app-container.dark-mode .sidebar-content h2 {
    color: var(--sharpbru-dark-text-primary, #f0f0f0);
}

.app-container.dark-mode #new-chat-button {
    background-color: var(--sharpbru-dark-button-bg, #4e45dc);
    color: var(--sharpbru-dark-button-icon, #e0e7ff);
}

.app-container.dark-mode #new-chat-button:hover {
    background-color: var(--sharpbru-dark-button-hover-bg, #3a33a3);
}

.app-container.dark-mode #chat-history-list li {
    color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

.app-container.dark-mode #chat-history-list li:hover {
    background-color: #3a3a3a;
    color: var(--sharpbru-dark-text-primary, #f0f0f0);
}

.app-container.dark-mode #chat-history-list li.active-chat {
    background-color: #4a4a4a;
    color: #ffffff;
}

.app-container.dark-mode .settings-area {
    border-top-color: var(--sharpbru-dark-border-color, #444);
}

.app-container.dark-mode .settings-area h3 {
    color: var(--sharpbru-dark-text-primary, #f0f0f0);
}

.app-container.dark-mode .toggle-label {
    color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

.app-container.dark-mode #sharpbru-chat-container {
    background-color: transparent;
}

.app-container.dark-mode #sharpbru-chat-display {
    background-color: transparent;
    color: var(--sharpbru-dark-text-primary, #f0f0f0);
}

/* ========================================================================
   DARK MODE SCROLLBAR STYLES
   ======================================================================== */

.app-container.dark-mode #sharpbru-chat-display::-webkit-scrollbar-track,
.app-container.dark-mode #chat-history-list::-webkit-scrollbar-track {
    background: #2a2a2a; 
}

.app-container.dark-mode #sharpbru-chat-display::-webkit-scrollbar-thumb,
.app-container.dark-mode #chat-history-list::-webkit-scrollbar-thumb {
    background: #555; 
}

.app-container.dark-mode #sharpbru-chat-display::-webkit-scrollbar-thumb:hover,
.app-container.dark-mode #chat-history-list::-webkit-scrollbar-thumb:hover {
    background: #777; 
}

.app-container.dark-mode .sharpbru-message.bot {
    background-color: #222222 !important; /* Matches your display background */
    color: var(--sharpbru-dark-bot-text, #e0e0e0);
    margin-right: auto;
    max-width: 95%;
    border: none !important;
    box-shadow: none !important;
}

/* Make the user bubble a neutral gray that blends with the theme */
.app-container.dark-mode .sharpbru-message.user {
    background-color: #2C2C2C; /* Slightly lighter than the background */
    color: #F8FAFC; 
    margin-left: auto;
}

.app-container.dark-mode .sharpbru-message.error {
    background-color: var(--sharpbru-dark-bg-error-content, #991b1b);
    color: var(--sharpbru-dark-text-error-content, #fca5a5);
}

.app-container.dark-mode .sharpbru-message code:not(pre code) {
    background-color: #444;
    color: #f0f0f0;
}

.app-container.dark-mode #sharpbru-form {
    border-top-color: var(--sharpbru-dark-border-color, #444);
}

.app-container.dark-mode #sharpbru-input {
    background-color: var(--sharpbru-dark-input-bg, #333333);
    border-color: var(--sharpbru-dark-input-border, #444);
    color: var(--sharpbru-dark-text-primary, #f0f0f0);
}

.app-container.dark-mode #sharpbru-input:focus {
    border-color: var(--sharpbru-dark-input-focus-border, #6366f1);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.app-container.dark-mode #sharpbru-input::placeholder {
    color: #888;
}

.app-container.dark-mode #sharpbru-form button {
    background-color: var(--sharpbru-dark-button-bg, #4e45dc);
    color: var(--sharpbru-dark-button-icon, #e0e7ff);
}

.app-container.dark-mode #sharpbru-form button:hover {
    background-color: var(--sharpbru-dark-button-hover-bg, #3a33a3);
}

.app-container.dark-mode .sharpbru-typing-indicator {
    color: var(--sharpbru-dark-muted-text, #888);
}

.app-container.dark-mode .sharpbru-message.thinking {
    background-color: #2a2a2a;
    color: #888;
}

.app-container.dark-mode #privacy-statement {
    color: #777;
}

.app-container.dark-mode .sidebar-content #user-info-container {
    border-top-color: var(--sharpbru-dark-border-color, #444);
}

.app-container.dark-mode .sidebar-content #user-display-name {
    color: var(--sharpbru-dark-text-primary, #f0f0f0);
}

.app-container.dark-mode #logout-button {
    color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

.app-container.dark-mode #logout-button:hover {
    color: var(--sharpbru-dark-text-primary, #f0f0f0);
}

.app-container.dark-mode #hamburger-menu {
    color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

.app-container.dark-mode #hamburger-menu:hover {
    background-color: #4a4a4a;
}

.app-container.dark-mode #welcome-message-text {
    color: #555;
}

.dark-mode #auth-wrapper {
    background-color: var(--sharpbru-dark-bg-page, #121212);
}

.dark-mode .auth-form-card {
    background-color: var(--sharpbru-dark-bg-display, #222222);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.dark-mode .auth-form-card h2 {
    color: var(--sharpbru-dark-text-primary, #f0f0f0);
}

.dark-mode .auth-form-card form label {
    color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

.dark-mode .auth-form-card form input[type="email"],
.dark-mode .auth-form-card form input[type="password"],
.dark-mode .auth-form-card form input[type="text"] {
    background-color: var(--sharpbru-dark-input-bg, #333333);
    border-color: var(--sharpbru-dark-input-border, #444);
    color: var(--sharpbru-dark-text-primary, #f0f0f0);
}

.dark-mode .auth-form-card form input:focus {
    border-color: var(--sharpbru-dark-input-focus-border, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.dark-mode .auth-form-card form button[type="submit"] {
    background-color: var(--sharpbru-dark-button-bg, #4e45dc);
    color: var(--sharpbru-dark-button-icon, #e0e7ff);
}

.dark-mode .auth-form-card form button[type="submit"]:hover {
    background-color: var(--sharpbru-dark-button-hover-bg, #3a33a3);
}

.dark-mode .auth-form-card p {
    color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

.dark-mode .auth-form-card p a {
    color: var(--sharpbru-dark-input-focus-border, #6366f1);
}

.dark-mode #registration-terms-modal-overlay {
    background-color: var(--sharpbru-dark-bg-page, #121212);
}

.dark-mode #registration-terms-modal-content {
    background-color: var(--sharpbru-dark-bg-display, #222222);
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.4);
}

.dark-mode #registration-notice-container {
    color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

.dark-mode #registration-notice-container h2,
.dark-mode #registration-notice-container strong {
    color: var(--sharpbru-dark-text-primary, #f0f0f0);
}

.dark-mode #accept-terms-modal-container {
    border-top: 1px solid var(--sharpbru-dark-border-color, #444);
}

.dark-mode #accept-terms-modal-container label[for="reg-accept-terms-modal"] {
    color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

.dark-mode #proceed-to-register-button:disabled {
    background-color: #444;
    color: #888;
}

.dark-mode .modal-close-button {
    color: #777;
}

.dark-mode .modal-close-button:hover {
    color: #aaa;
}

.dark-mode #desktop-panel {
    background-color: var(--desktop-panel-bg-dark);
    border-left-color: var(--desktop-panel-border-dark);
}

.dark-mode #desktop-panel-header {
    border-bottom-color: var(--desktop-panel-border-dark);
}

.dark-mode .desktop-tab-button {
    color: var(--sharpbru-dark-text-secondary);
}

.dark-mode .desktop-tab-button:hover {
    background-color: var(--desktop-tab-hover-bg-dark);
}

.dark-mode .desktop-tab-button.active-tab {
    background-color: var(--desktop-tab-active-bg-dark);
    color: var(--sharpbru-dark-text-primary);
}

.dark-mode #desktop-panel-close-button {
    color: var(--sharpbru-dark-text-secondary);
}

.dark-mode #desktop-panel-close-button:hover {
    color: var(--sharpbru-error-color);
}

.dark-mode #notepad-copy-btn {
    color: var(--sharpbru-dark-text-secondary);
}

.dark-mode #notepad-copy-btn:hover {
    color: var(--sharpbru-dark-text-primary);
}

.dark-mode #share-note-editor-button {
    color: var(--sharpbru-dark-text-secondary);
}

.dark-mode #share-note-editor-button:hover {
    color: var(--sharpbru-dark-text-primary);
}

/* Dark mode for note card copy button */
.dark-mode .note-card-copy svg {
    color: var(--sharpbru-dark-text-secondary);
}
.dark-mode .note-card-copy:hover svg {
    color: var(--sharpbru-dark-text-primary);
}
.dark-mode .note-card-copy.copied svg {
    color: #28a745;
}

/* Dark mode for note card share/export button */
.dark-mode .note-card-share-export svg {
    color: var(--sharpbru-dark-text-secondary);
}
.dark-mode .note-card-share-export:hover svg {
    color: var(--sharpbru-dark-text-primary);
}

/* Dark mode for note card dropdown menus */
.dark-mode .note-dropdown-menu,
.dark-mode #editor-share-dropdown {
    background-color: #2c2c2c;
    border-color: #444;
}
.dark-mode .note-dropdown-item,
.dark-mode .editor-dropdown-item {
    color: var(--sharpbru-dark-text-primary);
}
.dark-mode .note-dropdown-item:hover,
.dark-mode .editor-dropdown-item:hover {
    background-color: #3a3a3a;
}

.dark-mode #notepad-textarea {
    background-color: var(--sharpbru-dark-input-bg);
    border-color: var(--desktop-panel-border-dark);
    color: var(--sharpbru-dark-text-primary);
}

.dark-mode #notepad-textarea:focus {
    border-color: var(--sharpbru-dark-input-focus-border);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

/* --- Dark Mode: To-Do List --- */
.dark-mode .todo-item {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

.dark-mode .todo-item:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

.dark-mode .todo-text {
    color: var(--sharpbru-dark-text-primary);
}

.dark-mode .todo-item.completed .todo-text {
    color: var(--sharpbru-dark-muted-text, #888);
}

.dark-mode .todo-delete {
    color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

.dark-mode .todo-delete:hover {
    color: var(--sharpbru-error-color);
    background-color: rgba(231, 76, 60, 0.15);
}

.dark-mode .todo-edit-input {
    background-color: var(--sharpbru-dark-input-bg);
    border-color: var(--sharpbru-dark-input-focus-border);
    color: var(--sharpbru-dark-text-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.dark-mode #todo-add-input {
    background-color: var(--sharpbru-dark-input-bg);
    border-color: var(--desktop-panel-border-dark);
    color: var(--sharpbru-dark-text-primary);
}

.dark-mode #todo-add-input:focus {
    border-color: var(--sharpbru-dark-input-focus-border);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.dark-mode #todo-add-input::placeholder {
    color: var(--sharpbru-dark-muted-text, #888);
}

.dark-mode #todo-item-count {
    color: var(--sharpbru-dark-text-secondary);
}

.dark-mode #todo-add-button {
    background-color: var(--sharpbru-dark-button-bg);
    color: var(--sharpbru-dark-button-icon);
}

.dark-mode #todo-add-button:hover {
    background-color: var(--sharpbru-dark-button-hover-bg);
}


.dark-mode #notepad-editor {
    color: var(--sharpbru-dark-text-primary);
    border-color: var(--desktop-panel-border-dark);
}

.dark-mode #notepad-editor:focus {
    border-color: var(--sharpbru-dark-input-focus-border);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.dark-mode #notepad-editor.preview-mode {
    background-color: rgba(255, 255, 255, 0.03);
}

.dark-mode #notepad-word-count {
    color: #666;
}

.dark-mode #preview-toggle-button.active {
    background-color: var(--sharpbru-dark-button-bg);
    color: var(--sharpbru-dark-button-icon);
}

.dark-mode .desktop-content-footer {
    border-top-color: var(--desktop-panel-border-dark);
    color: var(--sharpbru-dark-text-secondary);
}

.dark-mode #desktop-toggle-button {
    background-color: #3a3a3a;
    border-color: #555;
    color: #ccc;
}

.dark-mode #desktop-toggle-button:hover {
    background-color: #4a4a4a;
    border-color: #666;
}

.dark-mode #desktop-panel-resizer-handle:hover::after {
    background-color: var(--sharpbru-dark-input-focus-border);
}

.dark-mode .tier-status-display.tier-free {
    background-color: #3a3a3a;
    border-color: #555;
    color: #ccc;
}

.dark-mode #user-tier-status.model-selector-active {
    background-color: var(--sharpbru-dark-button-bg);
    color: var(--sharpbru-dark-button-icon);
}

.dark-mode #user-tier-status.model-selector-active:hover {
    background-color: var(--sharpbru-dark-button-hover-bg);
}

.dark-mode #model-dropdown-menu {
    background-color: #2c2c2c;
    border-color: #444;
}

.dark-mode .model-item {
    color: var(--sharpbru-dark-text-secondary);
}

.dark-mode .model-item:hover {
    background-color: #3a3a3a;
    color: var(--sharpbru-dark-text-primary);
}

.dark-mode .modal-overlay {
    background-color: rgba(0, 0, 0, 0.7);
}

.dark-mode #profile-settings-modal-content.auth-form-card {
    background-color: var(--sharpbru-dark-bg-display);
}

.dark-mode #profile-settings-modal-content h2,
.dark-mode #profile-settings-modal-content h3,
.dark-mode #profile-settings-modal-content form label {
    color: var(--sharpbru-dark-text-primary);
}

.dark-mode #profile-settings-modal-content form input[type="text"],
.dark-mode #profile-settings-modal-content form input[type="password"] {
    background-color: var(--sharpbru-dark-input-bg);
    border-color: var(--sharpbru-dark-border-color);
    color: var(--sharpbru-dark-text-primary);
}

.dark-mode #profile-settings-modal-content form input:focus {
    border-color: var(--sharpbru-dark-input-focus-border);
}

.dark-mode .modal-tab-nav {
    border-bottom-color: var(--sharpbru-dark-border-color);
}

.dark-mode .modal-tab-button {
    color: var(--sharpbru-dark-text-secondary);
}

.dark-mode .modal-tab-button.active {
    color: var(--sharpbru-primary-color);
    border-bottom-color: var(--sharpbru-primary-color);
}

.dark-mode .modal-tab-button:hover {
    background-color: #3a3a3a;
}

.dark-mode .agent-item {
    border-color: var(--sharpbru-dark-border-color);
}

.dark-mode .agent-item-actions button {
    border-color: var(--sharpbru-dark-border-color);
    color: var(--sharpbru-dark-text-secondary);
}

.dark-mode .agent-item-actions button:hover {
    background-color: #3a3a3a;
    border-color: var(--sharpbru-dark-input-focus-border);
    color: var(--sharpbru-dark-text-primary);
}

.dark-mode #add-agent-modal-content input,
.dark-mode #add-agent-modal-content textarea {
    background-color: var(--sharpbru-dark-input-bg);
    border-color: var(--sharpbru-dark-border-color);
    color: var(--sharpbru-dark-text-primary);
}

.dark-mode #add-agent-modal-content input:focus,
.dark-mode #add-agent-modal-content textarea:focus {
    border-color: var(--sharpbru-dark-input-focus-border);
}

.dark-mode .youtube-preview-card {
    border-color: var(--sharpbru-dark-border-color);
}

.dark-mode .youtube-preview-card:hover {
    background-color: #2a2a2a;
}

.dark-mode .thread-menu {
    background-color: #3a3a3a;
    border-color: #555;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.dark-mode .thread-menu-item {
    color: var(--sharpbru-dark-text-primary);
}

.dark-mode .thread-menu-item:hover {
    background-color: #4a4a4a;
}

.dark-mode .thread-menu-item.delete:hover {
    background-color: var(--sharpbru-error-color);
    color: white;
}

.dark-mode .youtube-preview-source {
    color: var(--sharpbru-dark-text-secondary);
}

.dark-mode .youtube-preview-title {
    color: var(--sharpbru-dark-text-primary);
}

.dark-mode .image-thumbnail {
    border-color: var(--sharpbru-dark-border-color);
}

/* Fix Global Dark Mode Links */
.dark-mode a {
    color: #818CF8;
}
.dark-mode a:hover {
    color: #A5B4FC;
}

/* Fix Chat, Notepad, and Visited Dark Mode Links */
.dark-mode .sharpbru-message a,
.dark-mode #notepad-editor a,
.dark-mode .sharpbru-message a:visited,
.dark-mode #notepad-editor a:visited {
    color: #818CF8;
}

.dark-mode .sharpbru-message a:hover,
.dark-mode #notepad-editor a:hover {
    color: #A5B4FC;
}

.dark-mode .sharpbru-message a:active,
.dark-mode #notepad-editor a:active {
    background-color: rgba(129, 140, 248, 0.2);
}

/* Fix Dark Mode Thread Links */
.dark-mode .thread-link:visited {
    color: #818CF8; /* Was previously standard blue */
}

/* ========================================================================
   6. FILE ATTACHMENT STYLES
   ======================================================================== */

#attach-file-button {
    background: none;
    border: none;
    padding: 10px;
    cursor: pointer;
    color: #6c757d;
    transition: color 0.2s;
}

#attach-file-button, #add-image-from-chat-button {
    background: none;
    border: none;
    padding: 10px;
    cursor: pointer;
    color: #6c757d;
    transition: color 0.2s;
}

#attach-file-button:hover, #add-image-from-chat-button:hover {
    color: var(--sharpbru-primary-color);
}

#attach-file-button svg, #add-image-from-chat-button svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
}

.dark-mode #attach-file-button {
    color: #999;
}

.dark-mode #attach-file-button:hover {
    color: var(--sharpbru-dark-input-focus-border);
}

#file-preview-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    background-color: #e9ecef;
    border-radius: 5px;
    font-size: 0.85rem;
    margin-top: 8px;
}

.dark-mode #file-preview-container {
    background-color: #3a3a3a;
    color: #ccc;
}

#file-preview-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

#file-preview-clear {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: #6c757d;
    padding: 0 4px;
    line-height: 1;
}

.dark-mode #file-preview-clear {
    color: #999;
}

#file-preview-clear:hover {
    color: #333;
}

.dark-mode #file-preview-clear:hover {
    color: #fff;
}

/* --- Thread File Memory Indicator ---
   Persistent bar shown when a file is "remembered" for the active thread.
   Visually distinct (muted/amber) from the active file-preview (grey). */
#thread-file-memory-container {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background-color: #fff3cd;
    border: 1px solid #ffe69c;
    border-radius: 5px;
    font-size: 0.8rem;
    margin-top: 8px;
    color: #856404;
}

.dark-mode #thread-file-memory-container {
    background-color: #3d3517;
    border-color: #5a4d1f;
    color: #d4a72c;
}

#thread-file-memory-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.thread-file-memory-hint {
    font-style: italic;
    opacity: 0.8;
    font-size: 0.75rem;
}

#thread-file-memory-clear {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: inherit;
    padding: 0 4px;
    line-height: 1;
    margin-left: auto;
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

#thread-file-memory-clear:hover {
    opacity: 1;
}

.file-upload-indicator {
    display: inline-block;
    margin-left: 10px;
    font-style: italic;
    color: #6c757d;
}

.dark-mode .file-upload-indicator {
    color: #999;
}

.file-content-display {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-top: 10px;
    background-color: #f8f9fa;
    max-height: 200px;
    overflow-y: auto;
}

.dark-mode .file-content-display {
    border-color: #444;
    background-color: #2a2a2a;
}

.file-content-display h4 {
    margin-top: 0;
    font-size: 1rem;
    font-weight: 600;
    border-bottom: 1px solid #ccc;
    padding-bottom: 5px;
    margin-bottom: 10px;
}

.dark-mode .file-content-display h4 {
    border-bottom-color: #555;
}

.file-content-display pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.9rem;
    color: #333;
}

.dark-mode .file-content-display pre {
    color: #ddd;
}

/* --- Notes Grid Styles --- */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    padding: 10px;
    flex-grow: 1;
    overflow-y: auto;
    grid-auto-rows: 150px; 
    align-content: flex-start; 
}

.note-card {
    background-color: #fff;
    border: 1px solid var(--desktop-panel-border-light);
    border-radius: var(--sharpbru-border-radius);
    padding: 15px;
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 140px; /* Set a consistent minimum height */
}

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

.note-card-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--sharpbru-text-color);
    font-size: 1rem;
    overflow-wrap: break-word;
}

.note-card-preview {
    font-size: 0.9rem;
    color: #555;
    flex-grow: 1;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow-wrap: break-word;
}

.grid-footer-placeholder {
    flex-grow: 1;
}

.grid-footer-buttons {
    display: flex;
    gap: 10px;
}

.content-spinner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.desktop-tab-content.loading .content-spinner-overlay {
    opacity: 1;
    pointer-events: auto;
}

.content-spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--sharpbru-primary-color);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
}

.dark-mode .content-spinner-overlay {
    background-color: rgba(40, 40, 40, 0.7);
}

.dark-mode .content-spinner {
    border-color: var(--sharpbru-dark-border-color);
    border-top-color: var(--sharpbru-dark-input-focus-border);
}

/* ========================================================================
   7. MAIN PAGE LOADING INDICATOR
   ======================================================================== */

#loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    /* Use a solid background color to completely hide the app as it loads */
    background-color: #ffffff; 
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999; /* Ensure it's on top of all other content */
}

#loading-indicator .spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #e0e0e0; /* Light grey track */
    border-top: 5px solid var(--sharpbru-primary-color); /* Blue spinner */
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

html.dark-mode #loading-indicator {
    background-color: var(--sharpbru-dark-bg-page);
}

html.dark-mode #loading-indicator .spinner {
    border-color: #444;
    border-top-color: var(--sharpbru-primary-color);
}

/* ========================================================================
   8. GRID PLACEHOLDER STYLES
   ======================================================================== */

.notes-grid-placeholder {
  /* Make the text span the full width of the grid container */
  grid-column: 1 / -1; 
  
  text-align: center;
  padding: 40px 20px;
  font-size: 0.9rem;
  margin: 0;
  
  /* Set the default text color for light mode */
  color: #6c757d; 
}

/* Set the text color specifically for dark mode */
body.dark-mode .notes-grid-placeholder {
  color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

/* --- Shared Note Indicator: Border Style --- */
.note-card.is-shared {
    /* Adds a 4px wide border using your primary color */
    border-left: 4px solid var(--sharpbru-primary-color);
}

/* ========================================================================
   VOICE CHAT STYLES (Orb, Mic, Toggle)
   ======================================================================== */

/* --- Voice Orb Container --- */
#voice-orb-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 0 8px 0;
    width: 100%;
    box-sizing: border-box; /* Forces strict width calculation */
    margin: 0 auto;         /* Guarantees dead-center alignment */
    transition: opacity 0.3s ease;
}

/* --- The Orb --- */
.voice-orb {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #7c73e6, #4e45dc, #2a2480);
    box-shadow: 0 0 30px rgba(78, 69, 220, 0.3), inset -6px -6px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.5s ease;
    position: relative;
}

/* State: Idle (Breathing) */
.voice-orb--idle {
    animation: voiceOrbBreathe 4s ease-in-out infinite;
}

@keyframes voiceOrbBreathe {
    0%, 100% { transform: scale(1); box-shadow: 0 0 30px rgba(78, 69, 220, 0.3); }
    50% { transform: scale(1.06); box-shadow: 0 0 45px rgba(78, 69, 220, 0.5); }
}

/* State: Listening (Expanded, Green glow) */
.voice-orb--listening {
    background: radial-gradient(circle at 35% 35%, #34d399, #10b981, #064e3b);
    box-shadow: 0 0 60px rgba(52, 211, 153, 0.7);
    transform: scale(1.12);
    animation: voiceOrbRipple 2s linear infinite;
}

@keyframes voiceOrbRipple {
    0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.4), 0 0 60px rgba(52, 211, 153, 0.7); }
    100% { box-shadow: 0 0 0 20px rgba(52, 211, 153, 0), 0 0 60px rgba(52, 211, 153, 0.7); }
}

/* State: Thinking (Swirling) */
.voice-orb--thinking {
    background: conic-gradient(from 0deg, #8b5cf6, #4e45dc, #8b5cf6);
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.5);
    animation: voiceOrbSpin 2s linear infinite;
}

@keyframes voiceOrbSpin {
    100% { transform: rotate(360deg); }
}

/* State: Speaking (Pulsing rapidly) */
.voice-orb--speaking {
    background: radial-gradient(circle at 35% 35%, #7c73e6, #4e45dc, #2a2480);
    animation: voiceOrbPulse 0.5s alternate infinite;
}

@keyframes voiceOrbPulse {
    0% { transform: scale(1); box-shadow: 0 0 30px rgba(78, 69, 220, 0.4); }
    100% { transform: scale(1.1); box-shadow: 0 0 60px rgba(78, 69, 220, 0.8); }
}

/* --- Orb Status Text --- */
.voice-orb-status {
    font-size: 0.7rem;
    font-family: var(--sharpbru-font-family);
    color: var(--subtle-text-color, #6c757d);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 8px;
    transition: color 0.3s ease;
}


/* --- Speak Interface (Mic Button) --- */
.voice-speak-interface {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    width: 100%;
    box-sizing: border-box; /* Forces strict width calculation */
    margin: 0 auto;         /* Guarantees dead-center alignment */
}

.voice-mic-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 3px solid #dee2e6;
    background-color: #f0f0f0;
    color: var(--sharpbru-text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.voice-mic-btn:hover {
    background-color: #e0e0e0;
    border-color: #ccc;
}

.voice-mic-btn:active,
.voice-mic-btn.voice-mic-btn--recording {
    background-color: #10b981;
    border-color: #064e3b;
    color: white;
    transform: scale(1.08);
    box-shadow: 0 0 20px rgba(52, 211, 153, 0.4);
}

.voice-mic-btn svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
}

.voice-mic-hint {
    font-size: 0.8rem;
    color: var(--subtle-text-color, #6c757d);
    margin-top: 8px;
    font-family: var(--sharpbru-font-family);
    transition: color 0.3s ease;
}

/* --- Dark Mode Overrides for Voice Chat --- */
.dark-mode .voice-orb {
    background: radial-gradient(circle at 35% 35%, #7c73e6, #4e45dc, #2a2480);
    box-shadow: 0 0 30px rgba(78, 69, 220, 0.4), inset -6px -6px 12px rgba(0, 0, 0, 0.5);
}

.dark-mode .voice-orb-status {
    color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

.dark-mode .voice-mic-btn {
    background-color: var(--sharpbru-dark-input-bg, #333);
    border-color: var(--sharpbru-dark-border-color, #444);
    color: var(--sharpbru-dark-text-primary, #f0f0f0);
}

.dark-mode .voice-mic-btn:hover {
    background-color: #444;
    border-color: #555;
}

.dark-mode .voice-mic-btn:active,
.dark-mode .voice-mic-btn.voice-mic-btn--recording {
    background-color: #10b981;
    border-color: #064e3b;
    color: white;
}

.dark-mode .voice-mic-hint {
    color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

/* Ensure the voice elements center inside the main app body, not the whole window */
#chat-app-wrapper,
.chat-area,
#sharpbru-chat-container {
    position: relative !important; /* Creates a strict layout bounding box */
}

/* Force the Voice Elements to align to the same text workspace center line */
#voice-orb-container,
.voice-speak-interface,
#voice-speak-interface {
    width: 100% !important;
    max-width: 100% !important;
    left: 0 !important;
    right: 0 !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
}

.inline-code {
    background-color: rgba(0, 0, 0, 0.1); /* Or your preferred shade */
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: monospace;
}

.markdown-blockquote {
    border-left: 4px solid #ccc; /* Or your brand color */
    padding-left: 1rem;
    margin-left: 0;
    color: #555;
}

/* ========================================================================
   USAGE STATISTICS (Super Admin Panel)
   ======================================================================== */

/* Totals cards row */
.usage-stats-totals {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.usage-stat-card {
    flex: 1 1 110px;
    min-width: 110px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    background-color: #f8f9fa;
    border: 1px solid var(--desktop-panel-border-light, #e0e0e0);
    border-radius: var(--sharpbru-border-radius, 8px);
    text-align: center;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.usage-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--sharpbru-primary-color, #4F46E5);
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.usage-stat-label {
    font-size: 0.72rem;
    color: var(--subtle-text-color, #6c757d);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* --- Usage Trend Chart --- */
.usage-chart-container {
    width: 100%;
    max-height: 220px;
    min-height: 180px;
    margin-bottom: 15px;
    padding: 12px;
    border: 1px solid var(--desktop-panel-border-light, #e0e0e0);
    border-radius: var(--sharpbru-border-radius, 8px);
    background-color: #fff;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.usage-chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* --- Delete User Button (destructive action) --- */
.delete-user-button {
    background-color: #e74c3c !important;
    color: #fff !important;
    border: 1px solid #c0392b !important;
}

.delete-user-button:hover:not(:disabled) {
    background-color: #c0392b !important;
    border-color: #a93226 !important;
}

.delete-user-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* --- Super Admin: Compact icon buttons for user management --- */
.user-management-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.user-management-actions .styled-select {
    flex: 1 1 auto;
    min-width: 0;
}

.user-action-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--sharpbru-dark-border-color, #ccc);
    border-radius: 6px;
    background-color: var(--sharpbru-primary-color, #4f46e5);
    color: #fff;
    cursor: pointer;
    transition: background-color 0.2s, opacity 0.2s;
    flex-shrink: 0;
}

.user-action-icon-button:hover:not(:disabled) {
    background-color: var(--sharpbru-primary-hover-color, #4338ca);
}

.user-action-icon-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.user-action-icon-button svg {
    display: block;
}

.delete-user-icon-button {
    background-color: #e74c3c;
    border-color: #c0392b;
}

.delete-user-icon-button:hover:not(:disabled) {
    background-color: #c0392b;
    border-color: #a93226;
}

/* Table container with scroll */
.usage-stats-container {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--desktop-panel-border-light, #e0e0e0);
    border-radius: var(--sharpbru-border-radius, 8px);
    background-color: #fff;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.usage-stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    font-family: var(--sharpbru-font-family);
}

.usage-stats-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.usage-stats-table th {
    background-color: #f1f3f5;
    color: var(--sharpbru-text-color, #333);
    font-weight: 600;
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--desktop-panel-border-light, #e0e0e0);
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.3s ease;
}

.usage-stats-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 22px;
}

.usage-stats-table th.sortable:hover {
    background-color: #e9ecef;
}

.usage-stats-table th.sortable::after {
    content: '⇅';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: var(--subtle-text-color, #6c757d);
    opacity: 0.5;
}

.usage-stats-table th.sortable-active {
    color: var(--sharpbru-primary-color, #4F46E5);
    background-color: #eef2ff;
}

.usage-stats-table th.sort-asc::after {
    content: '▲';
    opacity: 1;
    color: var(--sharpbru-primary-color, #4F46E5);
    font-size: 0.6rem;
}

.usage-stats-table th.sort-desc::after {
    content: '▼';
    opacity: 1;
    color: var(--sharpbru-primary-color, #4F46E5);
    font-size: 0.6rem;
}

.usage-stats-table tbody tr {
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.15s ease;
}

.usage-stats-table tbody tr:last-child {
    border-bottom: none;
}

.usage-stats-table tbody tr:hover {
    background-color: #f8f9fa;
}

.usage-stats-table td {
    padding: 6px 10px;
    color: var(--sharpbru-text-color, #333);
    vertical-align: middle;
}

.usage-user-cell {
    font-weight: 500;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.usage-number-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.usage-last-used-cell {
    color: var(--subtle-text-color, #6c757d);
    white-space: nowrap;
    font-size: 0.78rem;
}

.usage-never {
    color: var(--sharpbru-dark-muted-text, #aaa);
    font-style: italic;
}

/* Loading / error states */
.usage-loading {
    padding: 20px;
    text-align: center;
    color: var(--subtle-text-color, #6c757d);
    font-size: 0.85rem;
}

.usage-loading.error {
    color: var(--sharpbru-error-color, #e74c3c);
}

/* --- Dark Mode: Usage Statistics --- */

.dark-mode .usage-stat-card {
    background-color: var(--sharpbru-dark-input-bg, #333);
    border-color: var(--sharpbru-dark-border-color, #444);
}

.dark-mode .usage-stat-label {
    color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

.dark-mode .usage-chart-container {
    background-color: var(--sharpbru-dark-bg-display, #222);
    border-color: var(--sharpbru-dark-border-color, #444);
}

.dark-mode .usage-stats-container {
    background-color: var(--sharpbru-dark-bg-display, #222);
    border-color: var(--sharpbru-dark-border-color, #444);
}

.dark-mode .usage-stats-table th {
    background-color: var(--sharpbru-dark-bg-sidebar-overhang, #3A3A3A);
    color: var(--sharpbru-dark-text-primary, #f0f0f0);
    border-bottom-color: var(--sharpbru-dark-border-color, #444);
}

.dark-mode .usage-stats-table th.sortable:hover {
    background-color: #454545;
}

.dark-mode .usage-stats-table th.sortable-active {
    color: var(--sharpbru-dark-input-focus-border, #0EA5E9);
    background-color: rgba(14, 165, 233, 0.12);
}

.dark-mode .usage-stats-table th.sort-asc::after,
.dark-mode .usage-stats-table th.sort-desc::after {
    color: var(--sharpbru-dark-input-focus-border, #0EA5E9);
}

.dark-mode .usage-stats-table tbody tr {
    border-bottom-color: var(--sharpbru-dark-border-color, #444);
}

.dark-mode .usage-stats-table tbody tr:hover {
    background-color: var(--sharpbru-dark-bg-sidebar-overhang, #3A3A3A);
}

.dark-mode .usage-stats-table td {
    color: var(--sharpbru-dark-text-primary, #f0f0f0);
}

.dark-mode .usage-last-used-cell {
    color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

.dark-mode .usage-never {
    color: var(--sharpbru-dark-muted-text, #888);
}

.dark-mode .usage-loading {
    color: var(--sharpbru-dark-text-secondary, #b0b0b0);
}

/* Responsive: stack stat cards on narrow modals */
@media (max-width: 480px) {
    .usage-stat-card {
        flex: 1 1 calc(50% - 5px);
    }
}

/* ================================================================
   STREAMING CHAT — live token rendering
   ================================================================ */

/* Streaming content container — tokens appear live as they arrive */
.streaming-content {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ========================================================================
   DRAG AND DROP TO-DO LIST STYLES
   ======================================================================== */

.todo-actions-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-shrink: 0;
    opacity: 0; /* Hide both icons by default */
    transition: opacity 0.2s ease;
}

.todo-item:hover .todo-actions-stack {
    opacity: 1; /* Show both icons on hover */
}

.todo-drag-handle {
    color: #aaa;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: color 0.2s ease;
}

.todo-drag-handle:hover {
    color: var(--sharpbru-text-color);
}

.todo-drag-handle:active {
    cursor: grabbing;
}

/* Ensure the delete button fits tightly underneath the drag handle */
.todo-delete {
    opacity: 1 !important; /* Let the wrapper handle the hover opacity */
    padding: 0 !important;
    line-height: 1;
}

/* Visual feedback while an item is actively being dragged */
.todo-item.dragging {
    opacity: 0.5;
    background-color: rgba(79, 70, 229, 0.05);
}

/* Visual line indicating where the item will drop */
.todo-item.drag-over {
    box-shadow: 0 -2px 0 0 var(--sharpbru-primary-color);
}

/* --- Dark Mode Overrides --- */
.dark-mode .todo-item.dragging {
    background-color: rgba(255, 255, 255, 0.05);
}

.dark-mode .todo-drag-handle {
    color: var(--sharpbru-dark-text-secondary);
}

.dark-mode .todo-drag-handle:hover {
    color: var(--sharpbru-dark-text-primary);
}