/* Kitano AI workspace polish
 * Loaded after the legacy frontend bundle so the chat shell has one final,
 * predictable responsive and theme layer. It is intentionally scoped to the
 * Kitano workspace classes and does not style marketing or billing sections.
 */

body.frontend-body {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

body.frontend-body :where(
    .kitano-icon-button,
    .kitano-round-action,
    .kitano-send,
    .kitano-intelligence-button,
    .kitano-tool-item,
    .kitano-choice,
    .kitano-setting-row
) {
    -webkit-tap-highlight-color: transparent;
}

body.frontend-body :where(
    .kitano-icon-button,
    .kitano-round-action,
    .kitano-send,
    .kitano-intelligence-button
) {
    min-width: 40px;
    min-height: 40px;
}

body.frontend-body :where(
    .kitano-icon-button,
    .kitano-round-action,
    .kitano-send,
    .kitano-intelligence-button,
    .kitano-tool-item,
    .kitano-choice,
    .kitano-setting-row,
    .kitano-history-open,
    .kitano-popover-link
):focus-visible {
    outline: 3px solid color-mix(in srgb, #6f78f4 52%, transparent) !important;
    outline-offset: 2px;
}

body.frontend-body .kitano-svg-icon {
    width: 19px;
    height: 19px;
    stroke-width: 1.8;
}

body.frontend-body .kitano-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--kitano-ink) !important;
    text-decoration: none !important;
}

body.frontend-body .kitano-brand .kitano-brand-mark {
    width: 32px;
    height: 32px;
    max-width: none;
    flex: 0 0 32px;
    object-fit: cover;
    border: 1px solid var(--kitano-line);
    border-radius: 50%;
    filter: none !important;
}

body.frontend-body .kitano-brand-name {
    color: inherit;
    font-size: 18px;
    font-weight: 780;
    letter-spacing: -.035em;
    line-height: 1;
    white-space: nowrap;
}

body.frontend-body .kitano-nav,
body.frontend-body .kitano-composer,
body.frontend-body .kitano-popover,
body.frontend-body .kitano-tool-menu,
body.frontend-body .kitano-command-menu,
body.frontend-body .kitano-intelligence-panel,
body.frontend-body .kitano-search-dialog,
body.frontend-body .kitano-sources-panel {
    background-color: var(--kitano-panel) !important;
    border-color: var(--kitano-line) !important;
}

body.frontend-body .kitano-nav {
    background-color: var(--kitano-bg) !important;
    box-shadow: 0 1px 0 color-mix(in srgb, var(--kitano-ink) 4%, transparent);
}

body.frontend-body .kitano-composer {
    width: min(860px, calc(100% - 28px));
    border-width: 1px !important;
    box-shadow: 0 12px 34px rgba(16, 24, 40, .08) !important;
}

