:root {
    --ai-bg0: #f5f7ff;
    --ai-bg1: #ffffff;
    --ai-card: rgba(255, 255, 255, 0.85);
    --ai-card2: rgba(255, 255, 255, 0.95);
    --ai-border: rgba(2, 6, 23, 0.10);
    --ai-text: rgba(2, 6, 23, 0.92);
    --ai-muted: rgba(2, 6, 23, 0.62);
    --ai-muted2: rgba(2, 6, 23, 0.52);
    --ai-primary: #0044da;
    --ai-primary2: #0044da;
    --ai-success: #16a34a;
    --ai-shadow: 0 14px 34px rgba(2, 6, 23, 0.08);
}

body.ai-app[data-theme="dark"] {
    --ai-bg0: #060814;
    --ai-bg1: #0b1220;
    --ai-card: rgba(255, 255, 255, 0.06);
    --ai-card2: rgba(255, 255, 255, 0.08);
    --ai-border: rgba(255, 255, 255, 0.10);
    --ai-text: rgba(255, 255, 255, 0.92);
    --ai-muted: rgba(255, 255, 255, 0.68);
    --ai-muted2: rgba(255, 255, 255, 0.55);
    --ai-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

html, body {
    height: 100%;
}

body.ai-app {
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    background:
        radial-gradient(1100px 650px at 10% 0%, rgba(0, 68, 218, 0.18), transparent 60%),
        radial-gradient(1000px 600px at 90% 10%, rgba(0, 68, 218, 0.14), transparent 62%),
        radial-gradient(800px 600px at 50% 100%, rgba(22, 163, 74, 0.08), transparent 62%),
        linear-gradient(180deg, var(--ai-bg0), var(--ai-bg1));
    color: var(--ai-text);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.nav-auth-link--mobile-signin {
    display: none;
}

@media (max-width: 1000px) {
    .nav-auth-link--mobile-signin {
        display: inline-flex;
    }
}

.ai-top {
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    border-bottom: 1px solid var(--ai-border);
    background: rgba(255, 255, 255, 0.70);
    backdrop-filter: blur(12px);
}

body.ai-app[data-theme="dark"] .ai-top {
    background: rgba(6, 8, 20, 0.55);
}

.ai-top__brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-top__brand-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.ai-top__logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(2, 6, 23, 0.18);
}

.ai-top__titles {
    display: grid;
    gap: 3px;
}

.ai-top__title {
    font-size: 14px;
    letter-spacing: 0.02em;
    font-weight: 750;
}

.ai-top__subtitle {
    font-size: 12px;
    color: var(--ai-muted);
}

.ai-top__actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.ai-top__actions .ai-theme-btn {
    margin-left: auto;
}

.ai-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
}

.ai-modal.is-open {
    display: block;
}

.ai-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.55);
    backdrop-filter: blur(6px);
}

.ai-modal__dialog {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(520px, calc(100vw - 32px));
    background: var(--ai-bg1);
    border: 1px solid var(--ai-border);
    border-radius: 16px;
    box-shadow: var(--ai-shadow);
    padding: 16px;
}

.ai-modal__title {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.01em;
    margin-bottom: 6px;
}

.ai-modal__body {
    font-size: 13px;
    color: var(--ai-muted);
    line-height: 1.5;
}

