/* ==========================================================================
   COMPONENTS.CSS - Buttons, Inputs, Dropdowns, Controls
   ========================================================================== */

/* --- Controls Bar --- */
#controls-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    position: relative;
    width: 100%;
    z-index: 2000;
}

/* --- Glass Buttons, Labels, Inputs --- */
button.glass-btn,
.file-label,
select.glass-select,
input.glass-input {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.45rem 0.8rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #e2e8f0;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.2s ease;
    outline: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Theme-synced border using gradient - pseudo-element for rounded corners */
.glass-btn.theme-border {
    position: relative;
    border: none;
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.6)) 90%, #12161c 10%);
    color: var(--text-main, #e2e8f0);
    z-index: 1;
}

.glass-btn.theme-border::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 13px;
    background: var(--g);
    z-index: -1;
}

.glass-btn.theme-border::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.6)) 94%, #0f1318 6%);
    z-index: -1;
}

button.glass-btn:hover,
.file-label:hover,
select.glass-select:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
}

button.glass-btn:active {
    transform: scale(0.98);
}

/* --- Unified Theme-Synced Close Button (X) --- */
button.glass-btn.theme-close-btn,
.theme-close-btn {
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
    padding: 0 !important;
    gap: 0 !important;
    border-radius: 8px;
    border: 1px solid color-mix(in srgb, var(--bd, #334155) 72%, rgba(255, 255, 255, 0.22) 28%) !important;
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.6)) 88%, #0b1017 12%) !important;
    color: color-mix(in srgb, var(--text-main, #e2e8f0) 72%, #94a3b8 28%) !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.06rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.24);
    transition: all 0.2s ease;
}

button.glass-btn.theme-close-btn:hover,
.theme-close-btn:hover {
    border-color: color-mix(in srgb, var(--g1, #60a5fa) 54%, var(--g2, #f472b6) 46%) !important;
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.6)) 78%, rgba(255, 255, 255, 0.12) 22%) !important;
    color: var(--text-main, #f8fafc) !important;
    transform: translateY(-1px);
}

button.glass-btn.theme-close-btn:active,
.theme-close-btn:active {
    transform: scale(0.96);
}

.theme-close-btn .gradient-text {
    background: none !important;
    -webkit-background-clip: border-box !important;
    background-clip: border-box !important;
    -webkit-text-fill-color: currentColor !important;
    color: currentColor !important;
}

/* --- Wrappers --- */
.search-wrapper {
    position: relative;
    display: inline-block;
    z-index: 50;
}

.source-wrapper {
    position: relative;
    display: inline-block;
    z-index: 100;
}

.menu-wrapper,
.ai-wrapper {
    position: relative;
    display: inline-block;
    z-index: 10001;
}

/* --- Glass Input --- */
input.glass-input {
    font-weight: 400;
    width: 180px;
    transition: width 0.3s ease, background 0.2s;
    color: #fff;
}

input.glass-input::placeholder {
    color: #94a3b8;
}

input.glass-input:focus {
    width: 240px;
    background: rgba(255, 255, 255, 0.08);
    border-color: #a78bfa;
}

/* --- Glass Select --- */
select.glass-select option {
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.6)) 90%, #151a21 10%);
    color: #e2e8f0;
}

#jump-select {
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.6)) 84%, #232b35 16%);
    color: #e2e8f0;
    border: 1px solid #475569;
    padding: 6px 10px;
    border-radius: 8px;
    margin-right: 12px;
    font-size: 0.9rem;
    cursor: pointer;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#jump-select::-webkit-scrollbar,
#jump-select option::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

#jump-select option {
    scrollbar-width: none;
}

#jump-select.adaptive-repeat-pulse {
    border-color: #a78bfa;
    animation: adaptive-repeat-outline 1.45s ease-in-out infinite;
}

