:root {
    --bg-main: #041823;
    --bg-panel: #0a2230;
    --bg-panel-soft: #102d3f;
    --text-main: #e6f5ff;
    --text-muted: #9ec3d7;
    --line: rgba(255, 255, 255, 0.12);
    --brand-a: #43bbbd;
    --brand-b: #0979b9;
    --user-bubble: linear-gradient(90deg, #43bbbd, #0979b9);
    --assistant-bubble: #11354b;
    --assistant-text: #e6f5ff;
    --shadow: 0 20px 40px rgba(0, 0, 0, 0.28);
    --chat-header-height: 76px;
    --chat-content-max-width: 1080px;
    --body-radial-a: rgba(67, 187, 189, 0.18);
    --body-radial-b: rgba(9, 121, 185, 0.22);
    --header-bg: rgba(4, 24, 35, 0.78);
    --header-bg-strong: rgba(4, 24, 35, 0.86);
    --section-alt-bg: rgba(7, 31, 45, 0.45);
    --sidebar-bg: linear-gradient(180deg, rgba(7, 30, 44, 0.98), rgba(6, 24, 36, 0.96));
    --surface-glass: rgba(255, 255, 255, 0.03);
    --surface-card: rgba(10, 34, 48, 0.72);
    --surface-card-soft: rgba(16, 45, 63, 0.6);
    --composer-bg: rgba(4, 24, 35, 0.9);
    --input-bg: rgba(16, 45, 63, 0.6);
    --composer-border: rgba(255, 255, 255, 0.12);
    --composer-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
    --composer-gap-bottom: 14px;
    --composer-radius: 18px;
    --welcome-bg: rgba(16, 45, 63, 0.45);
    --message-system-bg: rgba(255, 255, 255, 0.07);
    --code-bg: rgba(4, 24, 35, 0.72);
    --code-border: rgba(255, 255, 255, 0.14);
    --emphasis-text: #d8f7ff;
    --danger: #ef5f6b;
    --danger-strong: #d64350;
    --danger-glow: rgba(239, 95, 107, 0.28);
    --scroll-track: rgba(9, 121, 185, 0.2);
    --scroll-track-strong: rgba(9, 121, 185, 0.35);
    --scroll-border: rgba(4, 24, 35, 0.58);
    --overlay-bg: rgba(0, 0, 0, 0.4);
}

html[data-theme='light'] {
    --bg-main: #eef5fb;
    --bg-panel: #ffffff;
    --bg-panel-soft: #e8f2f8;
    --text-main: #122938;
    --text-muted: #4c687a;
    --line: rgba(10, 42, 69, 0.18);
    --assistant-bubble: #e7f1f8;
    --assistant-text: #122938;
    --shadow: 0 18px 34px rgba(22, 58, 86, 0.16);
    --body-radial-a: rgba(67, 187, 189, 0.14);
    --body-radial-b: rgba(9, 121, 185, 0.14);
    --header-bg: rgba(250, 253, 255, 0.84);
    --header-bg-strong: rgba(246, 251, 255, 0.9);
    --section-alt-bg: rgba(212, 231, 245, 0.45);
    --sidebar-bg: linear-gradient(180deg, rgba(246, 251, 255, 0.98), rgba(235, 245, 252, 0.97));
    --surface-glass: rgba(255, 255, 255, 0.72);
    --surface-card: rgba(255, 255, 255, 0.86);
    --surface-card-soft: rgba(240, 248, 253, 0.9);
    --composer-bg: rgba(243, 250, 255, 0.94);
    --input-bg: rgba(255, 255, 255, 0.94);
    --composer-border: rgba(10, 42, 69, 0.16);
    --composer-shadow: 0 12px 26px rgba(22, 58, 86, 0.16);
    --welcome-bg: #f3f6f9;
    --message-system-bg: rgba(255, 255, 255, 0.82);
    --code-bg: rgba(14, 42, 66, 0.08);
    --code-border: rgba(14, 42, 66, 0.2);
    --emphasis-text: #194768;
    --danger: #df4d5a;
    --danger-strong: #c53645;
    --danger-glow: rgba(223, 77, 90, 0.2);
    --scroll-track: rgba(9, 121, 185, 0.14);
    --scroll-track-strong: rgba(9, 121, 185, 0.24);
    --scroll-border: rgba(255, 255, 255, 0.9);
    --overlay-bg: rgba(6, 18, 30, 0.22);
}

* {
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--brand-a) var(--scroll-track);
}

*::-webkit-scrollbar {
    width: 11px;
    height: 11px;
}

*::-webkit-scrollbar-track {
    background: linear-gradient(180deg, var(--scroll-track), rgba(67, 187, 189, 0.12));
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--brand-a), var(--brand-b));
    border-radius: 999px;
    border: 2px solid var(--scroll-border);
}

*::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #63d8da, #0d91d2);
}

*::-webkit-scrollbar-corner {
    background: var(--scroll-track-strong);
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Manrope', 'Segoe UI', sans-serif;
    background:
        radial-gradient(circle at 10% -20%, var(--body-radial-a), transparent 45%),
        radial-gradient(circle at 95% 20%, var(--body-radial-b), transparent 35%),
        var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
}

body.chat-page {
    display: grid;
    grid-template-rows: auto 1fr;
    height: 100dvh;
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
}