.ai-modal__actions {
    margin-top: 14px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.ai-modal__actions .ai-btn {
    border-color: rgba(0, 68, 218, 0.22);
    background: var(--ai-primary);
    color: #ffffff;
}

.ai-modal__actions .ai-btn:hover {
    background: var(--ai-primary2);
    border-color: rgba(0, 68, 218, 0.32);
}

body.ai-app[data-theme="dark"] .ai-modal__actions .ai-btn:hover {
    background: var(--ai-primary2);
    border-color: rgba(0, 68, 218, 0.38);
}

.ai-modal__actions .ai-btn.ai-btn--ghost {
    background: rgba(0, 68, 218, 0.08);
    color: rgba(2, 6, 23, 0.92);
}

body.ai-app[data-theme="dark"] .ai-modal__actions .ai-btn.ai-btn--ghost {
    background: rgba(0, 68, 218, 0.18);
    color: rgba(255, 255, 255, 0.92);
}

.ai-btn {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid rgba(2, 6, 23, 0.12);
    background: rgba(255, 255, 255, 0.75);
    color: rgba(2, 6, 23, 0.90);
    font-size: 13px;
    font-weight: 750;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background 220ms ease, border-color 220ms ease, color 220ms ease, transform 180ms ease, box-shadow 220ms ease;
    white-space: nowrap;
    font-family: inherit;
}

.ai-btn::-moz-focus-inner {
    border: 0;
    padding: 0;
}

body.ai-app[data-theme="dark"] .ai-btn {
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.92);
}

.ai-btn:hover {
    transform: translateY(-1px);
    background: rgba(0, 68, 218, 0.08);
    border-color: rgba(0, 68, 218, 0.28);
}

body.ai-app[data-theme="dark"] .ai-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.22);
}

.ai-btn--ghost {
    background: transparent;
}

.ai-theme-btn {
    width: 44px;
    padding: 0;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.ai-theme-btn__icon {
    position: absolute;
    width: 18px;
    height: 18px;
    transition: opacity 220ms ease, transform 220ms ease;
}

.ai-theme-btn__sun {
    opacity: 0;
    transform: rotate(-20deg) scale(0.85);
}

.ai-theme-btn__moon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

body.ai-app[data-theme="dark"] .ai-theme-btn__sun {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

body.ai-app[data-theme="dark"] .ai-theme-btn__moon {
    opacity: 0;
    transform: rotate(20deg) scale(0.85);
}

.ai-icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid rgba(2, 6, 23, 0.12);
    background: rgba(255, 255, 255, 0.75);
    color: rgba(2, 6, 23, 0.90);
    text-decoration: none;
    font-size: 13px;
    font-weight: 650;
    white-space: nowrap;
    transition: background 220ms ease, border-color 220ms ease, color 220ms ease, transform 180ms ease, box-shadow 220ms ease;
}

.ai-icon-btn:hover {
    transform: translateY(-1px);
    background: rgba(0, 68, 218, 0.08);
    border-color: rgba(0, 68, 218, 0.28);
}

body.ai-app[data-theme="dark"] .ai-icon-btn {
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.92);
}

body.ai-app[data-theme="dark"] .ai-icon-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.22);
}

.ai-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

.ai-shell {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 18px;
    max-width: 1480px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
    min-height: 0;
    height: calc(100vh - 72px);
    overflow: hidden;
}

.ai-shell--chat {
    flex-direction: row;
    align-items: stretch;
    gap: 18px;
}

