:root {
    --bg: #060607;
    --bg-soft: #0e0e12;
    --panel: #101015;
    --panel-soft: #17171f;
    --line: #2b2b36;
    --line-soft: #20202a;
    --text: #f4f4f6;
    --muted: #9a9aa7;
    --white: #ffffff;
    --black: #000000;
    --radius: 14px;
    --shadow: 0 24px 52px rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "Manrope", "Segoe UI", sans-serif;
}

a {
    color: inherit;
}

.chat-body {
    min-height: 100vh;
    min-height: 100dvh;
}

.chat-preloader {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-content: center;
    gap: 12px;
    background: rgba(8, 8, 10, 0.95);
    transition: opacity 0.2s ease;
}

.chat-preloader.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.chat-preloader-spinner {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.24);
    border-top-color: #fff;
    animation: chat-spin 0.8s linear infinite;
    margin: 0 auto;
}

.chat-preloader-label {
    font-size: 0.92rem;
    font-weight: 700;
}

@keyframes chat-spin {
    to {
        transform: rotate(360deg);
    }
}

.chat-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    background:
        radial-gradient(
            900px 460px at 80% 0%,
            rgba(255, 255, 255, 0.05),
            transparent 70%
        ),
        radial-gradient(
            540px 360px at 24% 100%,
            rgba(255, 255, 255, 0.05),
            transparent 72%
        ),
        linear-gradient(180deg, #08080b 0%, #0d0d11 100%);
    transition: background 0.35s ease;
}

.chat-shell.is-smart-mode {
    background:
        radial-gradient(
            980px 520px at 78% -8%,
            rgba(255, 255, 255, 0.09),
            transparent 72%
        ),
        radial-gradient(
            700px 430px at 15% 100%,
            rgba(255, 255, 255, 0.09),
            transparent 74%
        ),
        linear-gradient(180deg, #06060a 0%, #0f1016 100%);
}

.chat-shell.is-mode-switching .chat-smart-toggle {
    animation: chat-mode-pulse 0.5s ease;
}

@keyframes chat-mode-pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.04);
    }
    100% {
        transform: scale(1);
    }
}

.chat-sidebar {
    width: 320px;
    flex: 0 0 320px;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 500;
    border-right: 1px solid var(--line);
    background: linear-gradient(
        180deg,
        rgba(8, 8, 11, 0.98),
        rgba(13, 13, 18, 0.95)
    );
    padding: 14px;
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    gap: 12px;
}

.chat-brand {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 6px 6px 2px;
}

.chat-brand img {
    width: 44px;
    height: 44px;
}

.chat-brand-text strong {
    display: block;
    font-size: 1.03rem;
    font-weight: 800;
    line-height: 1.1;
}

.chat-brand-text span {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.76rem;
}

.chat-new-button {
    min-height: 44px;
    border-radius: 12px;
    border: 1px solid #555566;
    background: linear-gradient(180deg, #f2f2f4, #dfdfe5);
    color: #111119;
    font-size: 0.92rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition:
        transform 0.16s ease,
        box-shadow 0.16s ease;
}

.chat-new-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(255, 255, 255, 0.2);
}

.chat-new-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-sessions-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.chat-sessions-count {
    border-radius: 999px;
    border: 1px solid #4a4a5b;
    padding: 2px 8px;
    font-size: 0.74rem;
    color: #d8d8e3;
}

.chat-sessions {
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-content: flex-start;
    gap: 8px;
    overflow-y: auto;
    padding-right: 2px;
}

.chat-session-item {
    min-height: 56px;
    max-height: 88px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    color: #f4f4f7;
    text-align: left;
    display: grid;
    align-content: center;
    gap: 3px;
    padding: 9px 10px;
    cursor: pointer;
    flex: 0 0 auto;
}

.chat-session-item:hover {
    border-color: #626276;
}

.chat-session-item.is-active {
    border-color: #f0f0f3;
    background: rgba(255, 255, 255, 0.14);
    color: #101016;
}

