/* Brimly palettes */
.theme-dark {
    --bg-canvas: #0d0e12;
    --bg-surface: #11131a;
    --bg-elevated: #161922;
    --bg-sunken: #0b0c10;
    --border-subtle: #1f2230;
    --border-strong: #2c3040;
    --text-primary: #f3f4f6;
    --text-secondary: #c7ced8;
    --text-muted: #9aa3b1;
    --text-disabled: #6f7886;
    --accent-primary: #f2c94c;
    --accent-hover: #ffd768;
    --accent-pressed: #d9af2f;
    --accent-on: #0a0906;
    --success: #3DDC97;
    --warning: #F7C948;
    --error: #FF5A6A;
    --info: #7C5CFF;
    --chip-bg: #1c202b;
    --chip-border: #2f3444;
    --chip-text: #e6edf7;
    --chip-suggested-bg: #181c25;
    --chip-suggested-text: #c7ced8;
}

.theme-light {
    --bg-canvas: #F7F9FC;
    --bg-surface: #FFFFFF;
    --bg-elevated: #FFFFFF;
    --bg-sunken: #EEF3FA;
    --border-subtle: #D7E1EF;
    --border-strong: #B9C8DC;
    --text-primary: #1D2736;
    --text-secondary: #3C4A5E;
    --text-muted: #5A6B83;
    --text-disabled: #8AA0BC;
    --accent-primary: #5AA6FF;
    --accent-hover: #3B8FFF;
    --accent-pressed: #2563EB;
    --accent-on: #FFFFFF;
    --success: #148C61;
    --warning: #A36B00;
    --error: #C0392B;
    --info: #4B3FA3;
    --chip-bg: #E8F0FB;
    --chip-border: #D7E1EF;
    --chip-text: #1D2736;
    --chip-suggested-bg: #E4EDF9;
    --chip-suggested-text: #3C4A5E;
}

html, body {
    font-family: 'SF Pro Text', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-canvas);
    margin: 0;
    padding: 0;
    color: var(--text-primary);
    width: 100%;
    min-height: 100vh;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
}

html, body {
    scrollbar-width: thin;
}

html::-webkit-scrollbar, body::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

html::-webkit-scrollbar-button, body::-webkit-scrollbar-button {
    width: 0;
    height: 0;
    display: none;
}

.theme-dark {
    scrollbar-color: rgba(248, 250, 252, 0.22) rgba(255, 255, 255, 0.06);
    scrollbar-width: thin;
}

.theme-dark ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.theme-dark ::-webkit-scrollbar-button {
    width: 0;
    height: 0;
    display: none;
}

.theme-dark ::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.06);
}

.theme-dark ::-webkit-scrollbar-thumb {
    background-color: rgba(248, 250, 252, 0.22);
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.06);
}

.theme-dark ::-webkit-scrollbar-thumb:hover {
    background-color: rgba(248, 250, 252, 0.30);
}

#app {
    min-height: 100vh;
}

#blazor-error-ui {
    background: rgba(255, 255, 210, 0.98);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    color: #111827;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

#blazor-error-ui .reload {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

.landing-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0d0e12 0%, #11131a 60%, #090b0f 100%);
    padding: 40px 16px;
}

