:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #eef2f7;
    --text: #172033;
    --muted: #657085;
    --line: #dce2eb;
    --accent: #203c7a;
    --accent-strong: #162e61;
    --danger: #a12d36;
    --shadow: 0 18px 50px rgba(23, 32, 51, 0.08);
}

* { box-sizing: border-box; }
html { min-width: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
body { margin: 0; min-width: 0; min-height: 100vh; min-height: 100dvh; background: linear-gradient(180deg, #fbfcfe 0%, var(--bg) 55%); }
main { min-width: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
.shell { width: min(1440px, calc(100% - clamp(24px, 4vw, 64px))); margin: 0 auto; }

.site-header { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid rgba(220, 226, 235, 0.9); background: rgba(251, 252, 254, 0.92); backdrop-filter: blur(16px); }
.header-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { color: var(--text); font-weight: 800; letter-spacing: 0.12em; }
.brand:hover { text-decoration: none; }
.nav { min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 14px; }
.nav > a:not(.button) { color: var(--text); font-weight: 600; font-size: 0.94rem; }
.inline-form { display: inline; margin: 0; }
.language-form { display: flex; align-items: center; gap: 6px; }
.language-form select {
    min-height: 42px;
    max-width: 132px;
    padding: 0 30px 0 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}
.language-form select:focus { border-color: var(--accent); outline: 3px solid rgba(32, 60, 122, 0.12); }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent; font-weight: 700; cursor: pointer; transition: transform 120ms ease, background 120ms ease, border-color 120ms ease; }
.button:hover { text-decoration: none; transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.button-primary:hover { background: var(--accent-strong); }
.button-secondary { color: var(--text); background: var(--surface); border-color: var(--line); }
.button-ghost { color: var(--text); background: transparent; border-color: var(--line); }
.button-large { min-height: 50px; padding: 0 22px; }
.button-full { width: 100%; min-height: 48px; }

.hero { padding: 92px 0 76px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr); gap: 56px; align-items: center; }
.eyebrow, .card-kicker { margin: 0 0 14px; color: var(--accent); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.hero h1, .auth-card h1, .dashboard-heading h1 { margin: 0; letter-spacing: -0.035em; line-height: 1.02; }
.hero h1 { max-width: 800px; font-size: clamp(2.7rem, 6vw, 5.4rem); }
.hero-lead { max-width: 720px; margin: 28px 0 0; color: var(--muted); font-size: 1.16rem; line-height: 1.75; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 34px; }
.trust-card, .panel, .auth-card, .principle-card { border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.trust-card { padding: 28px; border-radius: 22px; }
.trust-flow { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.trust-flow li { display: flex; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.trust-flow li:last-child { border-bottom: 0; }
.trust-flow span { color: var(--muted); font-size: 0.78rem; font-weight: 800; }
.trust-flow strong { font-size: 0.96rem; }

.principles { padding: 24px 0 92px; }
.principle-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.principle-card { padding: 26px; border-radius: 18px; box-shadow: none; }
.principle-card h2, .panel h2 { margin: 0 0 12px; font-size: 1.2rem; }
.principle-card p, .panel p { margin: 0; color: var(--muted); line-height: 1.65; }

.auth-section { min-height: calc(100vh - 150px); min-height: calc(100dvh - 150px); display: grid; place-items: center; padding: clamp(36px, 7vh, 64px) 20px; }
.auth-card { width: min(520px, 100%); padding: 36px; border-radius: 22px; }
.auth-card h1 { font-size: 2.2rem; }
.auth-intro { margin: 16px 0 28px; color: var(--muted); line-height: 1.65; }
.auth-form { display: grid; gap: 20px; }
.field { display: grid; gap: 8px; }
.field label { font-size: 0.92rem; font-weight: 700; }
.field input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #c9d2df; border-radius: 9px; background: #fff; color: var(--text); outline: none; }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(32, 60, 122, 0.12); }
.field-hint { margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.45; }
.form-error { color: var(--danger); font-size: 0.86rem; }
.form-error ul { margin: 4px 0 0; padding-left: 18px; }
.form-error-summary { padding: 12px 14px; border: 1px solid #efc7cb; border-radius: 9px; background: #fff4f5; }
.auth-switch { margin: 24px 0 0; color: var(--muted); text-align: center; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body.assistant-body {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
}
body.assistant-body main {
    min-height: 0;
    display: flex;
    overflow: hidden;
}
body.assistant-body .site-footer { display: none; }
body.assistant-body .shell {
    width: calc(100% - clamp(16px, 2vw, 48px));
    max-width: none;
}

.assistant-page {
    flex: 1;
    min-width: 0;
    min-height: 0;
    padding: clamp(8px, 1.5vh, 18px) 0;
    overflow: hidden;
}
.assistant-layout {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-columns: clamp(230px, 20vw, 310px) minmax(0, 1fr);
    gap: clamp(10px, 1.4vw, 20px);
    align-items: stretch;
}
.assistant-sidebar,
.assistant-main {
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 20px;
    box-shadow: var(--shadow);
}
.assistant-sidebar {
    min-width: 0;
    min-height: 0;
    padding: clamp(16px, 2vw, 24px);
    display: flex;
    flex-direction: column;
    gap: clamp(14px, 2vh, 24px);
    overflow-y: auto;
}
.assistant-sidebar-title {
    margin: 0;
    font-size: 1.35rem;
    letter-spacing: -0.025em;
}
.assistant-account {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.86rem;
    overflow-wrap: anywhere;
}
.assistant-workspace-field select,
.assistant-composer textarea {
    width: 100%;
    border: 1px solid #c9d2df;
    background: #fff;
    color: var(--text);
    outline: none;
    font: inherit;
}
.assistant-workspace-field select {
    min-height: 44px;
    padding: 9px 11px;
    border-radius: 10px;
}
.assistant-workspace-field select:focus,
.assistant-composer textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(32, 60, 122, 0.12);
}
.assistant-membership-note {
    display: grid;
    gap: 4px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
}
.assistant-membership-note span {
    color: var(--muted);
    font-size: 0.78rem;
}
.assistant-membership-note strong {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.privacy-card {
    margin-top: auto;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-soft);
}
.privacy-card-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
}
.privacy-indicator {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #2d7a4e;
    box-shadow: 0 0 0 4px rgba(45, 122, 78, 0.12);
}
.privacy-card p {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.55;
}
.privacy-mode {
    display: inline-flex;
    margin-top: 14px;
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.assistant-main {
    min-width: 0;
    min-height: 0;
    height: 100%;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
}
.assistant-toolbar {
    min-height: 84px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}
.assistant-toolbar-label {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.assistant-toolbar h2 {
    margin: 0;
    font-size: 1.08rem;
}
.assistant-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.assistant-new-chat {
    min-height: 38px;
    padding-inline: 14px;
}
.agent-run-state {
    display: inline-flex;
    padding: 7px 10px;
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.assistant-thread {
    overflow-y: auto;
    min-height: 0;
    padding: clamp(18px, 4vh, 32px) clamp(18px, 5vw, 70px);
    scroll-behavior: smooth;
}
.assistant-empty {
    min-height: 100%;
    display: grid;
    place-items: center;
    align-content: center;
    text-align: center;
    padding: 48px 20px;
}
.assistant-empty[hidden] { display: none; }
.assistant-mark {
    width: 50px;
    height: 50px;
    display: grid;
    place-items: center;
    margin-bottom: 18px;
    border-radius: 14px;
    background: var(--text);
    color: #fff;
    font-weight: 900;
    letter-spacing: 0.08em;
}
.assistant-empty h2 {
    margin: 0;
    font-size: clamp(1.8rem, 4vw, 2.7rem);
    letter-spacing: -0.035em;
}
.assistant-empty > p:last-child {
    max-width: 600px;
    margin: 16px 0 0;
    color: var(--muted);
    line-height: 1.65;
}
.assistant-message {
    max-width: 760px;
    margin: 0 auto 28px;
}
.assistant-message-label {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}
.assistant-message-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.7;
}
.assistant-message-user .assistant-message-body {
    width: fit-content;
    max-width: min(680px, 92%);
    margin-left: auto;
    padding: 13px 16px;
    border-radius: 16px 16px 4px 16px;
    background: var(--accent);
    color: #fff;
}
.assistant-message-user .assistant-message-label {
    text-align: right;
}
.assistant-message-assistant .assistant-message-body {
    padding: 2px 0;
    color: var(--text);
}
.assistant-message.is-pending .assistant-message-body {
    color: var(--muted);
}

.assistant-composer-wrap {
    padding: 0 clamp(14px, 4vw, 64px) clamp(12px, 2vh, 24px);
}
.assistant-composer {
    border: 1px solid #c9d2df;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 14px 35px rgba(23, 32, 51, 0.08);
    overflow: hidden;
}
.assistant-composer:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(32, 60, 122, 0.09), 0 14px 35px rgba(23, 32, 51, 0.08);
}
.assistant-composer textarea {
    display: block;
    min-height: 62px;
    max-height: 220px;
    padding: 17px 18px 10px;
    resize: none;
    border: 0;
    box-shadow: none;
    line-height: 1.5;
}
.assistant-composer textarea:focus {
    border: 0;
    box-shadow: none;
}
.assistant-composer-footer {
    min-height: 52px;
    padding: 8px 10px 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}
.agent-status {
    margin: 0;
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.4;
}
.assistant-send-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.composer-hint {
    color: var(--muted);
    font-size: 0.72rem;
}
.assistant-send {
    min-height: 38px;
    padding-inline: 14px;
}
.assistant-boundary-note {
    margin: 10px 4px 0;
    color: var(--muted);
    text-align: center;
    font-size: 0.72rem;
    line-height: 1.45;
}
.button:disabled,
select:disabled,
textarea:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.site-footer { border-top: 1px solid var(--line); background: #fbfcfe; }
.footer-inner { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 18px; color: var(--muted); font-size: 0.86rem; }

@media (max-width: 820px) {
    .hero { padding-top: 64px; }
    .hero-grid, .principle-grid { grid-template-columns: 1fr; }
    .hero-grid { gap: 34px; }
    .nav { gap: 8px; }
    .nav > a:not(.button) { display: none; }
    .language-form select { max-width: 118px; }
    .auth-card { padding: 28px 22px; }

    .assistant-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
    }
    .assistant-sidebar {
        max-height: min(29dvh, 220px);
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(180px, 0.8fr);
        align-items: start;
        gap: 12px 18px;
    }
    .assistant-membership-note { display: none; }
    .privacy-card {
        margin-top: 0;
        grid-column: 1 / -1;
        padding: 12px 14px;
    }
    .privacy-card p { margin-top: 8px; }
    .privacy-mode { margin-top: 8px; }
    .assistant-toolbar { align-items: flex-start; }
    .assistant-composer-footer { align-items: flex-start; flex-direction: column; }
    .assistant-send-controls { width: 100%; justify-content: space-between; }
}

@media (max-width: 520px) {
    .shell { width: calc(100% - 20px); }
    .header-inner { min-height: 64px; gap: 10px; }
    .nav > .button, .inline-form { display: none; }
    .language-form select { min-height: 44px; max-width: 104px; font-size: 1rem; }
    .hero h1 { font-size: clamp(2.2rem, 13vw, 2.75rem); }
    .hero-actions { display: grid; }
    .button-large { width: 100%; }
    .footer-inner { flex-direction: column; align-items: flex-start; justify-content: center; padding: 18px 0; }

    .assistant-page { padding: 6px 0; }
    .assistant-layout { gap: 8px; }
    .assistant-sidebar {
        max-height: min(25dvh, 160px);
        grid-template-columns: 1fr;
        padding: 12px;
        gap: 9px;
        border-radius: 14px;
    }
    .assistant-account,
    .assistant-membership-note,
    .privacy-card p,
    .privacy-mode { display: none; }
    .assistant-sidebar-title { font-size: 1.05rem; }
    .assistant-sidebar .eyebrow { display: none; }
    .privacy-card {
        grid-column: auto;
        padding: 9px 11px;
    }
    .assistant-main { border-radius: 14px; }
    .assistant-toolbar {
        min-height: 64px;
        padding: 12px 14px;
        flex-direction: row;
        align-items: center;
    }
    .assistant-toolbar-label { display: none; }
    .assistant-toolbar-actions { width: auto; }
    .agent-run-state { display: none; }
    .assistant-new-chat { min-height: 44px; }
    .assistant-thread { padding: 18px 14px; }
    .assistant-empty { padding: 24px 8px; }
    .assistant-empty h2 { font-size: clamp(1.55rem, 9vw, 2rem); }
    .assistant-composer-wrap { padding: 0 8px 8px; }
    .assistant-composer textarea { font-size: 16px; }
    .assistant-composer-footer { padding: 6px 8px 8px 12px; }
    .composer-hint, .agent-status { display: none; }
    .assistant-send-controls { justify-content: flex-end; }
    .assistant-send { min-height: 44px; }
}

@media (max-height: 680px) and (min-width: 821px) {
    .assistant-sidebar { gap: 12px; padding-block: 14px; }
    .assistant-membership-note,
    .privacy-card p { display: none; }
    .privacy-mode { margin-top: 8px; }
    .assistant-toolbar { min-height: 66px; padding-block: 12px; }
    .assistant-empty { padding-block: 20px; }
    .assistant-mark { width: 42px; height: 42px; margin-bottom: 12px; }
}

@media (max-height: 520px) {
    body.assistant-body .header-inner {
        min-height: 52px;
    }

    body.assistant-body .nav > a:not(.button),
    body.assistant-body .nav > .button,
    body.assistant-body .inline-form {
        display: none;
    }

    body.assistant-body .language-form select {
        min-height: 36px;
        max-width: 108px;
    }

    .assistant-page {
        padding: 4px 0;
    }

    .assistant-layout {
        gap: 6px;
    }

    .assistant-sidebar {
        gap: 8px;
        padding: 10px 12px;
    }

    .assistant-sidebar-title {
        font-size: 1rem;
    }

    .assistant-account,
    .assistant-membership-note,
    .assistant-workspace-field > span,
    .privacy-card p,
    .privacy-mode {
        display: none;
    }

    .assistant-workspace-field select {
        min-height: 36px;
        padding-block: 5px;
    }

    .privacy-card {
        margin-top: 0;
        padding: 8px 10px;
    }

    .assistant-toolbar {
        min-height: 50px;
        padding: 8px 12px;
        align-items: center;
    }

    .assistant-toolbar-label {
        display: none;
    }

    .assistant-toolbar h2 {
        font-size: 0.98rem;
    }

    .assistant-new-chat {
        min-height: 36px;
        padding-inline: 11px;
    }

    .assistant-thread {
        padding: 10px 14px;
    }

    .assistant-empty {
        padding: 8px;
    }

    .assistant-mark,
    .assistant-empty .eyebrow,
    .assistant-empty > p:last-child {
        display: none;
    }

    .assistant-empty h2 {
        font-size: clamp(1.25rem, 5vw, 1.7rem);
    }

    .assistant-composer-wrap {
        padding: 0 8px 6px;
    }

    .assistant-composer textarea {
        min-height: 44px;
        padding: 10px 12px 6px;
    }

    .assistant-composer-footer {
        min-height: 40px;
        padding: 4px 6px 6px 10px;
    }

    .assistant-boundary-note,
    .agent-status,
    .composer-hint {
        display: none;
    }

    .assistant-send {
        min-height: 36px;
    }
}
