:root {
    color-scheme: light;
    --bg: #edf1f5;
    --bg-pattern: #d8e2ea;
    --surface: #ffffff;
    --surface-muted: #f6f8fb;
    --surface-strong: #e8eef4;
    --surface-glass: rgba(255, 255, 255, 0.82);
    --text: #111827;
    --text-muted: #667085;
    --border: #d8e1ea;
    --border-strong: #bdcad7;
    --primary: #155eef;
    --primary-strong: #0f44b8;
    --primary-soft: #e8f0ff;
    --accent: #0e9384;
    --accent-soft: #ddf7f1;
    --ink: #27364a;
    --danger: #b42318;
    --danger-soft: #fee4e2;
    --warning: #a15c07;
    --warning-soft: #fff0c7;
    --success: #067647;
    --success-soft: #dcfae6;
    --shadow: 0 20px 50px rgba(17, 24, 39, 0.12);
    --shadow-soft: 0 10px 26px rgba(17, 24, 39, 0.08);
    --radius: 8px;
    --speed: 180ms;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1419;
    --bg-pattern: #23303a;
    --surface: #171d24;
    --surface-muted: #202832;
    --surface-strong: #2a3541;
    --surface-glass: rgba(23, 29, 36, 0.84);
    --text: #f4f7fb;
    --text-muted: #a5b1c2;
    --border: #323f4c;
    --border-strong: #475569;
    --primary: #74a7ff;
    --primary-strong: #a9c8ff;
    --primary-soft: #1d3354;
    --accent: #4ed7c5;
    --accent-soft: #143b37;
    --ink: #d7e0ea;
    --danger: #f97066;
    --danger-soft: #4a1f1d;
    --warning: #fdbf4c;
    --warning-soft: #46320f;
    --success: #47cd89;
    --success-soft: #173b2b;
    --shadow: 0 22px 58px rgba(0, 0, 0, 0.32);
    --shadow-soft: 0 10px 26px rgba(0, 0, 0, 0.2);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

html {
    scrollbar-color: color-mix(in srgb, var(--text-muted) 42%, transparent) transparent;
}

body {
    margin: 0;
    background:
        linear-gradient(90deg, color-mix(in srgb, var(--bg-pattern) 18%, transparent) 1px, transparent 1px),
        linear-gradient(color-mix(in srgb, var(--bg-pattern) 18%, transparent) 1px, transparent 1px),
        linear-gradient(135deg, var(--bg), color-mix(in srgb, var(--surface-muted) 72%, var(--bg)));
    background-size: 38px 38px, 38px 38px, auto;
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.58;
    transform: none;
}

svg {
    flex: 0 0 auto;
}

.app-loading,
.loading-panel {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.loading-panel {
    min-height: auto;
    gap: 14px;
    color: var(--text-muted);
    animation: riseIn 360ms ease both;
}

.loading-mark {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 999px;
    animation: spin 0.8s linear infinite;
}

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

@keyframes riseIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.99);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes pulseDot {
    0%,
    80%,
    100% {
        opacity: 0.32;
        transform: translateY(0);
    }

    40% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

@keyframes themeReveal {
    from {
        clip-path: circle(0 at var(--theme-origin-x) var(--theme-origin-y));
    }

    to {
        clip-path: circle(var(--theme-reveal-radius) at var(--theme-origin-x) var(--theme-origin-y));
    }
}

::view-transition-old(root),
::view-transition-new(root) {
    animation: none;
    mix-blend-mode: normal;
}

.theme-reveal-active::view-transition-new(root) {
    animation: themeReveal 560ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.theme-reveal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    background:
        linear-gradient(90deg, color-mix(in srgb, var(--bg-pattern) 18%, transparent) 1px, transparent 1px),
        linear-gradient(color-mix(in srgb, var(--bg-pattern) 18%, transparent) 1px, transparent 1px),
        linear-gradient(135deg, var(--bg), color-mix(in srgb, var(--surface-muted) 72%, var(--bg)));
    background-size: 38px 38px, 38px 38px, auto;
    clip-path: circle(0 at var(--theme-origin-x) var(--theme-origin-y));
    animation: themeReveal 560ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.theme-reveal-overlay.dark {
    --bg: #0f1419;
    --bg-pattern: #23303a;
    --surface-muted: #202832;
}

.theme-reveal-overlay.light {
    --bg: #edf1f5;
    --bg-pattern: #d8e2ea;
    --surface-muted: #f6f8fb;
}

.app-shell {
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    overflow: hidden;
}

.sidebar {
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border-right: 1px solid var(--border);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow-y: auto;
    box-shadow: 14px 0 36px rgba(17, 24, 39, 0.04);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--primary) 94%, white), var(--accent)),
        var(--primary);
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    font-size: 22px;
    line-height: 1;
    box-shadow: 0 10px 22px color-mix(in srgb, var(--primary) 24%, transparent);
}