.chat-session-title {
    font-size: 0.88rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-session-meta {
    font-size: 0.73rem;
    color: #a8a8b5;
}

.chat-session-item.is-active .chat-session-meta {
    color: #2f303b;
}

.chat-sidebar-footer {
    border-top: 1px solid var(--line);
    padding: 10px 3px 2px;
    display: flex;
    align-items: center;
}

.chat-account-button {
    width: 100%;
    min-height: 38px;
    border-radius: 10px;
    border: 1px solid #555568;
    background: rgba(255, 255, 255, 0.04);
    text-decoration: none;
    color: #ececf2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 0.82rem;
    font-weight: 800;
}

.chat-account-button:hover {
    border-color: #8a8a9c;
    background: rgba(255, 255, 255, 0.1);
}

.chat-sidebar-overlay {
    display: none;
}

.chat-main {
    min-width: 0;
    flex: 1 1 auto;
    height: 100vh;
    height: 100dvh;
    min-height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr auto auto;
}

.chat-topbar {
    min-height: 72px;
    border-bottom: 1px solid var(--line);
    background: rgba(9, 9, 12, 0.66);
    backdrop-filter: blur(10px);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
}

.chat-topbar-menu {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    color: #fff;
    display: none;
}

.chat-topbar-title h1 {
    margin: 0;
    font-size: 1.06rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-topbar-title p {
    margin: 3px 0 0;
    font-size: 0.77rem;
    color: var(--muted);
}

.chat-topbar-metrics {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-metric {
    min-height: 34px;
    border-radius: 12px;
    border: 1px solid #464658;
    background: rgba(255, 255, 255, 0.04);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    font-size: 0.78rem;
    font-weight: 700;
}

.chat-metric i {
    font-size: 0.86rem;
}

.chat-metric-stack {
    display: grid;
    line-height: 1;
    gap: 3px;
}

.chat-metric-stack small {
    color: #9d9daf;
    font-size: 0.61rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.chat-metric-usage {
    min-width: 204px;
    padding-right: 12px;
}

.chat-metric-progress {
    width: 54px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    overflow: hidden;
    margin-left: 4px;
}

.chat-metric-progress span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #fcfcff 0%, #9292a8 100%);
    transition: width 0.2s ease;
}

.chat-metric-left {
    white-space: nowrap;
}

.chat-smart-toggle {
    min-height: 34px;
    border-radius: 12px;
    border: 1px solid #5e5e71;
    background: rgba(255, 255, 255, 0.08);
    color: #ececf2;
    padding: 0 11px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
    transition:
        border-color 0.2s ease,
        background 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
}

.chat-smart-toggle.is-active,
.chat-shell.is-smart-mode .chat-smart-toggle {
    border-color: #fff;
    background: #fff;
    color: #101018;
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(255, 255, 255, 0.23);
}

.chat-topbar-actions {
    display: inline-flex;
}

.chat-action-link {
    min-height: 34px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    text-decoration: none;
    color: #ececf1;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 11px;
    font-size: 0.78rem;
    font-weight: 700;
}

.chat-action-link:hover {
    border-color: #646479;
    background: rgba(255, 255, 255, 0.1);
}

.chat-messages {
    min-height: 0;
    overflow-y: auto;
    padding: 18px clamp(14px, 2vw, 28px);
    display: grid;
    align-content: start;
    gap: 16px;
    position: relative;
}

.chat-panel-loader {
    position: sticky;
    top: 8px;
    justify-self: center;
    z-index: 3;
    min-height: 34px;
    border-radius: 999px;
    border: 1px solid #464659;
    background: rgba(15, 15, 20, 0.92);
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    font-weight: 700;
}

.chat-panel-loader[hidden] {
    display: none;
}

.chat-panel-loader-spinner {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    animation: chat-spin 0.72s linear infinite;
}

.chat-welcome {
    width: min(800px, 100%);
    justify-self: center;
    text-align: center;
    margin: clamp(48px, 12vh, 130px) auto 24px;
    display: grid;
    gap: 12px;
}

.chat-welcome img {
    width: clamp(58px, 8vw, 74px);
    height: clamp(58px, 8vw, 74px);
    margin: 0 auto;
}

.chat-welcome h2 {
    margin: 0;
    font-size: clamp(1.6rem, 2.6vw, 2.5rem);
    line-height: 1.1;
}

.chat-welcome p {
    margin: 0;
    color: var(--muted);
    font-size: clamp(0.92rem, 1.3vw, 1.02rem);
}

.chat-welcome-quick {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-quick-button {
    min-height: 36px;
    border-radius: 999px;
    border: 1px solid #4b4b5f;
    background: rgba(255, 255, 255, 0.04);
    color: #f1f1f5;
    padding: 0 12px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.chat-quick-button:hover {
    border-color: #9c9cae;
}

.chat-message {
    max-width: min(980px, 100%);
    display: grid;
    gap: 5px;
}

.chat-message.is-user {
    justify-self: end;
}

.chat-message.is-assistant {
    justify-self: start;
}

.chat-message-head {
    font-size: 0.74rem;
    color: #a4a4b1;
    font-weight: 700;
}

.chat-message-bubble {
    border-radius: 14px;
    border: 1px solid #353543;
    background: rgba(16, 16, 22, 0.88);
    color: #f2f2f7;
    padding: 12px 14px;
    font-size: 0.94rem;
    line-height: 1.58;
    box-shadow: var(--shadow);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.chat-message.is-user .chat-message-bubble {
    border-color: #ededf3;
    background: #f4f4f6;
    color: #11111a;
    box-shadow: none;
}

.chat-message-bubble p {
    margin: 0 0 10px;
}

.chat-message-bubble p:last-child {
    margin-bottom: 0;
}

.chat-message-bubble ul,
.chat-message-bubble ol {
    margin: 6px 0 10px;
    padding-left: 20px;
}

.chat-message-bubble li + li {
    margin-top: 4px;
}

.chat-message-bubble pre {
    margin: 10px 0;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #3f3f4d;
    background: #0b0b11;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.chat-message-bubble code {
    font-family: "JetBrains Mono", "Consolas", monospace;
    font-size: 0.85rem;
    word-break: break-word;
}

.chat-message-bubble pre code {
    display: block;
    width: max-content;
    min-width: 100%;
    white-space: pre;
    word-break: normal;
}

.chat-message-bubble blockquote {
    margin: 10px 0;
    padding: 8px 10px;
    border-left: 3px solid #626274;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
}

.chat-message-bubble .katex-display {
    overflow-x: auto;
    overflow-y: hidden;
}

.chat-thinking-text {
    display: inline-block;
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: rgba(214, 232, 249, 0.92);
}

.chat-thinking-text.is-active {
    background: linear-gradient(
        90deg,
        rgba(149, 196, 240, 0.42) 0%,
        rgba(241, 251, 255, 0.98) 46%,
        rgba(145, 203, 247, 0.42) 100%
    );
    background-size: 230% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: chat-shimmer 1.35s linear infinite;
}

@keyframes chat-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -25% 0;
    }
}

.chat-reasoning-card {
    width: min(980px, 100%);
    justify-self: start;
    border: 1px solid #3f3f51;
    border-radius: 14px;
    background: rgba(14, 14, 20, 0.92);
    overflow: hidden;
}

.chat-reasoning-toggle {
    width: 100%;
    border: 0;
    background: transparent;
    color: #efeff7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 13px;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
}

.chat-reasoning-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
}

.chat-reasoning-toggle i:last-child {
    transition: transform 0.2s ease;
}

.chat-reasoning-toggle[aria-expanded="false"] i:last-child {
    transform: rotate(-90deg);
}

.chat-reasoning-body {
    border-top: 1px solid #333344;
    padding: 10px 14px 12px;
    display: grid;
    gap: 8px;
}

.chat-reasoning-body[hidden] {
    display: none;
}

.chat-reasoning-content {
    max-height: min(48vh, 310px);
    overflow-y: auto;
    padding-right: 2px;
}

.chat-reasoning-card.is-expanded .chat-reasoning-content {
    max-height: min(72vh, 760px);
}

.chat-reasoning-content::-webkit-scrollbar {
    width: 8px;
}

.chat-reasoning-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 999px;
}

.chat-reasoning-paragraphs {
    display: grid;
    gap: 8px;
}

.chat-reasoning-paragraphs p {
    margin: 0;
    color: #dbdbea;
    font-size: 0.83rem;
    line-height: 1.5;
}

.chat-reasoning-ops-title {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #a7a7ba;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.chat-reasoning-ops {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 6px;
    color: #dbdbea;
    font-size: 0.82rem;
}

.chat-reasoning-status {
    color: #9f9fb2;
    font-size: 0.76rem;
}

.chat-reasoning-expand {
    justify-self: start;
    min-height: 30px;
    border-radius: 999px;
    border: 1px solid #4b4b60;
    background: rgba(255, 255, 255, 0.04);
    color: #dcdceb;
    padding: 0 11px;
    font-size: 0.74rem;
    font-weight: 700;
    cursor: pointer;
}

.chat-reasoning-expand:hover {
    border-color: #8b8ba0;
    background: rgba(255, 255, 255, 0.1);
}

.chat-route-hint {
    margin: 0 clamp(14px, 2vw, 28px) 9px;
    border: 1px solid #4d4d60;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.06);
    color: #f1f1f6;
    padding: 9px 11px;
    font-size: 0.82rem;
}

.chat-composer-wrap {
    border-top: 1px solid var(--line);
    padding: 12px clamp(14px, 2vw, 28px) 15px;
    padding-bottom: calc(15px + env(safe-area-inset-bottom, 0px));
    display: grid;
    gap: 8px;
    background: rgba(7, 7, 10, 0.82);
}

.chat-composer {
    border: 1px solid #505064;
    border-radius: 16px;
    background: #101017;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
    padding: 10px;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s ease;
}

.chat-composer:focus-within {
    border-color: #f3f3f6;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
    transform: translateY(-1px);
}

.chat-composer-input-wrap {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: start;
}

.chat-composer-input-wrap i {
    margin-top: 6px;
    color: #9d9daf;
    font-size: 0.9rem;
}

.chat-composer textarea {
    min-height: 32px;
    max-height: 220px;
    resize: none;
    border: 0;
    outline: 0;
    width: 100%;
    background: transparent;
    color: #f2f2f7;
    font-size: 0.95rem;
    line-height: 1.45;
    font-family: inherit;
}

.chat-composer textarea::placeholder {
    color: #878796;
}

.chat-send-button {
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 14px;
    background: linear-gradient(145deg, #ffffff 0%, #dfe9ff 100%);
    color: #0c1528;
    font-size: 1.06rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        opacity 0.2s ease,
        background 0.2s ease;
}

.chat-send-button i {
    transition:
        transform 0.2s ease,
        opacity 0.2s ease;
}

.chat-send-button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 9px 22px rgba(170, 214, 255, 0.38);
}

.chat-send-button:hover:not(:disabled) i {
    transform: translateY(-1px);
}

.chat-send-button.is-ready {
    box-shadow: 0 10px 24px rgba(99, 174, 255, 0.26);
}

.chat-send-button:disabled {
    opacity: 0.56;
    cursor: not-allowed;
    box-shadow: none;
}

.chat-footer-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    color: #8f8fa0;
    font-size: 0.78rem;
}

.chat-footer-meta strong {
    color: #f4f4f6;
    font-size: 0.78rem;
    border: 1px solid #39394a;
    border-radius: 999px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.03);
}

