.jt-ai {
    --jt-ai-blue: #1769ff;
    --jt-ai-ink: #071722;
    --jt-ai-panel: #ffffff;
    --jt-ai-soft: #eef5ff;
    --jt-ai-line: rgba(7, 23, 34, .14);
    position: relative;
    z-index: 2147482000;
    flex: 0 0 auto;
    font-family: inherit;
}

.jt-ai__launch-group { display: flex; align-items: center; gap: 6px; }

.jt-ai__launcher {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 6px 11px 6px 6px;
    border: 0;
    border-radius: 999px;
    color: #fff;
    background: linear-gradient(135deg, #0754de, #6a31df);
    box-shadow: 0 16px 44px rgba(20, 69, 181, .34);
    font-weight: 800;
    cursor: pointer;
}

.jt-ai__launcher:hover { transform: translateY(-2px); }
.jt-ai__launcher:focus-visible,
.jt-ai__dialog button:focus-visible,
.jt-ai__dialog textarea:focus-visible,
.jt-ai__dialog input:focus-visible { outline: 3px solid #f6b900; outline-offset: 2px; }

.jt-ai__mark {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: #071722;
    background: radial-gradient(circle at 30% 25%, #fff, #80e8ff 48%, #88ffbf);
    font-size: .84rem;
    letter-spacing: .04em;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.8);
}

.jt-ai__quick-voice {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid rgba(23,105,255,.26);
    border-radius: 13px;
    color: #1049a3;
    background: #e8f1ff;
    box-shadow: 0 8px 22px rgba(20,69,181,.18);
    font-size: 1rem;
    cursor: pointer;
}
.jt-ai__quick-voice.is-listening { color: #fff; border-color: #ef5b6d; background: #df233b; animation: jt-ai-pulse 1s infinite; }

.jt-ai__dialog {
    position: absolute;
    left: 0;
    top: calc(100% + 12px);
    display: grid;
    grid-template-rows: auto minmax(180px, 1fr) auto auto auto;
    width: min(410px, calc(100vw - 28px));
    height: min(650px, calc(100dvh - 110px));
    min-height: 450px;
    overflow: hidden;
    border: 1px solid var(--jt-ai-line);
    border-radius: 24px;
    color: var(--jt-ai-ink);
    background: var(--jt-ai-panel);
    box-shadow: 0 28px 90px rgba(3, 24, 46, .32);
}

.jt-ai__dialog[hidden] { display: none; }

.jt-ai__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 17px;
    color: #fff;
    background: linear-gradient(135deg, #071b38, #1049a3 70%, #6a31df);
}

.jt-ai__header div { display: grid; gap: 2px; }
.jt-ai__header strong { font-size: 1.03rem; }
.jt-ai__header small { color: rgba(255,255,255,.78); font-size: .72rem; line-height: 1.35; }
.jt-ai__header button {
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255,255,255,.35);
    border-radius: 50%;
    color: #fff;
    background: rgba(255,255,255,.1);
    font-size: 1.45rem;
    cursor: pointer;
}

.jt-ai__messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding: 16px;
    overscroll-behavior: contain;
    background:
        radial-gradient(circle at 100% 0, rgba(94, 60, 220, .08), transparent 35%),
        linear-gradient(#f8fbff, #f2f7ff);
}

.jt-ai__message { display: grid; gap: 8px; max-width: 90%; }
.jt-ai__message > div:first-child {
    padding: 11px 13px;
    border: 1px solid rgba(7,23,34,.08);
    border-radius: 16px 16px 16px 5px;
    background: #fff;
    box-shadow: 0 7px 20px rgba(8,40,80,.07);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.5;
    font-size: .9rem;
}

.jt-ai__message--user { align-self: flex-end; }
.jt-ai__message--user > div:first-child {
    border-color: transparent;
    border-radius: 16px 16px 5px 16px;
    color: #fff;
    background: linear-gradient(135deg, #1667ee, #4330c4);
}

.jt-ai__sources {
    display: grid;
    gap: 6px;
    padding: 9px 10px;
    border-radius: 12px;
    background: rgba(23,105,255,.07);
}
.jt-ai__sources strong { font-size: .73rem; text-transform: uppercase; letter-spacing: .05em; color: #375075; }
.jt-ai__sources a { color: #0754de; font-size: .78rem; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }

.jt-ai__status {
    min-height: 18px;
    padding: 0 16px;
    color: #53657a;
    background: #f8fbff;
    font-size: .75rem;
}

.jt-ai__form { display: grid; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--jt-ai-line); background: #fff; }
.jt-ai__research { display: flex; align-items: center; gap: 7px; color: #3f5369; font-size: .72rem; }
.jt-ai__research input { accent-color: var(--jt-ai-blue); }
.jt-ai__composer { display: grid; grid-template-columns: 1fr auto auto; align-items: end; gap: 7px; }
.jt-ai__composer textarea {
    min-height: 48px;
    max-height: 130px;
    resize: vertical;
    padding: 11px 12px;
    border: 1px solid #becde0;
    border-radius: 14px;
    color: #071722;
    background: #f9fbff;
    font: inherit;
    font-size: .86rem;
}
.jt-ai__voice, .jt-ai__send {
    min-height: 46px;
    border: 0;
    border-radius: 13px;
    cursor: pointer;
    font-weight: 800;
}
.jt-ai__voice { width: 44px; color: #1049a3; background: #e8f1ff; }
.jt-ai__voice.is-listening { color: #fff; background: #df233b; animation: jt-ai-pulse 1s infinite; }
.jt-ai__send { padding: 0 14px; color: #fff; background: var(--jt-ai-blue); }
.jt-ai__send:disabled { cursor: wait; opacity: .55; }

.jt-ai__privacy {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 13px;
    border-top: 1px solid var(--jt-ai-line);
    color: #68788a;
    background: #fff;
    font-size: .66rem;
    line-height: 1.35;
}
.jt-ai__privacy button { flex: 0 0 auto; border: 0; border-radius: 9px; padding: 6px; background: #eef5ff; cursor: pointer; }

[data-theme="dark"] .jt-ai {
    --jt-ai-ink: #edf6ff;
    --jt-ai-panel: #0c1724;
    --jt-ai-soft: #122338;
    --jt-ai-line: rgba(255,255,255,.14);
}
[data-theme="dark"] .jt-ai__messages,
[data-theme="dark"] .jt-ai__status { background: #091421; }
[data-theme="dark"] .jt-ai__message > div:first-child,
[data-theme="dark"] .jt-ai__form,
[data-theme="dark"] .jt-ai__privacy { color: #edf6ff; background: #101f30; }
[data-theme="dark"] .jt-ai__composer textarea { color: #edf6ff; border-color: #36516d; background: #0b1826; }
[data-theme="dark"] .jt-ai__research,
[data-theme="dark"] .jt-ai__status,
[data-theme="dark"] .jt-ai__privacy { color: #b9c8d8; }

@keyframes jt-ai-pulse { 50% { transform: scale(.9); box-shadow: 0 0 0 8px rgba(223,35,59,.12); } }

@media (max-width: 600px) {
    .jt-ai { position: static; }
    .jt-ai__launcher > span:last-child { display: none; }
    .jt-ai__launcher { padding: 6px; min-height: 42px; }
    .jt-ai__dialog { position: fixed; inset: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)); width: auto; height: auto; min-height: 0; border-radius: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    .jt-ai *, .jt-ai *::before, .jt-ai *::after { animation: none !important; transition: none !important; }
}
