/* AI assistant — loaded with platform.css */
.ai-teaser {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 32px 0 8px;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
}
.ai-teaser__title {
    font-size: 1.05rem;
    margin: 0 0 6px;
    color: var(--text);
}
.ai-teaser__text {
    margin: 0;
    color: var(--text2);
    font-size: 0.92rem;
    max-width: 52ch;
}

#page-ai-assistant.page {
    max-width: 100%;
    padding: 16px 16px 40px;
}
#page-ai-assistant.page.active {
    display: flex;
    flex-direction: column;
}
#page-ai-assistant .page-title {
    font-size: 1.45rem;
    font-weight: 700;
    margin-bottom: 4px;
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
    -webkit-text-fill-color: var(--text);
    color: var(--text);
}
#page-ai-assistant .page-subtitle {
    margin-bottom: 12px;
    font-size: 0.95rem;
    max-width: 62ch;
}

.ai-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 16px;
    position: relative;
    flex: 1 1 auto;
    min-height: calc(100dvh - 72px - 32px);
    align-items: stretch;
}
.ai-sidebar-toggle {
    display: none;
}
.ai-sidebar-backdrop {
    display: none;
}
.ai-sidebar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 12px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.ai-sidebar__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}
.ai-sidebar__head strong {
    color: var(--text);
    font-size: 0.92rem;
}
.ai-conv-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-height: 0;
    overflow: auto;
}
.ai-conv-empty {
    color: var(--text3);
    font-size: 0.88rem;
    padding: 10px 8px;
}
.ai-conv-list button {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    border-left: 2px solid transparent;
    color: var(--text);
    border-radius: 0;
    padding: 10px 10px;
    cursor: pointer;
    min-height: 44px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.ai-conv-list button:hover {
    color: var(--text);
    background: var(--surface2);
}
.ai-conv-list button.active {
    border-left-color: var(--accent);
    background: var(--surface2);
    font-weight: 600;
}
.ai-conv-list button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.ai-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}
.ai-main__head {
    flex: 0 0 auto;
}

.ai-modes {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px;
    margin: 0 0 14px;
    font-size: 0.95rem;
}
.ai-mode {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1.5px solid var(--border);
    color: var(--text2);
    border-radius: var(--radius-btn);
    padding: 10px 12px;
    cursor: pointer;
    min-height: 44px;
    font-size: 0.85rem;
    line-height: 1.2;
}
.ai-mode:hover {
    color: var(--text);
    border-color: var(--text3);
}
.ai-mode.active {
    color: var(--text);
    border-color: var(--accent);
    background: rgba(79, 143, 255, 0.12);
    font-weight: 600;
}
.ai-mode:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

#page-ai-assistant .find-guest-cta {
    margin-bottom: 12px;
    max-width: none;
    text-align: left;
}
#page-ai-assistant .find-guest-cta__actions {
    justify-content: flex-start;
}
#page-ai-assistant .find-seo h3 {
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    margin: 20px 0 8px;
}

.ai-chat {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
}
.ai-chat.is-locked .ai-composer {
    display: none;
}

.ai-empty {
    flex: 1;
    padding: 20px 18px 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    max-width: 640px;
}
.ai-empty__lead {
    margin: 0;
    color: var(--text);
    font-size: 1rem;
    line-height: 1.5;
}
.ai-empty__hint {
    margin: 0;
    color: var(--text3);
    font-size: 0.88rem;
}
.ai-starters {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ai-starter {
    display: block;
    width: 100%;
    text-align: left;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-btn);
    color: var(--text);
    padding: 12px 14px;
    min-height: 44px;
    cursor: pointer;
    font: inherit;
    line-height: 1.4;
}
.ai-starter:hover {
    border-color: var(--text3);
    color: var(--text);
}
.ai-starter:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.ai-chat.is-locked .ai-starter {
    cursor: default;
    opacity: 0.85;
}