.chat-main.is-draft-empty .chat-messages {
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 16px;
    padding-top: 8px;
    padding-bottom: 18px;
}

.chat-main.is-draft-empty .chat-welcome {
    margin: 0 auto 24px;
}

.chat-main.is-draft-empty .chat-route-hint {
    display: none !important;
}

.chat-main.is-draft-empty .chat-composer-wrap {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    border-top: 0;
    background: transparent;
    width: min(860px, 100%);
    margin: 0 auto clamp(24px, 5vh, 44px);
    padding-top: 4px;
    z-index: 2;
}

.chat-main.is-draft-empty .chat-composer {
    max-width: 100%;
    margin: 0;
    border-radius: 18px;
    padding: 12px 12px 12px 14px;
    min-height: 84px;
}

.chat-main.is-draft-empty .chat-composer textarea {
    min-height: 52px;
    font-size: 1.02rem;
    line-height: 1.5;
}

@media (max-width: 1120px) {
    .chat-topbar {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .chat-topbar-menu {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .chat-topbar-actions {
        display: none;
    }

    .chat-metric-usage {
        min-width: 0;
    }

    .chat-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(86vw, 330px);
        height: 100dvh;
        transform: translateX(-101%);
        transition: transform 0.22s ease;
        box-shadow: 18px 0 36px rgba(0, 0, 0, 0.55);
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }

    .chat-shell.is-sidebar-open .chat-sidebar {
        transform: translateX(0);
    }

    .chat-sidebar-overlay {
        position: fixed;
        inset: 0;
        z-index: 480;
        background: rgba(0, 0, 0, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
        display: block;
    }

    .chat-shell.is-sidebar-open .chat-sidebar-overlay {
        opacity: 1;
        pointer-events: auto;
    }
}

@media (max-width: 900px) {
    .chat-topbar {
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-areas:
            "menu title"
            "metrics metrics";
        align-items: center;
        gap: 8px;
        padding: 10px 12px;
    }

    .chat-topbar-menu {
        grid-area: menu;
        width: 38px;
        height: 38px;
    }

    .chat-topbar-title {
        grid-area: title;
        min-width: 0;
    }

    .chat-topbar-metrics {
        grid-area: metrics;
        width: 100%;
        justify-content: flex-start;
        gap: 6px;
        padding-bottom: 2px;
    }

    .chat-metric {
        min-height: 32px;
        max-width: 100%;
    }

    .chat-metric-usage {
        min-width: 0;
        flex: 1 1 220px;
    }

    .chat-smart-toggle {
        min-height: 32px;
        white-space: nowrap;
    }

    .chat-main.is-draft-empty .chat-composer-wrap {
        position: static;
        border-top: 0;
        background: transparent;
        padding-top: 10px;
        width: 100%;
        margin: 0;
    }
}

@media (max-width: 760px) {
    .chat-shell {
        min-height: 100dvh;
    }

    .chat-topbar {
        padding: 8px 10px;
        gap: 6px;
    }

    .chat-topbar-title h1 {
        font-size: 0.92rem;
    }

    .chat-topbar-title p {
        font-size: 0.7rem;
    }

    .chat-topbar-metrics {
        justify-content: flex-start;
        gap: 5px;
    }

    .chat-metric,
    .chat-smart-toggle {
        min-height: 30px;
        font-size: 0.7rem;
        padding-left: 8px;
        padding-right: 8px;
    }

    .chat-metric-progress {
        display: none;
    }

    .chat-composer-input-wrap {
        gap: 8px;
    }

    .chat-composer-input-wrap i {
        margin-top: 5px;
    }

    .chat-messages {
        padding: 14px 10px;
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }

    .chat-route-hint,
    .chat-composer-wrap {
        padding-left: 10px;
        padding-right: 10px;
        margin-left: 0;
        margin-right: 0;
    }

    .chat-message-bubble {
        font-size: 0.9rem;
    }

    .chat-message-bubble pre {
        margin: 8px 0;
        padding: 9px 10px;
    }

    .chat-message-bubble pre code {
        font-size: 0.77rem;
    }

    .chat-main.is-draft-empty .chat-composer-wrap {
        bottom: auto;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        margin-bottom: 0;
    }
}

@media (max-width: 520px) {
    .chat-sidebar {
        width: min(92vw, 350px);
    }

    .chat-metric-left {
        display: none;
    }

    .chat-metric-usage {
        flex: 1 1 100%;
    }

    .chat-smart-toggle {
        flex: 1 1 auto;
        justify-content: center;
    }

    .chat-welcome {
        width: min(94vw, 580px);
        gap: 10px;
    }

    .chat-welcome h2 {
        font-size: clamp(1.34rem, 7vw, 1.58rem);
    }

    .chat-welcome-quick {
        gap: 6px;
    }

    .chat-quick-button {
        min-height: 34px;
        font-size: 0.73rem;
        padding: 0 10px;
    }

    .chat-composer {
        gap: 8px;
        padding: 8px 0 4px;
        border-radius: 0;
    }

    .chat-composer textarea {
        font-size: 0.92rem;
        line-height: 1.4;
    }

    .chat-send-button {
        width: 42px;
        height: 42px;
        border-radius: 12px;
    }

    .chat-footer-meta {
        font-size: 0.72rem;
        gap: 6px;
    }

    .chat-footer-meta strong {
        font-size: 0.71rem;
        padding: 0;
    }
}

@media (max-width: 380px) {
    .chat-topbar {
        padding: 8px 8px;
    }

    .chat-messages {
        padding-left: 8px;
        padding-right: 8px;
    }

    .chat-route-hint,
    .chat-composer-wrap {
        padding-left: 8px;
        padding-right: 8px;
    }
}

:root {
    --accent: #72d8ff;
    --accent-strong: #4db6ff;
    --accent-soft: rgba(114, 216, 255, 0.22);
    --success: #8effc7;
    --danger: #ff8f9e;
}

.chat-shell {
    position: relative;
    isolation: isolate;
    background:
        radial-gradient(
            1200px 640px at 88% -8%,
            rgba(114, 216, 255, 0.15),
            transparent 62%
        ),
        radial-gradient(
            860px 520px at 8% 112%,
            rgba(80, 118, 255, 0.16),
            transparent 68%
        ),
        linear-gradient(180deg, #05070d 0%, #070a12 100%);
}

.chat-shell::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
    background-size:
        44px 44px,
        44px 44px;
    mask-image: radial-gradient(circle at 60% 25%, #000 24%, transparent 84%);
}

.chat-shell.is-smart-mode {
    background:
        radial-gradient(
            1220px 680px at 86% -12%,
            rgba(135, 237, 255, 0.2),
            transparent 60%
        ),
        radial-gradient(
            920px 540px at 8% 108%,
            rgba(115, 145, 255, 0.22),
            transparent 66%
        ),
        linear-gradient(180deg, #040813 0%, #080b17 100%);
}

.chat-sidebar {
    border-right: 1px solid rgba(173, 205, 255, 0.16);
    background:
        linear-gradient(180deg, rgba(8, 11, 20, 0.94), rgba(7, 9, 16, 0.86)),
        radial-gradient(
            580px 280px at 10% -8%,
            rgba(114, 216, 255, 0.15),
            transparent 64%
        );
    backdrop-filter: blur(14px);
}

.chat-brand img {
    border-radius: 0;
    background: transparent;
    padding: 0;
}

.chat-brand-text strong {
    font-size: 1.02rem;
    letter-spacing: 0.01em;
}

.chat-brand-text span {
    color: #a8c2dc;
}

.chat-new-button {
    border: 1px solid rgba(154, 204, 255, 0.54);
    background: linear-gradient(140deg, #f7fbff 0%, #d8e6ff 100%);
    color: #101427;
    box-shadow: 0 12px 28px rgba(99, 168, 255, 0.17);
}

.chat-new-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(100, 178, 255, 0.28);
}

.chat-sessions-count {
    border-color: rgba(144, 182, 230, 0.34);
    color: #c7dbf2;
    background: rgba(114, 216, 255, 0.08);
}

.chat-session-item {
    border-color: rgba(136, 165, 208, 0.24);
    background:
        linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.035),
            rgba(255, 255, 255, 0.01)
        ),
        rgba(8, 11, 18, 0.84);
}

.chat-session-item:hover {
    border-color: rgba(123, 201, 255, 0.58);
    background:
        linear-gradient(
            180deg,
            rgba(114, 216, 255, 0.14),
            rgba(84, 114, 255, 0.07)
        ),
        rgba(9, 12, 20, 0.92);
}

.chat-session-item.is-active {
    border-color: rgba(151, 230, 255, 0.92);
    background: linear-gradient(
        180deg,
        rgba(190, 239, 255, 0.9),
        rgba(148, 206, 255, 0.82)
    );
    color: #081321;
    box-shadow: 0 14px 32px rgba(63, 141, 225, 0.28);
}

.chat-session-item.is-active .chat-session-meta {
    color: rgba(11, 28, 46, 0.72);
}

.chat-sidebar-footer {
    border-top-color: rgba(145, 177, 217, 0.2);
}

.chat-account-button {
    border-color: rgba(141, 170, 207, 0.28);
    background: rgba(255, 255, 255, 0.04);
}

.chat-account-button:hover {
    border-color: rgba(139, 215, 255, 0.65);
    background: rgba(114, 216, 255, 0.12);
}

.chat-topbar {
    border-bottom-color: rgba(137, 170, 214, 0.24);
    background:
        linear-gradient(180deg, rgba(7, 10, 18, 0.94), rgba(8, 10, 17, 0.78)),
        radial-gradient(
            600px 240px at 30% -10%,
            rgba(114, 216, 255, 0.12),
            transparent 70%
        );
    backdrop-filter: blur(14px);
}

.chat-topbar-title h1 {
    font-size: 1.12rem;
    letter-spacing: 0.01em;
}

.chat-topbar-title p {
    color: #a8bfd8;
}

.chat-metric {
    border-color: rgba(145, 173, 217, 0.34);
    background: rgba(255, 255, 255, 0.035);
    color: #e7f2ff;
}

.chat-metric i {
    color: #b7ddff;
}

.chat-metric-stack small {
    color: #9db5cc;
}

.chat-metric-progress {
    background: rgba(157, 193, 231, 0.22);
}

.chat-metric-progress span {
    background: linear-gradient(90deg, #83e8ff 0%, #71b7ff 50%, #88f8c4 100%);
}

.chat-smart-toggle {
    border-color: rgba(132, 181, 230, 0.5);
    background: linear-gradient(
        180deg,
        rgba(114, 216, 255, 0.12),
        rgba(120, 140, 255, 0.09)
    );
}

.chat-smart-toggle.is-active,
.chat-shell.is-smart-mode .chat-smart-toggle {
    border-color: rgba(155, 238, 255, 0.96);
    background: linear-gradient(160deg, #e9fbff 0%, #d7ecff 100%);
    color: #0b1630;
    box-shadow: 0 10px 24px rgba(99, 190, 255, 0.32);
}

.chat-action-link {
    border-color: rgba(139, 169, 208, 0.33);
    background: rgba(255, 255, 255, 0.03);
}

.chat-action-link:hover {
    border-color: rgba(128, 211, 255, 0.66);
    background: rgba(114, 216, 255, 0.12);
}

.chat-messages {
    padding-top: 24px;
    padding-bottom: 20px;
    gap: 18px;
}

.chat-message {
    width: min(920px, 100%);
}

.chat-message-head {
    font-size: 0.72rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #99b7d3;
}

.chat-message.is-user .chat-message-head {
    text-align: right;
    color: #c5d7ea;
}

.chat-message-bubble {
    border-color: rgba(136, 166, 210, 0.3);
    background:
        linear-gradient(180deg, rgba(12, 17, 28, 0.94), rgba(8, 12, 20, 0.93)),
        radial-gradient(
            420px 240px at 8% 0%,
            rgba(114, 216, 255, 0.09),
            transparent 72%
        );
    box-shadow: 0 10px 30px rgba(2, 8, 19, 0.45);
}

.chat-message.is-user .chat-message-bubble {
    border-color: rgba(176, 225, 255, 0.62);
    background: linear-gradient(145deg, #e8f5ff 0%, #dbe8ff 100%);
    color: #0b1628;
    box-shadow: 0 12px 28px rgba(88, 149, 223, 0.2);
}

.chat-message-bubble blockquote {
    border-left-color: #7ccfff;
    background: rgba(114, 216, 255, 0.08);
}

.chat-live-status {
    width: min(920px, 100%);
    display: grid;
    gap: 5px;
    padding: 3px 2px 9px;
}

.chat-live-status-line {
    font-size: 0.88rem;
    line-height: 1.42;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: #d8ebff;
}

.chat-live-status-line.is-active {
    background: linear-gradient(
        90deg,
        rgba(148, 196, 238, 0.36) 0%,
        rgba(245, 252, 255, 1) 45%,
        rgba(148, 206, 247, 0.36) 100%
    );
    background-size: 235% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: chat-shimmer 1.22s linear infinite;
}

.chat-live-status-feed {
    display: grid;
    gap: 4px;
}

.chat-live-status-item {
    position: relative;
    padding-left: 12px;
    color: #9fb9d4;
    font-size: 0.75rem;
    line-height: 1.45;
}

.chat-live-status-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.59em;
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: rgba(151, 215, 255, 0.72);
}

.chat-live-status-meta {
    color: #8ba5c0;
    font-size: 0.72rem;
    line-height: 1.3;
}

.chat-live-status.is-final .chat-live-status-line {
    color: #bcf5d6;
    background: none;
    animation: none;
}

.chat-live-status.is-error .chat-live-status-line {
    color: #ffd3dd;
    background: none;
    animation: none;
}

.chat-route-hint {
    border-color: rgba(133, 173, 220, 0.28);
    background: linear-gradient(
        180deg,
        rgba(114, 216, 255, 0.11),
        rgba(106, 132, 255, 0.08)
    );
    color: #d5ebff;
}

.chat-composer-wrap {
    border-top: 0;
    background: transparent;
    backdrop-filter: none;
}

.chat-composer {
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    padding: 8px 0 4px;
}

.chat-composer:focus-within {
    border: 0;
    box-shadow: none;
    transform: none;
}

.chat-composer-input-wrap i {
    color: #9dc2e2;
}

.chat-composer textarea::placeholder {
    color: #7f9ebd;
}

.chat-send-button {
    background: linear-gradient(145deg, #ebf9ff 0%, #d2e7ff 100%);
    color: #091125;
    box-shadow: 0 10px 24px rgba(99, 174, 255, 0.26);
}

.chat-send-button:hover:not(:disabled) {
    box-shadow: 0 12px 26px rgba(97, 186, 255, 0.32);
}

.chat-send-button:disabled {
    background: linear-gradient(
        145deg,
        rgba(172, 193, 217, 0.42) 0%,
        rgba(139, 163, 192, 0.42) 100%
    );
    color: rgba(22, 37, 58, 0.7);
    box-shadow: none;
}

.chat-footer-meta {
    color: #95b0cb;
}

.chat-footer-meta strong {
    border: 0;
    background: transparent;
    padding: 0;
    color: #dcf0ff;
}

.chat-main.is-draft-empty .chat-welcome {
    margin-top: 0;
}

.chat-main.is-draft-empty .chat-composer-wrap {
    border: 0;
    background: transparent;
}

@media (max-width: 900px) {
    .chat-topbar {
        border-bottom-color: rgba(133, 166, 206, 0.28);
    }

    .chat-sidebar {
        width: min(86vw, 340px);
    }

    .chat-topbar-metrics {
        gap: 6px;
    }

    .chat-live-status-line {
        font-size: 0.84rem;
    }

    .chat-live-status-item {
        font-size: 0.73rem;
    }
}

@media (max-width: 760px) {
    .chat-shell::before {
        opacity: 0.35;
    }

    .chat-message-bubble {
        border-radius: 13px;
    }

    .chat-topbar-metrics {
        flex-wrap: wrap;
    }

    .chat-smart-toggle {
        flex: 1 1 100%;
        justify-content: center;
    }

    .chat-send-button {
        width: 40px;
        height: 40px;
        border-radius: 11px;
    }
}

@media (max-width: 520px) {
    .chat-sidebar {
        width: min(94vw, 360px);
    }

    .chat-footer-meta strong {
        width: 100%;
        text-align: center;
    }
}

.chat-main {
    position: relative;
    grid-template-rows: 1fr auto auto;
}

.chat-floating-menu {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 620;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(152, 191, 235, 0.4);
    border-radius: 11px;
    background: rgba(10, 15, 24, 0.76);
    color: #ebf6ff;
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 24px rgba(2, 8, 20, 0.34);
}

.chat-floating-menu:hover {
    border-color: rgba(146, 228, 255, 0.84);
    background: rgba(14, 20, 31, 0.94);
}

.chat-live-status {
    gap: 7px;
    padding: 2px 2px 12px;
}

.chat-live-status-line {
    font-size: 0.9rem;
}

.chat-live-status-feed {
    gap: 6px;
}

.chat-live-status-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding-left: 0;
}

.chat-live-status-item::before {
    display: none;
}

.chat-live-status-time {
    flex: 0 0 auto;
    color: #8db2d9;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.chat-live-status-text {
    min-width: 0;
}

.chat-composer-wrap {
    position: sticky;
    bottom: 0;
    z-index: 24;
    padding-top: 8px;
    background: linear-gradient(
        180deg,
        rgba(7, 10, 18, 0),
        rgba(7, 10, 18, 0.64) 18%,
        rgba(7, 10, 18, 0.9) 100%
    );
}

.chat-composer {
    border: 1px solid rgba(133, 167, 211, 0.32);
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(12, 18, 30, 0.92), rgba(9, 14, 24, 0.92)),
        radial-gradient(
            420px 180px at 12% -10%,
            rgba(132, 224, 255, 0.14),
            transparent 74%
        );
    box-shadow: 0 16px 34px rgba(2, 8, 20, 0.36);
    padding: 7px;
    gap: 7px;
}

.chat-composer:focus-within {
    border-color: rgba(160, 236, 255, 0.86);
    box-shadow: 0 18px 36px rgba(19, 45, 78, 0.38);
}

.chat-composer-input-wrap {
    align-items: center;
    gap: 6px;
}

.chat-smart-lamp {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    border: 1px solid rgba(132, 177, 223, 0.42);
    background: rgba(255, 255, 255, 0.03);
    color: #c9dff6;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition:
        border-color 0.2s ease,
        background 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease;
}

.chat-smart-lamp i {
    font-size: 0.96rem;
}

.chat-smart-lamp.is-active,
.chat-shell.is-smart-mode .chat-smart-lamp {
    border-color: rgba(170, 247, 255, 0.92);
    background: linear-gradient(
        160deg,
        rgba(133, 246, 255, 0.22) 0%,
        rgba(154, 178, 255, 0.19) 100%
    );
    color: #effaff;
    box-shadow: 0 10px 24px rgba(86, 196, 255, 0.24);
}

.chat-composer textarea {
    min-height: 36px;
    max-height: 240px;
    padding: 5px 8px;
    border-radius: 10px;
    font-size: 0.96rem;
    line-height: 1.42;
}

.chat-composer textarea::placeholder {
    color: #89a7c6;
}

.chat-send-button {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    border: 1px solid rgba(152, 208, 255, 0.44);
    background: linear-gradient(
        160deg,
        rgba(94, 202, 255, 0.28) 0%,
        rgba(129, 146, 255, 0.22) 100%
    );
    color: #e9f6ff;
    box-shadow:
        0 10px 24px rgba(66, 154, 232, 0.32),
        inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.chat-send-button i {
    font-size: 0.9rem;
    transform: translateX(0.5px);
}

.chat-send-button:hover:not(:disabled) {
    transform: translateY(-1px) scale(1.02);
    border-color: rgba(176, 237, 255, 0.9);
    box-shadow:
        0 14px 30px rgba(68, 175, 255, 0.36),
        inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.chat-send-button:disabled {
    border-color: rgba(125, 152, 184, 0.36);
    background: linear-gradient(
        160deg,
        rgba(84, 114, 150, 0.28) 0%,
        rgba(77, 96, 134, 0.28) 100%
    );
    color: rgba(193, 216, 243, 0.56);
    box-shadow: none;
}

.chat-footer-meta {
    align-items: flex-end;
}

.chat-footer-right {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
}

.chat-token-chip {
    min-height: 24px;
    border: 1px solid rgba(132, 170, 214, 0.34);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    color: #d5e9ff;
    padding: 0 9px;
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.chat-sessions {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.chat-sessions::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.chat-main.is-draft-empty .chat-composer-wrap {
    background: transparent;
}

@media (max-width: 1120px) {
    .chat-floating-menu {
        display: inline-flex;
    }
}

@media (max-width: 900px) {
    .chat-live-status-item {
        gap: 6px;
    }

    .chat-live-status-time {
        font-size: 0.64rem;
    }
}

@media (max-width: 760px) {
    .chat-composer-wrap {
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .chat-composer {
        border-radius: 15px;
        padding: 7px;
    }

    .chat-smart-lamp {
        width: 34px;
        height: 34px;
        border-radius: 10px;
    }

    .chat-composer textarea {
        min-height: 34px;
        font-size: 0.92rem;
    }

    .chat-send-button {
        width: 38px;
        height: 38px;
        border-radius: 11px;
    }
}

@media (max-width: 520px) {
    .chat-floating-menu {
        top: 8px;
        left: 8px;
    }

    .chat-footer-meta {
        gap: 6px;
    }

    .chat-footer-right {
        width: 100%;
    }

    .chat-token-chip {
        font-size: 0.69rem;
        padding: 0 8px;
    }

    .chat-send-button {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }
}