.landing-card {
    width: min(960px, 100%);
    background: var(--bg-surface);
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-subtle);
}
.landing-card h1 {
    margin: 0;
    font-size: 2.5rem;
    color: var(--text-primary, #f3f4f6);
}
.landing-subtitle {
    margin-top: 6px;
    color: var(--text-muted, #9aa3b1);
    font-size: 1rem;
}
.auth-sections {
    margin-top: 24px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 24px;
}
.auth-panel {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1 1 300px;
    max-width: 400px;
}
.auth-panel h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary, #f3f4f6);
}
.auth-panel label {
    color: var(--text-muted, #9aa3b1);
    font-size: 0.85rem;
}
.auth-panel label.remember-me,
.auth-panel label.remember-me span {
    color: var(--text-secondary, rgba(248, 250, 252, 0.9));
}
.auth-panel input {
    color: var(--text-primary, #f3f4f6);
    background: rgba(255, 255, 255, 0.02);
    border-color: var(--border-subtle);
}
.auth-panel input::placeholder {
    color: var(--text-muted, #9aa3b1);
}
.auth-panel .primary.full,
.auth-panel .ghost.full {
    font-size: 1rem;
    height: 42px;
}
.auth-panel .primary.full {
    background: var(--accent-primary);
    border-color: transparent;
    box-shadow: 0 8px 16px rgba(242, 201, 76, 0.4);
    color: #fff !important;
    font-weight: 600;
}
.auth-panel .ghost.full {
    border-color: rgba(249, 115, 22, 0.4);
    color: #f9f9f9;
    background: rgba(249, 115, 22, 0.08);
}
.auth-panel button {
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.landing-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgb(7, 8, 13);
    background: linear-gradient(145deg, #06070d 0%, #0f111a 45%, #0a0c10 100%);
    padding: 40px 16px;
}
.landing-card {
    width: fit-content;
    min-width: 320px;
    max-width: 1000px;
    background: rgba(14, 17, 25, 0.95);
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(148, 163, 184, 0.25);
    margin: 0 auto;
}
.landing-card h1 {
    margin: 0;
    font-size: 2.5rem;
    color: #f8fafc;
    text-align: center;
}
.landing-subtitle {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 1rem;
    text-align: center;
}
.auth-panel input::placeholder {
    color: rgba(248, 250, 252, 0.6);
}

.content-gate {
    border: 1px dashed var(--border-strong);
    border-radius: 14px;
    padding: 14px 16px;
    background: var(--bg-elevated);
    margin-bottom: 12px;
}

.content-gate-title {
    font-weight: 600;
    margin-bottom: 6px;
}

.content-gate-body {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.content-gate-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.content-gate-hint {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.attachment-placeholder {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(124, 92, 255, 0.15);
    border: 1px dashed rgba(124, 92, 255, 0.45);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.attachment-thumb {
    max-width: 220px;
    max-height: 160px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    display: inline-block;
    margin: 6px 0;
}

.operation-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0 12px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(0,0,0,.25);
    color: rgba(255,255,255,.85);
    font-size: 0.85rem;
}

.operation-progress-bar {
    position: relative;
    flex: 1;
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,.08);
}

.operation-progress-bar::after {
    content: "";
    position: absolute;
    inset: 0;
    width: 40%;
    background: linear-gradient(90deg, rgba(245,197,24,.2), rgba(245,197,24,.9), rgba(245,197,24,.2));
    animation: progress-pulse 1.2s ease-in-out infinite;
}

@keyframes progress-pulse {
    0% { transform: translateX(-60%); }
    100% { transform: translateX(160%); }
}

.layout {
    display: flex;
    flex-direction: row;
    height: 100vh;
    min-height: 100vh;
    background: var(--bg-canvas);
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.sidebar {
    background: var(--bg-sunken);
    color: var(--text-primary);
    border-right: 1px solid var(--border-subtle);
    border-bottom: none;
    padding: 16px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 300px;
    flex: 0 0 300px;
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.sidebar-footer {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}

.sidebar-splitter {
    width: 6px;
    cursor: col-resize;
    background: transparent;
    border-right: 1px solid var(--border-subtle);
    display: none;
}

.content {
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    flex: 1;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

.search-bar {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    position: sticky;
    top: 0;
    z-index: 5;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}
    flex-wrap: wrap;
    border-radius: 12px;
    margin: 8px 12px;
}

.search-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    background: var(--bg-sunken);
    color: var(--text-primary);
}

.mode-select, .primary, .ghost {
    border-radius: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    cursor: pointer;
    color: var(--text-primary);
}

.primary {
    background: var(--accent-primary);
    color: var(--accent-on);
    border-color: var(--accent-pressed);
}

.ghost {
    background: transparent;
    color: var(--text-secondary);
}

.new-bit-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding-inline: 14px;
    font-weight: 600;
}

.suggestions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.suggestions-dropdown {
    position: absolute;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    margin-top: 4px;
    z-index: 10;
}

/* Invisible backdrop to close dropdowns when clicking outside */
.dropdown-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    background: transparent;
}

/* Global toast notification */
.global-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    cursor: pointer;
    animation: toast-slide-in 0.3s ease-out;
    max-width: 90vw;
}
@keyframes toast-slide-in {
    from { transform: translateX(-50%) translateY(-100%); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}
.global-toast.toast-error {
    background: linear-gradient(135deg, #c0392b 0%, #96281b 100%);
    color: #fff;
    border: 1px solid #e74c3c;
}
.global-toast.toast-success {
    background: linear-gradient(135deg, #27ae60 0%, #1e8449 100%);
    color: #fff;
    border: 1px solid #2ecc71;
}
.toast-icon {
    font-size: 1.2rem;
}
.toast-text {
    font-weight: 500;
    flex: 1;
}
.toast-dismiss {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 1.4rem;
    cursor: pointer;
    opacity: 0.7;
    padding: 0 4px;
}
.toast-dismiss:hover {
    opacity: 1;
}

/* Multi-select dropdown for tags filter */
.multi-select-dropdown {
    position: relative;
    display: inline-block;
    z-index: 100;
}
.multi-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 120px;
}
.multi-select-trigger .dropdown-arrow {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.multi-select-options {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    z-index: 100;
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
}
.multi-select-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s ease;
    color: var(--text-primary);
}
.multi-select-option:hover {
    background: var(--bg-elevated);
}
.multi-select-option.selected {
    background: rgba(242, 201, 76, 0.15);
}
.multi-select-option input[type="checkbox"] {
    accent-color: var(--accent-primary);
    width: 16px;
    height: 16px;
}
.multi-select-option .tag-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
.clear-tags-btn {
    width: 100%;
    margin-top: 8px;
    padding: 8px;
    text-align: center;
    border-top: 1px solid var(--border-subtle);
}

.grid {
    display: flex;
    flex-direction: row;
    flex: 1;
    background: var(--bg-canvas);
    height: calc(100vh - 140px);
    max-height: calc(100vh - 140px);
    min-height: 0;
    overflow: hidden;
}

.list-pane {
    border-right: 1px solid var(--border-subtle);
    border-bottom: none;
    background: var(--bg-elevated);
    box-shadow: inset -1px 0 0 var(--border-subtle);
    padding: 8px;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
    width: 350px;
    flex: 0 0 350px;
}

.list-pane .list-toolbar {
    flex-shrink: 0;
}

.list-pane .active-filter-bar {
    flex-shrink: 0;
}

/* Single scrollable container for all bit groups */
.bit-list-container {
    flex: 1 1 auto;
    overflow-y: scroll !important; /* Always show scrollbar */
    overflow-x: hidden;
    min-height: 0; /* Important for flexbox scrolling */
    scrollbar-width: thin;
    scrollbar-color: #4a5568 #1a1a2e;
    padding-right: 4px;
}

/* Webkit scrollbar styling for bits list container */
.bit-list-container::-webkit-scrollbar {
    width: 8px;
}

.bit-list-container::-webkit-scrollbar-track {
    background: #1a1a2e;
    border-radius: 5px;
}

.bit-list-container::-webkit-scrollbar-thumb {
    background: #4a5568;
    border-radius: 5px;
    border: 2px solid #1a1a2e;
}

.bit-list-container::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Individual group lists - no scroll, just flow naturally */
.bit-list-group {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.list-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 4px 0 10px 0;
}

/* Active Filter Indicator Bar */
.active-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 12px;
    background: rgba(245, 197, 24, 0.1);
    border: 1px solid rgba(245, 197, 24, 0.3);
    border-radius: 8px;
    margin-bottom: 10px;
}

.filter-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.filter-chip:hover {
    transform: scale(1.02);
}

.filter-chip.folder-chip {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.filter-chip.tag-chip {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.filter-chip.query-chip {
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.chip-remove {
    font-size: 1rem;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.filter-chip:hover .chip-remove {
    opacity: 1;
}

.clear-filters-btn {
    margin-left: auto;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 4px;
    color: var(--text-muted);
}

.clear-filters-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

/* Legacy bit-list class - kept for compatibility */
.bit-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Ensure list-pane fills available height */
.list-pane {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.group-header {
    margin: 10px 0 4px 4px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.bit-list-item {
    padding: 12px 14px;
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    background: var(--bg-surface);
    border-radius: 12px;
}

.bit-list-item.active {
    background: var(--bg-elevated);
    box-shadow: inset 2px 0 0 var(--accent-primary);
}

.bit-title {
    font-weight: 600;
    color: var(--text-primary);
}

.bit-snippet {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 2px;
}

.bit-meta {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 4px;
}

.bit-row {
    display: grid;
    grid-template-columns: 24px 1fr auto auto;
    gap: 10px;
    align-items: center;
}
.bit-row-actions {
    display: flex;
    gap: 4px;
}

.bit-left .icon {
    color: var(--accent-primary);
}

.thumb {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid var(--border-strong);
}

.bit-right .chip {
    background: var(--chip-bg);
    border: 1px solid var(--chip-border);
    color: var(--chip-text);
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
}

.icon-btn {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    padding: 6px 10px;
}

.detail-pane {
    background: var(--bg-elevated);
    padding: 0;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-subtle);
    border-top: none;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: inset 1px 0 0 var(--border-subtle);
    border-radius: 0;
    position: relative;
}

.detail-pane-content {
    flex: 0 0 auto; /* Changed from 1 1 auto to prevent internal scroll */
    min-height: 0;
    overflow: visible; /* Let it expand into parent */
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

.detail-pane .detail-toolbar,
.detail-pane .detail-header,
.detail-pane .bit-metadata-row {
    flex: 0 0 auto;
}

.detail-pane .bit-rte {
    flex: 1 0 auto;
    min-height: 300px;
}

.detail-pane .editor-container {
    flex: 1 0 auto;
    min-height: 350px;
    padding-bottom: 20px;
}
.detail-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.detail-toolbar-actions {
    display: inline-flex;
    gap: 6px;
}

.grid-splitter {
    width: 6px;
    cursor: col-resize;
    background: transparent;
    border-left: 1px solid var(--border-subtle);
    border-right: 1px solid var(--bg-sunken);
    display: none;
}

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

.title-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    font-size: 1.1rem;
    background: var(--bg-sunken);
    color: var(--text-primary);
    font-weight: 600;
}

.detail-meta {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.description-input {
    margin-top: 8px;
    margin-bottom: 12px;
    padding: 8px 10px;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    background: var(--bg-sunken);
    color: var(--text-secondary);
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.4;
    min-height: 40px;
    resize: none;
    overflow: hidden;
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* Bit Metadata Row (Folder, Tags, Attachments - Top of Editor) */
.org-row-heading {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 6px 0 8px;
}

.bit-metadata-row .org-field-title {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.bit-metadata-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    padding: 8px 12px;
    background: var(--bg-sunken);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.bit-metadata-row.folder-tags-row {
    align-items: flex-start;
}

.bit-metadata-row.attachments-row {
    align-items: flex-start;
}

.bit-metadata-row .org-field {
    display: flex;
    align-items: center;
    gap: 6px;
}

.bit-metadata-row .folder-field {
    flex: 0 0 260px;
    min-width: 220px;
}

.bit-metadata-row .tags-field {
    flex: 1;
    min-width: 320px;
}

.bit-metadata-row .attachments-field {
    flex: 1;
    min-width: 300px;
}

.bit-metadata-row .org-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Organization Panels (Folder, Tags, Color, Attachments) */
.org-panel {
    border: 1px solid #333;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 8px;
    background: var(--bg-sunken);
}

.org-panel-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.org-panel .org-label {
    font-size: 1rem;
}

.org-panel-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    min-width: 70px;
}

.org-panel .org-select {
    padding: 5px 10px;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    max-width: 180px;
}

.org-panel .tag-select {
    padding: 5px 10px;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
}

.org-panel .org-add-btn {
    padding: 4px 6px;
}

.org-panel .bit-tag {
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 0.8rem;
    color: #ffffff;
    font-weight: 500;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.org-panel .tag-remove {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    line-height: 1;
}

.org-panel .tag-remove:hover {
    color: #ffffff;
}

.org-panel .color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.org-panel .color-swatch:hover {
    transform: scale(1.15);
}

.org-panel .color-swatch.selected {
    border-color: #fff;
    box-shadow: 0 0 0 2px var(--accent-primary);
}

.org-panel .upload-error-inline {
    color: #ff8895;
    font-size: 0.8rem;
}

.org-panel .attachment-count-inline {
    background: var(--accent-primary);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
}

.bit-metadata-row .org-select {
    padding: 5px 10px;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    max-width: 150px;
}

.bit-metadata-row .org-add-btn {
    padding: 4px 6px;
}

.bit-metadata-row .tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    max-height: 120px;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 30px;
}

.bit-metadata-row .bit-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 0.8rem;
    color: #ffffff;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.bit-metadata-row .bit-tag .tag-remove {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0 2px;
    line-height: 1;
}

.bit-metadata-row .bit-tag .tag-remove:hover {
    color: #ffffff;
}

.bit-metadata-row .tag-add-dropdown {
    display: flex;
    align-items: center;
}

.bit-metadata-row .tag-select {
    padding: 3px 6px;
    border: 1px dashed var(--border-subtle);
    border-radius: 12px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
}

.bit-metadata-row .tag-select:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.attachment-count-inline {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 4px 8px;
    background: var(--bg-elevated);
    border-radius: 12px;
}

.editor {
    margin-top: 12px;
    min-height: 260px;
    padding: 12px;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    font-size: 1rem;
    resize: vertical;
    background: var(--bg-sunken);
    color: var(--text-primary);
    line-height: 1.6;
}
.bit-rte .e-richtexteditor {
    border-radius: 12px;
    background: var(--bg-sunken);
    border: 1px solid var(--border-subtle);
    width: 100%;
}
.bit-rte .e-rte-content,
.bit-rte .e-rte-content .e-content {
    background: var(--bg-sunken);
    color: var(--text-primary);
    min-height: 260px;
    width: 100%;
}
.bit-rte .e-toolbar {
    border: 1px solid var(--border-subtle);
    border-radius: 10px 10px 0 0;
    background: var(--bg-elevated);
}
.bit-rte .e-rte-toolbar {

/* Safety net: sometimes after re-render the toolbar nodes exist but collapse to 0x0.
   These rules force the toolbar to participate in layout. */
.bit-rte .e-richtexteditor,
.bit-rte .e-rte-container {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.bit-rte .e-rte-toolbar,
.bit-rte .e-toolbar {
    flex: 0 0 auto;
    min-height: 42px; /* enough for one toolbar row */
    height: auto;
    overflow: visible;
}

.bit-rte .e-rte-content,
.bit-rte .e-content {
    flex: 1 1 auto;
    min-height: 0;
}
    width: 100%;
    flex-wrap: wrap;
    overflow: visible;
}

input[type="file"] {
    color: var(--text-secondary);
}

.upload-button {
    background: var(--accent-primary);
    color: var(--accent-on);
    border: 1px solid var(--accent-pressed);
    border-radius: 6px;
    padding: 10px 12px;
    cursor: pointer;
}
.upload-button:hover {
    background: var(--accent-hover);
}

.upload-wrapper {
    max-width: 520px;
}
.plain-dropzone {
    border: 1px dashed var(--border-subtle);
    border-radius: 10px;
    padding: 14px;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-surface);
    color: var(--text-primary);
    position: relative;
    min-width: 320px;
}
.plain-dropzone .browse { font-weight: 700; }
.plain-dropzone .hint { color: var(--text-muted); font-size: 0.95rem; }
.plain-dropzone .plain-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.upload-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}
.uploading-indicator {
    color: var(--text-muted);
    font-size: 0.95rem;
}
.file-pill {
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    background: var(--bg-surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.file-name {
    font-weight: 600;
    color: var(--text-primary);
}
.file-size {
    color: var(--text-muted);
    font-size: 0.9rem;
}
.remove-file {
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px 8px;
}
.remove-file:hover {
    color: var(--error);
}
.upload-wrapper .drop-overlay {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 5;
}
.dropzone {
    border: 1px dashed var(--border-subtle);
    border-radius: 10px;
    padding: 14px;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-surface);
    color: var(--text-primary);
    position: relative;
    min-width: 320px;
}
.dropzone .browse {
    font-weight: 700;
}
.drop-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* Inline Upload Control */
.upload-wrapper-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.plain-dropzone-inline {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border: 1px dashed var(--border-subtle);
    border-radius: 6px;
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    position: relative;
    font-size: 0.85rem;
}

.plain-dropzone-inline:hover {
    border-color: var(--accent-primary);
}

.plain-dropzone-inline .browse {
    font-weight: 600;
}

.plain-dropzone-inline .plain-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-pill-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    font-size: 0.8rem;
}

.file-pill-inline .file-name {
    color: var(--text-primary);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-pill-inline .file-size {
    color: var(--text-muted);
}

.remove-file-inline {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0 2px;
    line-height: 1;
}

.remove-file-inline:hover {
    color: var(--error);
}

.upload-button-inline {
    padding: 6px 14px;
    border-radius: 6px;
    background: var(--accent-primary);
    color: var(--accent-on);
    border: none;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
}

.upload-button-inline:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.upload-button-inline:not(:disabled):hover {
    background: var(--accent-hover);
}

.upload-error-inline {
    color: var(--error);
    font-size: 0.8rem;
}

.upload-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.upload-row input[type="file"] {
    width: auto;
}

.sf-upload-hide .e-upload-actions {
    display: none;
}
.sf-upload-hide .e-file-select,
.sf-upload-hide .e-file-drop {
    border: 1px dashed var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-primary);
}
.sf-upload-hide .e-upload {
    width: 100%;
}

.attachment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.attachment-card {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    background: var(--bg-surface);
}

.attachment-thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--bg-sunken);
}

.attachment-icon {
    width: 64px;
    height: 64px;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--bg-sunken);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
}

.attachment-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Attachments Table - Displayed above the bit editor */
.attachments-table-container {
    margin: 12px 0;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    background: var(--bg-elevated);
    overflow: hidden;
}

.attachments-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-sunken);
    border-bottom: 1px solid var(--border-subtle);
}

.attachments-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.attachments-table {
    overflow-x: auto;
}

.attachments-grid-table {
    width: 100%;
    border-collapse: collapse;
}

.attachments-grid-table thead {
    background: var(--bg-sunken);
}

.attachments-grid-table th {
    padding: 8px 12px;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
}

.attachments-grid-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.15s ease;
}

.attachments-grid-table tbody tr:hover {
    background: var(--bg-sunken);
}

.attachments-grid-table tbody tr:last-child {
    border-bottom: none;
}

.attachments-grid-table td {
    padding: 10px 12px;
    vertical-align: middle;
}

.attachment-thumbnail {
    width: 220px;
    height: 220px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-sunken);
    display: block;
}

.attachment-icon-placeholder {
    width: 220px;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-sunken);
    font-size: 1.5rem;
}

.attachment-name {
    color: var(--text-primary);
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

.attachment-type {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-family: monospace;
}

.attachment-size {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.attachment-actions {
    display: flex;
    gap: 4px;
}

.att-name {
    color: var(--text-primary);
    font-weight: 600;
}

.att-sub {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.download-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
}

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

.attachment-pending {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px dashed var(--border-subtle);
    border-radius: 12px;
    background: var(--bg-sunken);
    margin-bottom: 8px;
}

.toolbar {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.section-header {
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.section-subtext {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: -4px 0 10px 0;
    line-height: 1.3;
}

.section-header.clickable {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-actions {
    display: flex;
    gap: 4px;
}
.icon-btn svg {
    width: 18px;
    height: 18px;
}
.section-caret { color: var(--text-muted); font-size: 0.9rem; }

.logout-link {
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
}

.logout-link + li {
    margin-top: 4px;
}

.tree {
    list-style: none;
    padding-left: 0;
    margin: 0 0 12px 0;
}

.tree ul {
    list-style: none;
    padding-left: 16px;
    margin: 6px 0 0 0;
}

.tree-item {
    padding: 6px 8px;
    border-radius: 8px;
    color: var(--text-primary);
    display: block;
}
.tree-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}
.tree-entry-label {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}
.tree-entry-color {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    display: inline-flex;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.4);
}
.tree-entry-actions {
    display: flex;
    gap: 4px;
}
.tree-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.tree-row.selected {
    background: var(--accent-primary);
    border-radius: 4px;
    padding: 2px 6px;
    margin: -2px -6px;
}
.tree-row.selected .tree-entry-label,
.tree-row.selected .tree-entry-label span,
.tree-row.selected .tree-expander {
    color: var(--accent-on);
}
.tree-entry.selected {
    background: rgba(242, 201, 76, 0.15);
    border-radius: 4px;
}
.tree-expander {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 18px;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.tree-expander-spacer {
    display: inline-block;
    width: 18px;
    flex-shrink: 0;
}
.tree-label {
    cursor: pointer;
}
.tree-entry-label span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Top-level sidebar sections (All, Favorites, etc.) */
.section-nav > .tree-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-nav > .tree-item .icon,
.section-nav > .tree-item .icon svg {
    width: 16px;
    height: 16px;
    color: var(--accent-primary);
}
.tree-children {
    list-style: none;
    padding-left: 16px;
    margin: 4px 0 0 0;
}

.tree-item.active {
    background: rgba(255,255,255,0.08);
}

.placeholder {
    padding: 12px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.sidebar-panel {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
}
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 600;
}
.panel-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.form-row label {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.form-input,
.form-select,
textarea.form-input {
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    padding: 8px 10px;
    background: var(--bg-sunken);
    color: var(--text-primary);
}

textarea.form-input {
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}
.color-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.color-input {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    padding: 0;
    background: none;
}
.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
}
.color-swatch.selected {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(242, 201, 76, 0.4);
}
.form-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.error-message {
    color: #ff8895;
    background: rgba(255, 90, 106, 0.15);
    border: 1px solid rgba(255, 90, 106, 0.35);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
}
.success-message {
    color: #4ade80;
    background: rgba(74, 222, 128, 0.12);
    border: 1px solid rgba(74, 222, 128, 0.35);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
}


.sidebar-panel {
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 10, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.modal-card {
    background: var(--bg-surface);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid var(--border-subtle);
    width: min(420px, 90%);
    box-shadow: 0 20px 40px rgba(0,0,0,0.35);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-weight: 700;
}
.modal-close {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.4rem;
    cursor: pointer;
}

.icon {
    width: 12px;
    height: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
}
.icon svg {
    width: 12px;
    height: 12px;
}

.error {
    padding: 12px;
    color: #ff8895;
}

.auth-block {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.full {
    width: 100%;
}

/* =============================================
   Credit Display Styles
   ============================================= */

.credit-display {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    margin-bottom: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
}

.credit-display.compact {
    flex-direction: row;
    padding: 6px 10px;
    gap: 6px;
    align-items: center;
}

.credit-balance {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    transition: background 0.15s;
}

.credit-balance:hover {
    background: rgba(255, 255, 255, 0.05);
}

.credit-icon {
    font-size: 0.85rem;
    color: var(--accent-primary);
}

.credit-amount {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.credit-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.credit-reserved {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 4px;
}

.credit-balance.critical .credit-amount {
    color: var(--error);
}

.credit-balance.low .credit-amount {
    color: var(--warning);
}

.credit-balance.medium .credit-amount {
    color: var(--info);
}

.credit-balance.healthy .credit-amount {
    color: var(--success);
}

.credit-warning {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--warning);
    padding: 4px 8px;
    background: rgba(247, 201, 72, 0.1);
    border-radius: 6px;
}

.credit-error {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--error);
}

.credit-empty,
.credit-loading {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
}

/* =============================================
   Cost Confirmation Modal Styles
   ============================================= */

.cost-confirmation-modal {
    width: 480px !important;
    max-width: 95vw !important;
    max-height: 85vh;
    overflow-y: auto;
}

.cost-confirmation-modal .modal-header {
    margin-bottom: 16px;
}

.cost-confirmation-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 0;
}

.cost-summary {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cost-main {
    text-align: center;
    padding: 20px;
    background: var(--bg-sunken);
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
}

.cost-credits {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 6px;
}

.cost-amount {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.cost-unit {
    font-size: 1rem;
    color: var(--text-muted);
}

.cost-usd {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.cost-description {
    text-align: center;
    font-size: 0.95rem;
    color: var(--text-secondary);
    padding: 8px;
}

.cost-details-box {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px;
    background: var(--bg-sunken);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
}

.cost-details-box .detail-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.cost-details-box .detail-label {
    color: var(--text-muted);
}

.cost-details-box .detail-value {
    color: var(--text-primary);
    font-weight: 500;
}

.cost-message {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
}

.cost-breakdown {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 12px;
}

.breakdown-header {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 8px;
}

.breakdown-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-subtle);
}

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

.breakdown-name {
    color: var(--text-secondary);
}

.breakdown-credits {
    color: var(--text-primary);
    font-weight: 500;
}

.cost-details {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 10px;
    background: var(--bg-sunken);
    border-radius: 8px;
}

.detail-item {
    display: flex;
    gap: 4px;
    font-size: 0.85rem;
}

.detail-label {
    color: var(--text-muted);
}

.detail-value {
    color: var(--text-primary);
}

.balance-check {
    padding: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
}

.balance-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
}

.balance-row.sufficient .balance-value {
    color: var(--success);
}

.balance-row.insufficient .balance-value {
    color: var(--error);
}

.balance-label {
    color: var(--text-muted);
}

.balance-value {
    font-weight: 600;
}

.balance-after {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.balance-warning {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 8px 10px;
    background: rgba(255, 90, 106, 0.1);
    border: 1px solid rgba(255, 90, 106, 0.3);
    border-radius: 8px;
    color: var(--error);
    font-size: 0.85rem;
}

.cost-message {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
}

.cost-confirmation-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}

/* =============================================
   AI Operation Indicator Styles
   ============================================= */

.ai-operation-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(124, 92, 255, 0.1);
    border: 1px solid rgba(124, 92, 255, 0.3);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--info);
}

.ai-cost-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--chip-bg);
    border: 1px solid var(--chip-border);
    border-radius: 10px;
    font-size: 0.75rem;
    color: var(--accent-primary);
}

.ai-cost-badge .cost-icon {
    font-size: 0.7rem;
}

/* Wallet/Transaction History Styles */
.wallet-section {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
}

.wallet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.wallet-title {
    font-weight: 600;
    color: var(--text-primary);
}

.wallet-section .wallet-header,
.wallet-section .wallet-title,
.wallet-section .import-export-title {
    color: #f3f4f6 !important;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
}

.import-export-title {
    color: var(--text-primary, #f3f4f6) !important;
}

.transaction-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg-surface);
    border-radius: 8px;
    font-size: 0.85rem;
}

.transaction-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.transaction-operation {
    color: var(--text-primary);
}

.transaction-time {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.import-export-meta {
    color: var(--text-secondary, #c7ced8);
    font-size: 0.9rem;
}

.import-export-meta code {
    color: var(--accent-primary, #f2c94c);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    padding: 2px 6px;
}

/* Mobile/Tablet layout: stack everything for small screens */
.layout.mobile-layout {
    flex-direction: column !important;
    height: auto !important;
    min-height: 100vh !important;
    overflow: visible !important;
    background: magenta !important; /* DEBUG: if you see magenta background, CSS is being applied */
}

.layout.mobile-layout .sidebar {
    height: auto !important;
    width: 100% !important;
    flex: 1 1 auto !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border-subtle) !important;
}

.layout.mobile-layout .sidebar-splitter {
    display: none !important;
}

.layout.mobile-layout .content {
    flex-direction: column !important;
    height: auto !important;
    flex: 1 1 auto !important;
}

.layout.mobile-layout .search-bar {
    flex-direction: column;
    flex-shrink: 0;
}

.layout.mobile-layout .grid {
    flex-direction: column !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

.layout.mobile-layout .list-pane {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    width: 100% !important;
    flex: 1 1 auto !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border-subtle) !important;
}

.layout.mobile-layout .grid-splitter {
    display: none !important;
}

.layout.mobile-layout .detail-pane {
    height: auto !important;
    max-height: none !important;
    overflow-y: visible !important;
    width: 100% !important;
    flex: 1 1 auto !important;
    border-left: none !important;
    border-top: 1px solid var(--border-subtle) !important;
}

/* Desktop layout: 3-column for large screens */
.layout.desktop-layout {
    flex-direction: row !important;
    height: 100vh !important;
    overflow: hidden !important;
}

.layout.desktop-layout .sidebar {
    height: 100vh !important;
    width: 300px !important;
    flex: 0 0 300px !important;
    border-right: 1px solid var(--border-subtle) !important;
    border-bottom: none !important;
}

.layout.desktop-layout .sidebar-splitter {
    display: block !important;
}

.layout.desktop-layout .content {
    flex: 1 1 auto !important;
    height: auto !important;
}

.layout.desktop-layout .search-bar {
    flex-shrink: 0;
}

.layout.desktop-layout .grid {
    flex-direction: row !important;
    height: calc(100vh - 140px) !important;
    max-height: calc(100vh - 140px) !important;
    overflow: hidden !important;
}

.layout.desktop-layout .list-pane {
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
    width: 350px !important;
    flex: 0 0 350px !important;
    border-right: 1px solid var(--border-subtle) !important;
    border-bottom: none !important;
}

.layout.desktop-layout .grid-splitter {
    display: block !important;
}

.layout.desktop-layout .detail-pane {
    height: 100% !important;
    max-height: 100% !important;
    overflow-y: auto !important;
    width: auto !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    border-left: 1px solid var(--border-subtle) !important;
    border-top: none !important;
}

@media (max-width: 768px) {
    .search-bar {
        margin: 6px 8px;
        padding: 10px 12px;
    }

    .list-toolbar {
        flex-wrap: wrap;
        gap: 8px;
    }

    .detail-toolbar {
        flex-wrap: wrap;
        gap: 8px;
    }
}

.transaction-amount {
    font-weight: 600;
}

.transaction-amount.debit {
    color: var(--error);
}

.transaction-amount.credit {
    color: var(--success);
}

/* =============================================
   AI Action Button Styles
   ============================================= */

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-subtle);
    margin: 0 8px;
}

/* Organize Button Group */
.organize-button-group {
    display: flex;
    gap: 4px;
    background: var(--surface-dark);
    border-radius: 8px;
    padding: 4px;
    border: 1px solid var(--border-subtle);
}

.organize-button-group > span {
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 6px 8px;
    align-self: center;
}

.organize-option {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.organize-option:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
}

.organize-option.feeling-lucky {
    background: linear-gradient(135deg, #f5c518 0%, #ff6b35 100%);
    color: #000 !important;
    font-weight: 600;
}

.organize-option.feeling-lucky:hover:not(:disabled) {
    background: linear-gradient(135deg, #ffd700 0%, #ff8c42 100%);
}

.organize-option.feeling-lucky span {
    color: #000 !important;
}

.badge-free {
    background: #16a34a;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-cost {
    background: #f5c518;
    color: #000;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Responsive: Stack organize buttons on smaller screens */
@media (max-width: 1200px) {
    .organize-button-group {
        flex-wrap: wrap;
    }
    
    .organize-button-group > span {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 768px) {
    .organize-button-group {
        flex-direction: column;
        gap: 6px;
    }
    
    .organize-option {
        width: 100%;
        justify-content: center;
    }
}

.ai-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: rgba(124, 92, 255, 0.1);
    border-color: rgba(124, 92, 255, 0.3);
    color: var(--info);
    font-size: 0.85rem;
}

.ai-action-btn:hover {
    background: rgba(124, 92, 255, 0.2);
    border-color: rgba(124, 92, 255, 0.5);
}

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

.ai-action-btn .icon {
    color: var(--info);
}

/* Preview Cost Button */
.preview-cost-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: rgba(40, 167, 69, 0.1);
    border-color: rgba(40, 167, 69, 0.3);
    color: var(--success);
    font-size: 0.85rem;
}

.preview-cost-btn:hover {
    background: rgba(40, 167, 69, 0.2);
    border-color: rgba(40, 167, 69, 0.5);
}

.preview-cost-btn .spinner-sm {
    width: 14px;
    height: 14px;
}

/* Cost Preview Panel */
.cost-preview-panel {
    background: #1a1a2e !important;
    border: 2px solid #3d3d5c !important;
    border-radius: 12px;
    padding: 20px;
    margin: 16px 0;
    animation: slideDown 0.2s ease-out;
    overflow-x: auto;
}

/* Cost Preview Table */
.cost-preview-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.cost-preview-table th,
.cost-preview-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #2d2d44;
}

.cost-preview-table th {
    background: #12121f;
    color: #ffffff !important;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cost-preview-table tbody tr {
    transition: background 0.2s;
}

.cost-preview-table tbody tr:hover {
    background: rgba(245, 197, 24, 0.05);
}

.cost-preview-table tbody tr.breakdown-row {
    background: #0d0d18;
}

.cost-preview-table tbody tr.breakdown-row:hover {
    background: #0d0d18;
}

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

.cost-preview-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 0;
    padding-bottom: 12px;
    border-bottom: 1px solid #2d2d44;
}

.cost-preview-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 16px !important;
}

