:root {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-soft: #e7f1ee;
  --text: #18211e;
  --muted: #5c6b66;
  --border: #dfe5e2;
  --accent: #1f6f5c;
  --accent-hover: #185a4a;
  --accent-text: #ffffff;
  --error: #a4262c;
  --danger: #b4232a;
  --danger-hover: #951c22;
  --danger-soft: #fbe9ea;
  --danger-text: #ffffff;
  --shadow: 0 1px 2px rgba(24, 33, 30, .06);
  --shadow-raised: 0 2px 10px rgba(24, 33, 30, .08);
  /* One colour per knowledge collection, in domain.yaml order. */
  --c0: var(--accent);
  --c1: #c9772b;
  --c2: #2b5c8a;
  --c3: #8a4b7a;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121715;
    --surface: #1b2220;
    --surface-soft: #1f3530;
    --text: #e6ebe9;
    --muted: #9aa8a3;
    --border: #2b3532;
    --accent: #4fb39a;
    --accent-hover: #6cc6af;
    --accent-text: #0d1512;
    --error: #ff8a8f;
    --danger: #e5484d;
    --danger-hover: #f06b6f;
    --danger-soft: #3a2224;
    --danger-text: #ffffff;
    --shadow: none;
    --shadow-raised: 0 2px 10px rgba(0, 0, 0, .35);
    --c1: #e09a57;
    --c2: #6fa3d6;
    --c3: #c58ab5;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

button { font: inherit; cursor: pointer; color: inherit; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Layout: side menu + conversation. */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 280px; flex-shrink: 0; display: flex; flex-direction: column; gap: 24px;
  padding: 24px 18px; background: var(--surface); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.main-column { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

.brand {
  display: flex; align-items: center; gap: 10px; padding: 6px; margin: -6px 0;
  border-radius: 10px; cursor: pointer;
}
.brand:hover { background: var(--surface-soft); }
.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.brand-mark, .avatar, .welcome-mark { display: inline-flex; flex-shrink: 0; }
.brand-mark img, .brand-mark .monogram { width: 36px; height: 36px; }
.brand-title { font-size: 1rem; font-weight: 700; margin: 0; line-height: 1.25; }
.monogram {
  display: inline-flex; align-items: center; justify-content: center; border-radius: 28%;
  background: var(--accent); color: var(--accent-text); font-weight: 700;
}

.new-chat {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-text); font-weight: 600;
}
.new-chat:hover { background: var(--accent-hover); }
/* The two main actions: "New chat" and, right below, "New document". */
.sidebar-actions { display: flex; flex-direction: column; gap: 8px; }
/* Secondary action right below "New chat": same shape, quieter colours. */
.new-document {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px;
  border: 1px solid var(--border); border-radius: 10px; background: transparent; color: var(--accent);
  font-weight: 600; font-size: .92rem;
}
.new-document:hover { background: var(--surface-soft); border-color: var(--accent); }

.side-section { display: flex; flex-direction: column; gap: 4px; }
.side-heading { font-size: .75rem; font-weight: 600; color: var(--muted); margin: 0; padding: 0 8px 6px; }
.quick-starts { display: flex; flex-direction: column; gap: 2px; }
.quick-starts button {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 10px;
  border: 0; border-radius: 8px; background: transparent; text-align: left; font-size: .9rem;
}
.quick-starts button::before {
  content: ""; width: 8px; height: 8px; flex-shrink: 0; border-radius: 2px;
  background: var(--accent); transform: rotate(45deg);
}
.quick-starts button:hover:not(:disabled) { background: var(--surface-soft); }

.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.history-list li { display: flex; align-items: stretch; border-radius: 8px; }
.history-list li:hover, .history-list li.active { background: var(--surface-soft); }
.history-open {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; min-height: 44px; padding: 7px 10px;
  border: 0; border-radius: 8px; background: transparent; text-align: left; font-size: .88rem;
}
.history-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-date { font-size: .72rem; color: var(--muted); }
.history-delete {
  flex-shrink: 0; width: 36px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); opacity: 0;
}
.history-list li:hover .history-delete, .history-list li.active .history-delete, .history-delete:focus-visible { opacity: 1; }
.history-delete:hover { color: var(--error); }
.history-delete svg { width: 16px; height: 16px; }
.history-empty { margin: 0; padding: 0 8px; font-size: .82rem; color: var(--muted); }
@media (hover: none) { .history-delete { opacity: 1; } }

.collections { margin-top: auto; padding: 14px; border-radius: 10px; background: var(--bg); gap: 8px; }
.collections .side-heading { padding: 0; }
.collections ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: .82rem; }
.collections li { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--c0); }
.dot.c1 { background: var(--c1); }
.dot.c2 { background: var(--c2); }
.dot.c3 { background: var(--c3); }

