:root {
    --surface: #f4f1eb;
    --surface-raised: #ffffff;
    --surface-muted: #ebe7df;
    --text: #171714;
    --text-muted: #68645d;
    --line: #d8d3ca;
    --line-strong: #aaa49a;
    --accent: #c84f2d;
    --accent-strong: #a83d20;
    --dark: #20201d;
    --success: #276749;
    --success-surface: #edf7f1;
    --danger: #a72e2e;
    --danger-surface: #fff0ef;
    --focus: #2563eb;
    --radius-sm: 5px;
    --radius-md: 9px;
    --shadow: 0 14px 40px rgba(35, 31, 24, 0.08);
    --content-width: 1240px;
    --header-height: 68px;
    font-family: Pretendard, "Pretendard GOV", "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--surface);
    font-synthesis: none;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    min-width: 320px;
    background: var(--surface);
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--surface);
    color: var(--text);
    font-size: 15px;
    line-height: 1.55;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

.skip-link {
    position: fixed;
    z-index: 1000;
    top: 8px;
    left: 8px;
    padding: 10px 14px;
    background: var(--dark);
    color: #fff;
    transform: translateY(-150%);
}

.skip-link:focus {
    transform: translateY(0);
}

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

.app-header {
    position: sticky;
    z-index: 20;
    top: 0;
    display: grid;
    grid-template-columns: minmax(210px, 1fr) auto minmax(210px, 1fr);
    align-items: center;
    min-height: var(--header-height);
    padding: 0 max(24px, calc((100vw - var(--content-width)) / 2));
    border-bottom: 1px solid var(--line);
    background: rgba(244, 241, 235, 0.96);
}

.brand {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    gap: 11px;
    text-decoration: none;
}

.brand-mark,
.login-brand,
.chat-empty-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    background: var(--dark);
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 13px;
    letter-spacing: 0.08em;
}

.brand small {
    color: var(--text-muted);
    font-size: 11px;
}

.primary-navigation {
    display: flex;
    align-self: stretch;
    gap: 28px;
}

.primary-navigation a {
    position: relative;
    display: grid;
    place-items: center;
    min-width: 54px;
    color: var(--text-muted);
    font-weight: 650;
    text-decoration: none;
}

.primary-navigation a::after {
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 2px;
    background: var(--accent);
    content: "";
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 180ms ease;
}

.primary-navigation a:hover,
.primary-navigation a.is-active {
    color: var(--text);
}

.primary-navigation a.is-active::after {
    transform: scaleX(1);
}

.logout-form {
    justify-self: end;
}

.text-button {
    padding: 4px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 650;
    text-decoration: underline;
    text-underline-offset: 3px;
}

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

.page-shell {
    width: min(calc(100% - 48px), var(--content-width));
    min-height: calc(100vh - var(--header-height) - 78px);
    margin: 0 auto;
    padding: 64px 0 88px;
}

.page-shell-narrow {
    max-width: 920px;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 32px;
    margin-bottom: 36px;
}

.page-heading h1,
.conversation-heading h1,
.chat-heading h2 {
    margin: 0;
    letter-spacing: -0.04em;
    line-height: 1.16;
}

.page-heading h1 {
    font-size: clamp(32px, 4vw, 52px);
}

.section-kicker {
    margin: 0 0 10px;
    color: var(--accent-strong);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.14em;
}