.container {
    width: min(1120px, 92vw);
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(8px);
    background: var(--header-bg);
    border-bottom: 1px solid var(--line);
}

.chat-global-header {
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(10px);
    background: var(--header-bg-strong);
    border-bottom: 1px solid var(--line);
}

.chat-global-inner {
    min-height: var(--chat-header-height);
    padding: 10px 16px;
    display: grid;
    grid-template-columns: auto minmax(220px, 1fr) auto;
    align-items: center;
    gap: 12px;
}

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

.chat-brand {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px 10px;
    background: var(--surface-glass);
}

.chat-header-nav {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.chat-header-nav a {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 6px 10px;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.chat-header-nav a:hover {
    color: var(--text-main);
    border-color: var(--line);
}

.chat-header-nav a[aria-current='page'] {
    color: var(--text-main);
    border-color: rgba(67, 187, 189, 0.5);
    background: rgba(67, 187, 189, 0.12);
}

.chat-header-center {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.chat-header-center h1 {
    margin: 0;
    font-size: 0.96rem;
    font-weight: 700;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

#new-chat-header-btn {
    display: none;
}

.nav-wrap {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 14px;
    min-height: 74px;
    position: relative;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.brand-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.nav-links {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    justify-self: end;
    min-width: 0;
    gap: 18px;
    color: var(--text-muted);
    font-weight: 600;
}

.nav-links a:hover {
    color: var(--text-main);
}

.nav-utility {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.btn {
    border: 0;
    border-radius: 12px;
    padding: 12px 18px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(90deg, #43bbbd, #0979b9);
    color: white;
    box-shadow: 0 10px 26px rgba(9, 121, 185, 0.28);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text-main);
}

.btn-danger {
    background: linear-gradient(90deg, var(--danger), var(--danger-strong));
    color: #fff;
    box-shadow: 0 10px 24px var(--danger-glow);
}

.btn-nav {
    padding: 10px 14px;
}

.btn-small {
    padding: 9px 12px;
    font-size: 0.86rem;
}

.icon-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-btn-primary {
    width: 40px;
    height: 40px;
}

.nav-menu-toggle {
    display: none;
}

.icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 1rem;
    line-height: 1;
}

.icon-wrap svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.theme-toggle {
    color: var(--text-main);
}

.theme-icon {
    font-size: 1.05rem;
}

.btn-full {
    width: 100%;
}

.hero {
    padding: 80px 0 46px;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 30px;
    align-items: center;
}

.hero-copy h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.25rem);
    line-height: 1.08;
}

.hero-copy p {
    color: var(--text-muted);
    font-size: 1.08rem;
    margin: 18px 0 28px;
    max-width: 60ch;
}

.badge {
    display: inline-block;
    border: 1px solid rgba(67, 187, 189, 0.55);
    padding: 7px 12px;
    border-radius: 999px;
    color: #8de3e4;
    margin-bottom: 14px;
    font-size: 0.82rem;
    font-weight: 700;
}

.hero-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.hero-quick-form {
    margin-top: 16px;
    display: grid;
    gap: 8px;
    max-width: 720px;
}

.hero-quick-form label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

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

.hero-quick-form input[type='text'] {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--input-bg);
    color: var(--text-main);
    padding: 12px 14px;
    font: inherit;
}

.hero-quick-form input[type='text']::placeholder {
    color: var(--text-muted);
}

.hero-quick-form small {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.hero-card {
    background: var(--surface-card);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.hero-card h2 {
    margin: 0 0 14px;
    font-size: 1.25rem;
}

.hero-card ul {
    margin: 0;
    padding-left: 20px;
    color: var(--text-muted);
    display: grid;
    gap: 9px;
}

.section {
    padding: 42px 0 64px;
}

.section-alt {
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: var(--section-alt-bg);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.card {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 20px;
    background: var(--surface-card);
    animation: fadeUp 0.4s ease both;
}

.card h3 {
    margin: 0 0 10px;
}

.card p {
    margin: 0;
    color: var(--text-muted);
}

.steps-grid {
    margin-top: 18px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.step {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    background: var(--surface-card-soft);
    color: var(--text-muted);
}

.admin-main {
    padding-bottom: 24px;
}

.admin-hero-section {
    padding-bottom: 24px;
}

.admin-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.admin-hero h1 {
    margin: 0;
    font-size: clamp(1.7rem, 3.4vw, 2.4rem);
}

.admin-hero p {
    margin: 12px 0 0;
    max-width: 74ch;
    color: var(--text-muted);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.metric-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    background: var(--surface-card);
    box-shadow: var(--shadow);
}

.metric-card h3 {
    margin: 0;
    font-size: 0.92rem;
    color: var(--text-muted);
}

.metric-card strong {
    display: block;
    margin-top: 8px;
    font-size: 1.8rem;
    line-height: 1.05;
}

.metric-card p {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 0.86rem;
}

.admin-content-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.admin-card {
    display: grid;
    gap: 12px;
}

.admin-card h2 {
    margin: 0;
    font-size: 1.1rem;
}

.admin-detail-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.admin-detail-head h2 {
    margin: 0;
    font-size: 1.28rem;
}

.admin-detail-head .admin-muted {
    margin-top: 6px;
}

.admin-detail-metrics {
    margin-top: 14px;
}

.admin-muted {
    color: var(--text-muted);
    font-size: 0.88rem;
}

.admin-success,
.admin-error {
    margin: 0;
    border-radius: 10px;
    border: 1px solid var(--line);
    padding: 10px 12px;
    font-size: 0.88rem;
}

.admin-success {
    color: #87f0c1;
    background: rgba(42, 169, 114, 0.2);
}

.admin-error {
    color: #ffd0d4;
    background: rgba(239, 95, 107, 0.2);
}

.admin-budget-alert {
    margin: 0 0 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    padding: 12px 14px;
    font-size: 0.9rem;
}

.admin-budget-alert.is-warning {
    border-color: rgba(239, 181, 68, 0.55);
    background: rgba(239, 181, 68, 0.18);
    color: #ffe7ad;
}

.admin-budget-alert.is-critical {
    border-color: rgba(239, 95, 107, 0.55);
    background: rgba(239, 95, 107, 0.2);
    color: #ffd0d4;
}

.admin-budget-alert.is-ok {
    border-color: rgba(67, 187, 189, 0.45);
    background: rgba(67, 187, 189, 0.14);
    color: #9ef0f1;
}

.admin-table-wrap {
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: auto;
    background: var(--surface-card-soft);
}

.admin-table {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    border-right: 1px solid var(--line);
    vertical-align: top;
    font-size: 0.88rem;
}

.admin-table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.admin-table th:last-child,
.admin-table td:last-child {
    border-right: 0;
}

.admin-table tbody tr:last-child td {
    border-bottom: 0;
}

.admin-role-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.admin-role-select {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-glass);
    color: var(--text-main);
    padding: 7px 9px;
    font: inherit;
    font-size: 0.86rem;
}

.admin-user-link {
    color: var(--text-main);
    text-decoration: none;
}

.admin-user-link:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.admin-feature-form {
    display: grid;
    gap: 10px;
}

.admin-token-limit-form {
    display: grid;
    gap: 10px;
}

.admin-token-limit-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.admin-token-limit-field {
    display: grid;
    gap: 6px;
}

.admin-token-limit-field span {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.admin-token-limit-field .admin-role-select {
    width: 100%;
}

.admin-feature-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
    font-size: 0.9rem;
}

.admin-feature-toggle input {
    width: 16px;
    height: 16px;
}

.admin-settings-wrap {
    display: grid;
    gap: 10px;
}

.admin-settings-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.admin-settings-nav-item {
    min-height: 36px;
}

.admin-settings-nav-item.is-active {
    border-color: transparent;
    color: #fff;
    background: linear-gradient(90deg, #43bbbd, #0979b9);
}

.admin-editor-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.admin-public-grid {
    display: grid;
    gap: 10px;
}

.admin-public-grid.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-public-field {
    display: grid;
    gap: 6px;
}

.admin-public-field span {
    color: var(--text-muted);
    font-size: 0.84rem;
}

.admin-public-field input,
.admin-public-field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-glass);
    color: var(--text-main);
    padding: 10px 11px;
    font: inherit;
    font-size: 0.89rem;
}

.admin-public-field textarea {
    min-height: 92px;
    resize: vertical;
}

.admin-color-input-wrap {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
}

.admin-color-picker {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: transparent;
    cursor: pointer;
}

.admin-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.admin-color-picker::-webkit-color-swatch {
    border: 0;
    border-radius: 999px;
}

.admin-color-picker::-moz-color-swatch {
    border: 0;
    border-radius: 999px;
}

.admin-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.admin-preset-field {
    min-width: min(320px, 100%);
}

.admin-preset-field .admin-role-select {
    width: 100%;
}

.admin-theme-preview {
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
}

.admin-theme-preview-header,
.admin-theme-preview-footer {
    padding: 10px 12px;
    font-size: 0.84rem;
    font-weight: 700;
}

.admin-theme-preview-body {
    padding: 14px;
    display: grid;
    gap: 10px;
}

.admin-theme-preview-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
}

.admin-theme-preview-btn {
    width: fit-content;
    border: 0;
    border-radius: 999px;
    padding: 10px 14px;
    font-weight: 700;
}

.admin-form-section {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    background: var(--surface-card-soft);
    display: grid;
    gap: 10px;
}

.admin-form-section h3 {
    margin: 0;
    font-size: 0.98rem;
}

.admin-logo-preview-wrap {
    display: grid;
    gap: 8px;
    margin: 8px 0 12px;
}

.admin-logo-preview {
    width: auto;
    max-width: min(320px, 100%);
    max-height: 90px;
    object-fit: contain;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface-card-soft);
    padding: 10px;
}

.admin-divider {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 14px 0;
}

.admin-public-resource-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    background: var(--surface-glass);
    display: grid;
    gap: 8px;
}

