:root {
  --bg: #f4f1ea;
  --paper: #fffdf8;
  --ink: #1d2430;
  --muted: #5c6573;
  --line: #ddd6c8;
  --accent: #1f5c8b;
  --accent-hover: #174868;
  --user: #1f5c8b;
  --bot: #ffffff;
  --online: #1a7f4c;
  --offline: #9a4a3a;
  --err: #9a2f2f;
  --shadow: 0 10px 30px rgba(29, 36, 48, 0.08);
  --radius: 16px;
  font-family: "Segoe UI", "PT Sans", "Noto Sans", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

html, body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
}

body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

img, video, svg, canvas {
  max-width: 100%;
}

/* 16px on form controls avoids iOS zoom on focus */
input, select, textarea {
  font-size: 16px;
}

.login-body {
  display: grid;
  place-items: center;
  min-height: 100%;
  min-height: 100dvh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  padding: 24px;
  padding-top: max(24px, env(safe-area-inset-top, 0px));
  padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
  background:
    radial-gradient(1200px 500px at 10% -10%, #e8f0f7, transparent),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  max-width: 100%;
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.login-card h1 { margin: 0 0 6px; font-size: 1.5rem; overflow-wrap: anywhere; }
.lede { margin: 0 0 20px; color: var(--muted); overflow-wrap: anywhere; }
.error {
  background: #f8e8e6;
  color: var(--err);
  padding: 8px 12px;
  border-radius: 8px;
  margin: 0 0 16px;
  overflow-wrap: anywhere;
}
.login-card label { display: block; font-size: 0.9rem; margin-bottom: 14px; color: var(--muted); }
.login-card input, .composer textarea, .composer button, .login-card button {
  font: inherit;
}
.login-card input {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
}
.login-card button, #send {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
}
.login-card button { width: 100%; margin-top: 8px; font-weight: 600; font-size: 16px; }
.login-card button:hover, #send:hover { background: var(--accent-hover); }

.chat-body {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 12px 20px;
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  min-width: 0;
  width: 100%;
  max-width: 100%;
  flex: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}
.brand h1 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.25;
  min-width: 0;
}
.status {
  flex: none;
  white-space: nowrap;
  font-size: 0.8rem;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-weight: 600;
}
.status.online { color: var(--online); background: #e7f6ee; }
.status.offline { color: var(--offline); background: #f8ece9; }
.logout { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.logout:hover { color: var(--ink); }

.log {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  max-width: min(720px, 92%);
  min-width: 0;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.45;
  box-shadow: 0 1px 2px rgba(29, 36, 48, 0.06);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.msg.user {
  align-self: flex-end;
  background: var(--user);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.bot {
  align-self: flex-start;
  background: var(--bot);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.msg .meta {
  display: block;
  font-size: 0.72rem;
  opacity: 0.75;
  margin-bottom: 4px;
}
.msg .content {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.msg.user .content { white-space: pre-wrap; word-break: break-word; }
.msg.bot .content :first-child { margin-top: 0; }
.msg.bot .content :last-child { margin-bottom: 0; }
.msg .content pre,
.msg .content .table-wrap {
  display: block;
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.msg .content pre {
  background: #f3f5f8;
  padding: 8px 10px;
  border-radius: 8px;
  white-space: pre;
}
.msg .content pre code {
  overflow-wrap: normal;
  word-break: normal;
  white-space: pre;
}
.msg .content table {
  border-collapse: collapse;
  width: max-content;
  max-width: none;
}
.msg .content th,
.msg .content td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}
.msg .content code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 0.9em; }
.msg img.attach, .preview img {
  display: block;
  max-width: 100%;
  max-height: 280px;
  border-radius: 10px;
  margin-top: 8px;
}
.msg.user img.attach { border: 1px solid rgba(255,255,255,0.3); }

.composer {
  flex: none;
  position: sticky;
  bottom: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 10px 16px 16px;
  padding-bottom: max(16px, calc(10px + env(safe-area-inset-bottom, 0px)));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.preview { position: relative; width: fit-content; max-width: 100%; margin: 0 0 8px 44px; }
.preview.hidden { display: none; }
.preview img { max-height: 120px; }
#preview-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
}
.row { display: flex; align-items: flex-end; gap: 8px; min-width: 0; width: 100%; }
.attach {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  background: #fff;
  flex: none;
}
.attach:hover { border-color: var(--accent); }
#input {
  flex: 1 1 0;
  min-width: 0;
  width: 100%;
  resize: none;
  max-height: 160px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
}
#input:focus, .login-card input:focus, .scope select:focus,
.new-col input:focus, .title-field input:focus {
  outline: 2px solid rgba(31, 92, 139, 0.35);
  border-color: var(--accent);
}
#send { flex: none; height: 40px; font-weight: 600; white-space: nowrap; font-size: 16px; }
.empty-hint { margin: auto; color: var(--muted); text-align: center; overflow-wrap: anywhere; padding: 0 8px; }

/* --- navigation and collection scope --- */
.nav {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  flex: 0 1 auto;
}
.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
  flex: none;
}
.nav a:hover, .nav a.active { color: var(--ink); }
.scope {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  min-width: 0;
  flex: 1 1 auto;
}
.scope select {
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
  background: #fff;
  max-width: 220px;
  min-width: 0;
  width: auto;
}
.msg .scope-tag {
  display: inline-block;
  font-size: 0.7rem;
  opacity: 0.8;
  margin-left: 6px;
}

/* --- documentation manager --- */
.docs-body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  min-height: 100dvh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
.docs-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}
.docs-side {
  border-right: 1px solid var(--line);
  background: var(--paper);
  padding: 20px 16px;
  overflow: auto;
  min-width: 0;
}
.docs-side h2 { margin: 0 0 12px; font-size: 0.95rem; color: var(--muted); font-weight: 600; }
.col-list { list-style: none; margin: 0 0 20px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.col-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}
.col-item:hover { background: #f3eee6; }
.col-item.active { background: #e8f0f7; border-color: #c5d6e6; }
.col-item .col-name { display: block; font-weight: 600; overflow-wrap: anywhere; }
.col-item .col-count { display: block; font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.new-col label { display: block; font-size: 0.85rem; color: var(--muted); }
.new-col input {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 6px 0 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 16px;
}
.new-col button, .ghost, .danger, button.linkish {
  font: inherit;
  cursor: pointer;
}
.new-col button {
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
}
.new-col button:hover { background: var(--accent-hover); }
.docs-main { padding: 24px 28px 40px; overflow: auto; min-width: 0; max-width: 100%; }
.docs-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; min-width: 0; }
.docs-head h2 { margin: 0 0 4px; font-size: 1.35rem; overflow-wrap: anywhere; }
.col-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.col-actions.hidden, .hidden { display: none !important; }
.ghost, .ghost-link {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.85rem;
}
.ghost:hover, .ghost-link:hover { border-color: var(--accent); }
.danger { color: var(--err); }
button.danger:not(.ghost) {
  background: #fff;
  border: 1px solid #e3c4c0;
  border-radius: 8px;
  padding: 6px 10px;
}
.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: 14px;
  padding: 20px 18px;
  background: var(--paper);
  margin-bottom: 20px;
  min-width: 0;
  max-width: 100%;
}
.dropzone.drag { border-color: var(--accent); background: #eef4f9; }
.dropzone p { margin: 0 0 6px; overflow-wrap: anywhere; }
button.linkish {
  border: 0;
  background: none;
  color: var(--accent);
  padding: 0;
  font-weight: 600;
  text-decoration: underline;
}
.title-field { display: block; margin-top: 12px; font-size: 0.85rem; color: var(--muted); }
.title-field input {
  display: block;
  width: min(420px, 100%);
  max-width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 16px;
}
#doc-table-wrap {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.doc-table { width: 100%; min-width: 32rem; border-collapse: collapse; background: var(--paper); border-radius: 12px; overflow: hidden; }
.doc-table th, .doc-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc-table th { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.doc-title { font-weight: 600; overflow-wrap: anywhere; }
.doc-sub, .doc-error { font-size: 0.78rem; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.doc-error { color: var(--err); }
.doc-acts { white-space: nowrap; display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.badge-ready { color: var(--online); background: #e7f6ee; }
.badge-pending, .badge-processing { color: #8a6a16; background: #f7f0d8; }
.badge-error { color: var(--err); background: #f8e8e6; }

@media (max-width: 800px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-side { border-right: 0; border-bottom: 1px solid var(--line); }
}

/* Compact / two-row header and mobile chat layout */
@media (max-width: 600px) {
  .topbar {
    gap: 8px;
    padding: 8px 12px;
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }
  /* Chat header is heavy (title, badge, selector, links) — force two rows.
     Docs/login nav is short and stays on one row when it fits. */
  .chat-body .topbar {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
  }
  .brand h1 {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1 1 auto;
  }
  .status {
    font-size: 0.72rem;
    padding: 2px 7px;
  }
  .chat-body .brand {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }
  .chat-body .nav {
    width: 100%;
    gap: 8px;
    flex-wrap: nowrap;
    justify-content: flex-start;
  }
  .docs-body .nav { gap: 8px; }
  .scope {
    flex: 1 1 auto;
    min-width: 0;
    gap: 6px;
  }
  .scope-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .scope select {
    width: 100%;
    max-width: none;
    min-height: 40px;
    padding: 6px 8px;
  }
  .nav a { padding: 8px 2px; }
  .msg { max-width: 90%; }
  .log { padding: 12px 10px; }
  .preview { margin-left: 0; max-width: 100%; }
  #send { padding: 10px 12px; }
  .docs-head { flex-direction: column; align-items: stretch; }
  .docs-main {
    padding: 16px 12px 24px;
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
  }
  .docs-side { padding: 16px 12px; }
  .login-card { padding: 24px 18px; }
  .login-card h1 { font-size: 1.3rem; }
}


/* --- chat history sidebar --- */
.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  flex: none;
  font-size: 1.15rem;
  line-height: 1;
  padding: 0;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn.tiny {
  width: 32px;
  height: 32px;
  font-size: 0.95rem;
  border-radius: 8px;
}
.icon-btn.danger-icon { color: var(--err); }
.sidebar-toggle { display: none; }
.sidebar-close { display: none; }

.chat-shell {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  position: relative;
  overflow: hidden;
}

.sidebar {
  width: 280px;
  max-width: 100%;
  flex: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--paper);
  border-right: 1px solid var(--line);
  z-index: 30;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  flex: none;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.new-chat {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}
.new-chat:hover { background: var(--accent-hover); }

.chat-list {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-empty {
  margin: 16px 8px;
  color: var(--muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
  text-align: left;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 6px 8px 10px;
  cursor: pointer;
  background: transparent;
  color: var(--ink);
}
.chat-item:hover { background: #f3eee6; }
.chat-item.active { background: #e8f0f7; border-color: #c5d6e6; }
.chat-item-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-item-title {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-item-time {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
}
.chat-item-actions {
  flex: none;
  display: flex;
  gap: 2px;
}

.chat-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.sidebar-backdrop {
  display: none;
}

/* Drawer under 800px: keep the 5c3281d two-row header, no horizontal overflow */
@media (max-width: 800px) {
  .sidebar-toggle { display: grid; }
  .sidebar-close { display: grid; }
  .chat-body .brand { gap: 8px; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100%;
    height: 100dvh;
    width: min(320px, 86vw);
    max-width: 86vw;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: none;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    border-right: 1px solid var(--line);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 30px rgba(29, 36, 48, 0.18);
  }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(29, 36, 48, 0.4);
    z-index: 25;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }
  .sidebar-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }
}

/* --- admin panel --- */
.admin-body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  min-height: 100dvh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
}
.admin-layout {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 40px;
  padding-bottom: max(40px, env(safe-area-inset-bottom, 0px));
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.admin-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  min-width: 0;
  max-width: 100%;
}
.admin-card h2 { margin: 0 0 14px; font-size: 1.15rem; overflow-wrap: anywhere; }
.create-user {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px 16px;
  align-items: end;
  min-width: 0;
}
.create-user label { display: block; font-size: 0.85rem; color: var(--muted); min-width: 0; }
.create-user input, .create-user select {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
.create-user button {
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  min-height: 42px;
}
.create-user button:hover { background: var(--accent-hover); }
#user-table-wrap {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
#user-table { min-width: 36rem; }
#user-table th,
#user-table td {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}
#user-table .doc-title,
#user-table .doc-sub {
  overflow-wrap: normal;
  word-break: normal;
}
#user-table tr.active-row { background: #e8f0f7; }
.admin-chats {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: 16px;
  min-width: 0;
  min-height: 280px;
}
.admin-chat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  max-height: 60vh;
  overflow: auto;
}
.admin-chat-view {
  min-width: 0;
  max-height: 60vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 4px;
  background: var(--bg);
  border-radius: 12px;
  border: 1px solid var(--line);
}
.admin-chat-view .msg { max-width: 92%; }
#create-status.error { color: var(--err); }

@media (max-width: 800px) {
  .admin-chats { grid-template-columns: 1fr; }
  .admin-layout { padding: 16px 12px 24px; }
  .admin-card { padding: 16px 14px; }
}

@media (max-width: 600px) {
  .admin-body .topbar, .docs-body .topbar {
    /* short nav, wrap if needed, no forced two-row (chat header stays two-row) */
  }
  .chat-item-actions { opacity: 1; }
}