/* Conversation. */
.messages {
  flex: 1; width: 100%; max-width: 880px; margin: 0 auto; padding: 32px 32px 8px;
  display: flex; flex-direction: column; gap: 24px;
}
.welcome { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; margin-top: 6vh; }
.welcome-mark img, .welcome-mark .monogram { width: 56px; height: 56px; font-size: 1.6rem; }
.welcome p { white-space: pre-line; line-height: 1.6; margin: 0; font-size: 1.1rem; max-width: 680px; }
.examples { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; width: 100%; margin-top: 8px; }
.examples button {
  min-height: 44px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); text-align: left; font-size: .9rem; line-height: 1.45; box-shadow: var(--shadow);
}
.examples button:hover:not(:disabled) { border-color: var(--accent); }

/* Gallery of example documents, in the "New document" dialog. */
.gallery-dialog { width: min(1000px, calc(100vw - 32px)); }
.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; padding: 16px 0 4px;
}
.gallery-card {
  display: flex; flex-direction: column; gap: 6px; padding: 10px 10px 14px; text-align: left;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow);
}
.gallery-card:hover { border-color: var(--accent); }
.gallery-card strong { font-size: .95rem; padding: 4px 4px 0; }
.gallery-card > span {
  font-size: .8rem; color: var(--muted); line-height: 1.4; padding: 0 4px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.thumb {
  --scale: .35; position: relative; height: 200px; overflow: hidden; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--border);
}
.thumb::after {
  content: ""; position: absolute; inset: auto 0 0; height: 48px;
  background: linear-gradient(transparent, var(--paper-bg));
}
.thumb .paper {
  width: 640px; transform: scale(var(--scale)); transform-origin: top left;
  box-shadow: none; pointer-events: none;
}