.ai-sidebar {
    flex: 0 0 20%;
    min-width: 260px;
    max-width: 420px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

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

.ai-hero {
    flex: 0 0 auto;
}

.ai-chat {
    flex: 1 1 auto;
    min-height: 0;
}

.ai-hero__card {
    background: linear-gradient(180deg, var(--ai-card2), var(--ai-card));
    border: 1px solid var(--ai-border);
    border-radius: 18px;
    padding: 18px;
    box-shadow: var(--ai-shadow);
    max-height: 320px;
    overflow: auto;
}

.ai-shell--chat .ai-hero {
    flex: 1 1 auto;
    min-height: 0;
}

.ai-shell--chat .ai-hero__card {
    max-height: none;
    height: auto;
    overflow: visible;
}

.ai-shell--chat .ai-sidebar {
    align-self: flex-start;
}

.ai-hero__divider {
    height: 1px;
    width: 100%;
    background: rgba(2, 6, 23, 0.12);
    margin: 14px 0;
}

body.ai-app[data-theme="dark"] .ai-hero__divider {
    background: rgba(255, 255, 255, 0.14);
}

.ai-hero__history {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.ai-hero__card .ai-icon-btn {
    margin-bottom: 10px;
}

.ai-hero__history-itemwrap {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.ai-hero__history-itemwrap .ai-hero__history-item {
    flex: 1 1 auto;
    min-width: 0;
}

.ai-conv__menu {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.ai-conv__menu-btn {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: 1px solid rgba(2, 6, 23, 0.10);
    background: rgba(255, 255, 255, 0.55);
    color: inherit;
    height: 100%;
    min-height: 40px;
    width: 40px;
    border-radius: 12px;
    cursor: pointer;
    line-height: 1;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

body.ai-app[data-theme="dark"] .ai-conv__menu-btn {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
}

.ai-conv__menu-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 160px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(2, 6, 23, 0.10);
    border-radius: 12px;
    box-shadow: var(--ai-shadow);
    padding: 6px;
    display: none;
    z-index: 10;
}

body.ai-app[data-theme="dark"] .ai-conv__menu-panel {
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.ai-conv__menu.is-open .ai-conv__menu-panel {
    display: block;
}

.ai-conv__menu-item {
    width: 100%;
    text-align: left;
    padding: 10px 10px;
    border-radius: 10px;
    border: 0;
    background: transparent;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 650;
    color: inherit;
}

.ai-conv__menu-item:hover {
    background: rgba(2, 6, 23, 0.06);
}

body.ai-app[data-theme="dark"] .ai-conv__menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.ai-hero__history-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 4px;
    text-decoration: none;
    color: inherit;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid rgba(2, 6, 23, 0.10);
    background: rgba(255, 255, 255, 0.55);
    transition: background 220ms ease, border-color 220ms ease, transform 180ms ease;
}

.ai-hero__history-item:hover {
    background: rgba(0, 68, 218, 0.08);
    border-color: rgba(0, 68, 218, 0.28);
    transform: translateY(-1px);
}

body.ai-app[data-theme="dark"] .ai-hero__history-item {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
}

.ai-hero__history-title {
    font-size: 13px;
    font-weight: 650;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-hero__history-date {
    font-size: 12px;
    color: var(--ai-muted2);
    flex: 0 0 auto;
    white-space: nowrap;
}

.ai-hero__badge {
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: rgba(0, 68, 218, 0.12);
    border: 1px solid rgba(0, 68, 218, 0.25);
    color: rgba(2, 6, 23, 0.88);
}

body.ai-app[data-theme="dark"] .ai-hero__badge {
    background: rgba(0, 68, 218, 0.22);
    border: 1px solid rgba(0, 68, 218, 0.38);
    color: rgba(255, 255, 255, 0.92);
}

.ai-hero__headline {
    margin: 12px 0 8px;
    font-size: 30px;
    line-height: 1.15;
    letter-spacing: -0.02em;
    font-weight: 800;
}

.ai-hero__copy {
    margin: 0;
    color: var(--ai-muted);
    font-size: 14px;
    line-height: 1.55;
}

.ai-hero__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.ai-history {
    width: min(1100px, calc(100vw - 48px));
    margin: 14px auto 0;
}

.ai-shell--chat .ai-history {
    width: 100%;
    margin: 0 0 12px;
}

.ai-history__row {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    overflow-x: auto;
    padding: 6px 2px;
    scrollbar-width: thin;
}

.ai-chip.ai-chip--history {
    white-space: nowrap;
}

.ai-chip {
    border-radius: 999px;
    border: 1px solid rgba(2, 6, 23, 0.12);
    background: rgba(255, 255, 255, 0.75);
    color: rgba(2, 6, 23, 0.90);
    padding: 8px 12px;
    text-decoration: none;
    transition: background 220ms ease, border-color 220ms ease, transform 180ms ease;
}

body.ai-app[data-theme="dark"] .ai-chip {
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.92);
}

.ai-chip:hover {
    background: rgba(0, 68, 218, 0.08);
    border-color: rgba(0, 68, 218, 0.28);
    transform: translateY(-1px);
}

@media (max-width: 1000px) {
    .ai-shell {
        height: auto;
        overflow: visible;
        padding-bottom: calc(30px + env(safe-area-inset-bottom, 0px));
    }

    body.ai-app {
        overflow-x: hidden;
    }

    .ai-shell--chat {
        flex-direction: column;
        height: calc(100dvh - 72px);
        overflow: hidden;
    }

    .ai-sidebar {
        min-width: 0;
        max-width: none;
        width: 100%;
    }

    .ai-main {
        width: 100%;
        min-width: 0;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }

    .ai-chat__frame {
        height: auto;
        margin-bottom: 18px;
        padding-bottom: 14px;
    }

    .ai-composer {
        margin-bottom: 10px;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .ai-hero__card {
        padding: 14px;
        max-height: none;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .ai-hero__headline {
        font-size: 22px;
        margin-top: 8px;
    }

    .ai-hero__copy {
        font-size: 13px;
    }

    .ai-hero__divider + .ai-hero__copy {
        text-align: center;
    }

    .ai-hero__chips {
        justify-content: center;
    }

    .ai-msg__bubble {
        font-size: 14px;
    }

    .ai-modal__dialog {
        width: min(420px, calc(100vw - 48px));
    }

    .ai-hero__history {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 10px;
        overflow-x: auto;
        overflow-y: hidden;
        max-width: 100%;
        padding-bottom: 6px;
        margin-bottom: 10px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .ai-hero__history-itemwrap {
        flex: 0 0 auto;
        width: 220px;
        max-width: 70vw;
    }

    .ai-hero__history-item {
        width: 100%;
    }

    .ai-conv__menu-btn {
        display: none;
    }
}

body.ai-app[data-theme="dark"] .ai-chip:hover {
    background: rgba(255, 255, 255, 0.10);
}

.ai-chat__frame {
    background: linear-gradient(180deg, var(--ai-card2), var(--ai-card));
    border: 1px solid var(--ai-border);
    border-radius: 18px;
    box-shadow: var(--ai-shadow);
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: none;
    min-height: 0;
    overflow: hidden;
}

.ai-messages {
    flex: 1 1 auto;
    padding: 16px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-messages {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 68, 218, 0.35) rgba(2, 6, 23, 0.06);
}

body.ai-app[data-theme="dark"] .ai-messages {
    scrollbar-color: rgba(0, 68, 218, 0.45) rgba(255, 255, 255, 0.06);
}

.ai-messages::-webkit-scrollbar {
    width: 10px;
}

.ai-messages::-webkit-scrollbar-track {
    background: rgba(2, 6, 23, 0.06);
    border-left: 1px solid rgba(2, 6, 23, 0.06);
}

body.ai-app[data-theme="dark"] .ai-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.06);
    border-left: 1px solid rgba(255, 255, 255, 0.06);
}

.ai-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 68, 218, 0.30);
    border-radius: 999px;
    border: 3px solid rgba(2, 6, 23, 0.06);
}

body.ai-app[data-theme="dark"] .ai-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 68, 218, 0.40);
    border: 3px solid rgba(255, 255, 255, 0.06);
}

.ai-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 68, 218, 0.45);
}