@media (max-width: 1200px) {
    .cost-preview-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 600px) {
    .cost-preview-grid {
        grid-template-columns: 1fr !important;
    }
}

.cost-preview-card {
    background: #0d0d18 !important;
    border: 2px solid #3d3d5c !important;
    border-radius: 12px !important;
    padding: 18px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s !important;
}

.cost-preview-card:hover {
    border-color: #f5c518 !important;
    box-shadow: 0 4px 20px rgba(245, 197, 24, 0.2) !important;
    transform: translateY(-2px) !important;
}

.cost-preview-card.loading {
    opacity: 0.7 !important;
}

.preview-card-header {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    font-weight: 700 !important;
    color: #ffffff !important;
    font-size: 1.1rem !important;
    padding-bottom: 8px !important;
    border-bottom: 1px solid #2d2d44 !important;
}

.preview-icon {
    font-size: 1.5rem !important;
}

.preview-name {
    font-size: 1.1rem !important;
    color: #ffffff !important;
}

.preview-loading {
    display: flex !important;
    justify-content: center !important;
    padding: 30px 0 !important;
}

.preview-cost {
    display: flex !important;
    align-items: baseline !important;
    gap: 8px !important;
    padding: 8px 0 !important;
}

.preview-credits {
    font-size: 2.5rem !important;
    font-weight: 800 !important;
    color: #f5c518 !important;
}