.brand-title {
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1.2;
    text-transform: none;
}

.brand-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 2px;
}

.sidebar-section {
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.section-title {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 0 0 10px;
}

.section-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.section-row .section-title {
    margin: 0;
}

.account-line,
.metric-row,
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.account-name {
    font-weight: 800;
}

.account-email,
.metric-label,
.small-text {
    color: var(--text-muted);
    font-size: 13px;
}

.metric-row {
    min-height: 36px;
    padding: 6px 0;
}

.metric-value {
    font-weight: 800;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.content {
    min-width: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.topbar {
    min-height: 68px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-glass);
    backdrop-filter: blur(18px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-main {
    min-width: 0;
}

.topbar-title {
    font-size: 18px;
    font-weight: 800;
    text-transform: none;
}

.topbar-context {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.button,
.icon-button {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius);
    min-height: 40px;
    padding: 0 14px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform var(--speed) ease, border-color var(--speed) ease, background var(--speed) ease, box-shadow var(--speed) ease, color var(--speed) ease;
}

.button:hover,
.icon-button:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-soft);
    transform: translateY(-1px);
}

.button.primary {
    background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 78%, var(--accent)));
    border-color: color-mix(in srgb, var(--primary) 72%, var(--accent));
    color: white;
    box-shadow: 0 12px 24px color-mix(in srgb, var(--primary) 22%, transparent);
}

.button.primary:hover {
    box-shadow: 0 16px 30px color-mix(in srgb, var(--primary) 28%, transparent);
}

.button.secondary {
    background: var(--surface-muted);
}

.button.danger {
    background: var(--danger-soft);
    border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
    color: var(--danger);
}

.text-button {
    border: 0;
    background: transparent;
    color: var(--primary-strong);
    min-height: 34px;
    padding: 0;
    font-weight: 800;
    text-align: left;
    justify-self: start;
    transition: color var(--speed) ease;
}

.text-button:hover {
    color: var(--accent);
}

.text-button.compact {
    min-height: auto;
    font-size: 12px;
}

.menu-item {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    color: var(--text);
    border-radius: var(--radius);
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-weight: 800;
    transition: transform var(--speed) ease, border-color var(--speed) ease, background var(--speed) ease, box-shadow var(--speed) ease;
}

.menu-item span {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.menu-item strong {
    color: var(--text-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.menu-item:hover,
.menu-item.active {
    border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
    background: var(--surface);
    box-shadow: var(--shadow-soft);
    transform: translateY(-1px);
}

.icon-button {
    width: 42px;
    padding: 0;
}

.button:focus-visible,
.icon-button:focus-visible,
.feedback-button:focus-visible,
.history-item:focus-visible,
.menu-item:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary) 26%, transparent);
    outline-offset: 2px;
}

.view {
    min-height: 0;
}

.auth-layout,
.verify-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(360px, 0.92fr) minmax(420px, 1.08fr);
}

.auth-panel,
.verify-panel {
    background:
        radial-gradient(circle at 12% 8%, color-mix(in srgb, var(--primary-soft) 70%, transparent), transparent 32%),
        var(--surface);
    padding: clamp(28px, 4vw, 54px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--border);
}

.auth-box {
    width: min(100%, 470px);
    animation: riseIn 420ms ease both;
}

.auth-visual,
.verify-visual {
    padding: clamp(34px, 6vw, 78px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
    position: relative;
    overflow: hidden;
}

.auth-visual::before {
    content: "";
    position: absolute;
    inset: 8% 8% auto auto;
    width: 340px;
    aspect-ratio: 1;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent-soft) 72%, transparent);
    filter: blur(8px);
    z-index: -1;
}

.auth-kicker {
    display: inline-flex;
    width: fit-content;
    margin: 30px 0 0;
    border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
    background: var(--accent-soft);
    color: color-mix(in srgb, var(--accent) 74%, var(--ink));
    border-radius: 999px;
    padding: 7px 11px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.hero-title {
    font-size: clamp(34px, 5vw, 58px);
    line-height: 1;
    letter-spacing: 0;
    margin: 18px 0 14px;
    max-width: 760px;
}

.auth-intro {
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1.6;
    margin: 0 0 24px;
}

.auth-hero-copy h2 {
    font-size: clamp(34px, 5.2vw, 62px);
    line-height: 1.02;
    letter-spacing: 0;
    margin: 10px 0 16px;
    max-width: 780px;
}

.auth-hero-copy .section-title {
    letter-spacing: 0;
    text-transform: none;
}

.hero-copy {
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1.6;
    max-width: 650px;
    margin: 0;
}

.auth-showcase {
    width: min(100%, 680px);
    border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}

.showcase-header {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 14px;
}

.showcase-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: var(--success);
    box-shadow: 0 0 0 5px var(--success-soft);
}