body.frontend-body .kitano-composer:focus-within {
    border-color: color-mix(in srgb, #6f78f4 48%, var(--kitano-line)) !important;
    box-shadow: 0 0 0 4px color-mix(in srgb, #6f78f4 12%, transparent),
                0 14px 38px rgba(16, 24, 40, .1) !important;
}

body.frontend-body .kitano-composer textarea {
    color: var(--kitano-ink) !important;
    font-size: 15.5px !important;
    letter-spacing: -.006em;
}

body.frontend-body .kitano-composer textarea::placeholder {
    color: var(--kitano-muted) !important;
    opacity: .92;
}

/* The model/settings trigger is the visible model selector. Give it enough
 * room for a branded model label instead of reducing it to a tiny icon. */
body.frontend-body .kitano-intelligence-button {
    max-width: 230px;
    min-height: 40px;
    padding: 7px 11px !important;
    border: 1px solid var(--kitano-line) !important;
    border-radius: 12px !important;
    background: var(--kitano-soft) !important;
    color: var(--kitano-ink) !important;
    font-size: 13px !important;
    font-weight: 700;
}

body.frontend-body .kitano-intelligence-button:hover,
body.frontend-body .kitano-intelligence-button[aria-expanded="true"] {
    border-color: color-mix(in srgb, #6f78f4 48%, var(--kitano-line)) !important;
    background: color-mix(in srgb, #6f78f4 8%, var(--kitano-panel)) !important;
}

body.frontend-body .kitano-intelligence-button > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.frontend-body .kitano-intelligence-panel {
    width: min(320px, calc(100vw - 24px));
    padding: 9px !important;
    border-radius: 16px !important;
    box-shadow: 0 24px 64px rgba(15, 20, 34, .2) !important;
}

body.frontend-body .kitano-setting-row,
body.frontend-body #kitano-model-choices .kitano-choice {
    min-height: 56px;
    padding: 9px 11px;
    border-radius: 11px;
}

body.frontend-body :where(.kitano-setting-row, #kitano-model-choices .kitano-choice) strong {
    color: var(--kitano-ink);
    font-size: 13.5px !important;
    line-height: 1.25;
}

body.frontend-body :where(.kitano-setting-row, #kitano-model-choices .kitano-choice) small {
    color: var(--kitano-muted) !important;
    font-size: 12px !important;
    line-height: 1.35;
}

body.frontend-body .kitano-tool-menu {
    width: min(440px, calc(100vw - 24px));
    padding: 8px !important;
    border-radius: 16px !important;
    box-shadow: 0 22px 58px rgba(15, 20, 34, .18) !important;
}

body.frontend-body .kitano-tool-item {
    min-height: 54px !important;
    grid-template-columns: 28px minmax(0, auto) minmax(0, 1fr);
    gap: 9px;
    padding: 9px 11px !important;
    border-radius: 11px;
}

body.frontend-body .kitano-tool-item strong {
    color: var(--kitano-ink);
    font-size: 13.5px !important;
}

body.frontend-body .kitano-tool-item span {
    color: var(--kitano-muted) !important;
    font-size: 12.5px !important;
}

body.frontend-body .kitano-message.assistant .bubble {
    color: var(--kitano-ink) !important;
}

body.frontend-body .kitano-message.user .bubble {
    border: 1px solid var(--kitano-line);
}

html[data-kitano-theme="dark"] body.frontend-body {
    --kitano-bg: #121315;
    --kitano-panel: #1b1d20;
    --kitano-soft: #24272b;
    --kitano-line: #373b41;
    --kitano-ink: #f5f6f7;
    --kitano-muted: #b0b5be;
    background: var(--kitano-bg) !important;
}

html[data-kitano-theme="dark"] body.frontend-body :where(
    .kitano-nav,
    .kitano-composer,
    .kitano-popover,
    .kitano-tool-menu,
    .kitano-command-menu,
    .kitano-intelligence-panel,
    .kitano-search-dialog,
    .kitano-sources-panel,
    .kitano-sidebar-account
) {
    background: var(--kitano-panel) !important;
    border-color: var(--kitano-line) !important;
    backdrop-filter: none !important;
}

html[data-kitano-theme="dark"] body.frontend-body .kitano-composer {
    box-shadow: 0 16px 44px rgba(0, 0, 0, .28) !important;
}

html[data-kitano-theme="dark"] body.frontend-body .kitano-composer:focus-within {
    border-color: #686f83 !important;
    box-shadow: 0 0 0 4px rgba(130, 139, 255, .12),
                0 18px 48px rgba(0, 0, 0, .34) !important;
}

html[data-kitano-theme="dark"] body.frontend-body .kitano-intelligence-button {
    background: #25282d !important;
    border-color: #3d424a !important;
}

html[data-kitano-theme="dark"] body.frontend-body .kitano-intelligence-button:hover,
html[data-kitano-theme="dark"] body.frontend-body .kitano-intelligence-button[aria-expanded="true"] {
    background: #2b2f35 !important;
    border-color: #606775 !important;
}

body.frontend-body.kitano-chat-mode #capabilities,
body.frontend-body.kitano-chat-mode #prices {
    display: none !important;
}

@media (max-width: 700px) {
    html.kitano-chat-mode {
        width: 100%;
        height: 100%;
        overflow: hidden !important;
        overscroll-behavior: none;
    }

    body.frontend-body.kitano-chat-mode {
        width: 100%;
        height: 100%;
        overflow: hidden !important;
        overscroll-behavior: none;
    }

    body.frontend-body .kitano-hero.chat-active {
        position: fixed !important;
        inset: calc(58px + env(safe-area-inset-top)) 0 0 !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        padding: 42px 8px 0 !important;
        overflow: hidden !important;
        z-index: 2;
    }

    body.frontend-body .kitano-brand {
        justify-content: center;
        gap: 8px;
    }

    body.frontend-body .kitano-brand .kitano-brand-mark {
        width: 28px;
        height: 28px;
        flex-basis: 28px;
    }

    body.frontend-body .kitano-brand-name {
        font-size: 16px;
    }

    body.frontend-body .kitano-composer,
    body.frontend-body .kitano-hero.chat-active .kitano-composer {
        z-index: 75 !important;
        left: 9px !important;
        right: 9px !important;
        bottom: max(7px, env(safe-area-inset-bottom)) !important;
        width: auto !important;
        min-height: 120px !important;
        padding: 10px !important;
        border-radius: 26px !important;
        transition: border-color .18s ease, box-shadow .18s ease !important;
    }

    body.frontend-body .kitano-composer-row {
        display: grid !important;
        grid-template-columns: 46px minmax(0, 1fr) !important;
        grid-template-rows: minmax(58px, auto) 46px !important;
        width: 100%;
        min-width: 0;
        gap: 7px 8px !important;
        align-items: end;
    }

    body.frontend-body .kitano-composer textarea {
        display: block;
        grid-column: 1 / -1 !important;
        grid-row: 1 !important;
        width: 100% !important;
        min-width: 0 !important;
        height: var(--kitano-prompt-height, 58px) !important;
        min-height: 58px !important;
        max-height: min(220px, 34dvh) !important;
        padding: 12px 14px 7px !important;
        border-radius: 16px !important;
        font-size: 16px !important;
        line-height: 1.5 !important;
        white-space: pre-wrap !important;
        overflow-wrap: anywhere;
        overflow-x: hidden;
        overflow-y: hidden;
        scrollbar-width: thin;
        scrollbar-color: color-mix(in srgb, var(--kitano-ink) 35%, transparent) transparent;
    }

    body.frontend-body #kitano-tools-toggle {
        display: inline-grid !important;
        flex: 0 0 46px !important;
        grid-column: 1 !important;
        grid-row: 2 !important;
        width: 46px !important;
        min-width: 46px !important;
        height: 46px !important;
    }

    body.frontend-body .kitano-composer-actions {
        display: flex !important;
        flex: 0 0 auto !important;
        grid-column: 2 !important;
        grid-row: 2 !important;
        justify-content: flex-end;
        width: 100% !important;
        min-width: 0;
        gap: 4px !important;
        padding: 0 !important;
    }

    body.frontend-body .kitano-composer-actions > #kitano-intelligence-toggle {
        display: inline-flex !important;
        flex: 1 1 116px !important;
        width: auto !important;
        min-width: 96px !important;
        max-width: 154px !important;
        height: 46px !important;
        justify-content: center;
        padding: 0 10px !important;
        border-radius: 14px !important;
    }

    body.frontend-body #kitano-intelligence-toggle > span {
        display: block !important;
        min-width: 0;
        max-width: none;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body.frontend-body #kitano-intelligence-toggle > .fa-chevron-up {
        display: none !important;
    }

    body.frontend-body .kitano-composer-actions .kitano-round-action,
    body.frontend-body .kitano-composer-actions .kitano-send {
        flex: 0 0 46px !important;
        width: 46px !important;
        min-width: 46px !important;
        height: 46px !important;
    }

    body.frontend-body .kitano-intelligence-panel,
    body.frontend-body .kitano-intelligence-panel.open {
        position: fixed !important;
        z-index: 190 !important;
        left: 9px !important;
        right: 9px !important;
        top: auto !important;
        bottom: calc(var(--kitano-composer-height, 120px) + 15px + env(safe-area-inset-bottom)) !important;
        width: auto !important;
        max-height: min(66dvh, 560px) !important;
        overflow-y: auto !important;
        border-radius: 18px !important;
    }

    body.frontend-body .kitano-tool-menu {
        position: fixed !important;
        left: 9px !important;
        right: 9px !important;
        top: auto !important;
        bottom: calc(var(--kitano-composer-height, 120px) + 15px + env(safe-area-inset-bottom)) !important;
        width: auto !important;
        max-height: min(370px, 58dvh) !important;
        overflow-y: auto;
    }

    body.frontend-body .kitano-hero.chat-active .kitano-thread {
        flex: 1 1 auto !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        padding: 6px 3px 176px !important;
        scroll-padding-bottom: 176px !important;
        overscroll-behavior-y: contain;
        overflow-anchor: none;
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 390px) {
    body.frontend-body .kitano-composer textarea {
        min-width: 0 !important;
    }

    body.frontend-body .kitano-composer-actions > #kitano-intelligence-toggle {
        flex-basis: 74px !important;
        min-width: 68px !important;
        max-width: 92px !important;
        padding-inline: 7px !important;
    }

    body.frontend-body #kitano-intelligence-toggle > span {
        max-width: 66px;
    }

    body.frontend-body #kitano-intelligence-toggle > .fa-sparkles {
        display: none !important;
    }

    body.frontend-body .kitano-composer-actions .kitano-round-action,
    body.frontend-body .kitano-composer-actions .kitano-send,
    body.frontend-body #kitano-tools-toggle {
        flex-basis: 44px !important;
        width: 44px !important;
        min-width: 44px !important;
        height: 44px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.frontend-body .kitano-composer,
    body.frontend-body .kitano-intelligence-panel,
    body.frontend-body .kitano-tool-menu {
        transition: none !important;
    }
}