.preview-unit {
    font-size: 1rem !important;
    color: #cccccc !important;
}

.preview-usd {
    font-size: 0.95rem !important;
    color: #aaaaaa !important;
}

.preview-details {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    font-size: 0.9rem !important;
    padding: 12px 0 !important;
    border-top: 1px solid #2d2d44 !important;
}

.preview-detail-row {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}

.preview-detail-row .label {
    color: #aaaaaa !important;
}

.preview-detail-row .value {
    color: #ffffff !important;
    font-weight: 600 !important;
}

.preview-detail-row .model-tag {
    background: rgba(124, 92, 255, 0.3) !important;
    color: #c4b5fd !important;
    padding: 4px 10px !important;
    border-radius: 6px !important;
    font-size: 0.85rem !important;
    font-weight: 500 !important;
}

.preview-breakdown {
    font-size: 0.9rem !important;
    padding: 12px 0 !important;
    border-top: 1px solid #2d2d44 !important;
}

.preview-breakdown .breakdown-title {
    color: #cccccc !important;
    margin-bottom: 8px !important;
    font-weight: 600 !important;
}

.preview-breakdown .breakdown-item {
    display: flex !important;
    justify-content: space-between !important;
    padding: 4px 0 !important;
}

.preview-breakdown .breakdown-item .name {
    color: #dddddd !important;
}