.page-description {
    margin: 10px 0 0;
    color: var(--text-muted);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

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

.button:disabled {
    cursor: not-allowed;
    opacity: 0.46;
}

.button-disabled {
    cursor: not-allowed;
    opacity: 0.42;
}

.button-disabled:hover {
    transform: none;
}

.button-primary {
    background: var(--accent);
    color: #fff;
}

.button-primary:hover:not(:disabled) {
    background: var(--accent-strong);
}

.button-secondary {
    border-color: var(--line-strong);
    background: transparent;
    color: var(--text);
}

.button-secondary:hover:not(:disabled) {
    border-color: var(--text);
    background: var(--surface-raised);
}

.button-dark {
    background: var(--dark);
    color: #fff;
}

.button-dark:hover:not(:disabled) {
    background: #000;
}

.button-danger {
    border-color: #d9aaa5;
    background: transparent;
    color: var(--danger);
}

.button-danger:hover:not(:disabled) {
    border-color: var(--danger);
    background: var(--danger-surface);
}

.button-small {
    min-height: 36px;
    padding: 7px 12px;
    font-size: 13px;
}

.button-full {
    width: 100%;
}

.alert {
    margin: 0 0 24px;
    padding: 13px 15px;
    border: 1px solid;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.alert-error {
    border-color: #efb5b0;
    background: var(--danger-surface);
    color: var(--danger);
}

.alert-success {
    border-color: #b8d9c5;
    background: var(--success-surface);
    color: var(--success);
}

.data-section {
    border-top: 2px solid var(--text);
}

.section-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 62px;
    border-bottom: 1px solid var(--line);
}

.section-toolbar h2 {
    margin: 0;
    font-size: 16px;
}

.section-toolbar > span {
    color: var(--text-muted);
    font-size: 13px;
}

.table-scroll {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
    table-layout: fixed;
}

.data-table th,
.data-table td {
    padding: 20px 16px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
}

.data-table th:first-child,
.data-table td:first-child {
    width: 24%;
    padding-left: 0;
}

.data-table th:nth-child(2),
.data-table td:nth-child(2) {
    width: 8%;
}

.data-table th:nth-child(3),
.data-table td:nth-child(3) {
    width: 16%;
}

.data-table th:nth-child(4),
.data-table td:nth-child(4) {
    width: 8%;
}

.data-table th:nth-child(5),
.data-table td:nth-child(5) {
    width: 16%;
}

.data-table th:last-child,
.data-table td:last-child {
    width: 232px;
    padding-right: 0;
}

.data-table tbody tr {
    transition: background-color 160ms ease;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.5);
}

.profile-name,
.profile-description {
    display: block;
}

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

.model-name {
    overflow-wrap: anywhere;
    font-size: 13px;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
}

.status::before {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--line-strong);
    content: "";
}

.status-active {
    color: var(--success);
}

.status-active::before {
    background: var(--success);
}

.table-actions {
    text-align: right;
    white-space: nowrap;
}

.table-action-group {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.inline-action-form {
    display: inline-flex;
    margin: 0;
}

.empty-state {
    display: flex;
    min-height: 390px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    border-top: 2px solid var(--text);
    border-bottom: 1px solid var(--line);
    text-align: center;
}

.empty-state-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-bottom: 20px;
    border: 1px solid var(--line-strong);
    font-size: 24px;
}

.empty-state h2 {
    margin: 0;
    font-size: 22px;
}

.empty-state p {
    margin: 8px 0 22px;
    color: var(--text-muted);
}

.back-link {
    display: inline-block;
    margin-bottom: 14px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 650;
    text-decoration: none;
}

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

.profile-form {
    border-top: 2px solid var(--text);
}

.form-section {
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr);
    gap: 36px;
    padding: 36px 0;
    border-bottom: 1px solid var(--line);
}

.form-section-heading {
    display: grid;
    grid-template-columns: 28px 1fr;
    align-content: start;
    gap: 8px;
}

.form-section-heading > span {
    color: var(--accent-strong);
    font-size: 11px;
    font-weight: 800;
}

.form-section-heading h2 {
    margin: 0;
    font-size: 17px;
}

.form-section-heading p {
    margin: 5px 0 0;
    color: var(--text-muted);
    font-size: 13px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 18px;
}

.field-span-2 {
    grid-column: span 2;
}

.field-group {
    min-width: 0;
}

.field-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 750;
}

.field-group label span {
    color: var(--accent);
}

.field-label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 750;
}

.field-group label.checkbox-control {
    display: flex;
    min-height: 44px;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-raised);
    cursor: pointer;
    font-weight: 650;
}

.field-group .checkbox-control input[type="checkbox"] {
    width: 18px;
    min-height: 18px;
    height: 18px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: transparent;
    box-shadow: none;
    accent-color: var(--accent);
}

.field-group .checkbox-control input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
}