/* Kitano workspace visual system v7
 * A final, deliberately small override layer for the public workspace. It
 * improves depth, contrast and responsive composition without changing the
 * request, history, voice, image or task behaviour implemented by the page.
 */
body.frontend-body {
    --kitano-bg: #f6f7fb;
    --kitano-panel: #ffffff;
    --kitano-soft: #f0f2f7;
    --kitano-line: #dfe3ec;
    --kitano-ink: #121622;
    --kitano-muted: #687184;
    --kitano-brand-accent: #6875ff;
    --kitano-brand-cyan: #44c7e8;
    background: var(--kitano-bg) !important;
}

html[data-kitano-theme="dark"] body.frontend-body {
    --kitano-bg: #0d0f13;
    --kitano-panel: #17191f;
    --kitano-soft: #20232b;
    --kitano-line: #30343e;
    --kitano-ink: #f7f8fb;
    --kitano-muted: #a9b0bd;
    background: var(--kitano-bg) !important;
}

body.frontend-body :where(.page, .page-main, .main-content, .side-app, .frontend-background) {
    background: var(--kitano-bg) !important;
}

body.frontend-body .kitano-nav {
    min-height: 66px;
    background: color-mix(in srgb, var(--kitano-bg) 92%, transparent) !important;
    border-bottom: 1px solid color-mix(in srgb, var(--kitano-line) 86%, transparent) !important;
    box-shadow: 0 1px 0 color-mix(in srgb, var(--kitano-ink) 3%, transparent) !important;
    backdrop-filter: blur(20px) saturate(1.18) !important;
}