.preview-breakdown .breakdown-item .cost {
    color: #f5c518 !important;
    font-weight: 700 !important;
}

.preview-source {
    font-size: 0.8rem !important;
    color: #888888 !important;
    text-align: right !important;
    padding-top: 8px !important;
    font-style: italic !important;
}

.preview-action-btn {
    margin-top: auto !important;
    width: 100% !important;
    padding: 12px 16px !important;
    font-size: 1rem !important;
    font-weight: 700 !important;
    background: #f5c518 !important;
    color: #000000 !important;
    border: none !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: background 0.2s, transform 0.1s !important;
}

.preview-action-btn:hover {
    background: #ffda44 !important;
    transform: translateY(-2px) !important;
}

.preview-action-btn:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    transform: none !important;
}

/* Spinner */
.spinner-sm {
    width: 20px !important;
    height: 20px !important;
    border: 3px solid #3d3d5c !important;
    border-top-color: #f5c518 !important;
    border-radius: 50% !important;
    animation: spin 0.8s linear infinite !important;
}

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

.global-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.global-loading-card {
    background: rgba(17, 19, 26, 0.95);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 18px 48px rgba(0,0,0,0.45);
}

.global-loading-text {
    color: #f8fafc;
    font-weight: 600;
    font-size: 0.95rem;
}

