/* Chat Widget Styles - Docked Left Panel Design */
:root {
    --font-headings: var(--font-family-arabic, 'Cairo', sans-serif);
    --font-content: var(--font-family-arabic, 'Cairo', sans-serif);
    --chat-panel-width: var(--chatbot-panel-width, 360px);
    --chat-collapsed-width: 50px;
}

/* ===== Docked Chat Panel (Left by default for RTL, Right for LTR) ===== */
.chat-panel {
    position: fixed;
    left: 0;
    /* Default to left side for RTL books */
    top: 120px;
    /* Fixed position below header - will be adjusted by JS if needed */
    height: calc(100vh - 120px);
    width: var(--chat-panel-width);
    background: var(--bg-color, #ffffff);
    border-inline-end: 1px solid var(--border-color, #e0e0e0);
    display: flex !important;
    /* Force display */
    flex-direction: column;
    z-index: 900;
    /* Below header (1000) but above content (100) */
    transition: width 0.3s ease, transform 0.3s ease, top 0.3s ease;
    /* Add top transition */
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.05);
}

/* Chat Panel Left Position (explicit, same as default for RTL) */
.chat-panel.position-left {
    right: auto;
    left: 0;
    border-inline-start: none;
    border-inline-end: 1px solid var(--border-color, #e0e0e0);
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.05);
}

/* Chat Panel Right Position (for LTR books) */
.chat-panel.position-right {
    right: 0;
    left: auto;
    border-inline-end: none;
    border-inline-start: 1px solid var(--border-color, #e0e0e0);
    box-shadow: -2px 0 15px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .chat-panel {
    background: #1a1a1a;
    border-color: rgba(255, 255, 255, 0.1);
}

/* Collapsed State - Vertical Bar with Toggle */
.chat-panel.collapsed {
    width: var(--chat-collapsed-width);
}

.chat-panel.collapsed .chat-header,
.chat-panel.collapsed .chat-body-container,
.chat-panel.collapsed .chat-input-area,
.chat-panel.collapsed .chat-window-controls {
    /* Hide Controls Row too */
    display: none;
}

.chat-panel.collapsed .chat-collapse-bar {
    display: flex !important;
}

/* Collapse Bar (visible when collapsed) */
.chat-collapse-bar {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    /* Space between Title and Bottom Button */
    height: 100%;
    /* remove cursor: pointer since we have a button now? Or keep it as big click target? */
    /* Let's keep specific button for action to be clear */
    background: linear-gradient(180deg, var(--chatbot-primary-color, #f39c12), var(--chatbot-secondary-color, #d35400));
    color: white;
    padding: 20px 0;
    -webkit-user-select: none;
    user-select: none;
    overflow: hidden;
    width: 100%;
    /* Ensure it fills the 50px panel */
    z-index: 10001;
    /* Force top */
    /* writing-mode removed to debug visibility */
}

/* Title Container */
.chat-collapse-bar-title {
    white-space: nowrap;
    font-weight: 600;
    font-size: 1.1em;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* Arabic text: vertical, top-to-bottom, right-to-left characters */
.chat-collapse-bar-title .text-direction-arabic {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

/* Latin text: vertical, top-to-bottom (A at top, k at bottom) */
.chat-collapse-bar-title .text-direction-latin {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(0deg);
}

/* Bottom Toggle Button in Bar */
.chat-expand-btn {
    background: rgba(0, 0, 0, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    transition: background 0.2s;
}

.chat-expand-btn:hover {
    background: rgba(0, 0, 0, 0.4);
}

.chat-collapse-bar:hover {
    background: linear-gradient(180deg, var(--chatbot-secondary-color, #e67e22), var(--chatbot-primary-color, #c0392b));
}

/* 1. Remove chat icon as requested */
.chat-collapse-bar .collapse-icon {
    display: none;
}

/* 2. Text styling for Arabic (Up-to-Down reading) */
/* By default vertical-rl runs Top-to-Bottom.  */
/* But the orientation of characters might need adjustment. */
.chat-collapse-bar span {
    /* Ensure nice letter spacing */
    letter-spacing: 2px;
}

/* Helper for direction - handled in .chat-collapse-bar-title */
.text-direction-arabic {
    display: inline-block;
}

.text-direction-latin {
    display: inline-block;
}

/* Maximized State - Fullscreen Overlay */
.chat-panel.maximized {
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    z-index: 10000 !important;
    /* Above everything */
}

/* Hide collapse bar when maximized */
.chat-panel.maximized .chat-collapse-bar {
    display: none !important;
}

/* Hide old floating launcher */
.chat-launcher {
    display: none !important;
}

/* Window Controls Row - X left, drag handle center, maximize right */
.chat-window-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0;
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 8px;
    /* Added padding for breathing room */
    direction: ltr;
    position: relative;
    min-height: 44px;
    /* Industry-standard touch target height */
}

/* Drag handle in center - more prominent */
.chat-window-controls::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 3px;
    pointer-events: none;
}

/* Close button styling - Match maximize button */
.chat-close-btn {
    background: transparent !important;
}

.chat-close-btn:hover {
    background: #2f4356 !important;
}

/* Right-side panel: controls stay same order (maximize left, close right) */
.chat-panel.position-right .chat-window-controls {
    justify-content: space-between;
}

/* Window control buttons - 44x44px touch targets (Apple HIG standard) */
.chat-win-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    border-radius: 8px;
}

.chat-win-btn svg {
    width: 20px;
    height: 20px;
}

.chat-win-btn:hover {
    background: #2f4356;
}

/* Header - Compact layout with stars inline */
.chat-header {
    padding: 12px 5px 12px 16px;
    background: var(--chatbot-header-bg, linear-gradient(135deg, #f39c12, #d35400));
    color: white;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 10;
    min-height: 60px;
    overflow: visible;
}

/* Title with stars inline */
.chat-title {
    font-family: var(--font-headings, 'Cairo', sans-serif);
    font-weight: 700;
    font-size: 1.1em;
    flex-shrink: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Stars inline with title */
.chat-title::before {
    content: '✨';
    display: inline-block;
    font-size: 1.1em;
    line-height: 1;
    flex-shrink: 0;
}

/* Action Buttons */
.chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: nowrap;
    overflow: visible;
    position: relative;
}

.chat-action-btn {
    width: 40px;
    height: 40px;
    padding: 10px;
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.chat-action-btn svg {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px;
    min-height: 24px;
}

/* Font Size Controls */
.chat-font-size-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-inline-end: 6px;
    padding: 4px 8px;
    background: transparent;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-font-size-controls:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.6);
}

.chat-font-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    width: auto;
    min-width: 20px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0 4px;
    line-height: 1;
}

.chat-font-btn:hover {
    transform: scale(1.15);
    opacity: 0.8;
}

.chat-font-letter {
    color: white;
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-headings, 'Cairo', sans-serif);
    user-select: none;
    padding: 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    line-height: 1;
}

/* Settings Dropdown */
.chat-settings-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--bg-color, #ffffff);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    padding: 4px 0;
    z-index: 99999 !important;
    display: none;
    min-width: 240px;
}

.chat-settings-dropdown.active {
    display: block !important;
}

.chat-settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-settings-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.chat-settings-item span {
    font-size: 14px;
    color: var(--text-color, #333);
    font-weight: 500;
}

.chat-settings-item svg {
    width: 18px;
    height: 18px;
    color: var(--text-color, #666);
}

.chat-settings-divider {
    height: 1px;
    background: var(--border-color, rgba(0,0,0,0.1));
    margin: 4px 0;
}

.cross-book-menu-toggle {
    cursor: pointer;
}

/* Font controls in dropdown */
.chat-settings-item .chat-font-size-controls {
    border-color: var(--border-color, #ccc);
    margin: 0;
}

.chat-settings-dropdown .chat-font-btn {
    color: var(--text-color, #333);
}

.chat-settings-dropdown .chat-font-letter {
    color: var(--text-color, #333);
}

/* Extra compact for very narrow screens */
@media (max-width: 380px) {
    .chat-header {
        padding: 3px 4px !important;
        gap: 1px !important;
    }

    .chat-title {
        font-size: 0.75em !important;
        padding-left: 22px !important;
        max-width: 90px !important;
    }

    .chat-header::before {
        font-size: 1em !important;
        left: 4px !important;
    }

    .chat-action-btn {
        width: 22px !important;
        height: 22px !important;
    }

    .chat-action-btn svg {
        width: 11px !important;
        height: 11px !important;
    }

    .chat-font-size-controls {
        padding: 1px 2px !important;
    }

    .chat-font-btn {
        font-size: 12px !important;
        min-width: 12px !important;
        height: 18px !important;
    }

    .chat-font-letter {
        font-size: 10px !important;
        min-width: 10px !important;
    }
}

/* Tooltips for font size controls group */
.chat-font-size-controls[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 30, 30, 0.95);
    color: white;
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 10010;
    font-family: var(--font-content, sans-serif);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.chat-font-size-controls[data-tooltip]::before {
    content: '';
    position: absolute;
    top: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: rgba(30, 30, 30, 0.95);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 10010;
}

.chat-font-size-controls:hover[data-tooltip]::after,
.chat-font-size-controls:hover[data-tooltip]::before {
    opacity: 1;
    visibility: visible;
}

.chat-action-btn {
    background: transparent;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    color: white;
    cursor: pointer;
    border-radius: 6px;
    width: 26px !important;
    height: 26px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
    flex-shrink: 0;
}

.chat-action-btn svg {
    width: 13px !important;
    height: 13px !important;
}

.chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.05);
}

/* CSS Tooltips - positioned below buttons */
.chat-action-btn[aria-label]::after {
    content: attr(aria-label);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 30, 30, 0.95);
    color: white;
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 10010;
    font-family: var(--font-content, sans-serif);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

/* Tooltip arrow */
.chat-action-btn[aria-label]::before {
    content: '';
    position: absolute;
    top: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: rgba(30, 30, 30, 0.95);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 10010;
}

.chat-action-btn:hover::after,
.chat-action-btn:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Chat Body Container */
.chat-body-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 0 0 20px 20px;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    background: rgba(0, 0, 0, 0.02);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

[data-theme="dark"] .chat-messages {
    background: rgba(255, 255, 255, 0.02);
}

/* Message Bubbles - Modern Wide Design */
.chat-message {
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 95%;
    /* Increased from 85% to use more space */
    font-size: 0.95em;
    line-height: 1.6;
    position: relative;
    font-family: var(--font-content, sans-serif);
    animation: messageIn 0.3s ease-out;
    margin-bottom: 8px;
    /* Slight separation */
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

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

/* User Message - Right Side (RTL Start) */
.chat-message.user {
    background: linear-gradient(135deg, var(--chatbot-user-bubble-color, #f39c12), var(--chatbot-secondary-color, #e67e22));
    color: white;
    align-self: flex-start;
    /* In RTL flex-container this is Right */
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(243, 156, 18, 0.2);
    margin-left: auto;
    /* Push to right just in case */
    max-width: 90%;
}

/* Bot Message - Left Side (RTL End) / Full Width preference */
.chat-message.bot {
    background: var(--chatbot-bot-bubble-color, #ffffff);
    border: 1px solid rgba(0, 0, 0, 0.05);
    color: var(--text-color, #333);
    align-self: flex-end;
    /* In RTL this is Left */
    /* Make bot message nearly full width for reading comfort */
    width: 98%;
    max-width: 100%;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

/* Dark Mode Support */
[data-theme="dark"] .chat-message.bot {
    background: #2c3e50;
    border-color: rgba(255, 255, 255, 0.1);
    color: #ecf0f1;
}

[data-theme="dark"] .chat-window {
    background: #1a1a1a;
    border-color: rgba(255, 255, 255, 0.1);
}

/* Markdown Styling inside Bubbles */
.chat-message.bot strong {
    color: var(--chatbot-primary-color, #e67e22);
}

.chat-message.bot ul {
    margin: 8px 0;
    padding-right: 20px;
}

.chat-message.bot li {
    margin-bottom: 4px;
}

/* Input Area */
.chat-input-area {
    padding: 15px;
    background: var(--bg-color, #ffffff);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    gap: 10px;
    align-items: flex-end;
    border-radius: 0 0 20px 20px;
}

[data-theme="dark"] .chat-input-area {
    background: #1a1a1a;
    border-color: rgba(255, 255, 255, 0.1);
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    resize: none;
    height: 44px;
    max-height: 100px;
    font-family: inherit;
    font-size: 0.95em;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: rgba(0, 0, 0, 0.02);
    overflow-y: auto;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

/* Hide scrollbar for Chrome/Safari */
.chat-input::-webkit-scrollbar {
    display: none;
}

[data-theme="dark"] .chat-input {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.chat-input:focus {
    border-color: var(--chatbot-primary-color, #f39c12);
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.15);
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-primary-color, #f39c12), var(--chatbot-secondary-color, #d35400));
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(243, 156, 18, 0.3);
}

.chat-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.4);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: default;
    transform: none;
    box-shadow: none;
}

/* Keep send arrow pointing in send direction in RTL */
[dir="rtl"] .chat-send-btn {
    transform: scaleX(-1);
}

[dir="rtl"] .chat-send-btn:hover {
    transform: scaleX(-1) scale(1.08);
}

/* Typing Indicator */
.typing-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    margin: 0 2px;
    opacity: 0.4;
    animation: typing 1s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

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

    50% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* History View Layer */
.history-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color, #ffffff);
    z-index: 10;
    flex-direction: column;
    display: none;
    animation: fadeIn 0.3s;
}

.history-view.active {
    display: flex;
}

[data-theme="dark"] .history-view {
    background: #1a1a1a;
}

.history-header {
    padding: 15px;
    font-weight: bold;
    color: var(--chatbot-primary-color, #f39c12);
    border-bottom: 2px solid rgba(0, 0, 0, 0.05);
    font-family: var(--font-headings, 'Cairo', sans-serif);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

/* History Items */
.history-item {
    padding: 12px;
    margin-bottom: 8px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
    border-right: 3px solid transparent;
}

[data-theme="dark"] .history-item {
    background: rgba(255, 255, 255, 0.05);
}

.history-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .history-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.history-item.current {
    background: rgba(243, 156, 18, 0.1);
    border-right-color: var(--chatbot-primary-color, #f39c12);
}

.history-date {
    font-size: 0.8em;
    color: #888;
    margin-bottom: 4px;
}

.history-preview {
    font-size: 0.95em;
    color: var(--text-color, #333);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

[data-theme="dark"] .history-preview {
    color: #ecf0f1;
}

.empty-history {
    text-align: center;
    padding: 40px 20px;
    color: #888;
    font-style: italic;
}

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

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

/* Mobile Responsive */
@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 80px;
        height: 70vh;
        border-radius: 16px;
    }

    .chat-window-controls {
        border-radius: 16px 16px 0 0;
    }

    .chat-body-container {
        border-radius: 0 0 16px 16px;
    }

    .chat-launcher {
        right: 15px;
        bottom: 15px;
        width: 54px;
        height: 54px;
    }

    /* Mobile maximized - nearly full screen with small margin */
    .chat-window.maximized {
        width: calc(100vw - 16px);
        height: calc(100vh - 16px);
        right: 50%;
        bottom: 8px;
        transform: translateX(50%) scale(1);
        border-radius: 12px;
    }

    .chat-window.maximized .chat-window-controls {
        border-radius: 12px 12px 0 0;
    }
}

/* Chatbot header and button contrast fix */
.chat-header {
    background: var(--chatbot-header-bg, linear-gradient(135deg, #2c3e50, #34495e)) !important;
}

.chat-send-btn {
    background: linear-gradient(135deg, var(--chatbot-primary-color, #f39c12), var(--chatbot-secondary-color, #d35400)) !important;
}

.chat-send-btn svg {
    transform: scaleX(-1) !important;
}

/* Flip expand arrow for proper direction */
/* Default (left panel LTR): arrow points right (>) to indicate "open" */
.chat-expand-btn svg {
    transform: scaleX(1);
}

/* RTL with left panel: arrow should ALSO point right (>) to indicate "open" - NO FLIP */
/* (The default scaleX(1) already shows right arrow, so no override needed) */

/* When panel is on right side (LTR): arrow points left (<) to indicate "open" */
.chat-panel.position-right .chat-expand-btn svg {
    transform: scaleX(1);
}

/* RTL with right panel: arrow points right (>) to indicate "open" */
[dir="rtl"] .chat-panel.position-right .chat-expand-btn svg {
    transform: scaleX(1);
}

/* Window controls bar styling */
.chat-window-controls {
    background: var(--chatbot-controls-bg, #f39c12) !important;
}

[data-theme="dark"] .chat-window-controls {
    background: var(--chatbot-controls-bg, #0d1117) !important;
}

/* Sepia Theme Support */
[data-theme="sepia"] .chat-panel {
    background: #f4ecd8;
    border-color: #d4c8b4;
}

[data-theme="sepia"] .chat-messages {
    background: #faf7f0;
}

[data-theme="sepia"] .chat-message.bot {
    background: #e8dcc8;
    border-color: #d4c8b4;
    color: #5c4b37;
}

[data-theme="sepia"] .chat-window {
    background: #f4ecd8;
    border-color: #d4c8b4;
}

[data-theme="sepia"] .chat-input-area {
    background: #f4ecd8;
    border-color: #d4c8b4;
}

[data-theme="sepia"] .chat-input {
    background: #faf7f0;
    border-color: #d4c8b4;
    color: #5c4b37;
}

[data-theme="sepia"] .history-view {
    background: #f4ecd8;
}

[data-theme="sepia"] .history-item {
    background: #e8dcc8;
}

[data-theme="sepia"] .history-item:hover {
    background: #ddd0b8;
}

[data-theme="sepia"] .history-preview {
    color: #5c4b37;
}

[data-theme="sepia"] .chat-window-controls {
    background: var(--chatbot-controls-bg, #8b6914) !important;
}

/* High Contrast Theme Support */
[data-theme="high-contrast"] .chat-panel {
    background: #000000;
    border-color: #ffffff;
    border-width: 2px;
}

[data-theme="high-contrast"] .chat-messages {
    background: #000000;
}

[data-theme="high-contrast"] .chat-message.bot {
    background: #1a1a1a;
    border-color: #ffffff;
    color: #ffffff;
}

[data-theme="high-contrast"] .chat-window {
    background: #000000;
    border-color: #ffffff;
}

[data-theme="high-contrast"] .chat-input-area {
    background: #000000;
    border-color: #ffffff;
}

[data-theme="high-contrast"] .chat-input {
    background: #1a1a1a;
    border-color: #ffffff;
    color: #ffffff;
}

[data-theme="high-contrast"] .history-view {
    background: #000000;
}

[data-theme="high-contrast"] .history-item {
    background: #1a1a1a;
    border: 1px solid #ffffff;
}

[data-theme="high-contrast"] .history-item:hover {
    background: #333333;
}

[data-theme="high-contrast"] .history-preview {
    color: #ffffff;
}

[data-theme="high-contrast"] .chat-window-controls {
    background: var(--chatbot-controls-bg, #00ff00) !important;
}


/* Registration Prompt Styles */
.chat-message.registration-wall {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 16px;
    margin: 10px;
}

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

.prompt-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.prompt-message {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
}

.prompt-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.prompt-btn {
    display: block;
    padding: 12px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
}

.prompt-btn.primary {
    background: white;
    color: #764ba2;
}

.prompt-btn.primary:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
}

.prompt-btn.secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.prompt-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Usage Warning */
.chat-usage-warning {
    text-align: center;
    padding: 8px 12px;
    margin: 5px 10px;
    background: #fff3cd;
    color: #856404;
    border-radius: 8px;
    font-size: 12px;
}

.chat-usage-warning small {
    display: block;
}


/* Clarify Modal Registration Prompt */
.clarify-registration-prompt {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
}

.clarify-registration-prompt .prompt-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.clarify-registration-prompt .prompt-message {
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: 20px;
}

.clarify-registration-prompt .prompt-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.clarify-registration-prompt .prompt-btn {
    display: block;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
}

.clarify-registration-prompt .prompt-btn.primary {
    background: white;
    color: #764ba2;
}

.clarify-registration-prompt .prompt-btn.primary:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
}

.clarify-registration-prompt .prompt-btn.secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.clarify-registration-prompt .prompt-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.3);
}


/* ========================================
   MOBILE RESPONSIVE CHATBOT STYLES
   ======================================== */

/* Tablet Breakpoint (768px - 1024px) */
@media (max-width: 1024px) {
    .chat-panel {
        width: 320px;
    }

    .chat-panel.collapsed {
        width: var(--chat-collapsed-width);
    }

    .chat-panel.maximized {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        max-width: none !important;
    }
}

/* Mobile Breakpoint (below 860px) */
@media (max-width: 860px) {

    /* Mobile-specific header adjustments */
    .chat-header {
        padding: 10px 10px 10px 12px;
        gap: 12px;
        min-height: 56px;
    }

    /* Mobile-specific title - larger font, no wrap */
    .chat-title {
        font-size: 1.15em !important;
        line-height: 1 !important;
        white-space: nowrap !important;
        overflow: visible !important;
        text-overflow: clip !important;
        flex-shrink: 0 !important;
        flex-grow: 1 !important;
        max-width: none !important;
    }

    /* Mobile action buttons - slightly smaller */
    .chat-action-btn {
        width: 38px;
        height: 38px;
        padding: 9px;
    }

    .chat-action-btn svg {
        width: 20px !important;
        height: 20px !important;
    }

    /* Hide desktop collapse arrow icon on mobile */
    .chat-win-btn.chat-close-btn svg {
        display: none !important;
    }

    /* Show X icon on mobile using CSS - smaller size */
    .chat-win-btn.chat-close-btn::before {
        content: '×';
        /* Use small multiplication sign instead of heavy X */
        font-size: 18px;
        font-weight: 300;
        line-height: 1;
    }

    /* Remove background from restore button when maximized */
    .chat-panel.maximized .chat-win-btn {
        background: transparent !important;
    }

    .chat-panel.maximized .chat-win-btn:hover {
        background: rgba(255, 255, 255, 0.1) !important;
    }

    /* Hide print button on narrow mobile screens to save space */
    #btn-print-chat {
        display: none !important;
    }

    /* Chat Panel - Transform to slide-up overlay */
    .chat-panel:not(.force-desktop) {
        position: fixed;
        left: 0 !important;
        right: 0 !important;
        bottom: 0;
        top: auto !important;
        width: 100% !important;
        height: 70vh;
        max-height: calc(100vh - var(--header-height, 70px) - 20px);
        border-radius: 20px 20px 0 0;
        border: none;
        border-top: 1px solid var(--border-color, #e0e0e0);
        box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.2);
        transform: translateY(100%);
        transition: transform 0.3s ease, height 0.3s ease;
        z-index: 2000;
    }

    /* Right position override for mobile */
    .chat-panel.position-right:not(.force-desktop) {
        left: 0 !important;
        right: 0 !important;
    }

    /* Show chat panel when expanded (not collapsed) */
    .chat-panel:not(.collapsed):not(.force-desktop) {
        transform: translateY(0);
    }

    /* Collapsed state - show as floating button */
    .chat-panel.collapsed:not(.force-desktop) {
        width: 60px !important;
        height: 60px !important;
        top: auto !important;
        /* Override desktop top positioning */
        bottom: 20px;
        left: auto !important;
        right: 20px !important;
        border-radius: 50%;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        transform: translateY(0);
        overflow: hidden;
    }

    /* RTL: Move FAB to left side */
    [dir="rtl"] .chat-panel.collapsed:not(.force-desktop) {
        right: auto !important;
        left: 20px !important;
    }

    /* Collapsed bar becomes circular FAB */
    .chat-panel.collapsed .chat-collapse-bar {
        width: 60px;
        height: 60px;
        border-radius: 50%;
        padding: 0;
        justify-content: center;
        align-items: center;
    }

    .chat-panel.collapsed .chat-collapse-bar-title {
        display: none;
    }

    .chat-panel.collapsed .chat-expand-btn {
        width: 100%;
        height: 100%;
        margin: 0;
        background: transparent;
        border-radius: 50%;
    }

    .chat-panel.collapsed .chat-expand-btn svg {
        width: 28px;
        height: 28px;
        transform: none !important;
    }

    /* Replace arrow with chat icon on mobile FAB */
    .chat-panel.collapsed .chat-expand-btn svg {
        display: block !important;
        width: 28px;
        height: 28px;
    }

    /* Chat bubble SVG icon for mobile FAB */
    @media (max-width: 860px) {
        .chat-panel.collapsed .chat-expand-btn svg {
            /* Show SVG chat bubble icon */
        }
    }

    /* Maximized state on mobile - full screen */
    .chat-panel.maximized {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100dvh !important;
        height: 100vh !important; /* fallback for older browsers */
        max-height: 100dvh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        transform: translateY(0) !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* Ensure body container doesn't overflow in maximized state */
    .chat-panel.maximized .chat-body-container {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    /* Ensure messages area is scrollable */
    .chat-panel.maximized .chat-messages {
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        min-height: 0 !important;
    }

    /* Ensure input area stays at bottom */
    .chat-panel.maximized .chat-input-area {
        flex: 0 0 auto !important;
        position: sticky !important;
        bottom: 0 !important;
        z-index: 10 !important;
        padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
    }

    /* Window controls adjustments */
    .chat-window-controls {
        border-radius: 20px 20px 0 0;
        padding: 4px 8px;
    }

    .chat-panel.maximized .chat-window-controls {
        border-radius: 0;
    }

    /* Add drag handle indicator */
    .chat-window-controls::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
    }

    /* Header adjustments */
    .chat-header {
        padding: 10px 16px;
    }

    .chat-title {
        font-size: 1rem;
    }

    /* Messages area */
    .chat-messages {
        padding: 15px;
        gap: 12px;
    }

    .chat-message {
        max-width: 90%;
        font-size: 0.9em;
        padding: 10px 14px;
    }

    .chat-message.bot {
        width: 95%;
    }

    /* Input area */
    .chat-input-area {
        padding: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        border-radius: 0;
    }

    .chat-input {
        padding: 10px 14px;
        font-size: 16px;
        /* Prevent iOS zoom */
    }

    .chat-send-btn {
        width: 40px;
        height: 40px;
    }

    .chat-illustrate-btn {
        width: 40px;
        height: 40px;
    }

    /* History view */
    .history-header {
        padding: 12px;
    }

    .history-item {
        padding: 10px;
    }
}

/* Small Mobile (below 480px) */
@media (max-width: 480px) {
    .chat-panel {
        height: 80vh;
    }

    .chat-panel.collapsed {
        width: 56px !important;
        height: 56px !important;
        bottom: 16px;
        right: 16px !important;
    }

    [dir="rtl"] .chat-panel.collapsed {
        left: 16px !important;
    }

    .chat-panel.collapsed .chat-collapse-bar {
        width: 56px;
        height: 56px;
    }

    .chat-panel.collapsed .chat-expand-btn::before {
        font-size: 24px;
    }

    .chat-message {
        font-size: 0.85em;
        padding: 8px 12px;
    }

    .chat-input {
        padding: 8px 12px;
    }

    .chat-send-btn {
        width: 36px;
        height: 36px;
    }

    .chat-illustrate-btn {
        width: 36px;
        height: 36px;
    }
}

/* Mobile Overlay Background */
@media (max-width: 860px) {
    .chat-panel-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1999;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .chat-panel-overlay.active {
        display: block;
        opacity: 1;
    }
}

/* Landscape Mobile */
@media (max-width: 860px) and (orientation: landscape) {
    .chat-panel {
        height: 90vh;
        max-height: calc(100vh - 20px);
    }

    .chat-panel.maximized {
        height: 100dvh;
        height: 100vh;
        max-height: 100dvh;
        max-height: 100vh;
    }
}

/* Safe area support for notched devices */
@supports (padding: max(0px)) {
    @media (max-width: 860px) {
        .chat-input-area {
            padding-bottom: max(12px, env(safe-area-inset-bottom));
        }

        .chat-panel.collapsed {
            bottom: max(20px, calc(env(safe-area-inset-bottom) + 10px));
        }
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .chat-panel {
        transition: none;
    }

    .chat-message {
        animation: none;
    }
}

/* ===== Mobile Chat Header Refinements (Industry-Standard UX) ===== */
@media (max-width: 860px) {
    .chat-header {
        padding: 12px 16px 12px 16px;
        /* +10px right padding */
        gap: 12px;
        /* Tighter gap for mobile */
        min-height: 56px;
    }

    /* Prevent title truncation on mobile - show full name */
    .chat-title {
        font-size: 1em;
        white-space: nowrap;
        overflow: visible;
        /* Allow full name to show */
        text-overflow: clip;
        flex-shrink: 0;
        /* Don't shrink the title */
        max-width: none;
        /* Remove max-width constraint */
    }

    /* Industry-standard touch target: 44x44px minimum */
    .chat-action-btn {
        width: 36px !important;
        height: 36px !important;
        border-radius: 8px;
    }

    .chat-action-btn svg {
        width: 18px !important;
        height: 18px !important;
    }

    /* Optimal button spacing: 12px (Apple HIG / Material Design) */
    .chat-actions {
        gap: 12px;
    }

    /* Font controls slightly larger for touch */
    .chat-font-size-controls {
        padding: 6px 10px;
    }

    .chat-font-btn {
        min-width: 24px;
        height: 28px;
        font-size: 15px;
    }
}

/* ========================================
   RTL SPECIFIC OVERRIDES
   ======================================== */

/* Fix Dropdown positioning in RTL */
[dir="rtl"] .chat-settings-dropdown {
    right: auto;
    left: 0;
}

/* Swap window control buttons order in RTL */
[dir="rtl"] .chat-window-controls {
    flex-direction: row-reverse;
}


/* ===== Cross-Book Chat Toggle ===== */

.chat-cross-book-bar {
    display: flex;
    align-items: center;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    transition: background 0.2s;
}

.chat-cross-book-bar.active {
    background: rgba(99, 102, 241, 0.08);
    border-bottom-color: rgba(99, 102, 241, 0.2);
}

.cross-book-chat-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    color: #666;
    user-select: none;
    transition: color 0.2s;
}

.chat-cross-book-bar.active .cross-book-chat-toggle {
    color: var(--chatbot-primary-color, #6366f1);
    font-weight: 500;
}

.cross-book-chat-toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--chatbot-primary-color, #6366f1);
    cursor: pointer;
    margin: 0;
}

.cross-book-icon {
    font-size: 0.85rem;
    line-height: 1;
}

.cross-book-label {
    white-space: nowrap;
}

/* Dark theme */
[data-theme="dark"] .chat-cross-book-bar {
    background: rgba(255, 255, 255, 0.03);
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .chat-cross-book-bar.active {
    background: rgba(99, 102, 241, 0.15);
    border-bottom-color: rgba(99, 102, 241, 0.3);
}

[data-theme="dark"] .cross-book-chat-toggle {
    color: #aaa;
}

/* ===== Follow-up Question Buttons ===== */
.chat-followup-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(128, 128, 128, 0.15);
}

.chat-followup-btn {
    background: rgba(99, 102, 241, 0.08);
    color: var(--chatbot-primary-color, #6366f1);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 18px;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: start;
    line-height: 1.4;
    max-width: 100%;
}

.chat-followup-btn:hover {
    background: rgba(99, 102, 241, 0.18);
    border-color: var(--chatbot-primary-color, #6366f1);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.2);
}

.chat-followup-btn:active {
    transform: translateY(0);
}

[data-theme="dark"] .chat-followup-btn {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.35);
    color: #a5b4fc;
}

[data-theme="dark"] .chat-followup-btn:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: #818cf8;
}

/* ===== Illustrate Scene Button ===== */
.chat-illustrate-btn {
    background: none;
    border: 2px solid rgba(0, 0, 0, 0.1);
    color: var(--chatbot-primary-color, #818cf8);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    transition: background 0.2s, opacity 0.2s, border-color 0.2s;
    flex-shrink: 0;
    line-height: 1;
    opacity: 0.7;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
}

.chat-illustrate-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    opacity: 1;
}

[data-theme="dark"] .chat-illustrate-btn {
    border-color: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .chat-illustrate-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}
[data-theme="sepia"] .chat-illustrate-btn {
    border-color: #d4c8b4;
}
[data-theme="sepia"] .chat-illustrate-btn:hover {
    background: rgba(212, 200, 180, 0.2);
}
[data-theme="high-contrast"] .chat-illustrate-btn {
    border-color: #ffffff;
}
[data-theme="high-contrast"] .chat-illustrate-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ===== Scene Selector (after AI lists scenes) ===== */
.chat-scene-selector {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(128, 128, 128, 0.15);
}

.scene-selector-label {
    font-size: 0.82rem;
    color: var(--text-secondary, #666);
    margin: 0 0 8px 0;
    font-weight: 500;
}

.scene-selector-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-scene-btn {
    background: rgba(232, 121, 249, 0.08);
    color: #c026d3;
    border: 1px solid rgba(232, 121, 249, 0.25);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: start;
    line-height: 1.4;
}

.chat-scene-btn:hover {
    background: rgba(232, 121, 249, 0.18);
    border-color: #c026d3;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(232, 121, 249, 0.2);
}

.chat-scene-btn:active {
    transform: translateY(0);
}

[data-theme="dark"] .chat-scene-btn {
    background: rgba(232, 121, 249, 0.12);
    border-color: rgba(232, 121, 249, 0.35);
    color: #e879f9;
}

[data-theme="dark"] .chat-scene-btn:hover {
    background: rgba(232, 121, 249, 0.25);
    border-color: #e879f9;
}

/* Author toggle checkbox in scene selector */
.scene-author-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary, #888);
    margin-bottom: 8px;
    cursor: pointer;
}
.scene-author-toggle input[type="checkbox"] {
    accent-color: #c026d3;
    width: 14px;
    height: 14px;
}

/* "Illustrate full chapter" button */
.chat-scene-btn-all {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
    border-color: rgba(99, 102, 241, 0.3);
    font-weight: 600;
    margin-top: 4px;
}
.chat-scene-btn-all:hover {
    background: rgba(99, 102, 241, 0.22);
    border-color: #6366f1;
}
[data-theme="dark"] .chat-scene-btn-all {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border-color: rgba(99, 102, 241, 0.4);
}

/* ===== Illustration Progress Tracker ===== */
.illustration-progress {
    padding: 10px 0;
}
.illustration-progress-label {
    font-size: 0.82rem;
    color: var(--text-secondary, #888);
    margin-bottom: 6px;
}
.illustration-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(128,128,128,0.15);
    border-radius: 3px;
    overflow: hidden;
}
.illustration-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #c026d3, #6366f1);
    border-radius: 3px;
    transition: width 0.4s ease;
    width: 0%;
}
.illustration-progress-status {
    font-size: 0.75rem;
    color: var(--text-secondary, #999);
    margin-top: 4px;
}

/* ===== Story Slider (Fullscreen) ===== */
.story-slider-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(0,0,0,0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.story-slider-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    z-index: 2;
}
.story-slider-counter {
    color: #fff;
    font-size: 0.85rem;
    opacity: 0.8;
}
.story-slider-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.story-slider-close:hover { background: rgba(255,255,255,0.25); }
.story-slider-img-container {
    flex: 1;
    display: flex;
    touch-action: pan-x pan-y pinch-zoom;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 50px 0;
}
.story-slider-img-container.zoomed {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 0;
}
.story-slider-img-container.zoomed img {
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
    max-width: 200%;
    cursor: zoom-out;
}
.story-slider-img-container img {
    max-width: 100%;
    max-height: none;
    cursor: zoom-in;
    transition: transform 0.2s ease;
    object-fit: contain;
    border-radius: 8px;
}
.story-slider-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
.story-slider-nav:hover { background: rgba(255,255,255,0.25); }
.story-slider-prev { left: 12px; }
.story-slider-next { right: 12px; }
.story-slider-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 16px;
    z-index: 2;
}
.story-slider-save {
    background: linear-gradient(135deg, #c026d3, #6366f1);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 8px 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
}
.story-slider-save:hover { opacity: 0.9; }
.story-slider-save:active {
    transform: scale(0.92);
    opacity: 0.8;
}
.story-slider-save.saved {
    background: linear-gradient(135deg, #10b981, #059669);
    pointer-events: none;
}
.story-slider-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}
.story-slider-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transition: all 0.2s;
}
.story-slider-dot.active {
    background: #fff;
    width: 18px;
    border-radius: 3px;
}

/* ===== Story Scroll Layout (vertical panels — mirrors story.php) ===== */
.story-scroll-overlay {
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    background: #0f0f1a;
}
.story-scroll-header {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(15, 15, 26, 0.97);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(8px);
}
.story-scroll-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.story-scroll-body {
    max-width: 800px;
    margin: 20px auto;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.story-scroll-panel {
    border-radius: 12px;
    overflow: hidden;
    background: #1a1a2e;
    border: 1px solid rgba(255,255,255,0.08);
}
.story-scroll-panel img {
    width: 100%;
    display: block;
    cursor: zoom-in;
}
.story-scroll-caption {
    padding: 10px 14px;
    font-size: 0.85rem;
    color: #aaa;
    display: flex;
    align-items: center;
    gap: 8px;
}
.story-scroll-num {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}
.story-scroll-footer {
    position: sticky;
    bottom: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    background: rgba(15, 15, 26, 0.97);
    border-top: 1px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(8px);
}

/* ===== Story Thumbnails (Desktop: 70×70 next to hamburger, Mobile: 50×50 in actions panel) ===== */

/* Desktop: row of up to 4 thumbnails next to hamburger */
.story-thumbs-desktop {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 6px;
}

.story-thumb-btn {
    width: 70px;
    height: 70px;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    border-radius: 50%;
    transition: transform 0.2s;
}
.story-thumb-btn:hover {
    transform: scale(1.08);
}
.story-thumb-ring {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1px solid #fff;
    padding: 1px;
    overflow: hidden;
    position: relative;
}
.story-thumb-ring img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 25%;
    border-radius: 50%;
    display: block;
}
.story-thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--header-bg, #2c3e50);
    font-size: 1.4rem;
}

/* ===== Story Zoom Overlay (simple fullscreen image view) ===== */
.story-zoom-overlay {
    position: fixed;
    inset: 0;
    z-index: 10002;
    background: rgba(0,0,0,0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}
.story-zoom-overlay img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
}
.story-zoom-overlay .zoom-close {
    position: fixed;
    top: 12px;
    right: 16px;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10003;
}

/* Mobile: horizontal scrollable strip inside the mobile-actions-panel */
.story-strip-mobile {
    display: none;
    width: 100%;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
/* LOCKED: Mobile/tablet breakpoint is 965px */
@media (max-width: 965px) {
    .story-strip-mobile { display: block; }
    .story-thumbs-desktop { display: none !important; }
}
@media (min-width: 966px) {
    .story-strip-mobile { display: none !important; }
}
.story-strip-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px 0;
    justify-content: center;
}
.story-strip-scroll::-webkit-scrollbar { display: none; }

.story-thumb-btn.mobile {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}
.story-thumb-btn.mobile .story-thumb-ring {
    border-radius: 50%;
    border-width: 2px;
}
.story-thumb-btn.mobile .story-thumb-ring img {
    border-radius: 50%;
}
.story-thumb-btn.mobile .story-thumb-placeholder {
    border-radius: 50%;
    font-size: 1.1rem;
}

/* Input area layout with illustrate button */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

/* ===== Illustration History Cards ===== */
.chat-illustration-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-secondary, rgba(255,255,255,0.05));
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 10px;
}
.chat-illustration-card-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
}
.chat-illustration-card-text {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-primary, #fff);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-illustration-card-btn {
    background: linear-gradient(135deg, #c026d3, #6366f1);
    color: #fff;
    border: none;
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 0.75rem;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}
.chat-illustration-card-btn:hover { opacity: 0.85; }
.chat-illustration-card-btn:disabled { opacity: 0.5; cursor: default; }

/* ===== Illustration Loading ===== */
.illustration-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 0.85rem;
    color: var(--text-secondary, #888);
}

.illustration-loading-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(99, 102, 241, 0.2);
    border-top-color: var(--chatbot-primary-color, #6366f1);
    border-radius: 50%;
    animation: illustrate-spin 0.8s linear infinite;
}

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

/* ===== Illustration Image in Chat ===== */
.chat-illustration {
    display: flex;
    flex-direction: column;
}

.chat-illustration-img {
    max-width: 100%;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.chat-illustration-img:hover {
    opacity: 0.9;
}

.chat-illustration-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary, #888);
}

.chat-illustration-expand {
    background: rgba(99, 102, 241, 0.1);
    color: var(--chatbot-primary-color, #6366f1);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.chat-illustration-expand:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--chatbot-primary-color, #6366f1);
}

/* ===== Fullscreen Image Overlay ===== */
.chat-image-overlay {
    position: fixed;
    inset: 0;
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-image-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    cursor: pointer;
}

.chat-image-overlay-content {
    position: relative;
    width: 94vw;
    height: 94vh;
    display: flex;
    flex-direction: column;
    background: #1a1a2e;
    border-radius: 12px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 12px 60px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.chat-image-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.chat-image-overlay-caption {
    color: #e0e0e0;
    font-size: 0.9rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-image-overlay-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.chat-image-overlay-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.chat-image-overlay-scroll {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: repeating-conic-gradient(rgba(255,255,255,0.03) 0% 25%, transparent 0% 50%) 0 0 / 20px 20px;
}
.chat-image-overlay-scroll.zoomed-in {
    cursor: grab;
    align-items: flex-start;
    justify-content: flex-start;
}
.chat-image-overlay-scroll.zoomed-in:active {
    cursor: grabbing;
}

.chat-image-overlay-scroll img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    cursor: zoom-in;
    transition: width 0.2s ease, height 0.2s ease;
    object-fit: contain;
}
.chat-image-overlay-scroll.zoomed-in img {
    max-width: none;
    max-height: none;
    cursor: zoom-out;
    flex-shrink: 0;
}

.chat-image-overlay-zoom-level {
    color: rgba(255,255,255,0.5);
    font-size: 0.75rem;
    font-family: monospace;
    margin-inline-end: 8px;
    flex-shrink: 0;
}

/* Custom scrollbar for the overlay */
.chat-image-overlay-scroll::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.chat-image-overlay-scroll::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
}

.chat-image-overlay-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
}

.chat-image-overlay-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* ===== Illustration Action Buttons (Share + Citation under each illustration) ===== */
.chat-illustration-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.chat-ill-cached-badge {
    font-size: 0.75rem;
    margin-inline-end: 3px;
    opacity: 0.7;
}
.chat-ill-regen {
    font-size: 0.7rem !important;
}
.chat-illustration-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(99, 102, 241, 0.08);
    color: var(--chatbot-primary-color, #6366f1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.72rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    white-space: nowrap;
}
.chat-illustration-action-btn:hover {
    background: rgba(99, 102, 241, 0.18);
    border-color: var(--chatbot-primary-color, #6366f1);
}
.chat-illustration-action-btn:disabled {
    opacity: 0.5;
    cursor: default;
}
.chat-illustration-action-btn svg {
    flex-shrink: 0;
}

/* ===== Story Slider Action Buttons (footer share/citation row) ===== */
.story-slider-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.story-slider-share-panel,
.story-slider-citation {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.story-slider-share-panel:hover,
.story-slider-citation:hover {
    background: rgba(255,255,255,0.25);
}
.story-slider-share-panel:disabled,
.story-slider-citation:disabled {
    opacity: 0.5;
    cursor: default;
}
.story-slider-share-story {
    background: linear-gradient(135deg, #c026d3, #6366f1);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    white-space: nowrap;
}
.story-slider-share-story:hover { opacity: 0.9; }
.story-slider-share-story:disabled { opacity: 0.5; cursor: default; }

/* ===== Citation Image Overlay ===== */
.chat-citation-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(0,0,0,0.88);
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-citation-modal {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.chat-citation-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.25);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: background 0.2s;
}
.chat-citation-close:hover { background: rgba(255,255,255,0.3); }
.chat-citation-img {
    max-width: 85vw;
    max-height: 70vh;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.chat-citation-actions {
    display: flex;
    gap: 10px;
}
.chat-citation-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #c026d3, #6366f1);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 10px 22px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    transition: all 0.2s;
}
.chat-citation-btn:hover { opacity: 0.9; transform: translateY(-1px); }

/* ===== Story Slider Delete Button ===== */
.story-slider-delete {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #ef4444;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.story-slider-delete:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: #ef4444;
}

/* ===== Story Slider Dots Bar (above canvas) ===== */
.story-slider-dots-bar {
    position: absolute;
    top: 44px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 4px;
    align-items: center;
    padding: 8px 0;
    z-index: 2;
}

/* ===== Consistent Action Icon Buttons ===== */
.story-slider-action-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.story-slider-action-icon:hover {
    background: rgba(255,255,255,0.25);
    transform: scale(1.08);
}
.story-slider-action-icon:disabled {
    opacity: 0.5;
    cursor: default;
    transform: none;
}
.story-slider-action-delete {
    border-color: rgba(239, 68, 68, 0.35);
    color: #ef4444;
}
.story-slider-action-delete:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
}

/* ===== Presentation Slider ===== */
.presentation-slider-overlay {
    background: rgba(15, 23, 42, 0.98);
}
.pres-slide-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 76px 80px 70px;
    width: 100%;
    max-width: 1200px;
    overflow-y: auto;
}
.pres-slide {
    width: 100%;
}
.pres-slide-title {
    font-size: 2.4rem;
    color: #818cf8;
    margin-bottom: 24px;
    padding-bottom: 14px;
    border-bottom: 2px solid #334155;
    font-weight: 700;
}
.pres-slide-body {
    display: flex;
    gap: 40px;
    align-items: flex-start;
}
.pres-slide-bullets {
    flex: 1;
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 1.35rem;
    line-height: 2.2;
    color: #cbd5e1;
}
.pres-slide-bullets li {
    padding: 4px 0;
}
.pres-slide-bullets li::before {
    content: '▸ ';
    color: #818cf8;
    font-weight: bold;
}
[dir=rtl] .pres-slide-bullets li::before {
    content: '◂ ';
}
.pres-slide-visual {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pres-slide-visual img {
    max-width: 100%;
    max-height: 50vh;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: transform 0.2s;
}
.pres-slide-visual img:hover {
    transform: scale(1.02);
}
.pres-gen-visual-btn {
    background: linear-gradient(135deg, #818cf8, #6366f1);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
    margin-top: 10px;
}
.pres-gen-visual-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}
.pres-gen-visual-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}
.chat-presentation-btn {
    /* Same base as .chat-illustrate-btn, just different icon */
}

/* Mobile adjustments for presentation */
@media (max-width: 768px) {
    .pres-slide-container {
        padding: 76px 16px 70px;
    }
    .pres-slide-title {
        font-size: 1.15rem;
        margin-bottom: 12px;
        padding-bottom: 8px;
    }
    .pres-slide-body {
        flex-direction: column;
        gap: 16px;
    }
    .pres-slide-bullets {
        font-size: 0.88rem;
        line-height: 1.8;
    }
    .pres-slide-visual {
        width: 100%;
    }
    .pres-slide-visual img {
        max-height: 28vh;
    }
}

/* ===== Presentation Progress Widget ===== */
.pres-progress-widget {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 1px solid #334155;
    border-radius: 16px;
    padding: 16px 20px;
    max-width: 100%;
}
.pres-progress-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.pres-progress-icon {
    font-size: 1.3rem;
}
.pres-progress-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #e2e8f0;
}
.pres-progress-bar-container {
    width: 100%;
    height: 6px;
    background: #334155;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 10px;
}
.pres-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #818cf8, #c084fc, #818cf8);
    background-size: 200% 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
    animation: pres-bar-shimmer 2s ease-in-out infinite;
}
@keyframes pres-bar-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.pres-progress-step {
    display: flex;
    align-items: center;
    gap: 8px;
}
.pres-progress-step-icon {
    font-size: 1.1rem;
    transition: all 0.3s;
}
.pres-progress-step-text {
    font-size: 0.85rem;
    color: #94a3b8;
}
.pres-step-fade {
    animation: presStepFadeIn 0.4s ease;
}
@keyframes presStepFadeIn {
    0% { opacity: 0; transform: translateY(4px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ===== Presentation Preview Cards (Dry Run in Chat) ===== */
.pres-preview-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    padding: 4px 0;
}
.pres-preview-card {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 10px 14px;
    transition: border-color 0.2s;
}
.pres-preview-card:hover {
    border-color: #818cf8;
}
.pres-preview-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.pres-preview-card-num {
    background: #818cf8;
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}
.pres-preview-card-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #e2e8f0;
    flex: 1;
}
.pres-preview-visual-badge {
    font-size: 0.8rem;
    flex-shrink: 0;
}
.pres-preview-card-bullets {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.8rem;
    color: #94a3b8;
    line-height: 1.6;
}
.pres-preview-card-bullets li::before {
    content: '• ';
    color: #64748b;
}
.pres-preview-more {
    color: #64748b;
    font-style: italic;
}
.pres-preview-more::before {
    content: '' !important;
}

/* ===== Presentation Fullscreen ===== */
.pres-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.pres-fullscreen-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.pres-fullscreen-btn:hover {
    background: rgba(129,140,248,0.3);
    border-color: #818cf8;
}
/* When in fullscreen, scale up but constrain overflow */
.presentation-slider-overlay:fullscreen {
    background: #0f172a;
}
.presentation-slider-overlay:fullscreen .pres-slide-container {
    padding: 70px 100px 80px;
    max-width: 100%;
    max-height: 100vh;
    overflow-y: auto;
}
.presentation-slider-overlay:fullscreen .pres-slide-title {
    font-size: clamp(1.4rem, 3vw, 2.6rem);
}
.presentation-slider-overlay:fullscreen .pres-slide-bullets {
    font-size: clamp(1rem, 1.8vw, 1.5rem);
}
.presentation-slider-overlay:fullscreen .pres-slide-visual img {
    max-height: 60vh;
}
/* Fullscreen on small screens */
@media (max-width: 768px) {
    .presentation-slider-overlay:fullscreen .pres-slide-container {
        padding: 76px 16px 70px;
    }
    .presentation-slider-overlay:fullscreen .pres-slide-title {
        font-size: clamp(0.95rem, 3.5vw, 1.2rem);
    }
    .presentation-slider-overlay:fullscreen .pres-slide-bullets {
        font-size: clamp(0.78rem, 2.5vw, 0.92rem);
        line-height: 1.8;
    }
    .presentation-slider-overlay:fullscreen .pres-slide-body {
        flex-direction: column;
        gap: 16px;
    }
    .presentation-slider-overlay:fullscreen .pres-slide-visual img {
        max-height: 28vh;
    }
}

/* ===== Saved Presentation Image Slider ===== */
.pres-saved-img-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    padding: 50px 60px 70px;
    flex-direction: column;
}
.pres-saved-img-wrap img {
    max-width: min(95vw, 1100px);
    max-height: 72vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.pres-saved-caption {
    color: #94a3b8;
    margin-top: 14px;
    font-size: 0.95rem;
    text-align: center;
    max-width: 80%;
}
/* Saved slider fullscreen */
.presentation-slider-overlay:fullscreen .pres-saved-img-wrap {
    padding: 50px 40px 60px;
}
.presentation-slider-overlay:fullscreen .pres-saved-img-wrap img {
    max-width: 95vw;
    max-height: 82vh;
}
/* Saved slider mobile */
@media (max-width: 768px) {
    .pres-saved-img-wrap {
        padding: 50px 12px 70px;
    }
    .pres-saved-img-wrap img {
        max-width: 98vw;
        max-height: 65vh;
    }
    .pres-saved-caption {
        font-size: 0.85rem;
    }
}