.admin-public-resource-card h4 {
    margin: 0;
    font-size: 0.9rem;
}

.site-footer {
    border-top: 1px solid var(--line);
    background:
        radial-gradient(circle at 10% -30%, rgba(67, 187, 189, 0.12), transparent 45%),
        var(--surface-card-soft);
}

.footer-main {
    display: grid;
    grid-template-columns: minmax(260px, 1.4fr) minmax(180px, 1fr) minmax(180px, 1fr);
    gap: 24px;
    padding: 28px 0 22px;
}

.footer-brand-block {
    display: grid;
    gap: 10px;
}

.footer-brand {
    width: fit-content;
}

.footer-brand-block p {
    margin: 0;
    max-width: 52ch;
    line-height: 1.5;
    color: var(--text-muted);
    font-size: 0.93rem;
}

.footer-column {
    display: grid;
    align-content: start;
    gap: 8px;
}

.footer-column h3 {
    margin: 0 0 2px;
    font-size: 0.9rem;
    color: var(--text-main);
}

.footer-column a {
    color: var(--text-muted);
    font-size: 0.9rem;
    width: fit-content;
    transition: color 0.2s ease;
}

.footer-column a:hover {
    color: var(--text-main);
}

.footer-bottom {
    min-height: 58px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-top: 1px solid var(--line);
    padding: 10px 0;
    color: var(--text-muted);
    font-size: 0.84rem;
}