body.ai-app[data-theme="dark"] .ai-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 68, 218, 0.55);
}

.ai-msg {
    display: grid;
    gap: 6px;
}

.ai-msg {
    justify-items: start;
}

.ai-msg__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.ai-msg__role {
    font-size: 12px;
    color: var(--ai-muted2);
}

.ai-msg__bubble {
    max-width: 92%;
    width: fit-content;
    padding: 12px 12px;
    border-radius: 14px;
    border: 1px solid var(--ai-border);
    background: rgba(255, 255, 255, 0.70);
    color: rgba(2, 6, 23, 0.92);
    font-size: 15px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

@media (min-width: 1001px) {
    .ai-shell--chat .ai-msg__bubble {
        font-size: 20px;
    }
}

.ai-msg__row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.ai-msg--user .ai-msg__row {
    justify-content: flex-end;
}

.ai-msg--assistant .ai-msg__row {
    justify-content: flex-start;
}

.ai-msg__menu {
    position: relative;
    flex: 0 0 auto;
    margin-top: 2px;
}

.ai-msg__menu-btn {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: 1px solid rgba(2, 6, 23, 0.12);
    background: rgba(255, 255, 255, 0.65);
    color: rgba(2, 6, 23, 0.72);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

body.ai-app[data-theme="dark"] .ai-msg__menu-btn {
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.80);
}

.ai-msg__menu-btn:hover {
    background: rgba(255, 255, 255, 0.90);
}

body.ai-app[data-theme="dark"] .ai-msg__menu-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.ai-msg__menu-panel {
    position: absolute;
    top: 34px;
    right: 0;
    min-width: 140px;
    display: none;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid rgba(2, 6, 23, 0.12);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 18px 45px rgba(2, 6, 23, 0.18);
    z-index: 20;
}

body.ai-app[data-theme="dark"] .ai-msg__menu-panel {
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(15, 17, 32, 0.96);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.55);
}

