:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --bg-strong: #e9eef7;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-soft: #f8fafe;
  --surface-strong: #f0f4fb;
  --line: rgba(16, 24, 40, 0.08);
  --line-strong: rgba(16, 24, 40, 0.14);
  --text: #162033;
  --muted: #6e7a90;
  --muted-2: #94a0b2;
  --accent: #4d63ff;
  --accent-soft: rgba(77, 99, 255, 0.08);
  --accent-2: #1fc2af;
  --danger: #df5a63;
  --danger-soft: rgba(223, 90, 99, 0.1);
  --shadow: 0 18px 60px rgba(22, 33, 55, 0.08);
  --shadow-soft: 0 10px 30px rgba(22, 33, 55, 0.05);
  --radius: 28px;
  --radius-md: 22px;
  --radius-sm: 16px;
  --sidebar-w: 240px;
  --content-w: 1380px;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(77, 99, 255, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(31, 194, 175, 0.1), transparent 30%),
    linear-gradient(180deg, #f8fbff 0%, #f2f5fb 42%, #edf2f9 100%);
  color: var(--text);
  font-family: "Manrope", "Noto Sans SC", system-ui, sans-serif;
}

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

button,
input,
textarea {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  outline: none;
  padding: 10px 12px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input:focus,
textarea:focus {
  border-color: rgba(77, 99, 255, 0.42);
  box-shadow: 0 0 0 4px rgba(77, 99, 255, 0.1);
  background: rgba(255, 255, 255, 0.96);
}

textarea {
  resize: none;
  min-height: 46px;
  line-height: 1.64;
}

label {
  display: grid;
  gap: 8px;
}

label > span {
  color: var(--muted);
  font-size: 0.92rem;
}

.btn,
button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease, opacity 0.12s ease;
}

.btn:hover,
button.btn:hover,
.icon-button:hover,
.send-button:hover,
.model-chip:hover {
  transform: translateY(-1px);
}

.btn:disabled,
.icon-button:disabled,
.send-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), #6787ff);
  box-shadow: 0 12px 26px rgba(77, 99, 255, 0.2);
}

.btn.secondary {
  background: rgba(31, 194, 175, 0.12);
  border-color: rgba(31, 194, 175, 0.18);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.42);
}

.btn.danger {
  background: var(--danger-soft);
  border-color: rgba(223, 90, 99, 0.16);
}

.btn.small {
  padding: 6px 10px;
  border-radius: 11px;
  font-size: 0.84rem;
}

.btn.full {
  width: 100%;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 24px rgba(77, 99, 255, 0.22);
}

.brand-name {
  font-weight: 800;
  font-size: 1.02rem;
}

.brand-subtitle,
.muted {
  color: var(--muted);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 28px;
}

.auth-shell {
  width: min(980px, 100%);
  min-height: calc(100vh - 56px);
  display: grid;
  place-items: center;
}

.auth-card,
.chat-sidebar,
.admin-sidebar,
.welcome-card,
.composer-shell,
.assistant-card,
.user-card,
.panel,
.admin-note {
  backdrop-filter: blur(18px);
}

.auth-card {
  width: min(520px, 100%);
  padding: 34px;
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 20px 0 8px;
  font-size: clamp(2rem, 3vw, 2.6rem);
}

.auth-form {
  margin-top: 24px;
  display: grid;
  gap: 16px;
}

.auth-footer {
  margin-top: 18px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.alert {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid transparent;
  margin-top: 18px;
}

.alert.error {
  background: var(--danger-soft);
  border-color: rgba(223, 90, 99, 0.2);
  color: #b4434b;
}

.chat-page,
.admin-page {
  overflow-x: hidden;
}

.chat-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100dvh;
  height: 100dvh;
}

.chat-shell.is-dragover .composer-shell,
.chat-shell.is-dragover .chat-stage {
  box-shadow: inset 0 0 0 2px rgba(77, 99, 255, 0.22);
  background: rgba(77, 99, 255, 0.03);
}

.chat-sidebar,
.admin-sidebar {
  display: grid;
  align-content: stretch;
  gap: 14px;
  padding: 18px 16px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(245, 248, 253, 0.56));
  min-height: 0;
}