@keyframes adaptive-repeat-outline {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(96, 165, 250, 0), 0 0 0 0 rgba(167, 139, 250, 0);
        border-color: #475569;
    }

    50% {
        box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.55), 0 0 16px rgba(167, 139, 250, 0.35);
        border-color: #a78bfa;
    }
}

/* --- DROPDOWNS --- */
#search-dropdown,
#menu-dropdown,
#ai-dropdown {
    position: absolute;
    top: 115%;
    right: 0;
    width: 380px;
    max-height: min(800px, 85vh);
    overflow-y: auto;
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    display: none;
    flex-direction: column;
    z-index: 13020;
}

/* AI dropdown - smaller for controls bar */
#ai-dropdown {
    width: 180px;
    max-height: min(300px, 50vh);
}

/* Menu dropdown - positioned on left side under Tools */
#menu-dropdown {
    position: fixed;
    top: 0;
    left: 0;
    transform: none;
    width: min(280px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    overflow-x: hidden;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    z-index: 10005;
    transform-origin: top center;
}

/* Backdrop for menu popup */
#menu-dropdown.active::before {
    content: none;
}

#search-dropdown.active,
#menu-dropdown.active,
#source-dropdown.active,
#ai-dropdown.active {
    display: flex;
}

/* Hide scrollbar for dropdowns */
#search-dropdown::-webkit-scrollbar,
#menu-dropdown::-webkit-scrollbar,
#ai-dropdown::-webkit-scrollbar {
    display: none;
}

#menu-dropdown,
#source-dropdown,
#ai-dropdown {
    padding: 8px;
}

/* In trio/split view, align dropdowns to left to prevent cutoff */
#work-area.trio-view #ai-dropdown,
#work-area.split-view #ai-dropdown {
    right: auto;
    left: 0;
}

/* --- Dropdown Headers --- */
.dd-header {
    font-size: 0.75rem;
    text-transform: uppercase;
    background: var(--g);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 700;
    padding: 8px 4px 4px;
    border-bottom: 1px solid #334155;
    margin-bottom: 5px;
    margin-top: 10px;
}

.dd-header:first-child {
    margin-top: 0;
}

/* --- Menu Dropdown Buttons --- */
#menu-dropdown button.glass-btn,
#ai-dropdown button.glass-btn {
    width: 100%;
    border: none;
    background: transparent;
    justify-content: flex-start;
    border-radius: 8px;
    margin-bottom: 2px;
}

#menu-dropdown button.glass-btn:hover,
#ai-dropdown button.glass-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

#menu-dropdown button.glass-btn.active,
#ai-dropdown button.glass-btn.active {
    background: rgba(244, 114, 182, 0.15);
    border: 1px solid rgba(244, 114, 182, 0.3);
}

/* --- Tools Menu Help Markers --- */
.tools-help-toggle-row {
    display: flex;
    justify-content: flex-end;
    padding: 2px 2px 6px;
    margin: 0 0 2px;
}