.ai-msg__menu.is-open .ai-msg__menu-panel {
    display: grid;
    gap: 6px;
}

.ai-msg__menu-item {
    width: 100%;
    text-align: left;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(2, 6, 23, 0.08);
    background: rgba(255, 255, 255, 0.70);
    color: rgba(2, 6, 23, 0.86);
    padding: 0 10px;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
}

.ai-msg__menu-item:hover {
    background: rgba(255, 255, 255, 0.95);
}

.ai-msg__menu-item[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

body.ai-app[data-theme="dark"] .ai-msg__menu-item {
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.92);
}

body.ai-app[data-theme="dark"] .ai-msg__menu-item:hover {
    background: rgba(255, 255, 255, 0.12);
}

body.ai-app[data-theme="dark"] .ai-msg__bubble {
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.92);
}

.ai-msg--user {
    justify-items: end;
}

.ai-msg--user .ai-msg__meta {
    justify-content: flex-end;
}

.ai-msg--user .ai-msg__role {
    text-align: right;
}

.ai-msg--user .ai-msg__bubble {
    background: linear-gradient(135deg, rgba(0, 68, 218, 0.16), rgba(0, 68, 218, 0.10));
    border-color: rgba(0, 68, 218, 0.22);
}

body.ai-app[data-theme="dark"] .ai-msg--user .ai-msg__bubble {
    background: linear-gradient(135deg, rgba(0, 68, 218, 0.32), rgba(0, 68, 218, 0.18));
    border-color: rgba(0, 68, 218, 0.38);
}

.ai-msg--assistant .ai-msg__bubble {
    background: rgba(255, 255, 255, 0.70);
    border-color: var(--ai-border);
}

body.ai-app[data-theme="dark"] .ai-msg--assistant .ai-msg__bubble {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}

.ai-msg__hint {
    font-size: 12px;
    color: var(--ai-muted2);
}

.ai-typing {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    color: var(--ai-muted);
    font-size: 14px;
    font-weight: 650;
}

.ai-typing__word {
    display: inline-block;
    padding: 0;
    border-radius: 0;
    border: none;
    background: transparent;
    transform: translateY(0);
    transition: opacity 260ms ease, transform 260ms ease;
}

body.ai-app[data-theme="dark"] .ai-typing__word {
    background: transparent;
    border-color: transparent;
}

.ai-typing__word.is-pop {
    animation: aiPop 260ms ease-out;
}

.ai-typing__word.is-fade {
    opacity: 0;
    transform: translateY(2px);
}

@keyframes aiPop {
    0% {
        transform: translateY(2px);
        opacity: 0.75;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.ai-typing__dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding-left: 0;
}

.ai-typing__dots span {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: rgba(0, 68, 218, 0.55);
    animation: aiDot 1100ms infinite ease-in-out;
}

.ai-typing__dots span:nth-child(2) {
    animation-delay: 180ms;
}

.ai-typing__dots span:nth-child(3) {
    animation-delay: 360ms;
}

@keyframes aiDot {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.35;
    }
    40% {
        transform: translateY(-4px);
        opacity: 0.9;
    }
}

.ai-md {
    display: grid;
    gap: 8px;
}