/* =============================================
   Inline Attachments (Above Editor)
   ============================================= */

.attachments-inline {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    margin-bottom: 8px;
}

.attachments-inline .upload-error {
    color: var(--error);
    font-size: 0.85rem;
}

.attachments-inline .attachment-count {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.attachments-grid-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

/* =============================================
   AI Panels (Above Editor)
   ============================================= */

.ai-panels-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.ai-panel-above {
    background: #0d0d1a !important;
    border: 1px solid #2d2d44;
    border-radius: 12px;
    overflow: hidden;
}

.ai-panel-above,
.ai-panel-above * {
    color: #ffffff;
}

.ai-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #12121f !important;
    border-bottom: 1px solid #2d2d44;
    color: #ffffff !important;
    font-weight: 600;
}

.ai-panel-header span {
    color: #ffffff !important;
}

.ai-panel-header .panel-close {
    background: none;
    border: none;
    color: #888888 !important;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.ai-panel-header .panel-close:hover {
    color: #ffffff !important;
}

.ai-panel-body {
    padding: 16px;
    background: #0d0d1a !important;
    color: #ffffff !important;
}

.estimate-badge {
    color: #4ade80 !important;
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.estimate-total {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
}

.credits-big {
    color: #f5c518 !important;
    font-size: 2rem;
    font-weight: 700;
}

.credits-label {
    color: #aaaaaa !important;
    font-size: 0.9rem;
}

.estimate-reasoning {
    color: #cccccc !important;
    font-size: 0.8rem;
    margin-bottom: 12px;
}

.breakdown-title {
    color: #ffffff !important;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.breakdown-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1a1a2e !important;
    border-radius: 6px;
    padding: 8px 12px;
    flex: 1 1 200px;
    min-width: 200px;
}

.breakdown-info {
    flex: 1;
}

.breakdown-op {
    color: #ffffff !important;
    font-size: 0.85rem;
    font-weight: 500;
}

.breakdown-desc {
    color: #aaaaaa !important;
    font-size: 0.75rem;
}

.breakdown-credits {
    color: #f5c518 !important;
    font-weight: 600;
    margin-left: 12px;
}

.panel-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #2d2d44;
}