.footer-bottom p {
    margin: 0;
}

.auth-page {
    min-height: 100dvh;
}

.auth-shell {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(460px, 100%);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 26px 24px;
    background: var(--surface-card);
    box-shadow: var(--shadow);
}

.auth-brand {
    margin-bottom: 16px;
}

.auth-card h1 {
    margin: 0;
    font-size: 1.35rem;
}

.auth-subtitle {
    margin: 8px 0 16px;
    color: var(--text-muted);
}

.auth-error {
    margin-bottom: 12px;
    border: 1px solid rgba(239, 95, 107, 0.45);
    background: rgba(239, 95, 107, 0.12);
    color: var(--text-main);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.9rem;
}

.auth-social-block {
    display: grid;
    gap: 10px;
    margin: 2px 0 10px;
}

.auth-google-btn {
    width: 100%;
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.auth-google-btn .icon-wrap {
    width: 19px;
    height: 19px;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.82rem;
    text-transform: lowercase;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
}

.auth-form {
    display: grid;
    gap: 10px;
}

.auth-field {
    display: grid;
    gap: 6px;
}

.auth-field span {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 700;
}

.auth-field input {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--input-bg);
    color: var(--text-main);
    padding: 12px 13px;
    font: inherit;
}

.auth-field input:focus {
    outline: none;
    border-color: #43bbbd;
}

.auth-submit {
    margin-top: 4px;
    width: 100%;
}

.auth-helper-row {
    display: flex;
    justify-content: flex-end;
    margin-top: -2px;
}