.ai-md h1,
.ai-md h2,
.ai-md h3 {
    margin: 4px 0 0;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.ai-md h4 {
    margin: 4px 0 0;
    font-size: 14px;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--ai-text);
}

.ai-md h1 { font-size: 18px; }
.ai-md h2 { font-size: 16px; }
.ai-md h3 { font-size: 15px; }

.ai-md p {
    margin: 0;
}

.ai-md ul,
.ai-md ol {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 6px;
}

.ai-md hr {
    border: none;
    height: 1px;
    background: var(--ai-border);
    margin: 10px 0;
}

.ai-md ul.ai-tasklist {
    list-style: none;
    padding-left: 0;
}

.ai-md li.ai-li-task {
    list-style: none;
}

.ai-task {
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 10px;
    align-items: start;
}

.ai-task__box {
    width: 18px;
    height: 18px;
    border-radius: 6px;
    border: 1px solid rgba(2, 6, 23, 0.16);
    background: rgba(2, 6, 23, 0.03);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: rgba(2, 6, 23, 0.70);
    line-height: 1;
    margin-top: 1px;
}

body.ai-app[data-theme="dark"] .ai-task__box {
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.78);
}

.ai-md li {
    margin: 0;
}

.ai-md code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.92em;
    padding: 2px 6px;
    border-radius: 8px;
    border: 1px solid rgba(2, 6, 23, 0.10);
    background: rgba(2, 6, 23, 0.04);
}

body.ai-app[data-theme="dark"] .ai-md code {
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
}

.ai-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-top: 1px solid var(--ai-border);
    background: rgba(255, 255, 255, 0.45);
    flex-wrap: wrap;
}

body.ai-app[data-theme="dark"] .ai-toolbar {
    background: rgba(6, 8, 20, 0.22);
}

.ai-toolbar__group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ai-toolbar__label {
    font-size: 12px;
    color: var(--ai-muted2);
}

.ai-toolbar__select {
    height: 32px;
    border-radius: 10px;
    border: 1px solid rgba(2, 6, 23, 0.12);
    background: rgba(255, 255, 255, 0.80);
    color: rgba(2, 6, 23, 0.88);
    padding: 0 10px;
    font-size: 13px;
    outline: none;
}

body.ai-app[data-theme="dark"] .ai-toolbar__select {
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.92);
}

.ai-toolbar__btn {
    height: 32px;
    border-radius: 10px;
    border: 1px solid rgba(2, 6, 23, 0.12);
    background: rgba(255, 255, 255, 0.80);
    color: rgba(2, 6, 23, 0.88);
    padding: 0 12px;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
}

body.ai-app[data-theme="dark"] .ai-toolbar__btn {
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.92);
}

.ai-toolbar__btn:hover {
    background: rgba(255, 255, 255, 0.95);
}

body.ai-app[data-theme="dark"] .ai-toolbar__btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.ai-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 12px 12px;
    border-top: 1px dashed var(--ai-border);
    background: rgba(255, 255, 255, 0.35);
}

body.ai-app[data-theme="dark"] .ai-quick {
    background: rgba(6, 8, 20, 0.16);
}

.ai-quick__chip {
    height: 34px;
    border-radius: 999px;
    border: 1px solid rgba(2, 6, 23, 0.12);
    background: rgba(255, 255, 255, 0.80);
    color: rgba(2, 6, 23, 0.88);
    padding: 0 12px;
    font-size: 13px;
    cursor: pointer;
    transition: transform 120ms ease, background 120ms ease;
}

.ai-quick__chip:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.95);
}

body.ai-app[data-theme="dark"] .ai-quick__chip {
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.92);
}

body.ai-app[data-theme="dark"] .ai-quick__chip:hover {
    background: rgba(255, 255, 255, 0.12);
}

.ai-msg__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.ai-msg__btn {
    height: 28px;
    border-radius: 999px;
    border: 1px solid rgba(2, 6, 23, 0.12);
    background: rgba(255, 255, 255, 0.65);
    color: rgba(2, 6, 23, 0.82);
    font-size: 12px;
    font-weight: 650;
    padding: 0 10px;
    cursor: pointer;
}