.ai-log {
    flex: 1;
    overflow: auto;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ai-msg {
    max-width: min(720px, 100%);
    line-height: 1.55;
    overflow-wrap: anywhere;
    color: var(--text);
}
.ai-msg--user {
    align-self: flex-end;
    max-width: min(560px, 100%);
    padding: 10px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-btn);
}
.ai-msg--assistant {
    align-self: stretch;
    padding: 4px 0 12px;
    border-bottom: 1px solid var(--border);
}
.ai-msg--assistant:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.ai-msg h2,
.ai-msg h3,
.ai-msg h4 {
    margin: 0.5em 0 0.3em;
    color: var(--text);
    -webkit-text-fill-color: var(--text);
    background: none;
    font-size: 1rem;
}
.ai-msg ul,
.ai-msg ol {
    margin: 0.3em 0 0.3em 1.2em;
}
.ai-msg pre {
    margin: 10px 0;
    padding: 12px 14px;
    overflow: auto;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-btn);
    color: var(--text);
    font-size: 0.88rem;
}
.ai-msg code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
}
.ai-msg :not(pre) > code {
    background: var(--surface2);
    border: 1px solid var(--border);
    padding: 0.1em 0.35em;
    border-radius: 4px;
}

.ai-composer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--border);
}
.ai-composer textarea {
    width: 100%;
    min-height: 48px;
    max-height: 160px;
    resize: vertical;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-btn);
    padding: 10px 12px;
    font: inherit;
}
.ai-composer textarea:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}
.ai-composer__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.ai-composer__left,
.ai-composer__right {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.ai-composer__right {
    margin-left: auto;
}
.ai-composer__hint {
    margin: 0;
    color: var(--text3);
    font-size: 0.78rem;
}
.ai-file {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-btn);
    color: var(--text2);
    cursor: pointer;
}
.ai-file:hover {
    border-color: var(--text3);
    color: var(--text);
}
.ai-file input {
    display: none;
}
.ai-file-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    color: var(--text2);
    font-size: 0.85rem;
}
.ai-file-name {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 180px;
}
.ai-file-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-btn);
    color: var(--text2);
    background: transparent;
    font-size: 1.1rem;
    line-height: 1;
}
.ai-file-clear:hover {
    color: var(--text);
    border-color: var(--text3);
}
.ai-quota {
    color: var(--text3);
    font-size: 0.82rem;
    margin: 0;
    white-space: nowrap;
}
.ai-action {
    margin-top: 10px;
}
.ai-composer .btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

@media (min-width: 860px) {
    .ai-modes {
        flex-wrap: nowrap;
        gap: 6px 16px;
        border-bottom: 1px solid var(--border);
        margin-bottom: 16px;
    }
    .ai-mode {
        justify-content: flex-start;
        min-height: 0;
        padding: 10px 2px;
        font-size: 0.95rem;
        border: none;
        border-bottom: 2px solid transparent;
        border-radius: 0;
        margin-bottom: -1px;
        background: none;
    }
    .ai-mode:hover {
        border-color: transparent;
        color: var(--text);
    }
    .ai-mode.active {
        border-color: transparent;
        border-bottom-color: var(--accent);
        background: none;
    }
}

@media (max-width: 859px) {
    .ai-layout {
        grid-template-columns: 1fr;
        min-height: calc(100dvh - 72px - 24px);
    }
    .ai-sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        background: var(--surface);
        border: 1.5px solid var(--border);
        color: var(--text);
        border-radius: var(--radius-btn);
        padding: 0 12px;
        cursor: pointer;
        width: max-content;
    }
    .ai-sidebar-toggle:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }
    .ai-sidebar-backdrop {
        display: none;
        position: absolute;
        inset: 0;
        background: rgba(10, 14, 20, 0.55);
        z-index: 18;
        border: 0;
        padding: 0;
    }
    .ai-sidebar-backdrop.is-open {
        display: block;
    }
    .ai-sidebar {
        display: none;
        position: absolute;
        z-index: 20;
        left: 0;
        right: 0;
        top: 52px;
        max-height: min(70vh, 480px);
        box-shadow: var(--shadow);
    }
    .ai-sidebar.is-open {
        display: flex;
    }
    .ai-chat {
        min-height: 320px;
    }
    .ai-file-name {
        max-width: 120px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #page-ai-assistant.page {
        animation: none;
    }
}