.auth-inline-link {
    color: var(--text-muted);
    font-size: 0.84rem;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.auth-inline-link:hover {
    color: var(--text-main);
}

.auth-success {
    margin-bottom: 12px;
    border: 1px solid rgba(67, 187, 189, 0.5);
    background: rgba(67, 187, 189, 0.14);
    color: var(--text-main);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.9rem;
}

.auth-reset-preview {
    margin-top: 6px;
    border: 1px dashed var(--line);
    border-radius: 10px;
    padding: 9px 10px;
    background: var(--surface-card-soft);
    overflow-x: auto;
    word-break: break-all;
    font-size: 0.8rem;
}

.auth-info-text {
    margin-top: 6px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.auth-back-link {
    margin-top: 14px;
    display: inline-flex;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.auth-back-link:hover {
    color: var(--text-main);
}

.auth-switch {
    margin: 14px 0 2px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.auth-switch a {
    color: var(--text-main);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.auth-check {
    margin-top: 2px;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
    gap: 9px;
    color: var(--text-muted);
    font-size: 0.86rem;
    line-height: 1.45;
}

.auth-check input {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    accent-color: var(--brand-a);
}

.auth-check a {
    color: var(--text-main);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.legal-hero {
    padding-top: 38px;
    padding-bottom: 14px;
}

.legal-hero-wrap {
    display: grid;
    gap: 10px;
}

.legal-hero-wrap h1 {
    margin: 0;
    font-size: clamp(1.7rem, 3vw, 2.4rem);
    line-height: 1.15;
    letter-spacing: -0.01em;
}

.legal-hero-wrap p {
    margin: 0;
    color: var(--text-muted);
    max-width: 760px;
}

.legal-meta-row {
    margin-top: 2px;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.legal-grid {
    display: grid;
    gap: 14px;
}

.legal-card {
    padding: 18px;
}

.legal-card h2 {
    margin: 0 0 10px;
    font-size: 1.1rem;
}

.legal-content {
    color: var(--text-main);
    line-height: 1.66;
    white-space: normal;
}

.legal-cta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* Chat layout */
.chat-shell {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    height: 100%;
    max-height: 100%;
    min-height: 0;
    position: relative;
}

.chat-sidebar {
    border-right: 1px solid var(--line);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 16px;
    min-width: 0;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    position: relative;
    overflow: hidden;
    transition: transform 0.24s ease, opacity 0.24s ease, border-color 0.24s ease, padding 0.24s ease;
}

.chat-shell.sidebar-collapsed {
    grid-template-columns: 0 1fr;
}

.chat-shell.sidebar-collapsed .chat-sidebar {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
    border-right-color: transparent;
    padding-left: 0;
    padding-right: 0;
}

.sidebar-overlay {
    display: none;
}

.sidebar-top {
    display: grid;
    gap: 14px;
}

.logo-lockup {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-glass);
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.logo-lockup:hover {
    border-color: rgba(67, 187, 189, 0.55);
    background: rgba(67, 187, 189, 0.1);
}

.logo-lockup .brand-logo {
    width: 30px;
    height: 30px;
}

.logo-lockup-text {
    min-width: 0;
    display: grid;
    gap: 1px;
    line-height: 1.15;
}

.logo-lockup-text strong {
    font-size: 0.9rem;
    letter-spacing: 0.01em;
}

.logo-lockup-text small {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-tools {
    display: grid;
}

.conversation-search-input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface-card-soft);
    color: var(--text-main);
    font: inherit;
    font-size: 0.84rem;
    padding: 10px 11px;
}

.conversation-search-input::placeholder {
    color: var(--text-muted);
}

.conversation-search-input:focus {
    outline: none;
    border-color: rgba(67, 187, 189, 0.65);
    box-shadow: 0 0 0 3px rgba(67, 187, 189, 0.16);
}

.sidebar-label {
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-size: 0.72rem;
    font-weight: 700;
}

.conversation-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    min-width: 0;
}

.conversation-empty {
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 12px;
    color: var(--text-muted);
    font-size: 0.88rem;
    text-align: center;
}

.conversation-group-title {
    margin: 10px 2px 2px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.67rem;
    font-weight: 800;
}

.conversation-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 6px;
}

.conversation-item {
    width: 100%;
    min-width: 0;
    text-align: left;
    color: var(--text-main);
    font: inherit;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 11px 12px;
    cursor: pointer;
    background: var(--surface-card-soft);
    transition: border-color 0.2s ease, background 0.2s ease;
}

.conversation-item:hover {
    border-color: rgba(67, 187, 189, 0.5);
}

.conversation-item.active {
    border-color: #43bbbd;
    background: rgba(67, 187, 189, 0.2);
}

.conversation-item span {
    display: block;
    font-size: 0.84rem;
    color: var(--text-muted);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.conversation-item strong {
    display: block;
    font-size: 0.87rem;
    line-height: 1.35;
    margin-bottom: 4px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.conversation-meta {
    opacity: 0.88;
}

.conversation-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.conversation-rename-btn,
.conversation-delete-btn {
    width: 30px;
    height: 30px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.conversation-rename-btn svg,
.conversation-delete-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.conversation-row:hover .conversation-rename-btn,
.conversation-row.active .conversation-rename-btn,
.conversation-rename-btn:focus-visible,
.conversation-row:hover .conversation-delete-btn,
.conversation-row.active .conversation-delete-btn,
.conversation-delete-btn:focus-visible {
    opacity: 0.8;
    pointer-events: auto;
}

.conversation-rename-btn:hover,
.conversation-rename-btn:focus-visible {
    color: var(--text-main);
    border-color: rgba(67, 187, 189, 0.45);
    background: rgba(67, 187, 189, 0.1);
    outline: none;
}

.conversation-delete-btn:hover,
.conversation-delete-btn:focus-visible {
    color: var(--danger);
    border-color: rgba(239, 95, 107, 0.35);
    background: rgba(239, 95, 107, 0.1);
    outline: none;
}

.chat-main {
    display: grid;
    grid-template-rows: 1fr auto;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.sidebar-toggle {
    white-space: nowrap;
}

.model-pill {
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(67, 187, 189, 0.45);
    border-radius: 999px;
    padding: 6px 10px;
    color: #93e8e9;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.session-pill {
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--text-muted);
}

.quota-pill {
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(67, 187, 189, 0.45);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-main);
    background: rgba(67, 187, 189, 0.12);
    white-space: nowrap;
}

.quota-pill.is-warning {
    border-color: rgba(239, 181, 68, 0.65);
    background: rgba(239, 181, 68, 0.18);
}

.quota-pill.is-critical {
    border-color: rgba(239, 95, 107, 0.7);
    background: rgba(239, 95, 107, 0.2);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(4, 18, 30, 0.6);
    backdrop-filter: blur(3px);
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-card {
    width: min(430px, 100%);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px 18px 16px;
    background: var(--bg-panel);
    box-shadow: var(--shadow);
    position: relative;
}

.modal-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

.modal-close-btn:hover {
    border-color: var(--line);
    color: var(--text-main);
}

.modal-card h2 {
    margin: 0 0 8px;
    font-size: 1.1rem;
}

.modal-copy {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.5;
}

.modal-context {
    margin: 12px 0 0;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface-card-soft);
    color: var(--text-main);
    font-size: 0.9rem;
    line-height: 1.45;
}

.modal-actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-field-label {
    display: block;
    margin: 14px 0 7px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
}

.modal-text-input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface-card-soft);
    color: var(--text-main);
    font: inherit;
    padding: 10px 12px;
}

.modal-text-input:focus {
    outline: none;
    border-color: rgba(67, 187, 189, 0.65);
    box-shadow: 0 0 0 3px rgba(67, 187, 189, 0.16);
}

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

body.modal-open {
    overflow: hidden;
}

.messages {
    width: min(100%, var(--chat-content-max-width));
    justify-self: center;
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-height: 0;
    overscroll-behavior: contain;
}

.welcome-message {
    max-width: 700px;
    margin: auto;
    text-align: center;
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 32px 24px;
    background: var(--welcome-bg);
}

.welcome-message h2 {
    margin: 0 0 10px;
}

.welcome-message p {
    margin: 0;
    color: var(--text-muted);
}

.message {
    max-width: min(84%, 780px);
    padding: 15px 17px;
    border-radius: 16px;
    line-height: 1.58;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    animation: bubbleInSystem 0.24s ease both;
    display: grid;
    gap: 10px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.message:hover {
    transform: translateY(-1px);
}

.message.user {
    margin-left: auto;
    background: var(--user-bubble);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-bottom-right-radius: 4px;
    animation-name: bubbleInUser;
    animation-duration: 0.22s;
}

.message.user .message-time,
.message.user .message-author {
    color: rgba(255, 255, 255, 0.88);
}

.message.assistant {
    margin-right: auto;
    background: var(--assistant-bubble);
    color: var(--assistant-text);
    border: 1px solid var(--line);
    border-bottom-left-radius: 4px;
    white-space: normal;
    animation-name: bubbleInAssistant;
    animation-duration: 0.24s;
}

.message.system {
    margin: 0 auto;
    background: var(--message-system-bg);
    color: var(--text-muted);
    white-space: normal;
    max-width: min(92%, 760px);
}

.message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.74rem;
}

.message-identity {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.message-avatar {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    font-weight: 800;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}

.message-avatar.assistant {
    background: linear-gradient(90deg, #43bbbd, #0979b9);
}

.message-avatar.user {
    background: rgba(255, 255, 255, 0.22);
}

.message-avatar.system {
    background: rgba(255, 255, 255, 0.18);
}

.message-author {
    white-space: nowrap;
}

.message-time {
    color: var(--text-muted);
    white-space: nowrap;
}

.message-content {
    display: grid;
    gap: 12px;
}

.message.assistant p,
.message.system p {
    margin: 0 0 0.72em;
}

.message.assistant p:last-child,
.message.system p:last-child {
    margin-bottom: 0;
}

.message.assistant h1,
.message.assistant h2,
.message.assistant h3,
.message.assistant h4,
.message.system h1,
.message.system h2,
.message.system h3,
.message.system h4 {
    margin: 0 0 0.65em;
    line-height: 1.35;
}

.message.assistant h1,
.message.system h1 {
    font-size: 1.1rem;
}

.message.assistant h2,
.message.system h2 {
    font-size: 1.04rem;
}

.message.assistant h3,
.message.assistant h4,
.message.system h3,
.message.system h4 {
    font-size: 0.98rem;
}

.message.assistant ul,
.message.assistant ol,
.message.system ul,
.message.system ol {
    margin: 0 0 0.72em 1.2em;
    padding: 0;
}

.message.assistant li,
.message.system li {
    margin: 0.2em 0;
}

.message.assistant strong,
.message.system strong {
    color: var(--emphasis-text);
}

.message.assistant code,
.message.system code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 8px;
    padding: 2px 6px;
    font-size: 0.9em;
}

.message.assistant pre,
.message.system pre {
    margin: 0 0 0.72em;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: var(--code-bg);
    padding: 12px;
    overflow-x: auto;
}

.message.assistant pre code,
.message.system pre code {
    background: transparent;
    border: 0;
    padding: 0;
}

.message.assistant a,
.message.system a {
    color: #8de3e4;
    text-decoration: underline;
}

.generated-image-card {
    margin: 10px 0 0;
    display: grid;
    gap: 8px;
}

.generated-image-link {
    width: min(100%, 520px);
    display: block;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--surface-card-soft);
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.generated-image-link:hover {
    border-color: rgba(67, 187, 189, 0.6);
    transform: translateY(-1px);
}

.generated-image {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
    background: var(--surface-card-soft);
}

.generated-image-caption {
    margin: 0;
    font-size: 0.77rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.message-context {
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--text-muted);
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-glass);
    padding: 7px 10px;
}

.message-context-top {
    margin: 0 0 10px;
}

.message-context-bottom {
    margin: 10px 0 0;
}

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

.message-copy-btn,
.message-regenerate-btn,
.message-feedback-btn {
    width: 33px;
    height: 33px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-glass);
    color: var(--text-muted);
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.message-copy-btn .icon-wrap,
.message-regenerate-btn .icon-wrap,
.message-feedback-btn .icon-wrap {
    width: 14px;
    height: 14px;
}

.message-copy-btn:hover,
.message-regenerate-btn:hover,
.message-feedback-btn:hover {
    color: var(--text-main);
    border-color: rgba(67, 187, 189, 0.5);
    background: rgba(67, 187, 189, 0.14);
}

.message-copy-btn:disabled,
.message-regenerate-btn:disabled,
.message-feedback-btn:disabled {
    opacity: 0.72;
    cursor: default;
}

.message-copy-btn[data-copy-state='copied'] {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(90deg, #43bbbd, #0979b9);
}

.message-copy-btn[data-copy-state='error'] {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(90deg, var(--danger), var(--danger-strong));
}

.message-feedback {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    order: 2;
}

.message-copy-btn {
    order: 1;
}

.message-regenerate-btn {
    order: 3;
}

.message-feedback-btn.active {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(90deg, #43bbbd, #0979b9);
}

.message-feedback-btn[data-vote='down'].active {
    background: linear-gradient(90deg, var(--danger), var(--danger-strong));
}

.message-feedback-btn:disabled {
    opacity: 0.72;
}

.message.assistant .markdown-table-wrap,
.message.system .markdown-table-wrap {
    margin: 0 0 0.8em;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow-x: auto;
    background: var(--surface-card-soft);
}

.message.assistant table,
.message.system table {
    width: 100%;
    min-width: 420px;
    border-collapse: collapse;
}

.message.assistant thead,
.message.system thead {
    background: rgba(67, 187, 189, 0.12);
}

.message.assistant th,
.message.assistant td,
.message.system th,
.message.system td {
    padding: 10px 12px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.message.assistant th:last-child,
.message.assistant td:last-child,
.message.system th:last-child,
.message.system td:last-child {
    border-right: 0;
}

.message.assistant tbody tr:last-child td,
.message.system tbody tr:last-child td {
    border-bottom: 0;
}

.typing {
    opacity: 0.82;
    font-style: italic;
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.75;
    animation: typingPulse 1s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.3s;
}

.typing-text {
    line-height: 1.6;
    white-space: pre-wrap;
}

.composer {
    width: min(calc(100% - 24px), var(--chat-content-max-width));
    justify-self: center;
    border: 0;
    border-radius: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    background: transparent;
    backdrop-filter: none;
    box-shadow: none;
    position: sticky;
    bottom: calc(var(--composer-gap-bottom) + env(safe-area-inset-bottom, 0px));
    z-index: 3;
}

.composer-plus-wrap {
    position: relative;
    align-self: center;
}

.composer-plus-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: var(--text-main);
    font: inherit;
    font-size: 2.2rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.composer-plus-btn:hover {
    color: #43bbbd;
    background: rgba(67, 187, 189, 0.12);
    transform: translateY(-1px);
}

.composer-plus-btn:disabled {
    opacity: 0.65;
    cursor: default;
    transform: none;
}

.composer-action-menu {
    position: absolute;
    left: 0;
    bottom: calc(100% + 10px);
    width: min(370px, 86vw);
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--bg-panel);
    box-shadow: var(--shadow);
    padding: 10px;
    z-index: 20;
}

.composer-action-item {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-main);
    border-radius: 12px;
    padding: 11px 12px;
    font: inherit;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.composer-action-item .icon-wrap {
    width: 15px;
    height: 15px;
    color: var(--text-muted);
}

.composer-action-item:hover,
.composer-action-item:focus-visible {
    outline: none;
    border-color: rgba(67, 187, 189, 0.5);
    background: rgba(67, 187, 189, 0.14);
}

.composer-action-item:disabled {
    opacity: 0.42;
    cursor: not-allowed;
    border-color: var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
}

.composer-action-item:disabled .icon-wrap {
    color: var(--text-muted);
}

.composer-action-item:disabled:hover,
.composer-action-item:disabled:focus-visible {
    outline: none;
    border-color: var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
}

.composer-action-footnote {
    margin: 8px 2px 0;
    padding-top: 8px;
    border-top: 1px solid var(--line);
    color: var(--text-muted);
    font-size: 0.74rem;
    line-height: 1.35;
}

.composer-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.composer-hint[hidden] {
    display: none !important;
}

.composer-hint.is-error {
    color: var(--danger);
}

.composer-hint.is-success {
    color: #7ad7d9;
}

.composer-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 18px;
}

.composer-counter {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-left: auto;
}

.composer-counter.is-limit {
    color: var(--danger);
    font-weight: 700;
}

.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attachment-pill {
    min-width: min(280px, 100%);
    max-width: min(380px, 100%);
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-card-soft);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 8px 9px;
}

.attachment-pill-icon {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--surface-glass);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.attachment-pill-icon svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.attachment-pill-content {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.attachment-pill-name {
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-pill-meta {
    font-size: 0.73rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-pill-remove {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.attachment-pill-remove:hover,
.attachment-pill-remove:focus-visible {
    outline: none;
    color: var(--danger);
    border-color: rgba(239, 95, 107, 0.35);
    background: rgba(239, 95, 107, 0.1);
}

.attachment-pill-remove svg {
    width: 13px;
    height: 13px;
    fill: currentColor;
}

.composer-main-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--composer-border);
    border-radius: 999px;
    padding: 8px 10px;
    background: var(--composer-bg);
    backdrop-filter: blur(8px);
    box-shadow: var(--composer-shadow);
}

.composer textarea {
    resize: none;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-main);
    padding: 12px 8px;
    font: inherit;
    min-height: 50px;
    max-height: 260px;
}

.composer textarea::placeholder {
    color: var(--text-muted);
}

.composer textarea:focus {
    outline: none;
}

#send-btn {
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 24px rgba(9, 121, 185, 0.28);
}

#send-btn .icon-wrap {
    width: 18px;
    height: 18px;
}

#send-btn:hover {
    transform: translateY(-1px) scale(1.02);
}

#send-btn.is-cancel {
    background: linear-gradient(90deg, var(--danger), var(--danger-strong));
    box-shadow: 0 10px 24px var(--danger-glow);
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bubbleInAssistant {
    from {
        opacity: 0;
        transform: translate3d(-12px, 10px, 0) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
}

@keyframes bubbleInUser {
    from {
        opacity: 0;
        transform: translate3d(12px, 10px, 0) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
}

@keyframes bubbleInSystem {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typingPulse {
    0%,
    80%,
    100% {
        transform: scale(0.85);
        opacity: 0.45;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@media (max-width: 980px) {
    :root {
        --chat-header-height: 66px;
    }

    .nav-wrap {
        grid-template-columns: 1fr auto;
        min-height: 66px;
        padding: 10px 0;
        gap: 10px;
    }

    .nav-wrap .brand {
        min-width: 0;
    }

    .nav-wrap .brand span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .nav-utility {
        justify-content: flex-end;
    }

    .nav-menu-toggle {
        display: inline-flex;
    }

    .nav-links {
        display: none;
        grid-column: 1 / -1;
        justify-self: stretch;
        margin-top: 4px;
        padding: 10px;
        border: 1px solid var(--line);
        border-radius: 14px;
        background: var(--surface-card);
        box-shadow: var(--shadow);
        gap: 8px;
    }

    .site-header.nav-open .nav-links {
        display: grid;
        grid-template-columns: 1fr;
    }

    .nav-links a:not(.btn) {
        text-align: center;
        border: 1px solid var(--line);
        border-radius: 10px;
        padding: 10px 12px;
        background: var(--surface-glass);
    }

    .nav-links .btn-nav {
        width: 100%;
    }

    .btn-nav {
        padding: 10px 12px;
    }

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

    .hero-quick-form-row {
        grid-template-columns: 1fr;
    }

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

    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .admin-content-grid {
        grid-template-columns: 1fr;
    }

    .admin-editor-grid {
        grid-template-columns: 1fr;
    }

    .admin-public-grid.two-col {
        grid-template-columns: 1fr;
    }

    .admin-token-limit-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .admin-hero {
        display: grid;
        grid-template-columns: 1fr;
        align-items: start;
    }

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

    .chat-global-inner {
        min-height: var(--chat-header-height);
        grid-template-columns: auto 1fr auto;
        gap: 8px;
        padding: 8px 10px;
    }

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

    .chat-brand .brand-logo {
        width: 30px;
        height: 30px;
    }

    .chat-brand span {
        display: none;
    }

    .chat-header-nav,
    .session-pill,
    .quota-pill,
    .model-pill,
    .chat-home-link {
        display: none;
    }

    .chat-header-actions {
        gap: 8px;
    }

    #new-chat-header-btn {
        display: inline-flex;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
    }

    .chat-header-center {
        gap: 8px;
    }

    .chat-header-center h1 {
        font-size: 0.9rem;
    }

    .chat-shell {
        display: block;
        grid-template-columns: 1fr;
        height: 100%;
        min-height: 0;
    }

    .chat-shell.sidebar-collapsed {
        grid-template-columns: 1fr;
    }

    .conversation-delete-btn {
        opacity: 0.72;
        pointer-events: auto;
    }

    body.chat-page {
        height: 100dvh;
        overflow: hidden;
    }

    .chat-sidebar {
        border-bottom: 0;
        border-right: 1px solid var(--line);
        width: min(84vw, 320px);
        position: fixed;
        left: 0;
        top: var(--chat-header-height);
        bottom: 0;
        z-index: 45;
        transform: translateX(-100%);
        box-shadow: var(--shadow);
    }

    .chat-shell:not(.sidebar-collapsed) .chat-sidebar {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }

    .chat-shell:not(.sidebar-collapsed) .sidebar-overlay {
        display: block;
        position: fixed;
        inset: var(--chat-header-height) 0 0 0;
        border: 0;
        background: var(--overlay-bg);
        z-index: 35;
        cursor: pointer;
    }

    .chat-main {
        height: 100%;
        min-height: 0;
    }

    .messages,
    .composer {
        width: calc(100% - 14px);
        max-width: none;
    }

    .message {
        max-width: min(92%, 760px);
    }

    .composer {
        bottom: calc(8px + env(safe-area-inset-bottom, 0px));
        padding: 0;
        gap: 10px;
    }

    .composer-main-row {
        grid-template-columns: auto minmax(0, 1fr) auto;
        border-radius: 22px;
        padding: 7px 8px;
    }

    .attachment-pill {
        min-width: 100%;
        max-width: 100%;
    }

    .composer-action-menu {
        width: min(340px, 92vw);
    }

    .footer-main {
        grid-template-columns: 1fr 1fr;
        gap: 18px;
        padding: 22px 0 16px;
    }

    .footer-brand-block {
        grid-column: 1 / -1;
    }

    .footer-bottom {
        display: grid;
        gap: 3px;
        justify-content: start;
        padding: 10px 0 14px;
    }
}

@media (max-width: 560px) {
    .site-header .container {
        width: min(1120px, 94vw);
    }

    .nav-wrap {
        gap: 8px;
    }

    .nav-wrap .brand span {
        font-size: 0.94rem;
    }

    .nav-wrap .brand-logo {
        width: 30px;
        height: 30px;
    }

    .home-theme-toggle,
    .nav-menu-toggle {
        width: 34px;
        height: 34px;
    }

    .site-header.nav-open .nav-links {
        gap: 7px;
        padding: 9px;
    }

    .site-header.nav-open .nav-links a:not(.btn) {
        padding: 9px 10px;
        font-size: 0.88rem;
    }

    .site-header.nav-open .nav-links .btn-nav {
        font-size: 0.89rem;
        padding: 9px 10px;
    }

    .footer-main {
        grid-template-columns: 1fr;
        gap: 14px;
    }

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

    .admin-table {
        min-width: 500px;
    }

    .admin-token-limit-grid {
        grid-template-columns: 1fr;
    }

    .admin-settings-nav {
        display: grid;
        grid-template-columns: 1fr;
    }

    .admin-settings-nav-item {
        width: 100%;
        justify-content: center;
    }

    .admin-actions-row .btn {
        width: 100%;
    }

    .footer-column a {
        font-size: 0.88rem;
    }

    .footer-bottom {
        font-size: 0.8rem;
    }
}