body.frontend-body .kitano-brand .kitano-brand-mark {
    border-color: color-mix(in srgb, var(--kitano-brand-cyan) 35%, var(--kitano-line));
    box-shadow: 0 7px 22px rgba(36, 155, 210, .18);
}

body.frontend-body .kitano-nav-links > a:not(.kitano-start) {
    padding-inline: 4px;
    color: color-mix(in srgb, var(--kitano-ink) 88%, var(--kitano-muted));
    text-decoration: none;
    transition: color .16s ease, transform .16s ease;
}

body.frontend-body .kitano-nav-links > a:not(.kitano-start):hover {
    color: var(--kitano-ink);
    transform: translateY(-1px);
}

body.frontend-body .kitano-start,
body.frontend-body .kitano-nav-install {
    min-height: 42px;
    border-radius: 13px !important;
}

body.frontend-body .kitano-hero:not(.chat-active) {
    isolation: isolate;
    overflow: hidden;
    background:
        radial-gradient(circle at 18% 16%, color-mix(in srgb, var(--kitano-brand-cyan) 8%, transparent), transparent 29%),
        radial-gradient(circle at 82% 4%, color-mix(in srgb, var(--kitano-brand-accent) 11%, transparent), transparent 32%),
        linear-gradient(180deg, color-mix(in srgb, var(--kitano-panel) 18%, transparent), transparent 48%),
        var(--kitano-bg) !important;
}