.chat-sidebar {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.sidebar-new-btn,
.send-button {
  border: none;
  border-radius: 14px;
  cursor: pointer;
}

.sidebar-new-btn {
  padding: 10px 14px;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  background: linear-gradient(135deg, var(--accent), #6886ff);
  box-shadow: 0 14px 26px rgba(77, 99, 255, 0.2);
}

.sidebar-section {
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
}

.section-title {
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.conversation-list {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 6px;
  overflow: auto;
  min-height: 0;
  padding-right: 4px;
}

.conversation-item {
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.42);
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 3px;
  flex: 0 0 auto;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.12s ease;
}

.conversation-item:hover {
  background: rgba(255, 255, 255, 0.68);
  border-color: rgba(77, 99, 255, 0.12);
}

.conversation-item.active {
  border-color: rgba(77, 99, 255, 0.22);
  background: linear-gradient(135deg, rgba(77, 99, 255, 0.1), rgba(31, 194, 175, 0.08));
  box-shadow: var(--shadow-soft);
}

.conversation-item.empty {
  cursor: default;
}

.conversation-title {
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-meta,
.chat-subtitle,
.composer-status,
.field-hint,
.fetch-status,
.user-role,
.message-meta,
.attachment-empty,
.attachment-chip-name {
  color: var(--muted);
  font-size: 0.82rem;
}

.sidebar-footer {
  display: grid;
  gap: 8px;
  align-self: end;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.52);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--accent);
  background: rgba(77, 99, 255, 0.08);
}

.user-meta {
  display: grid;
  gap: 1px;
  min-width: 0;
  flex: 1 1 auto;
}

.user-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.user-name {
  font-weight: 700;
  font-size: 0.92rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-icon-btn {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.12s ease;
}

.mini-icon-btn svg {
  width: 14px;
  height: 14px;
}

.mini-icon-btn:hover {
  border-color: rgba(77, 99, 255, 0.22);
  background: rgba(77, 99, 255, 0.08);
  color: var(--accent);
  transform: translateY(-1px);
}

.sidebar-actions,
.admin-nav {
  display: grid;
  gap: 10px;
}

.sidebar-mini-actions {
  display: flex;
  justify-content: flex-start;
}

.mobile-menu-btn,
.mobile-sidebar-backdrop {
  display: none;
}

.mobile-new-chat-btn {
  display: none;
}

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

.chat-topbar,
.admin-header {
  padding: 18px 20px 10px;
}

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

.topbar-inner {
  width: 100%;
  max-width: var(--content-w);
  margin: 0 auto 0 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

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

.chat-subtitle {
  margin: 0;
  max-width: 720px;
}

.topbar-eyebrow {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.chat-title,
.admin-header h1 {
  margin: 6px 0 6px;
  font-size: clamp(1.35rem, 2.1vw, 1.9rem);
  line-height: 1.1;
}

.chat-stage {
  overflow: auto;
  min-height: 0;
  padding: 0 20px 8px;
}

.stage-inner {
  width: 100%;
  max-width: var(--content-w);
  margin: 0 auto 0 0;
}

.welcome-card {
  padding: 22px;
  border-radius: 24px;
  border: 1px solid rgba(77, 99, 255, 0.12);
  background:
    radial-gradient(circle at top right, rgba(31, 194, 175, 0.12), transparent 32%),
    radial-gradient(circle at top left, rgba(77, 99, 255, 0.12), transparent 28%),
    rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow);
}

.welcome-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(77, 99, 255, 0.08);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.welcome-card h2 {
  margin: 12px 0 8px;
  font-size: clamp(1.45rem, 2.1vw, 1.95rem);
  line-height: 1.08;
}

.welcome-card p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 0.92rem;
}

.welcome-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.welcome-chip,
.meta-pill,
.assistant-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.78rem;
}

.meta-pill.is-admin {
  color: #0d907f;
  border-color: rgba(31, 194, 175, 0.22);
}

.meta-pill.subtle {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.message-list {
  display: grid;
  gap: 14px;
  padding: 14px 0 20px;
}

.message {
  width: 100%;
}

.message.user {
  display: grid;
  justify-items: end;
  margin-left: auto;
  width: auto;
  max-width: min(420px, 100%);
}

.message.assistant {
  display: grid;
  gap: 10px;
}

.user-bubble {
  max-width: min(420px, 100%);
  background: linear-gradient(135deg, rgba(77, 99, 255, 0.14), rgba(31, 194, 175, 0.1));
  border: 1px solid rgba(77, 99, 255, 0.14);
  box-shadow: var(--shadow-soft);
}

.assistant-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-soft);
}

.assistant-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.message-copy-btn,
.code-copy-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.message-copy-btn.icon-only,
.code-copy-btn.icon-only {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
}

