/* ===================================================== */
/* ASSISTANT PANEL                                       */
/* ===================================================== */

.asst-panel {
    position: fixed;
    top: 70px;
    right: 20px; /* Startposition */
    width: 360px;
    height: 80vh;
    min-width: 300px;
    min-height: 400px;
    background: rgba(18, 18, 26, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 150;
    
    display: flex;
    flex-direction: column;
    
    overflow: hidden;

    /* Snappy Apple-like Spring Animation */
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px) scale(0.94);
    transform-origin: top right;
    transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.asst-panel.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.asst-resize-handle {
    display: none !important;
}

/* ===================================================== */
/* 8-WAY RESIZE HANDLES                                  */
/* ===================================================== */
.asst-resizer {
    position: absolute;
    z-index: 200;
}
.asst-resizer.r-n { top: 0; left: 10px; right: 10px; height: 6px; cursor: ns-resize; }
.asst-resizer.r-s { bottom: 0; left: 10px; right: 10px; height: 6px; cursor: ns-resize; }
.asst-resizer.r-w { left: 0; top: 10px; bottom: 10px; width: 6px; cursor: ew-resize; }
.asst-resizer.r-e { right: 0; top: 10px; bottom: 10px; width: 6px; cursor: ew-resize; }
.asst-resizer.r-nw { top: 0; left: 0; width: 12px; height: 12px; cursor: nwse-resize; }
.asst-resizer.r-ne { top: 0; right: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.asst-resizer.r-sw { bottom: 0; left: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.asst-resizer.r-se { bottom: 0; right: 0; width: 12px; height: 12px; cursor: nwse-resize; }

/* ===================================================== */
/* TOOLBAR                                               */
/* ===================================================== */

.asst-toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    cursor: move;
    user-select: none;
}

.asst-toolbar-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.asst-toolbar-actions {
    justify-content: flex-start;
}

.asst-spacer {
    flex: 1;
}

.asst-tabs-row {
    overflow: hidden;
}

.asst-tool-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
    flex-shrink: 0;
}

.asst-tool-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.asst-tool-btn svg { width: 15px; height: 15px; }

.asst-tool-btn.asst-close:hover {
    background: var(--danger);
    border-color: var(--danger);
}

/* ===================================================== */
/* TABS                                                  */
/* ===================================================== */

.asst-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.asst-tab {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 8px;
    max-width: 110px;
    min-width: 60px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: 0.15s;
    flex-shrink: 0;
}

.asst-tab:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.asst-tab.active {
    background: var(--accent-tint) !important;
    border-color: var(--accent) !important;
}

.asst-tab-label {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asst-tab.active .asst-tab-label {
    color: var(--text-primary);
}

.asst-tab-close {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.6;
    transition: 0.15s;
}

.asst-tab-close:hover {
    background: var(--danger);
    color: white;
    opacity: 1;
}

.asst-tab-close svg { width: 11px; height: 11px; }

/* Overflow */
.asst-tab-overflow {
    position: relative;
    flex-shrink: 0;
}

.asst-overflow-btn {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 5px 7px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 11px;
    transition: 0.15s;
}

.asst-overflow-btn:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.asst-tab-overflow.active .asst-overflow-btn {
    border-color: var(--accent);
    color: var(--text-primary);
}

.asst-overflow-btn svg { width: 12px; height: 12px; }

.asst-overflow-menu {
    display: none;
    position: fixed;               /* war: absolute - deshalb abgeschnitten */
    min-width: 200px;
    max-width: 280px;
    max-height: 320px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
    z-index: 9999;                 /* über allem */
    padding: 6px;
}

.asst-overflow-menu.open { display: block; }

.asst-overflow-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.15s;
}

.asst-overflow-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.asst-overflow-item.active {
    background: var(--accent-tint) !important;
}

.asst-overflow-item span {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.asst-overflow-item.active span { color: var(--text-primary); }

/* ===================================================== */
/* BODY / MESSAGES                                       */
/* ===================================================== */

.asst-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.asst-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.asst-messages::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}


.asst-empty {
    margin: auto;
    text-align: center;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
}

/* ===================================================== */
/* IN-PANEL DIALOGS (confirm / prompt / alert)           */
/* ===================================================== */
.asst-dialog-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: asstFadeIn 0.12s ease;
}