.tools-help-toggle-btn {
    width: 22px;
    height: 22px;
    border: 1px solid color-mix(in srgb, var(--bd, rgba(255, 255, 255, 0.2)) 82%, transparent 18%);
    border-radius: 999px;
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.65)) 82%, transparent 18%);
    color: color-mix(in srgb, var(--text-main, #e2e8f0) 78%, #9aa6b6 22%);
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.tools-help-toggle-btn:hover,
.tools-help-toggle-btn:focus-visible {
    border-color: color-mix(in srgb, var(--g1, #7c3aed) 58%, var(--bd, rgba(255, 255, 255, 0.22)) 42%);
    color: color-mix(in srgb, var(--g1, #7c3aed) 55%, var(--text-main, #e2e8f0) 45%);
    outline: none;
}

.tools-help-toggle-btn:active {
    transform: scale(0.97);
}

.tools-help-toggle-btn.active {
    background: color-mix(in srgb, var(--g1, #7c3aed) 20%, var(--card-bg, rgba(15, 23, 42, 0.65)) 80%);
    border-color: color-mix(in srgb, var(--g1, #7c3aed) 56%, var(--bd, rgba(255, 255, 255, 0.22)) 44%);
    color: color-mix(in srgb, var(--text-main, #e2e8f0) 62%, var(--g1, #7c3aed) 38%);
}

.tools-help-toggle-btn span:last-child {
    display: none;
}

.tool-help-item-wrap {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tool-help-item-wrap>button.glass-btn {
    flex: 1 1 auto;
    margin-bottom: 2px;
}

.tool-help-marker {
    position: relative;
    width: 18px;
    height: 18px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--bd, rgba(255, 255, 255, 0.2)) 76%, transparent 24%);
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.65)) 76%, transparent 24%);
    color: color-mix(in srgb, var(--text-main, #e2e8f0) 72%, #99a3b3 28%);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    cursor: help;
    padding: 0;
    flex: 0 0 18px;
    transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

#menu-dropdown.help-markers-visible .tool-help-marker {
    display: inline-flex;
}

#menu-dropdown.help-markers-visible .tool-help-marker:hover,
#menu-dropdown.help-markers-visible .tool-help-marker:focus-visible {
    border-color: color-mix(in srgb, var(--g1, #7c3aed) 52%, var(--bd, rgba(255, 255, 255, 0.22)) 48%);
    color: color-mix(in srgb, var(--g1, #7c3aed) 44%, var(--text-main, #e2e8f0) 56%);
    outline: none;
    transform: scale(1.03);
}

.tool-help-marker::after {
    content: attr(data-tip);
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    width: clamp(150px, 36vw, 210px);
    padding: 7px 9px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--bd, rgba(255, 255, 255, 0.2)) 84%, transparent 16%);
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.7)) 90%, #0c1119 10%);
    color: var(--text-main, #e2e8f0);
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.35;
    text-align: left;
    white-space: normal;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.34);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    z-index: 10032;
    transition: opacity 0.14s ease, visibility 0.14s ease, transform 0.16s ease;
}

.tool-help-marker::before {
    content: '';
    position: absolute;
    right: calc(100% + 4px);
    top: 50%;
    transform: translateY(-50%);
    border-left: 6px solid color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.7)) 90%, #0c1119 10%);
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.14s ease, visibility 0.14s ease;
    z-index: 10031;
}

.tool-help-marker:hover::after,
.tool-help-marker:hover::before,
.tool-help-marker:focus-visible::after,
.tool-help-marker:focus-visible::before {
    opacity: 1;
    visibility: visible;
}

.tool-help-marker:hover::after,
.tool-help-marker:focus-visible::after {
    transform: translateY(-50%) translateX(-1px);
}

/* --- Search Items --- */
.search-item {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: background 0.1s;
}

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

.search-item:hover {
    background: #334155;
}

.s-idx {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 700;
    text-transform: uppercase;
}

.s-txt {
    font-size: 0.9rem;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* PDF Search Results */
.search-item-pdf {
    background: rgba(59, 130, 246, 0.05);
    border-left: 2px solid rgba(59, 130, 246, 0.3);
}

.search-item-pdf:hover {
    background: rgba(59, 130, 246, 0.12);
}

.search-item-pdf .s-idx {
    color: #60a5fa;
}

.search-item-pdf .s-txt {
    white-space: normal;
    max-height: 40px;
    overflow: hidden;
}

/* --- Small Toggle Buttons --- */
#as-toggle-small,
#aa-toggle-small,
#ae-toggle-small,
#ax-toggle-small,
#source-btn-small,
#reset-q-small {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--bd);
    color: var(--text-main);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 10px;
    transition: all 0.2s ease;
}

#as-toggle-small:hover,
#aa-toggle-small:hover,
#ae-toggle-small:hover,
#ax-toggle-small:hover,
#source-btn-small:hover,
#reset-q-small:hover {
    background: rgba(255, 255, 255, 0.1);
}

#as-toggle-small.active,
#aa-toggle-small.active,
#ae-toggle-small.active,
#ax-toggle-small.active,
#source-btn-small.active,
#reset-q-small.active {
    border-color: #a78bfa;
    background: rgba(167, 139, 250, 0.15);
    color: #a78bfa;
    box-shadow: 0 0 10px rgba(167, 139, 250, 0.1);
}

#source-btn-small {
    color: #60a5fa;
    border-color: #60a5fa;
}

#source-btn-small:hover {
    background: rgba(96, 165, 250, 0.15);
}

/* Visual Feedback for Shortcut Press */
#source-btn-small.active {
    background-color: #fff !important;
    color: #000 !important;
    transform: scale(1.1);
    box-shadow: 0 0 15px #fff;
}

/* Filter Banner */
#filter-banner {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.92), rgba(30, 41, 59, 0.78));
    color: #cbd5e1;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid color-mix(in srgb, var(--g1, #60a5fa) 45%, rgba(148, 163, 184, 0.25) 55%);
    box-shadow: 0 8px 24px rgba(2, 6, 23, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
    margin-bottom: 1rem;
    display: none;
    font-size: 0.95rem;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

#filter-banner-text {
    flex: 1;
    min-width: 0;
}

.filter-banner-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.filter-banner-btn {
    border: 1px solid color-mix(in srgb, var(--g1, #60a5fa) 38%, rgba(148, 163, 184, 0.28) 62%);
    background: rgba(15, 23, 42, 0.4);
    color: #e2e8f0;
    border-radius: 9px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.36rem 0.68rem;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.filter-banner-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: color-mix(in srgb, var(--g2, #a78bfa) 50%, rgba(148, 163, 184, 0.32) 50%);
    transform: translateY(-1px);
}

#adaptive-snapshot-btn {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.16), rgba(167, 139, 250, 0.14));
}

@media (max-width: 820px) {
    #filter-banner {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-banner-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* --- Shortcuts Button & Panel --- */
#shortcuts-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
    font-weight: bold;
    cursor: pointer;
    z-index: 5000;
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s;
}

#shortcuts-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    transform: scale(1.05);
}

#shortcuts-panel {
    position: fixed;
    bottom: 75px;
    right: 20px;
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    border: 1px solid var(--bd, #334155);
    padding: 16px;
    border-radius: 12px;
    z-index: 5000;
    display: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    width: 260px;
    font-size: 0.9rem;
    color: #cbd5e1;
    animation: fadeIn 0.2s ease;
}

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

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

.key-tag {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.85rem;
    color: #e2e8f0;
    transition: all 0.2s ease;
}

.key-tag.editable {
    cursor: pointer;
    border-color: rgba(96, 165, 250, 0.3);
}

.key-tag.editable:hover {
    background: rgba(96, 165, 250, 0.2);
    border-color: #60a5fa;
}

.key-tag.editing {
    background: linear-gradient(135deg, #60a5fa22, #a78bfa22);
    border-color: #a78bfa;
    box-shadow: 0 0 10px rgba(167, 139, 250, 0.4);
    animation: pulse-edit 1s infinite;
}

@keyframes pulse-edit {

    0%,
    100% {
        box-shadow: 0 0 10px rgba(167, 139, 250, 0.4);
    }

    50% {
        box-shadow: 0 0 20px rgba(167, 139, 250, 0.6);
    }
}

/* --- Question Image Minimize Button --- */
.q-image-wrapper {
    position: relative;
    display: none;
    margin-bottom: 1rem;
}

.q-image-wrapper.minimized .q-image {
    display: none;
}

.q-image-wrapper.minimized .q-image-minimize-btn {
    position: relative;
    top: auto;
    right: auto;
    margin: 0 auto;
    display: flex;
}

.q-image-wrapper.minimized::before {
    content: "📷 Image hidden";
    display: block;
    text-align: center;
    padding: 8px;
    color: #64748b;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px dashed rgba(255, 255, 255, 0.1);
    cursor: pointer;
}

.q-image-minimize-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.6)) 82%, #171c23 18%);
    color: #e2e8f0;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
    z-index: 10;
}

.q-image-minimize-btn:hover {
    background: rgba(248, 113, 113, 0.8);
    border-color: rgba(248, 113, 113, 0.5);
    transform: scale(1.1);
}

/* ==========================================================================
   DEEP DIVE / AI RESPONSE FORMATTING (Theme-Synced)
   ========================================================================== */

.ai-formatted-response {
    line-height: 1.7;
    color: var(--text-main, #e2e8f0);
}

/* Section headers - theme gradient synced */
.dd-section-header {
    color: var(--g1, #60a5fa);
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.25;
    margin: 1.05rem 0 0.5rem 0;
    padding-left: 12px;
    border-left: 3px solid var(--g1, #60a5fa);
}

.dd-section-header:first-child {
    margin-top: 0;
}

/* Add clearer separation between consecutive deep-dive sections */
.ai-formatted-response .dd-section-header:not(:first-child) {
    margin-top: 1.6rem;
}

/* Bold text */
.dd-bold {
    color: var(--ai-bold, #bfdbfe);
    font-weight: 600;
}

/* Italic text */
.dd-italic {
    color: var(--text-main, #e2e8f0);
    font-style: italic;
    opacity: 0.92;
}

/* Bullet points - theme synced */
.dd-bullet {
    color: var(--g1, #60a5fa);
    margin-right: 8px;
    font-weight: bold;
}

/* Numbered lists */
.dd-number {
    color: var(--g1, #60a5fa);
    font-weight: 600;
    margin-right: 8px;
}

/* Paragraphs */
.dd-paragraph {
    margin: 0 0 1.05rem 0;
    padding-left: 1rem;
}

.ai-formatted-response .dd-section-header+.dd-paragraph {
    margin-top: 0.2rem;
    padding-left: 1.1rem;
}

.ai-formatted-response .dd-paragraph:last-child {
    margin-bottom: 0;
}

.dd-line + .dd-line {
    margin-top: 0.35rem;
}

.dd-list-item {
    margin: 1rem 0;
    line-height: 1.72;
    padding-left: 1.2rem;
    text-indent: -1.1rem;
}

.dd-list-item + .dd-list-item {
    margin-top: 1.25rem;
}

/* Code blocks */
.dd-code-block {
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    padding: 12px;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    overflow-x: auto;
    margin: 0.5rem 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Inline code */
.dd-code-inline {
    background: rgba(99, 102, 241, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    color: #a5b4fc;
    font-size: 0.9em;
}




/* AI Popup Modal */
.ai-popup-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: transparent;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    pointer-events: none;
}

.ai-popup-modal.active {
    display: flex;
}

.ai-popup-content {
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    border: 1px solid var(--bd, #334155);
    border-radius: 16px;
    padding: 1.5rem;
    max-width: 100vw;
    width: 600px;
    max-height: 100vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    scrollbar-width: none;
    -ms-overflow-style: none;
    pointer-events: auto;
    position: relative;
}

#ai-popup-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    z-index: 10;
    border-right: 3px solid var(--g1, #60a5fa);
    border-bottom: 3px solid var(--g1, #60a5fa);
    border-radius: 0 0 16px 0;
    opacity: 0.35;
    transition: opacity 0.15s;
}

#ai-popup-resize-handle:hover {
    opacity: 1;
}

.ai-popup-content::-webkit-scrollbar {
    display: none;
}

.ai-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ai-popup-body {
    color: var(--text-main, #e2e8f0);
    line-height: 1.7;
}

/* --- AI Edit Button --- */
.ai-edit-btn {
    position: relative;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    color: var(--text-sub, #94a3b8);
    font-size: 0.75rem;
    padding: 5px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-left: 0.5rem;
    backdrop-filter: blur(4px);
}

/* Gradient border via pseudo-element */
.ai-edit-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 8px;
    padding: 1px;
    background: linear-gradient(135deg, var(--g1, #60a5fa), var(--g2, #a78bfa));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.4;
    transition: opacity 0.25s ease;
}

.ai-edit-btn:hover {
    color: var(--text-main, #f1f5f9);
    background: rgba(255, 255, 255, 0.1);
}

.ai-edit-btn:hover::before {
    opacity: 0.8;
}

/* --- Section Editor Modal --- */
.section-editor-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: color-mix(in srgb, var(--card-bg, rgba(15, 23, 42, 0.6)) 42%, rgba(10, 12, 16, 0.94) 58%);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10001;
}

.section-editor-modal.active {
    display: flex;
}

.section-editor-content {
    background: var(--card-bg, rgba(15, 23, 42, 0.6));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 0;
    max-width: 550px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    position: relative;
}

.section-editor-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 1.5rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.section-editor-body::-webkit-scrollbar {
    display: none;
}

.section-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.section-editor-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.section-editor-close {
    margin-left: 0.25rem;
}

.section-editor-close:hover {
    transform: translateY(-1px);
}

/* Section items list */
.section-editor-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 1rem;
}

.section-editor-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-left: 3px solid transparent;
    border-radius: 12px;
    padding: 12px;
    transition: all 0.2s;
}

.section-editor-item:hover {
    border-color: rgba(255, 255, 255, 0.15);
    border-left-color: color-mix(in srgb, var(--g1, #60a5fa) 58%, var(--g2, #f472b6) 42%);
}

.section-editor-item:focus-within {
    border-left-color: color-mix(in srgb, var(--g1, #60a5fa) 58%, var(--g2, #f472b6) 42%);
}

.section-editor-item.dragging {
    opacity: 0.5;
    border-color: var(--g1, #4ade80);
}

.section-editor-item.drag-over {
    border-color: var(--g1, #4ade80);
    background: rgba(255, 255, 255, 0.08);
}

.section-drag-handle {
    cursor: grab;
    color: #475569;
    font-size: 1rem;
    padding: 2px 4px;
    user-select: none;
    flex-shrink: 0;
    margin-top: 4px;
}

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

.section-editor-fields {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.section-editor-fields input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--text-main, #e2e8f0);
    font-size: 0.9rem;
    font-weight: 600;
    outline: none;
    transition: border-color 0.2s;
}

.section-editor-fields input:focus {
    border-color: var(--g1, #4ade80);
}

.section-editor-fields textarea {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--text-sub, #94a3b8);
    font-size: 0.78rem;
    resize: none;
    overflow-y: hidden;
    min-height: 32px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.section-editor-fields textarea:focus {
    border-color: var(--g1, #4ade80);
    color: var(--text-main, #e2e8f0);
}

.section-delete-btn {
    background: none;
    border: none;
    color: #475569;
    font-size: 1rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-top: 4px;
}

.section-delete-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.section-add-btn {
    width: 100%;
    padding: 10px;
    background: rgba(0, 0, 0, 0.15);
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 0;
    color: var(--text-sub, #94a3b8);
}

.section-add-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--g1, #4ade80);
}

.section-limit-warning {
    font-size: 0.75rem;
    color: #94a3b8;
    text-align: center;
    margin-bottom: 0.75rem;
}

.section-editor-actions {
    padding: 0.75rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    background: inherit;
}

.section-editor-footer {
    display: flex;
    gap: 8px;
    padding: 0 1.5rem 1.25rem;
    flex-shrink: 0;
    background: inherit;
}

.section-apply-btn {
    flex: 1;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-main, #e2e8f0);
    transition: all 0.2s;
}

.section-apply-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--g1, #4ade80);
}

.section-apply-btn.primary {
    background: var(--g);
    border: none;
    color: #fff;
}

.section-apply-btn.primary:hover {
    opacity: 0.9;
}