body.frontend-body .kitano-hero:not(.chat-active)::before {
    position: absolute;
    z-index: -1;
    inset: 0;
    content: "";
    background-image: radial-gradient(circle, color-mix(in srgb, var(--kitano-ink) 12%, transparent) .7px, transparent .8px);
    background-size: 27px 27px;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,.55), transparent 58%);
    opacity: .25;
    pointer-events: none;
}

body.frontend-body .kitano-hero:not(.chat-active) > h1 {
    max-width: 880px;
    text-shadow: 0 1px 0 color-mix(in srgb, var(--kitano-panel) 65%, transparent);
}

body.frontend-body .kitano-hero:not(.chat-active) > .kitano-lead {
    max-width: 720px;
    color: color-mix(in srgb, var(--kitano-muted) 91%, var(--kitano-ink));
}

body.frontend-body .kitano-composer {
    border-color: color-mix(in srgb, var(--kitano-line) 78%, var(--kitano-ink)) !important;
    background: color-mix(in srgb, var(--kitano-panel) 96%, var(--kitano-soft)) !important;
    box-shadow: 0 20px 60px rgba(18, 24, 40, .11), 0 3px 10px rgba(18, 24, 40, .055) !important;
}

html[data-kitano-theme="dark"] body.frontend-body .kitano-composer {
    background: #181b21 !important;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .34), inset 0 1px 0 rgba(255,255,255,.025) !important;
}

body.frontend-body .kitano-composer :where(.kitano-round-action, .kitano-intelligence-button) {
    border-color: color-mix(in srgb, var(--kitano-line) 82%, transparent) !important;
    transition: transform .16s ease, color .16s ease, border-color .16s ease, background-color .16s ease;
}

body.frontend-body .kitano-composer :where(.kitano-round-action, .kitano-intelligence-button):hover {
    border-color: color-mix(in srgb, var(--kitano-brand-accent) 42%, var(--kitano-line)) !important;
    color: var(--kitano-ink) !important;
    transform: translateY(-1px);
}

body.frontend-body .kitano-hero:not(.chat-active) .kitano-suggestion {
    border-color: color-mix(in srgb, var(--kitano-line) 84%, transparent) !important;
    background: color-mix(in srgb, var(--kitano-panel) 97%, var(--kitano-soft)) !important;
    box-shadow: 0 10px 28px rgba(19, 28, 48, .055);
}

body.frontend-body .kitano-hero.chat-active {
    background:
        linear-gradient(90deg, transparent, color-mix(in srgb, var(--kitano-panel) 18%, transparent) 50%, transparent),
        var(--kitano-bg) !important;
}

body.frontend-body .kitano-hero.chat-active .kitano-thread {
    width: min(900px, 100%);
    margin-inline: auto;
}

body.frontend-body .kitano-message.user .bubble {
    max-width: min(72ch, 78vw);
    border-color: color-mix(in srgb, var(--kitano-line) 78%, var(--kitano-ink));
    background: color-mix(in srgb, var(--kitano-soft) 90%, var(--kitano-panel));
    box-shadow: 0 5px 18px rgba(18, 24, 40, .045);
}

html[data-kitano-theme="dark"] body.frontend-body .kitano-message.user .bubble {
    background: #252830 !important;
    border-color: #363b46 !important;
}

body.frontend-body .kitano-message.assistant .bubble {
    color: color-mix(in srgb, var(--kitano-ink) 95%, var(--kitano-muted)) !important;
}