/* A document page, used for thumbnails and the full preview. Always light, like paper. */
.paper {
  --paper-bg: #ffffff;
  background: var(--paper-bg); color: #1d2421; padding: 44px 52px; line-height: 1.55;
  font-size: .95rem; box-shadow: var(--shadow-raised); border-radius: 4px;
}
.thumb { --paper-bg: #ffffff; }
.paper > :first-child { margin-top: 0; }
.paper h2 { font-size: 1.6rem; margin: 0 0 .8em; }
.paper h3 { font-size: 1.1rem; margin: 1.4em 0 .5em; padding-bottom: .25em; border-bottom: 1px solid #dfe5e2; }
.paper h4 { font-size: 1rem; margin: 1.2em 0 .4em; }
.paper table { border-collapse: collapse; margin: .6em 0; width: 100%; font-size: .9em; }
.paper th, .paper td { border: 1px solid #cfd7d3; padding: 5px 8px; text-align: left; vertical-align: top; }
.paper th { background: #eef3f1; }
.paper ol, .paper ul { padding-left: 1.4em; }
.paper li { margin: .25em 0; }
.paper a { color: #1f6f5c; }

/* Dialogs: the document gallery and the full-size preview of an example document. */
.modal {
  width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0;
  border: 0; border-radius: 16px; background: var(--surface); color: var(--text);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .3); flex-direction: column;
}
.modal[open] { display: flex; }
.modal::backdrop { background: rgba(10, 15, 13, .55); }
.modal-head { display: flex; align-items: flex-start; gap: 16px; padding: 20px 20px 14px 24px; }
.modal-heading { flex: 1; min-width: 0; }
.modal-heading h2 { margin: 6px 0 4px; font-size: 1.2rem; }
.modal-heading p { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.45; }
.badge {
  display: inline-block; font-size: .72rem; font-weight: 600; padding: 3px 9px; border-radius: 10px;
  background: var(--surface-soft); color: var(--accent);
}
.icon-button {
  width: 40px; height: 40px; flex-shrink: 0; border: 0; border-radius: 10px; background: transparent;
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted);
}
.icon-button:hover { background: var(--surface-soft); color: var(--text); }
.modal-body { flex: 1; overflow-y: auto; padding: 8px 24px 24px; background: var(--bg); }
.preview .modal-body .paper { margin-top: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field > label, .field legend { font-weight: 600; font-size: .92rem; padding: 0; }
.field input[type=text], .field textarea {
  font: inherit; font-size: .95rem; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); width: 100%; resize: vertical;
}
.field input[type=text]:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: .8; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.choices label {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--surface); font-size: .9rem; cursor: pointer;
}
.choices input { position: absolute; opacity: 0; pointer-events: none; }
.choices label:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.choices label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Questions the bot asks as a form, below its reply. */
.chat-form {
  padding: 18px 20px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.chat-form-fields { display: flex; flex-direction: column; gap: 16px; margin: 0; padding: 0; border: 0; min-width: 0; }
.chat-form .primary {
  align-self: flex-start; min-height: 42px; padding: 0 18px; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--accent-text); font-weight: 600; font-size: .9rem;
}
.chat-form .primary:hover:not(:disabled) { background: var(--accent-hover); }
.chat-form-fields:disabled { opacity: .65; }
.chat-form-fields:disabled .primary { display: none; }
.chat-form-fields:disabled .choices label { cursor: default; }

.preview-actions {
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.preview-actions a, .preview-actions button {
  min-height: 42px; padding: 0 16px; border-radius: 10px; font-size: .9rem; font-weight: 600;
  display: inline-flex; align-items: center; text-decoration: none; border: 0;
}
.preview-actions .secondary { background: var(--surface-soft); color: var(--accent); }
.preview-actions .secondary:hover { background: var(--border); }
.preview-actions .primary { background: var(--accent); color: var(--accent-text); }
.preview-actions .primary:hover { background: var(--accent-hover); }

/* Confirmation before deleting a chat: small, centred, with the safe choice first. */
.confirm-dialog { width: min(400px, calc(100vw - 32px)); }
.confirm-dialog[open] { animation: confirm-in .16s ease-out; }
.confirm-dialog[open]::backdrop { animation: backdrop-in .16s ease-out; }
@keyframes confirm-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes backdrop-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .confirm-dialog[open], .confirm-dialog[open]::backdrop { animation: none; }
}
.confirm-dialog form { display: flex; flex-direction: column; }
.confirm-body { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 28px 28px 20px; }
.confirm-icon {
  width: 52px; height: 52px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--danger-soft); color: var(--danger); margin-bottom: 16px;
}
.confirm-icon svg { width: 24px; height: 24px; }
.confirm-body h2 { margin: 0 0 12px; font-size: 1.15rem; }
.confirm-name {
  margin: 0 0 12px; max-width: 100%; padding: 8px 12px; border-radius: 8px; background: var(--bg);
  border: 1px solid var(--border); font-size: .88rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.confirm-body p:last-child { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 24px 24px; }
.confirm-actions button {
  min-height: 44px; padding: 0 16px; border: 0; border-radius: 10px; font-size: .92rem; font-weight: 600;
}
.confirm-actions .secondary { background: var(--surface-soft); color: var(--text); }
.confirm-actions .secondary:hover { background: var(--border); }
.confirm-actions .danger { background: var(--danger); color: var(--danger-text); }
.confirm-actions .danger:hover { background: var(--danger-hover); }
.confirm-actions .danger:focus-visible { outline-color: var(--danger); }

.message { display: flex; gap: 14px; max-width: 100%; }
.message .content { display: flex; flex-direction: column; gap: 10px; min-width: 0; max-width: 760px; }
.avatar img, .avatar .monogram { width: 34px; height: 34px; font-size: .95rem; }
.message.user { justify-content: flex-end; }
.message.user .avatar { display: none; }
.message.user .content { max-width: min(560px, 85%); align-items: flex-end; }
.bubble {
  background: var(--surface); border-radius: 4px 18px 18px 18px; box-shadow: var(--shadow);
  padding: 14px 20px; line-height: 1.6; max-width: 100%; overflow-wrap: anywhere;
}
.message.user .bubble {
  background: var(--accent); color: var(--accent-text); border-radius: 18px 18px 4px 18px;
  padding: 12px 18px; white-space: pre-wrap;
}
.message.error .bubble { color: var(--error); }
.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble h1, .bubble h2, .bubble h3 { font-size: 1.05rem; margin: 1em 0 .4em; }
.bubble table { border-collapse: collapse; margin: .5em 0; display: block; overflow-x: auto; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; }
.bubble code { background: var(--bg); padding: 1px 4px; border-radius: 4px; }
.bubble a { color: var(--accent); }

.attachments { display: flex; flex-direction: column; gap: 10px; }
.attachments:empty { display: none; }
.sources-card {
  align-self: flex-start; max-width: 100%; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
}
.sources-card[open] { align-self: stretch; }
.sources-card > summary {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: pointer;
  font-size: .82rem; font-weight: 600; color: var(--muted); list-style: none; border-radius: 12px;
  user-select: none;
}
.sources-card > summary::-webkit-details-marker { display: none; }
.sources-card > summary:hover { color: var(--text); }
.sources-card > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sources-card .chevron {
  width: 14px; height: 14px; flex-shrink: 0; fill: none; stroke: currentColor;
  stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s;
}
.sources-card[open] .chevron { transform: rotate(90deg); }
.sources-count {
  min-width: 20px; padding: 1px 7px; border-radius: 10px; text-align: center;
  background: var(--surface-soft); color: var(--text); font-size: .75rem;
}
.sources-dots { display: flex; gap: 3px; }
.sources-card[open] .sources-dots { display: none; }
.sources-card .sources { padding: 4px 12px 12px; }
.sources { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.sources li {
  display: flex; align-items: center; gap: 6px; font-size: .82rem; padding: 6px 12px;
  border-radius: 14px; background: var(--surface); border: 1px solid var(--border);
}
.sources li:has(> a) { padding: 0; }
.sources a {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 14px;
  color: inherit; text-decoration: none;
}
.sources a:hover { color: var(--accent); text-decoration: underline; }
.sources a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sources .external {
  width: 13px; height: 13px; flex-shrink: 0; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: .7;
}
.doc {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: 12px; background: var(--surface); border: 1px solid var(--border); max-width: 520px;
}
.doc > svg {
  width: 40px; height: 40px; padding: 9px; border-radius: 8px; flex-shrink: 0;
  background: var(--surface-soft); color: var(--accent); stroke-width: 1.7;
}
.doc-text { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 2px; font-size: .9rem; }
.doc-text span { font-size: .78rem; color: var(--muted); }
.doc-text .doc-missing { color: var(--c1); font-weight: 600; }
.doc a {
  font-size: .85rem; font-weight: 600; padding: 9px 12px; border-radius: 8px;
  background: var(--surface-soft); color: var(--accent); text-decoration: none;
}
.doc a:hover { background: var(--accent); color: var(--accent-text); }

/* "Working" indicator: bouncing dots, a label and a running clock. */
.typing .bubble { color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.typing-dots { display: inline-flex; gap: 5px; }
.typing-dots span {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
.typing-elapsed { font-variant-numeric: tabular-nums; font-size: .88rem; }
.typing-hint { flex-basis: 100%; margin: 4px 0 0; font-size: .88rem; animation: typing-fade .4s ease-out; }
@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .35; }
  40% { transform: translateY(-5px); opacity: 1; }
}
@keyframes typing-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .typing-dots span { animation: typing-pulse 1.6s infinite ease-in-out; }
  .typing-hint { animation: none; }
}
@keyframes typing-pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

/* Composer. */
.composer { position: sticky; bottom: 0; padding: 12px 32px 16px; background: var(--bg); }
.composer form {
  display: flex; align-items: flex-end; gap: 10px; max-width: 816px; margin: 0 auto;
  padding: 8px 8px 8px 18px; border-radius: 16px; background: var(--surface);
  box-shadow: var(--shadow-raised); border: 1px solid var(--border);
}
.composer form:focus-within { border-color: var(--accent); }
.composer textarea {
  flex: 1; font: inherit; resize: none; padding: 10px 0; border: 0; outline: none;
  background: transparent; color: var(--text); max-height: 200px; line-height: 1.5;
}
.send {
  width: 44px; height: 44px; flex-shrink: 0; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-text); display: inline-flex; align-items: center; justify-content: center;
}
.send:hover:not(:disabled) { background: var(--accent-hover); }
.disclaimer { max-width: 816px; margin: 8px auto 0; font-size: .75rem; color: var(--muted); text-align: center; line-height: 1.4; }

/* Narrow screens: the side menu becomes a top bar; the welcome cards cover the shortcuts. */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar {
    width: auto; height: auto; flex-direction: row; align-items: center; justify-content: space-between;
    gap: 12px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--border); z-index: 1;
  }
  .brand { padding: 4px; margin: -4px; min-width: 0; }
  .brand-mark img, .brand-mark .monogram { width: 30px; height: 30px; }
  .side-section { display: none; }
  .new-chat { padding: 0 14px; }
  .sidebar-actions { flex-direction: row; flex-shrink: 0; }
  /* Too little room for two labels next to the title: "New document" keeps only its icon. */
  .new-document { min-height: 44px; width: 44px; padding: 0; }
  .new-document span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .brand-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .gallery-grid .thumb { height: 150px; }
  .gallery-card { padding: 8px 8px 12px; }
  .gallery-card strong { font-size: .84rem; padding: 4px 2px 0; hyphens: auto; overflow-wrap: anywhere; }
  .gallery-card > span { padding: 0 2px; }
  .main-column { min-height: 0; flex: 1; }
  .messages { padding: 20px 16px 8px; }
  .welcome { margin-top: 2vh; }
  .avatar { display: none; }
  .composer { padding: 8px 16px 12px; }
  .paper { padding: 24px 20px; }
  .paper h2 { font-size: 1.3rem; }
  .thumb .paper { padding: 44px 52px; }
  .modal-body { padding: 4px 12px 16px; }
  .preview-actions .primary { flex-basis: 100%; justify-content: center; }
}