.panel-actions button {
    flex: 1;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.panel-actions .ghost {
    background: transparent !important;
    border: 1px solid #4a5568 !important;
    color: #cccccc !important;
}

.panel-actions .ghost:hover {
    background: rgba(255,255,255,0.1) !important;
    color: #ffffff !important;
}

.panel-actions .primary {
    background: #f5c518 !important;
    color: #000000 !important;
    border: none !important;
    font-weight: 600;
}

.panel-actions .primary:hover {
    background: #ffd768 !important;
}

.panel-actions .primary:disabled {
    background: #6b7280 !important;
    color: #9ca3af !important;
    cursor: not-allowed;
}

/* Suggestion panel styles */
.suggestion-section {
    background: #12121f !important;
    border: 1px solid #2d2d44;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}

.section-label {
    color: #f5c518 !important;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.suggestion-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.suggestion-item {
    margin-bottom: 10px;
}

.item-label {
    display: block;
    color: #aaaaaa !important;
    font-size: 0.75rem;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.item-value {
    display: block;
    color: #ffffff !important;
    font-size: 0.9rem;
    line-height: 1.4;
}

.item-value.highlight-pink {
    color: #f0abfc !important;
    background: rgba(240,171,252,0.15) !important;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(240,171,252,0.4);
}

.item-value.highlight-blue {
    color: #93c5fd !important;
    background: rgba(147,197,253,0.15) !important;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(147,197,253,0.4);
}

.folder-badge {
    display: inline-block;
    background: rgba(245,197,24,0.25) !important;
    color: #fcd34d !important;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 500;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.tag.purple {
    background: rgba(124,92,255,0.3) !important;
    color: #c4b5fd !important;
}

.tag.green {
    background: rgba(74,222,128,0.3) !important;
    color: #86efac !important;
}

.confidence-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #1a1a2e !important;
    border-radius: 6px;
    padding: 8px 10px;
    margin-top: 10px;
}

.bar-track {
    flex: 1;
    height: 8px;
    background: #2d2d44 !important;
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #f5c518, #4ade80) !important;
    border-radius: 4px;
}

.bar-value {
    color: #ffffff !important;
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 40px;
    text-align: right;
}

/* Editor container */
.editor-container {
    width: 100%;
}

/* Ensure Rich Text Editor toolbar is always visible */
.bit-rte {
    width: 100% !important;
}

.bit-rte .e-toolbar,
.bit-rte .e-rte-toolbar {
    visibility: visible !important;
    display: flex !important;
    opacity: 1 !important;
}

/* Auto-height Rich Text Editor */
.bit-rte.auto-height .e-richtexteditor {
    height: 100% !important;
    width: 100% !important;
}

.bit-rte.auto-height .e-rte-content,
.bit-rte.auto-height .e-rte-content .e-content {
    height: 100% !important;
    width: 100% !important;
    word-wrap: break-word !important;
    white-space: pre-wrap !important;
}

.bit-rte.auto-height .e-rte-content .e-content {
    /* Allow content to flow naturally */
    max-height: none !important;
}

.ai-suggestions-panel {
    flex: 0 0 320px !important; /* Fixed width, don't grow or shrink */
    width: 320px !important;
    min-width: 280px;
    max-width: 350px;
    background: #0d0d1a;
    color: #fff;
    border: 1px solid #2d2d44;
    border-radius: 12px;
    padding: 16px;
    align-self: flex-start; /* Don't stretch to full height */
    max-height: calc(100vh - 300px);
    overflow-y: auto;
    background: #0d0d1a;
    border: 1px solid #2d2d44;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.suggestions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #2d2d44;
}

.suggestions-title {
    color: #ffffff !important;
    font-weight: 600;
    font-size: 1rem;
}

/* Force all text in side panels to be visible */
.ai-suggestions-panel,
.ai-suggestions-panel * {
    color: #ffffff;
}

.ai-suggestions-panel .suggestions-label,
.ai-suggestions-panel .cost-tokens,
.ai-suggestions-panel .credits-label,
.ai-suggestions-panel .cost-usd,
.ai-suggestions-panel .breakdown-name {
    color: #999999 !important;
}

.ai-suggestions-panel .credits-value {
    color: #f5c518 !important;
}

.ai-suggestions-panel .breakdown-credits {
    color: #f5c518 !important;
}

.suggestions-close {
    background: none;
    border: none;
    color: #888;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.suggestions-close:hover {
    color: #fff;
}

.suggestions-section {
    background: #12121f;
    border: 1px solid #2d2d44;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}

.suggestions-section-title {
    color: #f5c518 !important;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.suggestions-row {
    margin-bottom: 10px;
}

.suggestions-row:last-child {
    margin-bottom: 0;
}

.suggestions-label {
    display: block;
    color: #888888 !important;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.suggestions-value {
    display: block;
    color: #ffffff !important;
    font-size: 0.9rem;
    line-height: 1.4;
}

.suggestions-value.italic {
    color: #bbbbbb !important;
    font-style: italic;
    font-size: 0.85rem;
}

.suggestions-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-chip {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.tag-chip.purple {
    background: rgba(124, 92, 255, 0.25);
    color: #c4b5fd !important;
}

.tag-chip.gray {
    background: rgba(100, 116, 139, 0.35);
    color: #cbd5e1 !important;
}

.tag-chip.green {
    background: rgba(74, 222, 128, 0.25);
    color: #86efac !important;
}

.folder-chip {
    display: inline-block;
    background: rgba(245, 197, 24, 0.2);
    color: #fcd34d !important;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 500;
}

.confidence-meter {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #1a1a2e;
    border-radius: 6px;
    padding: 8px 10px;
}

.confidence-meter .bar-track {
    flex: 1;
    height: 8px;
    background: #2d2d44;
    border-radius: 4px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, #f5c518, #4ade80);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.confidence-text {
    color: #ffffff !important;
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 40px;
    text-align: right;
}

.suggestions-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #2d2d44;
}

.suggestions-actions .ghost {
    color: #aaaaaa !important;
}

.suggestions-actions .primary {
    background: #f5c518;
    color: #000 !important;
    font-weight: 600;
}

/* Cost Preview Side Panel */
.cost-preview-side {
    overflow-y: auto;
}

.cost-status {
    margin-bottom: 12px;
    font-size: 0.8rem;
}

.status-warning {
    color: #ffa500 !important;
}

.status-live {
    color: #4ade80 !important;
}

.cost-item {
    background: #12121f;
    border: 1px solid #2d2d44;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

.cost-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.cost-icon {
    font-size: 1.1rem;
}

.cost-operation {
    color: #ffffff !important;
    font-weight: 600;
    font-size: 0.9rem;
}

.cost-loading {
    color: #888888 !important;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cost-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cost-credits {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.credits-value {
    color: #f5c518 !important;
    font-size: 1.5rem;
    font-weight: 700;
}

.credits-label {
    color: #888888 !important;
    font-size: 0.8rem;
}

.cost-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.cost-usd {
    color: #aaaaaa !important;
    font-size: 0.85rem;
}

.cost-model {
    background: rgba(124, 92, 255, 0.3);
    color: #c4b5fd !important;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.cost-tokens {
    display: flex;
    gap: 12px;
    color: #888888 !important;
    font-size: 0.8rem;
}

.cost-breakdown {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #2d2d44;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
}

.breakdown-name {
    color: #aaaaaa !important;
    font-size: 0.8rem;
}

.breakdown-credits {
    color: #f5c518 !important;
    font-weight: 600;
    font-size: 0.85rem;
}

.cost-tip {
    background: rgba(245, 197, 24, 0.1);
    border: 1px solid rgba(245, 197, 24, 0.3);
    border-radius: 6px;
    padding: 10px;
    color: #cccccc !important;
    font-size: 0.85rem;
    text-align: center;
    margin-top: 8px;
}

.cost-tip strong {
    color: #ffffff !important;
}

/* Responsive: Tablet and below */
@media (max-width: 1024px) {
    .editor-with-sidebar {
        flex-direction: column !important;
    }
    
    .editor-main {
        width: 100% !important;
        flex: 0 0 auto !important;
    }
    
    .ai-suggestions-panel {
        flex: 0 0 auto !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: unset;
        max-height: 350px;
        order: -1; /* Show suggestions above editor on tablet */
    }
}

/* Responsive: Mobile */
@media (max-width: 768px) {
    .ai-suggestions-panel {
        max-height: 300px;
        padding: 12px;
        border-radius: 8px;
    }
    
    .suggestions-header {
        margin-bottom: 12px;
        padding-bottom: 10px;
    }
    
    .suggestions-title {
        font-size: 0.9rem;
    }
    
    .suggestions-section {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    .suggestions-section-title {
        font-size: 0.85rem;
        margin-bottom: 8px;
    }
    
    .suggestions-label {
        font-size: 0.7rem;
    }
    
    .suggestions-value {
        font-size: 0.85rem;
    }
    
    .tag-chip {
        font-size: 0.75rem;
        padding: 2px 6px;
    }
    
    .suggestions-actions {
        padding-top: 10px;
    }
    
    .suggestions-actions button {
        padding: 8px 14px;
        font-size: 0.85rem;
    }
}

/* Responsive: Small mobile */
@media (max-width: 480px) {
    .ai-suggestions-panel {
        max-height: 280px;
        padding: 10px;
    }
    
    .suggestions-row {
        margin-bottom: 8px;
    }
    
    .suggestions-tags {
        gap: 4px;
    }
    
    .confidence-meter {
        padding: 6px 8px;
    }
    
    .suggestions-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .suggestions-actions button {
        width: 100%;
    }
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    z-index: 300;
    animation: slideIn 0.3s ease;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.toast.error {
    background: #dc2626;
    color: #fff !important;
}

.toast.success {
    background: #16a34a;
    color: #fff !important;
}

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

/* =============================================
   Top-up Section Styles
   ============================================= */

.topup-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.topup-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 16px;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    background: var(--bg-surface);
    cursor: pointer;
    transition: all 0.15s;
    min-width: 70px;
}

.topup-btn:hover {
    border-color: var(--accent-primary);
    background: rgba(242, 201, 76, 0.05);
}

.topup-btn.selected {
    border-color: var(--accent-primary);
    background: rgba(242, 201, 76, 0.15);
    box-shadow: 0 0 0 2px rgba(242, 201, 76, 0.2);
}

.topup-credits {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.topup-price {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* =============================================
   Estimator Loading State
   ============================================= */

.estimator-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: var(--text-muted);
}

.price-source-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--chip-bg);
    border: 1px solid var(--chip-border);
    border-radius: 6px;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* =============================================
   Enhanced Cost Breakdown Styles
   ============================================= */

.cost-details-section {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px;
    background: var(--bg-sunken);
    border-radius: 10px;
    margin-top: 12px;
}

.detail-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.detail-label {
    color: var(--text-muted);
}

.detail-value {
    color: var(--text-primary);
    font-weight: 500;
}

.model-badge {
    padding: 2px 8px;
    background: rgba(124, 92, 255, 0.15);
    border: 1px solid rgba(124, 92, 255, 0.3);
    border-radius: 6px;
    color: var(--info);
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.8rem;
}

.cost-breakdown {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 12px;
    margin-top: 12px;
}

.breakdown-header {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}

.breakdown-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-subtle);
}

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

.breakdown-row.breakdown-total {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 2px solid var(--border-strong);
    border-bottom: none;
    font-weight: 600;
}

.breakdown-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.breakdown-name {
    color: var(--text-primary);
    font-weight: 500;
}

.breakdown-desc {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.breakdown-cost {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.breakdown-credits {
    color: var(--accent-primary);
    font-weight: 600;
}

.breakdown-usd {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* RichTextEditor image sizing - allow images to display at reasonable sizes */
.e-rte-content img,
.e-content img,
.bit-rte img,
.e-richtexteditor img,
.e-richtexteditor .e-content img,
.e-richtexteditor .e-rte-content img,
.e-rte-container img,
div[role="textbox"] img {
    max-width: 100% !important;
    max-height: 800px !important;
    height: auto !important;
    width: auto !important;
    object-fit: contain !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    display: inline-block !important;
}

/* Override any Syncfusion inline styles that may constrain images */
img[style*="max-width"] {
    max-width: 100% !important;
}

img[style*="max-height"] {
    max-height: 800px !important;
}

img[style*="width"] {
    width: auto !important;
}

img[style*="height"] {
    height: auto !important;
}


.related-bits-panel {
    position: relative;
    flex: 0 0 auto;
    border-top: 1px dashed var(--border-subtle);
    background: var(--bg-canvas);
    margin: 24px 0; /* Matches editor width by using 0 horizontal margin inside padded container */
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: auto !important;
    min-height: 44px;
}

.related-bits-panel.open {
    height: auto !important; /* No fixed height when open, let it flow */
}

.related-bits-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    font-weight: 600;
    flex: 0 0 44px; /* Fixed toggle height */
    height: 44px;
    border: none;
    background: transparent;
    cursor: pointer;
}

.related-bits-list {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 8px 0 16px;
    min-height: 0;
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
}

.related-bits-items {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
}

.related-bits-items > * + * {
    margin-top: 10px;
}

.related-bits-list > *,
.related-bits-items > * {
    width: 100% !important;
    flex: 0 0 auto !important;
    display: block !important;
}

.related-bit-row {
    width: 100% !important;
    display: block !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
    align-self: stretch !important;
}

.related-bit-row .related-bit-item {
    width: 100% !important;
}

.related-bit-item {
    display: block !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    text-align: left !important; /* Force left alignment for the button content */
    padding: 12px 16px !important;
    border-left: 4px solid #f29c4c;
    border-radius: 8px;
    background: rgba(255, 255, 255, .08) !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.related-bit-layout {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 16px;
    align-items: start;
    width: 100%;
}

.related-bit-info {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Align children to the left */
    text-align: left;
    justify-self: start;
}

.related-bit-title-panel,
.related-bit-desc-panel {
    width: 100% !important;
    padding: 8px 10px !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 10px !important;
    background: var(--bg-sunken) !important;
    box-sizing: border-box !important;
    display: block !important;
}

.related-bit-title-panel {
    margin-bottom: 6px;
}

.related-bit-desc-panel {
    margin-top: 6px;
}

.related-bit-title {
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    margin-bottom: 2px;
    color: var(--text-primary);
    text-align: left;
    margin: 0;
    display: block;
    padding: 8px 10px !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 10px !important;
    background: var(--bg-sunken) !important;
    box-sizing: border-box !important;
}

.related-bit-desc {
    opacity: 0.8;
    font-size: 0.8rem;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal; /* Allow wrapping for description */
    text-align: left;
    margin: 0;
    display: block;
    padding: 8px 10px !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 10px !important;
    background: var(--bg-sunken) !important;
    box-sizing: border-box !important;
    margin-top: 6px !important;
}

.related-bit-score {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    padding-top: 2px;
    min-width: 84px;
    justify-self: end;
    text-align: right;
}

.related-bit-score .score-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.score-value {
    color: #ffffff;
    font-weight: 700;
    font-size: 0.75rem;
}

/* Related Bits layout enforcement (single full-width row per item) */
.related-bits-panel,
.related-bits-list,
.related-bits-items,
.related-bit-row {
    width: 100% !important;
    max-width: none !important;
    text-align: left !important;
    box-sizing: border-box !important;
}

.related-bits-items {
    display: flex !important;
    flex-direction: column !important;
}

.related-bits-items > * {
    display: block !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.related-bit-row {
    padding: 0 16px !important;
}

/* Responsive stacking overrides - Tablet and below (max 1024px) */
@media (max-width: 1024px) {
    .layout {
        display: flex !important;
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        height: auto !important;
        min-height: 100vh !important;
        overflow: visible !important;
    }

    .sidebar {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: none !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-subtle) !important;
        overflow: auto !important;
    }

    .sidebar-body {
        overflow: visible !important;
    }

    .sidebar-splitter {
        display: none !important;
    }

    .content {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 auto !important;
    }

    .search-bar {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .grid {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        width: 100% !important;
    }

    .list-pane {
        width: 100% !important;
        max-width: none !important;
        min-width: 100% !important;
        height: auto !important;
        max-height: none !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-subtle) !important;
        overflow: visible !important;
        flex: 0 0 auto !important;
    }

    .grid-splitter {
        display: none !important;
    }

    .detail-pane {
        width: 100% !important;
        max-width: none !important;
        min-width: 100% !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        border-left: none !important;
        border-top: 1px solid var(--border-subtle) !important;
        border-radius: 0 !important;
        flex: 0 0 auto !important;
    }

    .detail-pane-content {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .bit-list-item {
        flex-direction: column !important;
    }
}

/* Responsive stacking overrides - Wider tablets (max 1400px) */
@media (max-width: 1400px) and (min-width: 1025px) {
    .list-pane {
        width: 40% !important;
        max-width: 40% !important;
        min-width: 40% !important;
    }

    .detail-pane {
        width: 60% !important;
        max-width: 60% !important;
        min-width: 60% !important;
    }
}

/* Responsive stacking overrides - Original wide breakpoint (for desktop-ish responsive) */
@media (max-width: 1600px) and (min-width: 1401px) {
    .list-pane {
        width: 45% !important;
        max-width: 45% !important;
        min-width: 45% !important;
    }

    .detail-pane {
        width: 55% !important;
        max-width: 55% !important;
        min-width: 55% !important;
    }
}