.field-group .checkbox-control span {
    color: var(--text);
}

.field-group input,
.field-group select,
.field-group textarea {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-raised);
    color: var(--text);
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field-group textarea {
    min-height: 96px;
    resize: vertical;
}

.field-group .prompt-input {
    min-height: 280px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 14px;
    line-height: 1.65;
}

.field-group input:hover,
.field-group select:hover,
.field-group textarea:hover {
    border-color: #777168;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
    border-color: var(--text);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
}

.field-help,
.field-error {
    display: block;
    margin-top: 6px;
    font-size: 12px;
}

.field-help {
    color: var(--text-muted);
}

.field-error {
    color: var(--danger);
    font-weight: 650;
}

.field-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}

.character-count {
    flex: none;
    color: var(--text-muted);
    font-size: 12px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 28px;
}

.app-footer {
    display: flex;
    width: min(calc(100% - 48px), var(--content-width));
    min-height: 78px;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin: 0 auto;
    border-top: 1px solid var(--line);
    color: var(--text-muted);
    font-size: 12px;
}

/* Login */
.login-page {
    display: grid;
    place-items: center;
    background: var(--surface);
}

.error-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 40px 20px;
}

.error-panel {
    width: min(100%, 580px);
    padding: 48px;
    border-top: 3px solid var(--text);
    background: var(--surface-raised);
    box-shadow: var(--shadow);
}

.error-brand {
    width: fit-content;
    margin-bottom: 48px;
}

.error-code {
    margin: 0 0 8px;
    color: var(--accent);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.error-panel h1 {
    margin: 0;
    font-size: clamp(28px, 5vw, 40px);
    letter-spacing: -0.04em;
    line-height: 1.2;
}

.error-panel > p:not(.error-code) {
    margin: 14px 0 30px;
    color: var(--text-muted);
}

.error-actions {
    display: flex;
    gap: 10px;
}

.login-shell {
    display: grid;
    width: 100%;
    min-height: 100vh;
    place-items: center;
    padding: 32px 20px;
}

.login-panel {
    width: min(100%, 410px);
    padding: 42px;
    border-top: 3px solid var(--text);
    background: var(--surface-raised);
    box-shadow: var(--shadow);
}

.login-brand {
    margin-bottom: 28px;
}

.login-panel h1 {
    margin: 0;
    font-size: 30px;
    letter-spacing: -0.04em;
}

.login-description {
    margin: 8px 0 28px;
    color: var(--text-muted);
}

.stack-form {
    display: grid;
    gap: 18px;
}

/* Conversation */
.chat-page {
    overflow: hidden;
}

.chat-shell {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    height: calc(100vh - var(--header-height));
    min-height: 0;
    background: var(--surface-raised);
}

.conversation-panel {
    min-width: 0;
    overflow: hidden;
    border-right: 1px solid var(--line);
    background: var(--surface);
}

.conversation-panel > summary {
    display: none;
}

.conversation-panel-inner {
    display: flex;
    height: 100%;
    flex-direction: column;
    padding: 24px 18px;
}

.conversation-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 0 4px 22px;
    border-bottom: 1px solid var(--line);
}

.conversation-profile-summary {
    min-width: 0;
}