/* Signed-in user at the bottom of the side menu. */
.account { gap: 6px; padding: 12px 8px 0; border-top: 1px solid var(--border); }
.account-email { margin: 0; font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.account-actions { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.account-link {
  padding: 6px 0; border: 0; background: none; color: var(--accent); font-size: .85rem;
  font-weight: 600; text-decoration: none;
}
.account-link:hover { text-decoration: underline; }
.account-button { display: none; }
@media (max-width: 860px) {
  .sidebar { overflow: visible; }
  .account-button:not([hidden]) {
    display: inline-flex; align-items: center; justify-content: center; width: 44px; min-height: 44px;
    border: 1px solid var(--border); border-radius: 10px; background: transparent; color: var(--accent);
  }
  .account-button[aria-expanded="true"] { background: var(--surface-soft); border-color: var(--accent); }
  .sidebar .account.open {
    display: flex; position: absolute; top: 62px; right: 16px; width: min(300px, calc(100vw - 32px));
    padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: var(--shadow-raised);
  }
}

/* Sign-in and waiting page. */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card {
  width: min(420px, 100%); display: flex; flex-direction: column; gap: 22px; padding: 32px 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-raised);
  color: var(--text);
}
.auth-brand { cursor: default; margin: 0; padding: 0; }
.auth-brand:hover { background: none; }
.auth-card section { display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { font-size: 1.35rem; margin: 0; }
.auth-card p { margin: 0; line-height: 1.55; color: var(--muted); }
.auth-email { font-size: .88rem; overflow-wrap: anywhere; }
.auth-error { color: var(--error) !important; font-size: .9rem; margin: 0; }
.google-button {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 46px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  color: var(--text); font-weight: 600; text-decoration: none;
}
.google-button:hover { border-color: var(--accent); background: var(--surface-soft); }
.google-g { stroke: none; width: 20px; height: 20px; }
.auth-card .secondary, .admin-head .secondary {
  align-self: flex-start; min-height: 40px; padding: 8px 16px; border: 0; border-radius: 10px;
  background: var(--surface-soft); color: var(--accent); font-weight: 600; text-decoration: none;
  display: inline-flex; align-items: center;
}
.auth-card .secondary:hover, .admin-head .secondary:hover { background: var(--border); }

/* The admin's user list. */
.admin-page { color: var(--text); }
.admin-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.admin-head .brand { color: inherit; text-decoration: none; margin: 0; }
.admin-main { max-width: 1000px; margin: 0 auto; padding: 32px 24px; }
.admin-main h1 { font-size: 1.5rem; margin: 0 0 8px; }
.admin-intro { margin: 0 0 20px; color: var(--muted); line-height: 1.5; }
.table-wrap { overflow-x: auto; }
.users-table {
  width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; font-size: .9rem;
}
.users-table th, .users-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.users-table th { font-size: .78rem; color: var(--muted); font-weight: 600; background: var(--bg); }
.users-table tr:last-child td { border-bottom: 0; }
.users-table tr.status-pending { background: var(--surface-soft); }
.status-badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--bg); color: var(--muted); white-space: nowrap;
}
.status-badge.approved { background: var(--surface-soft); color: var(--accent); }
.status-badge.pending { background: var(--accent); color: var(--accent-text); }
.status-badge.blocked { background: var(--danger-soft); color: var(--danger); }
.user-actions { display: flex; gap: 8px; justify-content: flex-end; white-space: nowrap; }
.user-actions button { min-height: 36px; padding: 6px 14px; border: 0; border-radius: 8px; font-weight: 600; font-size: .85rem; }
.user-actions .primary { background: var(--accent); color: var(--accent-text); }
.user-actions .primary:hover { background: var(--accent-hover); }
.user-actions .secondary { background: var(--danger-soft); color: var(--danger); }
.user-actions .secondary:hover { background: var(--danger); color: var(--danger-text); }
/* Phones: one card per user instead of a wide table. */
@media (max-width: 640px) {
  .admin-head { padding: 12px 16px; }
  .admin-head .brand-title { display: none; }
  .admin-head .secondary { white-space: nowrap; }
  .admin-main { padding: 24px 16px; }
  .users-table thead { display: none; }
  .users-table, .users-table tbody, .users-table tr, .users-table td { display: block; }
  .users-table tr { padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .users-table tr:last-child { border-bottom: 0; }
  .users-table td { padding: 2px 0; border: 0; }
  .users-table td:first-child { font-weight: 600; }
  .users-table td:nth-child(2) { color: var(--muted); overflow-wrap: anywhere; }
  .users-table td:nth-child(3) { padding-top: 8px; }
  .users-table td:nth-child(4) { display: none; }
  .user-actions { justify-content: flex-start; padding-top: 10px; }
  .user-actions:empty { display: none; }
}