.showcase-question {
    width: fit-content;
    max-width: 88%;
    margin-left: auto;
    background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, var(--ink)));
    color: white;
    border-radius: var(--radius);
    padding: 12px 14px;
    font-weight: 700;
    line-height: 1.45;
}

.showcase-answer {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    margin-top: 14px;
}

.showcase-answer span {
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
    background: var(--accent-soft);
    border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border));
    position: relative;
}

.showcase-answer span::after {
    content: "";
    position: absolute;
    inset: 9px;
    border-radius: 999px;
    background: var(--accent);
}

.showcase-answer p {
    margin: 0;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    border-radius: var(--radius);
    padding: 12px 14px;
    color: var(--text);
    line-height: 1.55;
}

.visual-stack {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    max-width: 760px;
}

.visual-card {
    border: 1px solid var(--border);
    background: var(--surface-glass);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-soft);
    min-height: 126px;
    display: grid;
    align-content: space-between;
}

.visual-card strong {
    font-size: 24px;
    color: var(--ink);
}

.visual-card span {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.4;
}

.trust-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 760px;
}

.trust-strip span {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius);
    padding: 8px 10px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    background: var(--surface-muted);
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 28px 0;
}

.auth-tab {
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    min-height: 40px;
    font-weight: 800;
    transition: background var(--speed) ease, color var(--speed) ease, box-shadow var(--speed) ease;
}

.auth-tab.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 5px 14px rgba(17, 24, 39, 0.09);
}

.form {
    display: grid;
    gap: 14px;
}

.field {
    display: grid;
    gap: 7px;
}

.field label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 800;
}

.field input,
.field textarea {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius);
    min-height: 46px;
    padding: 12px 13px;
    transition: border-color var(--speed) ease, box-shadow var(--speed) ease, background var(--speed) ease;
}

.field input:hover,
.field textarea:hover {
    border-color: var(--border-strong);
}

.field input:focus,
.field textarea:focus {
    border-color: color-mix(in srgb, var(--primary) 58%, var(--border));
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 10%, transparent);
}

.field textarea {
    resize: none;
    line-height: 1.5;
    text-transform: none;
}

.field textarea::placeholder {
    text-transform: none;
}

.alert {
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.45;
    animation: riseIn 240ms ease both;
}

.alert.error {
    background: var(--danger-soft);
    border-color: color-mix(in srgb, var(--danger) 22%, transparent);
    color: var(--danger);
}

.alert.warning {
    background: var(--warning-soft);
    border-color: color-mix(in srgb, var(--warning) 22%, transparent);
    color: var(--warning);
}

.alert.success {
    background: var(--success-soft);
    border-color: color-mix(in srgb, var(--success) 22%, transparent);
    color: var(--success);
}

.verify-code {
    font-size: 28px;
    letter-spacing: 8px;
    text-align: center;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.chat-scroll {
    overflow-y: auto;
    padding: 30px 24px;
    scroll-behavior: smooth;
}

.welcome {
    max-width: 940px;
    margin: 0 auto 24px;
    animation: riseIn 420ms ease both;
}

.welcome h1 {
    font-size: clamp(30px, 4vw, 48px);
    margin: 0 0 12px;
    letter-spacing: 0;
    max-width: 760px;
}

.empty-kicker {
    color: var(--accent);
    font-size: 13px;
    font-weight: 800;
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.prompt-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 22px;
}

.prompt-button {
    text-align: left;
    min-height: 106px;
    border: 1px solid var(--border);
    background: var(--surface-glass);
    border-radius: var(--radius);
    padding: 15px;
    color: var(--text);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset;
    transition: transform var(--speed) ease, border-color var(--speed) ease, box-shadow var(--speed) ease, background var(--speed) ease;
}

.prompt-button:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
    box-shadow: var(--shadow-soft);
    background: var(--surface);
}

.prompt-button strong {
    display: block;
    margin-bottom: 8px;
    font-size: 15px;
}

.prompt-button span {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.45;
}

.messages {
    max-width: 940px;
    margin: 0 auto;
    display: grid;
    gap: 16px;
}

.message {
    display: grid;
    gap: 7px;
    animation: messageIn 240ms ease both;
}