.message-copy-btn.icon-only svg,
.code-copy-btn.icon-only svg {
  width: 15px;
  height: 15px;
}

.message-copy-btn:hover,
.code-copy-btn:hover {
  border-color: rgba(77, 99, 255, 0.22);
  background: rgba(77, 99, 255, 0.08);
}

.message-content {
  line-height: 1.7;
  padding: 11px 13px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  overflow-wrap: anywhere;
  font-size: 0.94rem;
}

.assistant-answer.is-error {
  border-color: rgba(223, 90, 99, 0.18);
  background: rgba(223, 90, 99, 0.06);
}

.stream-placeholder {
  margin: 0;
  color: var(--muted);
}

.reasoning-card {
  border: 1px solid rgba(77, 99, 255, 0.1);
  border-radius: 16px;
  background: rgba(245, 248, 255, 0.92);
}

.reasoning-card summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
}

.reasoning-card summary::-webkit-details-marker {
  display: none;
}

.reasoning-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 4px rgba(77, 99, 255, 0.08);
}

.reasoning-title {
  font-weight: 800;
  font-size: 0.92rem;
}

.reasoning-state {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.8rem;
}

.reasoning-body {
  padding: 0 12px 12px;
  color: #4e5c74;
  line-height: 1.66;
  font-size: 0.9rem;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6,
.markdown-body pre,
.markdown-body table {
  margin: 0 0 0.9rem;
}

.markdown-body p:last-child,
.markdown-body ul:last-child,
.markdown-body ol:last-child,
.markdown-body blockquote:last-child,
.markdown-body pre:last-child,
.markdown-body table:last-child {
  margin-bottom: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  line-height: 1.28;
  font-weight: 800;
}

.markdown-body h1 { font-size: 1.34rem; }
.markdown-body h2 { font-size: 1.18rem; }
.markdown-body h3 { font-size: 1.06rem; }
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 { font-size: 1rem; }

.markdown-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.25rem;
}

.markdown-body li + li {
  margin-top: 0.28rem;
}

.markdown-body code {
  padding: 0.16rem 0.38rem;
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.05);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.94em;
}

.markdown-body blockquote {
  border-left: 3px solid rgba(77, 99, 255, 0.32);
  padding: 10px 14px;
  background: rgba(77, 99, 255, 0.04);
  border-radius: 0 14px 14px 0;
}

.code-block {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f8fbff;
  overflow: hidden;
}

.code-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 24, 39, 0.03);
}

.code-block-lang {
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.code-block pre {
  margin: 0;
  padding: 10px 10px 12px;
  overflow-x: auto;
}

.code-block code {
  display: block;
  padding: 0;
  background: transparent;
  white-space: pre;
  font-size: 0.92rem;
  line-height: 1.65;
}

.chat-composer {
  padding: 6px 20px calc(16px + env(safe-area-inset-bottom));
}

.composer-shell {
  width: 100%;
  max-width: var(--content-w);
  margin: 0 auto 0 0;
  padding: 10px 12px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.attachment-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.12s ease;
}

.icon-button svg {
  width: 15px;
  height: 15px;
}

.icon-button.subtle {
  color: var(--muted);
}

.mobile-camera-btn {
  display: none;
}

.icon-button:hover {
  border-color: rgba(77, 99, 255, 0.22);
  background: rgba(77, 99, 255, 0.06);
}

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

.message-attachments {
  justify-content: flex-end;
  margin-bottom: 8px;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 200px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(248, 250, 254, 0.96);
}

.attachment-chip-icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 0.66rem;
  font-weight: 800;
  color: var(--accent);
  background: rgba(77, 99, 255, 0.08);
}

.attachment-chip-name {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-remove-btn {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(22, 32, 51, 0.08);
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  font-size: 12px;
}

.attachment-remove-btn:hover {
  background: rgba(223, 90, 99, 0.12);
  color: var(--danger);
}

.composer-field {
  display: block;
}

.composer-field textarea {
  border: none;
  background: transparent;
  padding: 4px 4px;
  box-shadow: none;
  max-height: 220px;
  overflow-y: auto;
  font-size: 0.95rem;
}

.composer-field textarea:focus {
  box-shadow: none;
}

.composer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 6px;
}