.ai-msg__btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

.ai-msg__btn:hover {
    background: rgba(255, 255, 255, 0.90);
}

body.ai-app[data-theme="dark"] .ai-msg__btn {
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.88);
}

body.ai-app[data-theme="dark"] .ai-msg__btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.ai-fab {
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 58px;
    height: 58px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(0, 68, 218, 1), rgba(0, 68, 218, 0.90));
    border: 1px solid rgba(0, 68, 218, 0.40);
    box-shadow: 0 16px 40px rgba(2, 6, 23, 0.18);
    display: grid;
    place-items: center;
    text-decoration: none;
    color: #ffffff;
    z-index: 1400;
}

.ai-fab:hover {
    background: linear-gradient(180deg, rgba(0, 68, 218, 1), rgba(0, 68, 218, 0.96));
    border-color: rgba(0, 68, 218, 0.60);
}

.ai-fab__icon svg {
    width: 26px;
    height: 26px;
}

.ai-fab__popup {
    position: absolute;
    right: 72px;
    bottom: 8px;
    width: min(320px, calc(100vw - 120px));
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0, 68, 218, 0.18);
    box-shadow: 0 18px 45px rgba(2, 6, 23, 0.18);
    color: rgba(15, 23, 42, 0.92);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity 220ms ease, transform 220ms ease;
}

.ai-fab__popup.is-open {
    opacity: 1;
    transform: translateY(0);
}

.ai-composer {
    padding: 12px;
    border-top: 1px solid var(--ai-border);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    background: rgba(255, 255, 255, 0.55);
    align-items: stretch;
}

body.ai-app[data-theme="dark"] .ai-composer {
    background: rgba(6, 8, 20, 0.35);
}

.ai-composer__inputwrap {
    background: rgba(255, 255, 255, 0.80);
    border: 1px solid rgba(2, 6, 23, 0.12);
    border-radius: 14px;
    padding: 10px 12px;
}

body.ai-app[data-theme="dark"] .ai-composer__inputwrap {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
}

.ai-input {
    width: 100%;
    resize: none;
    border: none;
    outline: none;
    background: transparent;
    color: rgba(2, 6, 23, 0.92);
    font-size: 14px;
    line-height: 1.45;
    font-family: inherit;
    min-height: 22px;
    max-height: 160px;
}

body.ai-app[data-theme="dark"] .ai-input {
    color: rgba(255, 255, 255, 0.92);
}

.ai-input::placeholder {
    color: rgba(2, 6, 23, 0.52);
}

body.ai-app[data-theme="dark"] .ai-input::placeholder {
    color: rgba(255, 255, 255, 0.55);
}

.ai-send {
    height: auto;
    align-self: stretch;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid rgba(0, 68, 218, 0.20);
    background: var(--ai-primary);
    color: white;
    font-size: 14px;
    font-weight: 750;
    cursor: pointer;
    transition: transform 120ms ease;
}

.ai-send:hover {
    transform: translateY(-1px);
}

.ai-send[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.ai-footnote {
    padding: 10px 12px 14px;
    font-size: 12px;
    color: var(--ai-muted2);
    border-top: 1px dashed var(--ai-border);
    background: rgba(255, 255, 255, 0.45);
}

body.ai-app[data-theme="dark"] .ai-footnote {
    background: rgba(6, 8, 20, 0.25);
}

@media (max-width: 980px) {
    .ai-shell {
        padding: 14px;
    }

    .ai-shell--chat {
        flex-direction: column;
    }

    .ai-sidebar {
        flex: 0 0 auto;
        min-width: 0;
        max-width: none;
    }

    .ai-chat__frame {
        min-height: 0;
        height: 100%;
    }

    .ai-top {
        height: auto;
        padding: 12px 14px;
        gap: 10px;
        flex-wrap: wrap;
    }

    .ai-top__actions {
        width: 100%;
        justify-content: flex-start;
    }
}