body.frontend-body .kitano-message.assistant .bubble :where(h1, h2, h3) {
    text-wrap: balance;
}

body.frontend-body .kitano-message.assistant .bubble :where(blockquote.kitano-callout, details, .kitano-table-shell) {
    box-shadow: 0 8px 28px rgba(18, 24, 40, .04);
}

body.frontend-body .kitano-generated-figure,
body.frontend-body .kitano-source-card.kitano-output-card,
body.frontend-body .kitano-audio-result {
    border: 1px solid var(--kitano-line);
    box-shadow: 0 18px 48px rgba(18, 24, 40, .09);
}

body.frontend-body .kitano-generated-figure {
    background: color-mix(in srgb, var(--kitano-soft) 82%, var(--kitano-panel));
}

body.frontend-body .kitano-image-edit,
body.frontend-body .kitano-image-download {
    min-width: 46px;
    height: 42px;
    background: rgba(12, 15, 21, .84);
    border: 1px solid rgba(255,255,255,.16);
    box-shadow: 0 10px 30px rgba(0,0,0,.24);
}

body.frontend-body .kitano-status.visible,
body.frontend-body .kitano-inline-task {
    border-color: color-mix(in srgb, var(--kitano-brand-accent) 26%, var(--kitano-line)) !important;
    background: color-mix(in srgb, var(--kitano-panel) 95%, var(--kitano-brand-accent)) !important;
    box-shadow: 0 16px 45px rgba(43, 51, 112, .09);
}

body.frontend-body .kitano-capability,
body.frontend-body .kitano-price-card {
    background: color-mix(in srgb, var(--kitano-panel) 97%, var(--kitano-soft));
    border-color: color-mix(in srgb, var(--kitano-line) 88%, transparent);
    box-shadow: 0 18px 52px rgba(18, 24, 40, .065);
}

body.frontend-body .kitano-price-card.featured {
    border-color: color-mix(in srgb, var(--kitano-brand-accent) 58%, var(--kitano-line));
    box-shadow: 0 24px 70px rgba(79, 89, 215, .15);
}

@media (max-width: 700px) {
    body.frontend-body .kitano-nav {
        min-height: calc(58px + env(safe-area-inset-top));
        backdrop-filter: blur(18px) saturate(1.12) !important;
    }

    /* The idle page should read like a complete landing screen. Only an
       active conversation needs the fixed, bottom-aligned composer. */
    body.frontend-body .kitano-hero:not(.chat-active) {
        min-height: auto !important;
        padding: clamp(30px, 6vh, 54px) 12px 54px !important;
        overflow: visible !important;
    }

    body.frontend-body .kitano-hero:not(.chat-active) .kitano-composer {
        position: relative !important;
        z-index: 5 !important;
        inset: auto !important;
        width: min(100%, 520px) !important;
        min-height: 120px !important;
        margin: 24px auto 0 !important;
    }

    body.frontend-body .kitano-hero:not(.chat-active) .kitano-suggestions {
        order: initial;
        margin-top: 12px !important;
    }

    body.frontend-body .kitano-hero:not(.chat-active) .kitano-note {
        margin-top: 14px !important;
    }

    body.frontend-body .kitano-hero.chat-active .kitano-thread {
        padding-inline: 7px !important;
    }

    body.frontend-body .kitano-message.user .bubble {
        max-width: min(88vw, 62ch);
        padding: 11px 14px;
    }

    body.frontend-body .kitano-message.assistant .bubble {
        font-size: 15px !important;
        line-height: 1.6 !important;
    }

    body.frontend-body .kitano-message.assistant .kitano-message-actions,
    body.frontend-body .kitano-message.user .kitano-message-actions {
        opacity: .82 !important;
        visibility: visible !important;
        transform: none !important;
    }
}

@media (max-width: 390px) {
    body.frontend-body .kitano-hero:not(.chat-active) > h1 {
        font-size: clamp(30px, 9.4vw, 38px) !important;
    }

    body.frontend-body .kitano-hero:not(.chat-active) > .kitano-lead {
        font-size: 14px !important;
    }
}