.send-button {
  padding: 9px 16px;
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  background: linear-gradient(135deg, var(--accent), #6886ff);
  box-shadow: 0 14px 26px rgba(77, 99, 255, 0.18);
}

.admin-shell {
  display: grid;
  grid-template-columns: 288px 1fr;
  min-height: 100vh;
}

.admin-content {
  display: grid;
  gap: 18px;
  min-width: 0;
  padding-bottom: 32px;
}

.grid.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 0 34px;
}

.panel {
  padding: 24px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
}

.panel h2 {
  margin-top: 0;
}

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

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: auto;
}

.inline-toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.fetch-status {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px dashed var(--line-strong);
  background: rgba(255, 255, 255, 0.55);
}

.fetch-status[data-tone="success"] {
  color: #0d907f;
  border-color: rgba(31, 194, 175, 0.24);
  background: rgba(31, 194, 175, 0.08);
}

.fetch-status[data-tone="error"] {
  color: #b4434b;
  border-color: rgba(223, 90, 99, 0.24);
  background: rgba(223, 90, 99, 0.08);
}

.fetch-status[data-tone="warning"] {
  color: #8a6b18;
  border-color: rgba(201, 159, 44, 0.24);
  background: rgba(201, 159, 44, 0.08);
}

.model-chip-list {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.model-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  cursor: pointer;
}

.admin-note {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.58);
}

.admin-note p {
  color: var(--muted);
  margin-bottom: 0;
}

.users-panel {
  margin: 0 34px;
}

.table-wrap {
  overflow: auto;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.user-table th,
.user-table td {
  text-align: left;
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

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

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

.inline-actions input {
  width: 180px;
}

@media (max-width: 1140px) {
  .chat-shell,
  .admin-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100dvh;
  }

  .chat-sidebar,
  .admin-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .chat-sidebar {
    grid-template-rows: auto auto auto auto;
    height: auto;
  }

  .sidebar-new-btn {
    width: auto;
    align-self: flex-start;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.86rem;
  }

  .chat-main {
    overflow: visible;
  }

  .chat-stage {
    overflow: visible;
  }

  .topbar-inner {
    width: 100%;
  }

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

@media (max-width: 760px) {
  html,
  body,
  .chat-page {
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
  }

  .chat-shell {
    grid-template-columns: 1fr;
    height: 100dvh;
    min-height: 100dvh;
    position: relative;
  }

  .chat-main {
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
  }

  .chat-sidebar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 14px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(82vw, 320px);
    max-width: 320px;
    padding: 16px;
    border-right: 1px solid var(--line);
    border-bottom: none;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 20px 50px rgba(22, 33, 55, 0.18);
    overflow: auto;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 40;
  }

  .sidebar-section {
    flex: 1 1 auto;
    min-height: 0;
    gap: 10px;
  }

  .conversation-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }

  .sidebar-footer {
    margin-top: auto;
    align-self: auto;
  }

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

  .mobile-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(15, 23, 42, 0.22);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .chat-shell.mobile-sidebar-open .mobile-sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-menu-btn {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--text);
  }

  .mobile-camera-btn {
    display: inline-grid;
  }

  .mobile-menu-btn svg,
  .mobile-new-chat-btn svg {
    width: 18px;
    height: 18px;
  }

  .mobile-new-chat-btn {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--accent);
  }

  .chat-topbar {
    padding: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(18px);
  }

  .topbar-inner {
    width: 100%;
    max-width: none;
    min-height: 56px;
    margin: 0;
    padding: 11px 14px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }

  .topbar-copy {
    flex: 1 1 auto;
    min-width: 0;
  }

  .topbar-eyebrow,
  .chat-subtitle,
  .header-meta,
  .welcome-card,
  .composer-status,
  #refresh-files-btn {
    display: none;
  }

  .chat-title {
    margin: 0;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .chat-stage {
    overflow: auto;
    overscroll-behavior: contain;
    padding: 10px 12px 6px;
  }

  .stage-inner {
    width: 100%;
    max-width: none;
    margin: 0;
  }

  .message,
  .message.user {
    width: 100%;
  }

  .admin-header,
  .composer-bottom,
  .assistant-toolbar,
  .inline-toolbar,
  .inline-actions form {
    flex-direction: column;
    align-items: stretch;
  }

  .assistant-card,
  .composer-shell,
  .panel,
  .auth-card {
    border-radius: 18px;
  }

  .message-list {
    gap: 12px;
    padding: 0 0 12px;
  }

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

  .composer-shell {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 10px;
  }

  .message-content {
    padding: 12px 13px;
  }

  .inline-actions input {
    width: 100%;
  }
}