.message.user {
    justify-items: end;
}

.message-label {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 800;
}

.message-body {
    max-width: min(780px, 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px 16px;
    line-height: 1.62;
    background: var(--surface);
    box-shadow: 0 8px 24px rgba(17, 24, 39, 0.06);
    overflow-wrap: anywhere;
}

.message-body > :first-child {
    margin-top: 0;
}

.message-body > :last-child {
    margin-bottom: 0;
}

.message.user .message-body {
    background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 76%, var(--ink)));
    border-color: color-mix(in srgb, var(--primary) 78%, var(--ink));
    color: white;
    box-shadow: 0 12px 28px color-mix(in srgb, var(--primary) 25%, transparent);
}

.message-body a {
    color: var(--primary-strong);
    font-weight: 700;
}

.message.user .message-body a {
    color: white;
}

.message-body code {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 5px;
    font-size: 0.92em;
}

.message.user .message-body code {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.18);
}

.message-body pre {
    overflow: auto;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
}

.message-body pre code {
    border: 0;
    padding: 0;
    background: transparent;
}

.message.user .message-body pre {
    background: rgba(255, 255, 255, 0.12);
}

.message-actions {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.feedback-button {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    color: var(--text-muted);
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--speed) ease, border-color var(--speed) ease, background var(--speed) ease, color var(--speed) ease, box-shadow var(--speed) ease;
}

.feedback-button:hover {
    border-color: var(--border-strong);
    color: var(--text);
    transform: translateY(-1px);
}

.feedback-button.active {
    background: var(--primary-soft);
    border-color: color-mix(in srgb, var(--primary) 34%, var(--border));
    color: var(--primary-strong);
    box-shadow: 0 8px 18px color-mix(in srgb, var(--primary) 16%, transparent);
}

.typing {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.typing-dots {
    display: inline-flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--primary);
    animation: pulseDot 1.1s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 140ms;
}

.typing-dots span:nth-child(3) {
    animation-delay: 280ms;
}

.inline-image {
    margin: 14px 0;
}

.inline-image img {
    display: block;
    max-width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
}

.inline-image-caption {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 13px;
}

.composer {
    border-top: 1px solid var(--border);
    background: var(--surface-glass);
    backdrop-filter: blur(18px);
    padding: 18px 24px 20px;
}

.composer-inner {
    max-width: 1040px;
    margin: 0 auto;
    display: grid;
    gap: 10px;
}

.composer-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.composer-row .field textarea {
    min-height: 70px;
    padding: 15px 14px;
}

.file-input {
    display: none;
}

.image-preview {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    border-radius: var(--radius);
    padding: 8px 10px;
    animation: riseIn 180ms ease both;
}

.image-preview.active {
    display: flex;
}

.range-stack {
    display: grid;
    gap: 14px;
}

.range-label {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 800;
}

input[type="range"] {
    width: 100%;
}

.setting-group {
    display: grid;
    gap: 9px;
}

.setting-group + .setting-group {
    margin-top: 18px;
}

.setting-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 800;
}

.setting-heading strong {
    color: var(--text);
    font-size: 13px;
    text-align: right;
}

.segment-options {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
}

.segment-option {
    min-width: 0;
    min-height: 38px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 800;
    padding: 0 4px;
    transition: background var(--speed) ease, color var(--speed) ease, box-shadow var(--speed) ease, transform var(--speed) ease;
}

.segment-option:hover {
    color: var(--text);
}

.segment-option span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.segment-option.active {
    background: var(--surface);
    color: var(--primary-strong);
    box-shadow: 0 4px 12px rgba(17, 24, 39, 0.09);
}

.segment-option:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary) 25%, transparent);
    outline-offset: 2px;
}

.setting-help {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.45;
    min-height: 34px;
}

.sidebar-actions {
    display: grid;
    gap: 10px;
    margin-top: auto;
}

.sidebar-actions .button {
    width: 100%;
}

.usage-list {
    display: grid;
    gap: 8px;
}

.usage-event {
    border: 1px solid var(--border);
    background: var(--surface-muted);
    border-radius: var(--radius);
    padding: 10px;
    font-size: 13px;
}

.history-list {
    display: grid;
    gap: 8px;
}

.history-panel-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(8, 12, 16, 0.38);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--speed) ease;
}

.history-panel-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.history-panel {
    position: fixed;
    inset: 14px 14px 14px auto;
    width: min(92vw, 430px);
    z-index: 40;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    transform: translateX(calc(100% + 24px));
    transition: transform 0.24s ease;
    overflow: hidden;
}

.history-panel.open {
    transform: translateX(0);
}