.conversation-heading h1 {
    max-width: 100%;
    overflow: hidden;
    font-size: 21px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-new-button {
    width: 100%;
    min-height: 40px;
}

.model-summary {
    display: block;
    max-width: 220px;
    margin-top: 6px;
    overflow: hidden;
    color: var(--text-muted);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-button {
    display: grid;
    width: 40px;
    height: 40px;
    flex: none;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

.icon-button:hover {
    border-color: var(--text);
    background: var(--surface-raised);
}

.conversation-request-state {
    margin: 12px 4px 0;
    color: var(--text-muted);
    font-size: 12px;
}

.conversation-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-top: 12px;
}

.conversation-item {
    display: block;
    padding: 12px 11px;
    border-left: 2px solid transparent;
    color: var(--text-muted);
    text-decoration: none;
    transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}

.conversation-item + .conversation-item {
    margin-top: 3px;
}

.conversation-item:hover {
    background: rgba(255, 255, 255, 0.72);
    color: var(--text);
}

.conversation-item.is-active {
    border-left-color: var(--accent);
    background: var(--surface-raised);
    color: var(--text);
}

.conversation-item strong,
.conversation-item span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-item strong {
    font-size: 13px;
}

.conversation-item span {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 11px;
}

.compact-empty {
    margin: 18px 4px;
    color: var(--text-muted);
    font-size: 13px;
}

.chat-workspace {
    display: grid;
    min-width: 0;
    min-height: 0;
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
}

.chat-heading { grid-row: 1; }
.chat-notice { grid-row: 2; }
.message-region { grid-row: 3; }
.stream-alert { grid-row: 4; }
.composer { grid-row: 5; }

.chat-heading {
    display: flex;
    min-height: 88px;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px clamp(20px, 4vw, 52px);
    border-bottom: 1px solid var(--line);
}

.chat-heading h2 {
    font-size: 21px;
}

.chat-heading .section-kicker {
    margin-bottom: 5px;
}

.connection-state {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
}

.connection-state::before {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--line-strong);
    content: "";
}

.connection-state.is-generating {
    color: var(--accent-strong);
}

.connection-state.is-generating::before {
    background: var(--accent);
    animation: pulse 1.2s ease-in-out infinite;
}

.message-region {
    min-height: 0;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.chat-notice {
    padding: 9px clamp(20px, 4vw, 52px);
    border-bottom: 1px solid #b8d9c5;
    background: var(--success-surface);
    color: var(--success);
    font-size: 13px;
    font-weight: 650;
}

.message-list {
    width: min(calc(100% - 40px), 820px);
    margin: 0 auto;
    padding: 30px 0;
}

.message {
    max-width: 84%;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.message + .message {
    margin-top: 18px;
}

.message-user {
    margin-left: auto;
    border-color: var(--dark);
    background: var(--dark);
    color: #fff;
}

.message-assistant {
    margin-right: auto;
}

.message-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 7px;
    font-size: 11px;
}

.message-meta span {
    color: var(--text-muted);
}

.message-user .message-meta span {
    color: rgba(255, 255, 255, 0.65);
}

.message-content {
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.message-assistant .message-content,
.message-thinking-content {
    line-height: 1.72;
    white-space: normal;
}

.markdown-content > :first-child {
    margin-top: 0;
}

.markdown-content > :last-child {
    margin-bottom: 0;
}

.markdown-content p {
    margin: 0 0 0.85em;
}

.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin: 1.35em 0 0.55em;
    color: var(--text);
    font-weight: 780;
    letter-spacing: -0.02em;
    line-height: 1.4;
}

.markdown-content h3[data-markdown-level="1"] {
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
    font-size: 18px;
}

.markdown-content h4[data-markdown-level="2"] {
    font-size: 16px;
}

.markdown-content h5,
.markdown-content h6 {
    font-size: 14px;
}

.markdown-content ul,
.markdown-content ol {
    margin: 0 0 0.9em;
    padding-left: 1.55em;
}

.markdown-content li {
    padding-left: 0.15em;
}

.markdown-content li + li {
    margin-top: 0.42em;
}

.markdown-content li::marker {
    color: var(--accent-strong);
    font-weight: 750;
}

.markdown-content strong {
    font-weight: 780;
}

.markdown-content em {
    color: #4f4b45;
}

.markdown-content a {
    color: var(--accent-strong);
    font-weight: 650;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.markdown-content a:hover {
    text-decoration-thickness: 2px;
}

.markdown-content blockquote {
    margin: 1em 0;
    padding: 10px 14px;
    border-left: 3px solid var(--accent);
    background: var(--surface-muted);
    color: #504c45;
}

.markdown-content blockquote > :last-child {
    margin-bottom: 0;
}

.markdown-content hr {
    height: 1px;
    margin: 1.25em 0;
    border: 0;
    background: var(--line);
}

.markdown-content code {
    padding: 0.13em 0.38em;
    border: 1px solid #d5cfc4;
    border-radius: 4px;
    background: #ebe6dc;
    color: #713820;
    font-family: Consolas, "SFMono-Regular", "Liberation Mono", monospace;
    font-size: 0.88em;
    overflow-wrap: normal;
}

.markdown-content pre {
    max-width: 100%;
    margin: 1em 0;
    overflow-x: auto;
    border: 1px solid #353531;
    border-radius: var(--radius-sm);
    background: var(--dark);
    color: #f6f2e9;
    tab-size: 4;
}

.markdown-content pre code {
    display: block;
    min-width: max-content;
    padding: 14px 16px;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 12px;
    line-height: 1.65;
    white-space: pre;
}

.message-progress {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.6;
}

.message-progress[hidden] {
    display: none;
}

.message-thinking {
    margin: 0 0 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
    color: var(--text-muted);
}

.message-thinking > summary {
    cursor: pointer;
    font-size: 12px;
    font-weight: 750;
}

.message-thinking-content {
    margin-top: 10px;
    overflow-wrap: anywhere;
    font-size: 13px;
    line-height: 1.65;
    white-space: pre-wrap;
}

.message-sources {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.message-sources > strong {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
}

.message-sources ol {
    display: grid;
    gap: 10px;
    margin: 0;
    padding-left: 20px;
}

.message-sources a {
    color: var(--text);
    font-size: 12px;
    font-weight: 750;
    overflow-wrap: anywhere;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.message-web-sources small {
    display: block;
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 650;
}

.message-sources p {
    display: -webkit-box;
    margin: 4px 0 0;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.55;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.message-status {
    display: block;
    margin-top: 10px;
    color: var(--danger);
    font-size: 12px;
    font-weight: 700;
}

.message-failure {
    padding-left: 12px;
    border-left: 3px solid var(--danger);
    color: var(--danger);
}

.message-failure strong {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
}

.message-failure p {
    margin: 0;
    color: var(--text);
    line-height: 1.6;
}

.message.is-streaming .message-content::after {
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 3px;
    background: var(--accent);
    content: "";
    vertical-align: -0.12em;
    animation: blink 750ms step-end infinite;
}

.chat-empty {
    display: flex;
    height: 100%;
    min-height: 300px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 40px 24px;
    text-align: center;
}

.chat-empty-mark {
    margin-bottom: 18px;
}

.chat-empty h3 {
    margin: 0;
    font-size: 20px;
}

.chat-empty p {
    margin: 7px 0 20px;
    color: var(--text-muted);
}

.stream-alert {
    display: flex;
    width: min(calc(100% - 40px), 820px);
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 0 auto 10px;
    padding: 10px 13px;
    border: 1px solid #efb5b0;
    border-radius: var(--radius-sm);
    background: var(--danger-surface);
    color: var(--danger);
    font-size: 13px;
    font-weight: 650;
}

.stream-alert[hidden] {
    display: none;
}

.composer {
    width: min(calc(100% - 40px), 820px);
    margin: 0 auto;
    padding: 14px 0 20px;
    border-top: 1px solid var(--line);
}

.composer textarea {
    display: block;
    width: 100%;
    max-height: 180px;
    min-height: 48px;
    padding: 12px 14px;
    overflow-y: auto;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-raised);
    field-sizing: content;
    resize: none;
}

.composer textarea:focus {
    border-color: var(--text);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
}

.composer-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 9px;
}

.composer-hint {
    margin-right: auto;
    color: var(--text-muted);
    font-size: 11px;
}

@keyframes pulse {
    50% { opacity: 0.35; }
}

@keyframes blink {
    50% { opacity: 0; }
}

@media (max-width: 900px) {
    .app-header {
        grid-template-columns: 1fr auto;
        padding-inline: 20px;
    }

    .primary-navigation {
        position: fixed;
        z-index: 19;
        right: 0;
        bottom: 0;
        left: 0;
        min-height: 56px;
        justify-content: center;
        gap: clamp(10px, 5vw, 40px);
        padding-inline: 8px;
        border-top: 1px solid var(--line);
        background: var(--surface-raised);
    }

    .primary-navigation a {
        align-self: stretch;
    }

    .primary-navigation a::after {
        top: -1px;
        bottom: auto;
    }

    .logout-form {
        grid-column: 2;
    }

    .page-shell {
        min-height: calc(100vh - var(--header-height) - 56px);
        padding-bottom: 96px;
    }

    .app-footer {
        margin-bottom: 56px;
    }

    .chat-page {
        overflow: auto;
        padding-bottom: 56px;
    }

    .chat-shell {
        display: block;
        height: auto;
        min-height: calc(100vh - var(--header-height) - 56px);
    }

    .conversation-panel {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .conversation-panel > summary {
        display: flex;
        min-height: 48px;
        align-items: center;
        justify-content: space-between;
        padding: 0 20px;
        cursor: pointer;
        font-size: 13px;
        font-weight: 750;
        list-style: none;
    }

    .conversation-panel > summary::-webkit-details-marker {
        display: none;
    }

    .conversation-panel[open] > summary span:last-child {
        transform: rotate(180deg);
    }

    .conversation-panel-inner {
        height: auto;
        max-height: min(440px, calc(100dvh - var(--header-height) - 104px));
        padding: 12px 20px 18px;
    }

    .conversation-heading {
        padding-inline: 0;
    }

    .conversation-list {
        max-height: 170px;
    }

    .chat-workspace {
        min-height: calc(100vh - var(--header-height) - 105px);
        grid-template-rows: auto auto minmax(420px, 1fr) auto auto;
    }
}

@media (max-width: 900px) {
    .page-shell {
        width: min(calc(100% - 32px), var(--content-width));
        padding-top: 40px;
    }

    .page-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 20px;
        margin-bottom: 28px;
    }

    .page-heading .button {
        width: 100%;
    }

    .table-scroll {
        overflow: visible;
    }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100% !important;
    }

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

    .data-table tr {
        padding: 20px 0;
        border-bottom: 1px solid var(--line);
    }

    .data-table td,
    .data-table td:first-child,
    .data-table td:last-child {
        display: grid;
        grid-template-columns: 86px minmax(0, 1fr);
        align-items: baseline;
        min-height: 34px;
        padding: 6px 0;
        border: 0;
    }

    .data-table td::before {
        color: var(--text-muted);
        content: attr(data-label);
        font-size: 11px;
        font-weight: 700;
    }

    .data-table td:first-child {
        display: block;
        padding-top: 0;
        padding-bottom: 12px;
    }

    .data-table td:first-child::before,
    .data-table .table-actions::before {
        display: none;
    }

    .data-table .table-actions {
        display: block;
        padding-top: 12px;
    }

    .data-table .table-action-group {
        display: flex;
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .profile-description {
        white-space: normal;
    }

    .form-section {
        grid-template-columns: 1fr;
        gap: 22px;
        padding: 28px 0;
    }

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

    .field-span-2 {
        grid-column: auto;
    }

    .app-footer {
        width: calc(100% - 32px);
        align-items: flex-start;
        flex-direction: column;
        justify-content: center;
        gap: 3px;
    }

    .message {
        max-width: 92%;
    }
}

@media (max-width: 480px) {
    .app-header {
        min-height: 62px;
        padding-inline: 16px;
    }

    .brand small {
        display: none;
    }

    .brand-mark {
        width: 30px;
        height: 30px;
    }

    .logout-form .text-button {
        font-size: 12px;
    }

    .login-panel {
        padding: 32px 24px;
    }

    .error-panel {
        padding: 36px 24px;
    }

    .error-actions .button {
        flex: 1;
    }

    .field-meta {
        align-items: flex-start;
        flex-direction: column;
        gap: 0;
    }

    .form-actions .button {
        flex: 1;
    }

    .chat-heading {
        min-height: 76px;
        padding-inline: 16px;
    }

    .chat-heading h2 {
        font-size: 18px;
    }

    .message-list,
    .stream-alert,
    .composer {
        width: calc(100% - 28px);
    }

    .message-list {
        padding: 22px 0;
    }

    .message {
        max-width: 96%;
        padding: 13px 14px;
    }

    .composer-hint {
        display: none;
    }
}

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