.asst-dialog-box {
    width: 100%;
    max-width: 320px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.asst-dialog-msg {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
    margin: 0;
}

.asst-dialog-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
}

.asst-dialog-input:focus {
    outline: none;
    border-color: var(--accent);
}

.asst-dialog-btns {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.asst-empty svg { width: 36px; height: 36px; opacity: 0.4; }
.asst-empty p { font-size: 14px; color: var(--text-secondary); font-weight: 500; }
.asst-empty span { font-size: 12px; max-width: 220px; }

/* Message bubbles */
.asst-msg {
    display: flex;
    max-width: 100%;
}

/* Beide Rollen: volle Breite, keine Seiten-Ausrichtung mehr */
.asst-msg.user,
.asst-msg.assistant {
    justify-content: stretch;
}

.asst-msg-content {
    max-width: 100%;
    width: 100%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.asst-inline-image {
    margin-bottom: 8px;
}

.asst-inline-image img {
    max-width: 100%;
    max-height: 220px;
    border-radius: 10px;
    display: block;
    border: 1px solid rgba(255, 255, 255, 0.14);
}

.asst-msg.user .asst-msg-content {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}

.asst-msg.assistant .asst-msg-content {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.asst-msg-content .text-dialog { color: var(--color-dialog, #e0e0e0); }
.asst-msg-content .text-italic { color: var(--color-italic, #a0a0b0); font-style: italic; }
.asst-msg-content .text-bold { color: var(--color-bold, #fff); font-weight: 600; }
.asst-msg-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 13px;
}
.asst-msg-content pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

/* Code-Blöcke im Assistant umbrechen statt seitlich scrollen */
.asst-msg-content pre {
    white-space: pre-wrap !important;
    word-break: break-word !important;
    overflow-x: hidden !important;
}

.asst-msg-content pre code {
    white-space: pre-wrap !important;
    word-break: break-word !important;
}

/* Typing indicator */
.asst-dots span {
    display: inline-block;
    animation: asstWave 1.4s infinite ease-in-out both;
    font-weight: bold;
    font-size: 18px;
    color: var(--accent);
    margin: 0 1px;
}
.asst-dots span:nth-child(1) { animation-delay: -0.32s; }
.asst-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes asstWave {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* ===================================================== */
/* LINK CONTEXT                                          */
/* ===================================================== */

.asst-link-charitem {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: 0.15s;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
}

.asst-link-charitem:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
}

.asst-link-charitem.checked {
    background: var(--accent-tint) !important;
    border-color: var(--accent) !important;
}

.asst-link-avatar {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.asst-link-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.asst-link-avatar svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.asst-link-charitem span {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asst-link-charitem.checked span {
    color: var(--text-primary);
}

/* Check badge - only visible when checked */
.asst-link-check {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    background: var(--color-custom, var(--accent)) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0;
    transform: scale(0.6);
    transition: 0.15s;
}

.asst-link-charitem.checked .asst-link-check {
    opacity: 1;
    transform: scale(1);
}

.asst-link-check svg {
    width: 12px;
    height: 12px;
    color: white;
}

.asst-link-charlist {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    max-height: 280px;
    overflow-y: auto;
    padding: 6px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 10px;
}

/* ===================================================== */
/* STORY PICKER                                         */
/* ===================================================== */

.asst-story-picker {
    position: relative;
}

.asst-story-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
}

.asst-story-trigger span {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asst-story-trigger svg {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}

.asst-story-menu {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    z-index: 20;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
    overflow: hidden;
}

.asst-story-menu.open {
    display: block;
}

.asst-story-search-wrap {
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

.asst-story-search-wrap input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.asst-story-list {
    max-height: 260px;
    overflow-y: auto;
    padding: 6px;
}

.asst-story-group {
    margin-bottom: 6px;
}

.asst-story-group:last-child {
    margin-bottom: 0;
}

.asst-story-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 8px 6px;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.asst-story-group-avatar {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    overflow: hidden;
    flex-shrink: 0;
}

.asst-story-group-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.asst-story-group-avatar svg {
    width: 12px;
    height: 12px;
    color: var(--text-muted);
}

.asst-story-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 13px;
}

.asst-story-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.asst-story-item.selected {
    background: var(--accent-tint) !important;
    color: var(--text-primary) !important;
}

.asst-story-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asst-story-count {
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 999px;
}

.asst-story-empty {
    padding: 10px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ===================================================== */
/* LINK BAR                                              */
/* ===================================================== */

.asst-linkbar {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.asst-link-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--accent-tint) !important;
    border: 1px solid var(--accent-glow) !important;
    border-radius: 12px;
    font-size: 11px;
    color: var(--text-secondary);
}

.asst-link-chip svg { width: 12px; height: 12px; }

/* ===================================================== */
/* INPUT                                                 */
/* ===================================================== */

.asst-input-area {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.asst-image-preview {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
}

.asst-image-preview img {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    object-fit: cover;
}

.asst-image-clear {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: auto;
}

.asst-image-clear:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.asst-image-clear svg {
    width: 14px;
    height: 14px;
}

.asst-image-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.asst-image-btn:hover {
    background: rgba(255, 255, 255, 0.18);
}

#asst-input {
    display: block;
    vertical-align: bottom;
    box-sizing: border-box;
    flex: 1;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 200px;
    line-height: 1.5;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#asst-input::-webkit-scrollbar {
    width: 0;
    display: none;
}

#asst-input:focus {
    outline: none;
    border-color: var(--accent);
}

.asst-send {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: var(--accent);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
    flex-shrink: 0;
}

.asst-send:hover { background: var(--accent-hover); }
.asst-send:disabled { opacity: 0.5; cursor: not-allowed; }
.asst-send svg { width: 18px; height: 18px; }
.asst-send.retry-ready {
    box-shadow: 0 0 0 2px var(--accent-glow), 0 0 14px var(--accent-glow);
}
.asst-send.retry-ready:hover {
    box-shadow: 0 0 0 2px var(--accent), 0 0 18px var(--accent-glow);
}

.asst-stop { background: var(--danger); }
.asst-stop:hover { background: #dc2626; }

/* ===================================================== */
/* MOBILE                                                */
/* ===================================================== */

@media (max-width: 768px) {
    .asst-panel {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh !important;     /* killt das inline 80vh */
        max-height: 100dvh !important;
        border-radius: 0 !important;
        border: none !important;
        transform: none !important;    /* Pop-In Transform würde sonst verschieben */
        z-index: 500 !important;
    }

    .asst-panel.open {
        transform: none !important;
    }

    .asst-resizer,
    .asst-resize-handle {
        display: none !important;
    }

    .asst-toolbar {
        cursor: default !important;
    }

    .asst-tab { max-width: 90px; }
}

/* ===================================================== */
/* SETTINGS OVERLAY (im Panel, wie Debug)                */
/* ===================================================== */

.asst-settings-overlay {
    position: absolute;
    inset: 0;
    background: var(--bg-secondary, rgba(18, 18, 26, 0.98));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 50;
    display: flex;
    flex-direction: column;
    animation: asstFadeIn 0.15s ease;
}

.asst-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.asst-settings-header span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.asst-settings-header svg { width: 15px; height: 15px; color: var(--accent); }

.asst-settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scrollbar-width: thin;
}

.asst-settings-content label {
    display: block;
    margin: 14px 0 6px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.asst-set-hint {
    opacity: 0.6;
    font-size: 11px;
    font-weight: 400;
}

.asst-settings-content textarea,
.asst-settings-content input[type="text"],
.asst-settings-content input[type="password"],
.asst-settings-content input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
}

.asst-settings-content textarea:focus,
.asst-settings-content input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Number-Stepper ausblenden - Assistant Settings & Link Menü */
#asst-settings-overlay input[type="number"]::-webkit-inner-spin-button,
#asst-settings-overlay input[type="number"]::-webkit-outer-spin-button,
#asst-link-modal input[type="number"]::-webkit-inner-spin-button,
#asst-link-modal input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#asst-settings-overlay input[type="number"],
#asst-link-modal input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.asst-set-divider {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.asst-set-row {
    display: flex;
    gap: 12px;
}

.asst-settings-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

#asst-set-save svg,
#asst-set-cancel svg {
    width: 13px !important;
    height: 13px !important;
}

@keyframes asstFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===================================================== */
/* STORY PICKER (grouped by character) - Fix 4           */
/* ===================================================== */

.asst-story-picker {
    position: relative;
    width: 100%;
}

.asst-story-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: 0.15s;
    text-align: left;
}

.asst-story-trigger:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.asst-story-trigger span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.asst-story-trigger svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.2s;
}

.asst-story-menu.open ~ .asst-story-trigger svg,
.asst-story-picker:has(.asst-story-menu.open) .asst-story-trigger svg {
    transform: rotate(180deg);
}

/* Dropdown menu */
.asst-story-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
    z-index: 50;
    overflow: hidden;
    animation: asstFadeIn 0.12s ease;
}

.asst-story-menu.open { display: block; }

/* Search box */
.asst-story-search-wrap {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
}

.asst-story-search-wrap input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
}

.asst-story-search-wrap input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Scrollable list */
.asst-story-list {
    max-height: 320px;
    overflow-y: auto;
    padding: 6px;
    scrollbar-width: thin;
}

.asst-story-list::-webkit-scrollbar { width: 5px; }
.asst-story-list::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

/* Group */
.asst-story-group {
    margin-bottom: 8px;
}

.asst-story-group:last-child { margin-bottom: 0; }

.asst-story-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin-bottom: 2px;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

.asst-story-group-avatar {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.asst-story-group-avatar img { width: 100%; height: 100%; object-fit: cover; }
.asst-story-group-avatar svg { width: 13px; height: 13px; color: var(--text-muted); }

.asst-story-group-header span {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Story item */
.asst-story-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    padding-left: 34px;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.12s;
    font-size: 13px;
    color: var(--text-secondary);
}

.asst-story-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.asst-story-item.selected {
    background: rgba(124, 58, 237, 0.18);
    color: var(--text-primary);
}

.asst-story-item[data-id=""] {
    padding-left: 10px;
    gap: 8px;
    justify-content: flex-start;
    color: var(--text-muted);
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    padding-bottom: 10px;
}

.asst-story-item[data-id=""] svg { width: 14px; height: 14px; }
.asst-story-item[data-id=""].selected { color: var(--accent); }

.asst-story-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.asst-story-count {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 28px;
    text-align: center;
}

.asst-story-item.selected .asst-story-count {
    background: var(--accent-glow) !important;
    color: var(--text-primary) !important;
}

.asst-story-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ===================================================== */
/* EDIT & DELETE ACTIONS (Inside Bubble)                 */
/* ===================================================== */

.asst-msg-content {
    display: flex;
    flex-direction: column;
}

.asst-msg-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0.3;
    transition: opacity 0.2s;
}

.asst-msg.user .asst-msg-actions {
    border-top: 1px solid rgba(0, 0, 0, 0.15);
}

.asst-msg:hover .asst-msg-actions {
    opacity: 1;
}

.asst-msg-actions button {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
    opacity: 0.7;
}

.asst-msg-actions button:hover {
    background: rgba(255, 255, 255, 0.15);
    opacity: 1;
}

.asst-msg-actions button svg {
    width: 14px;
    height: 14px;
}

.asst-edit-area {
    width: 100%;
    min-height: 80px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    padding: 8px;
    font-family: inherit;
    resize: vertical;
}

.asst-edit-area:focus {
    outline: none;
    border-color: var(--accent);
}

.asst-edit-btns {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

/* ===================================================== */
/* SELECTION QUICK-ACTIONS POPUP                         */
/* ===================================================== */

.asst-selection-popup {
    position: fixed;
    display: none;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    background: rgba(18, 18, 26, 0.95);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    z-index: 9999;
    transform: translate(-50%, -100%);
    margin-top: -8px;
    animation: asstFadeIn 0.12s ease;
}

.asst-selection-popup.show {
    display: flex;
}

.asst-sel-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 28px;
    padding: 0 8px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.15s;
    white-space: nowrap;
}

.asst-sel-btn:hover {
    background: var(--accent);
    color: white;
}

.asst-sel-btn svg {
    width: 13px;
    height: 13px;
}