.history-panel-header {
    min-width: 0;
    padding: 18px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.history-panel-header h2 {
    margin: 4px 0 0;
    font-size: 20px;
    line-height: 1.2;
}

.history-panel-actions {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-muted);
}

.history-panel-scroll {
    min-height: 0;
    overflow-y: auto;
    padding: 14px 18px 18px;
}

.history-item {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    color: var(--text);
    border-radius: var(--radius);
    padding: 10px;
    display: grid;
    gap: 5px;
    text-align: left;
    transition: border-color var(--speed) ease, background var(--speed) ease, box-shadow var(--speed) ease, transform var(--speed) ease;
}

.history-item:hover {
    border-color: color-mix(in srgb, var(--primary) 34%, var(--border));
    background: var(--surface);
    box-shadow: var(--shadow-soft);
    transform: translateY(-1px);
}

.history-item.active {
    border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
    background: var(--primary-soft);
}

.history-item.loading {
    opacity: 0.68;
    pointer-events: none;
}

.history-title {
    font-size: 13px;
    font-weight: 800;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-meta,
.history-empty {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.35;
}

.history-empty {
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 10px;
    background: color-mix(in srgb, var(--surface-muted) 78%, transparent);
}

.mobile-sidebar-toggle {
    display: none;
}

.sidebar.mobile-open {
    transform: translateX(0);
}

.sidebar-backdrop {
    display: none;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(92vw, 360px);
        max-width: 360px;
        z-index: 30;
        transform: translateX(-105%);
        transition: transform 0.24s ease;
        box-shadow: var(--shadow);
        padding: max(16px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
        border-right: 1px solid var(--border);
    }

    .history-item {
        min-height: 58px;
    }

    .history-panel {
        inset: 0;
        width: min(100vw, 430px);
        max-width: 100vw;
        border-radius: 0;
        border-top: 0;
        border-bottom: 0;
    }

    .history-panel-header {
        padding: max(16px, env(safe-area-inset-top)) 16px 16px;
    }

    .history-panel-actions {
        padding: 10px 16px;
    }

    .history-panel-scroll {
        padding: 12px 16px max(18px, env(safe-area-inset-bottom));
    }

    .mobile-sidebar-toggle {
        display: inline-flex;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 25;
        background: rgba(8, 12, 16, 0.46);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.18s ease;
    }

    .sidebar-backdrop.active {
        opacity: 1;
        pointer-events: auto;
    }

    body.sidebar-lock {
        overflow: hidden;
    }

    .segment-option {
        min-height: 44px;
        font-size: 12px;
    }

    .auth-layout,
    .verify-layout {
        grid-template-columns: 1fr;
    }

    .auth-panel,
    .verify-panel {
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding: 30px 20px;
    }

    .auth-visual,
    .verify-visual {
        padding: 30px 20px;
    }

    .visual-stack {
        grid-template-columns: 1fr;
    }

    .prompt-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .topbar {
        padding: 0 10px;
        min-height: 52px;
    }

    .topbar-title {
        font-size: 15px;
    }

    .topbar-context {
        display: none;
    }

    .chat-scroll {
        padding: 14px 12px;
    }

    .welcome {
        margin-bottom: 12px;
    }

    .welcome h1 {
        font-size: 27px;
        line-height: 1.05;
        margin-bottom: 8px;
    }

    .welcome .hero-copy {
        font-size: 14px;
        line-height: 1.45;
    }

    .empty-kicker {
        font-size: 11px;
        margin-bottom: 7px;
    }

    .prompt-grid {
        gap: 8px;
        margin-top: 12px;
    }

    .prompt-button {
        min-height: 58px;
        padding: 10px 11px;
    }

    .prompt-button strong {
        margin-bottom: 3px;
        font-size: 14px;
    }

    .prompt-button span {
        font-size: 12px;
        line-height: 1.3;
    }

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

    .composer-row {
        grid-template-columns: auto minmax(0, 1fr) auto;
        gap: 8px;
    }

    .composer-row .button.primary {
        width: auto;
        padding: 0 12px;
    }

    .composer-row .field textarea {
        min-height: 52px;
        padding: 12px;
    }

    .message-body {
        padding: 13px 14px;
    }

    .hero-title {
        font-size: clamp(32px, 13vw, 48px);
    }
}

@media (max-width: 380px) {
    .composer-row .button.primary {
        width: 42px;
        padding: 0;
        gap: 0;
        font-size: 0;
    }

    .composer-row .button.primary svg {
        width: 19px;
        height: 19px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.001ms !important;
    }

    .theme-reveal-active::view-transition-new(root),
    .theme-reveal-overlay {
        animation: none !important;
    }
}
