/*
 * CrushIt Support - design system.
 *
 * BRANDING LIVES IN ONE PLACE: the :root block. Every colour below is a var()
 * reference, so rebranding is those values and nothing else. Seeded from the
 * CrushIt app icon (teal #0f7a65) until the official hexes arrive.
 *
 * Design intent: a support console, not a landing page. Colour carries meaning
 * rather than decoration -- greys do the layout, teal marks the one action worth
 * taking, and red/amber mean a queue needs attention. Density is deliberate: an
 * agent working an exam-season backlog needs to see fifteen chats at once, not
 * five padded cards.
 *
 * Both schemes are styled. Agents work nights around exam season and a
 * hardcoded light theme is genuinely painful at 3am.
 */

:root {
  /* --- Brand ---------------------------------------------------------- */
  --brand: #0f7a65;
  --brand-hover: #0c6150;
  --brand-soft: #e6f4f0;
  --brand-contrast: #ffffff;

  /* --- Surfaces ------------------------------------------------------- */
  --bg: #f6f7f8;
  --panel: #ffffff;
  --panel-alt: #fafbfb;
  --hover: #f1f3f4;
  --line: #e4e7e8;
  --line-soft: #eef0f1;

  /* --- Text: three weights, no more. More than three and nothing reads
         as primary. --------------------------------------------------- */
  --ink: #16191c;
  --ink-soft: #5a6268;
  --muted: #8b9298;

  /* --- Bubbles -------------------------------------------------------- */
  --incoming: #ffffff;
  --outgoing: #e7f4ef;
  --agent-bubble: #e8ecf8;

  /* --- Status --------------------------------------------------------- */
  --danger: #c0392b;
  --danger-soft: #fdeceb;
  --warning: #b26a00;
  --warning-soft: #fdf3e3;
  --success: #0f7a65;
  --success-soft: #e6f4f0;

  /* --- Type scale: 11 / 12 / 13 / 15 / 19. Small and tight; a support
         console is read at a glance, not at arm's length. --------------- */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 15px;
  --fs-lg: 19px;

  /* --- Geometry: restrained radii. Big pill-shaped everything is the
         single loudest "template" tell. -------------------------------- */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 32, 0.06);
  --shadow: 0 2px 8px rgba(16, 24, 32, 0.08);
  --shadow-lg: 0 8px 28px rgba(16, 24, 32, 0.14);

  --sidebar-width: 330px;
  --topbar-height: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #34d3a8;
    --brand-hover: #5ae0bb;
    --brand-soft: #12312a;
    --brand-contrast: #06231c;

    --bg: #0d1013;
    --panel: #14181c;
    --panel-alt: #171c21;
    --hover: #1d2329;
    --line: #252c33;
    --line-soft: #1c2228;

    --ink: #e8ecef;
    --ink-soft: #a3adb5;
    --muted: #6f7a83;

    --incoming: #1b2127;
    --outgoing: #16362e;
    --agent-bubble: #1e2740;

    --danger: #f0736a;
    --danger-soft: #2e1917;
    --warning: #e0a44a;
    --warning-soft: #2b2115;
    --success: #34d3a8;
    --success-soft: #12312a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.6);
  }
}

/* The viewer's explicit toggle must beat the OS preference in both
   directions, so these carry the same declarations at higher specificity. */
:root[data-theme="dark"] {
  --brand: #34d3a8; --brand-hover: #5ae0bb; --brand-soft: #12312a; --brand-contrast: #06231c;
  --bg: #0d1013; --panel: #14181c; --panel-alt: #171c21; --hover: #1d2329;
  --line: #252c33; --line-soft: #1c2228;
  --ink: #e8ecef; --ink-soft: #a3adb5; --muted: #6f7a83;
  --incoming: #1b2127; --outgoing: #16362e; --agent-bubble: #1e2740;
  --danger: #f0736a; --danger-soft: #2e1917; --warning: #e0a44a; --warning-soft: #2b2115;
  --success: #34d3a8; --success-soft: #12312a;
}

:root[data-theme="light"] {
  --brand: #0f7a65; --brand-hover: #0c6150; --brand-soft: #e6f4f0; --brand-contrast: #ffffff;
  --bg: #f6f7f8; --panel: #ffffff; --panel-alt: #fafbfb; --hover: #f1f3f4;
  --line: #e4e7e8; --line-soft: #eef0f1;
  --ink: #16191c; --ink-soft: #5a6268; --muted: #8b9298;
  --incoming: #ffffff; --outgoing: #e7f4ef; --agent-bubble: #e8ecf8;
  --danger: #c0392b; --danger-soft: #fdeceb; --warning: #b26a00; --warning-soft: #fdf3e3;
  --success: #0f7a65; --success-soft: #e6f4f0;
}

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

html, body {
  height: 100%;
  margin: 0;
}

body {
  /* System stack: it renders in the OS's own text style, which is what makes
     an interface read as native rather than as a web template. */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: var(--fs-base);
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* Phone numbers, IDs and timestamps line up only in tabular figures.
   Without this, a column of times visibly jitters as the digits change. */
.mono, .num, time, .meta-time {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-lg); }
h2 { font-size: var(--fs-md); }
h3 { font-size: var(--fs-base); }
p { margin: 0 0 10px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.spacer { flex: 1; }
.hidden, [hidden] { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 6px;
  border: 3px solid var(--panel);
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* Visible focus everywhere. Agents work this interface by keyboard all day. */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-radius: var(--radius-sm);
}

/* ====================================================================== */
/* Controls                                                                */
/* ====================================================================== */
button {
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: 7px 13px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--brand);
  color: var(--brand-contrast);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}
button:hover:not(:disabled) { background: var(--brand-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.secondary {
  background: var(--panel);
  color: var(--ink-soft);
  border-color: var(--line);
}
button.secondary:hover:not(:disabled) { background: var(--hover); color: var(--ink); }

button.ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: transparent;
  padding: 6px 8px;
}
button.ghost:hover:not(:disabled) { background: var(--hover); color: var(--ink); }

button.danger { background: var(--danger); color: #fff; }
button.danger:hover:not(:disabled) { filter: brightness(1.08); }

button.small { padding: 5px 10px; font-size: var(--fs-xs); }

/* Icon-only buttons must stay square or they read as a squashed text button. */
button.icon {
  padding: 0;
  width: 30px;
  height: 30px;
  justify-content: center;
}
button svg { width: 15px; height: 15px; flex: none; }

input[type="text"], input[type="email"], input[type="password"],
input[type="search"], input[type="url"], textarea, select {
  font: inherit;
  font-size: var(--fs-base);
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { resize: vertical; line-height: 1.5; }
::placeholder { color: var(--muted); }

label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.field { margin-bottom: 16px; }
.hint { font-size: var(--fs-sm); color: var(--muted); margin-top: 5px; }

/* ====================================================================== */
/* Shell                                                                   */
/* ====================================================================== */
.app-shell { display: flex; flex-direction: column; height: 100%; }

.topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--topbar-height);
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: none;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: var(--fs-base);
  margin-right: 6px;
}
.brand-mark img { width: 22px; height: 22px; border-radius: var(--radius-sm); }

.topbar nav { display: flex; gap: 2px; }
.topbar nav a {
  padding: 6px 11px;
  border-radius: var(--radius);
  color: var(--ink-soft);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.topbar nav a:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.topbar nav a.active { background: var(--brand-soft); color: var(--brand); }

.workspace { display: flex; flex: 1; min-height: 0; }

/* ====================================================================== */
/* Sidebar                                                                 */
/* ====================================================================== */
.sidebar {
  width: var(--sidebar-width);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  min-height: 0;
}

.sidebar-head {
  padding: 10px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}

.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--muted);
  pointer-events: none;
}
.search-wrap input { padding-left: 30px; }

.filter-strip {
  display: flex;
  gap: 5px;
  margin-top: 9px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 1px;
}
.filter-strip::-webkit-scrollbar { display: none; }

.chip {
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  white-space: nowrap;
  cursor: pointer;
}
.chip:hover { background: var(--hover); color: var(--ink); }
.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-contrast);
}
.chip .count {
  margin-left: 5px;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.contact-list { flex: 1; overflow-y: auto; min-height: 0; }

.contact-row {
  display: flex;
  gap: 10px;
  padding: 9px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--line-soft);
  /* Transparent by default so the selected state does not shift the text by
     3px when it gains a border. */
  border-left: 3px solid transparent;
}
.contact-row:hover { background: var(--hover); }
.contact-row.active {
  background: var(--brand-soft);
  border-left-color: var(--brand);
}

.contact-row .body { flex: 1; min-width: 0; }
.contact-row .name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: var(--fs-base);
  /* Names run long and phone numbers are worse. Truncating keeps the row
     height fixed so the list scans as a column. */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-row .preview {
  color: var(--ink-soft);
  font-size: var(--fs-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.contact-row .meta {
  font-size: var(--fs-xs);
  color: var(--muted);
  flex: none;
  text-align: right;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 600;
  background: var(--muted);
  user-select: none;
}
.avatar.sm { width: 26px; height: 26px; font-size: var(--fs-xs); }

/* ====================================================================== */
/* Labels: tag = fact (filled), segment = queue (outlined)                  */
/* The shape difference is load-bearing -- a chat has many tags but exactly  */
/* one segment, and an agent must tell them apart without reading either.    */
/* ====================================================================== */
.tag-row { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }

.tag {
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  color: #fff;
  white-space: nowrap;
}

.segment-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid currentColor;
  background: transparent;
  white-space: nowrap;
}

.pill {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  flex: none;
}
.pill.bot { background: var(--line); color: var(--ink-soft); }
.pill.human { background: var(--warning-soft); color: var(--warning); }

/* ====================================================================== */
/* Conversation                                                            */
/* ====================================================================== */
.conversation {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.conversation-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.conversation-head .who { min-width: 0; }
.conversation-head .who strong {
  display: block;
  font-size: var(--fs-md);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conversation-head .who span {
  display: block;
  font-size: var(--fs-sm);
  color: var(--muted);
}

/* The four dropdowns used to sit loose in the header, which is most of what
   made it look unfinished. Grouping them into one bordered strip reads as a
   single control cluster instead of four stray widgets. */
.meta-bar {
  display: flex;
  align-items: center;
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.meta-bar select {
  border: none;
  border-radius: 0;
  background: var(--panel);
  font-size: var(--fs-sm);
  padding: 6px 8px;
  width: auto;
  max-width: 150px;
  color: var(--ink-soft);
}
.meta-bar select:focus { box-shadow: none; }
.meta-bar select:hover { background: var(--hover); color: var(--ink); }

.thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.msg { display: flex; max-width: min(620px, 78%); }
.msg.out { align-self: flex-end; justify-content: flex-end; }
.msg + .msg.out:not(.out + .msg.out),
.msg + .msg:not(.out):not(:where(.msg:not(.out) + .msg)) { margin-top: 9px; }

.bubble {
  background: var(--incoming);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 7px 11px 5px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.msg.out .bubble { background: var(--outgoing); border-color: transparent; }
.msg.agent .bubble { background: var(--agent-bubble); border-color: transparent; }

.bubble .text { white-space: pre-wrap; word-wrap: break-word; font-size: var(--fs-base); }
.bubble .foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}
.bubble .foot .who-sent { font-weight: 500; }
.bubble .foot .failed { color: var(--danger); font-weight: 600; }

.bubble img, .bubble video {
  max-width: 100%;
  border-radius: var(--radius);
  display: block;
  margin-bottom: 4px;
}
.bubble audio { width: 260px; max-width: 100%; margin-bottom: 4px; }

.doc-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  margin-bottom: 4px;
}
.doc-link:hover { background: var(--hover); text-decoration: none; }
.doc-link svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.doc-link .doc-name {
  font-size: var(--fs-sm);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-divider {
  align-self: center;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--panel);
  border: 1px solid var(--line-soft);
  padding: 2px 10px;
  border-radius: 20px;
  margin: 10px 0;
}

/* ====================================================================== */
/* Composer                                                                */
/* ====================================================================== */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  flex: none;
  position: relative;
}
.composer textarea {
  flex: 1;
  max-height: 160px;
  border-radius: var(--radius-lg);
  padding: 9px 12px;
}

/* The /shortcut picker. Anchored above the composer so it opens into empty
   space rather than covering the message the agent is replying to. */
.qr-picker {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 12px;
  right: 12px;
  max-width: 520px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 40;
  padding: 4px;
}
.qr-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 9px;
  border-radius: var(--radius);
  cursor: pointer;
}
.qr-item:hover, .qr-item.active { background: var(--brand-soft); }
.qr-item .qr-shortcut {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--brand);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.qr-item .qr-preview {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qr-item .qr-shared {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.qr-empty { padding: 12px; font-size: var(--fs-sm); color: var(--muted); text-align: center; }

/* ====================================================================== */
/* Notices                                                                 */
/* ====================================================================== */
.outage-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--danger);
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 500;
  flex: none;
}
.outage-banner button {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border-color: transparent;
}
.outage-banner button:hover { background: rgba(255, 255, 255, 0.28); }

.bot-notice {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px;
  background: var(--panel-alt);
  border-bottom: 1px solid var(--line-soft);
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  flex: none;
}
.bot-notice svg { width: 14px; height: 14px; color: var(--muted); flex: none; }

.notice {
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.notice.error { background: var(--danger-soft); color: var(--danger); border-color: currentColor; }
.notice.success { background: var(--success-soft); color: var(--success); border-color: currentColor; }
.notice.warning { background: var(--warning-soft); color: var(--warning); border-color: currentColor; }

/* ====================================================================== */
/* Empty states                                                            */
/* ====================================================================== */
.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  color: var(--muted);
}
.empty-state svg {
  width: 34px;
  height: 34px;
  margin-bottom: 12px;
  color: var(--line);
}
.empty-state strong {
  display: block;
  font-size: var(--fs-md);
  color: var(--ink-soft);
  margin-bottom: 3px;
}
.empty-state p { font-size: var(--fs-sm); margin: 0; }

/* ====================================================================== */
/* Cards, tables, settings                                                 */
/* ====================================================================== */
.page {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
  min-height: 0;
}
.page-inner { max-width: 780px; margin: 0 auto; }
.page-title { margin-bottom: 18px; }
.page-title p { color: var(--muted); font-size: var(--fs-sm); margin: 3px 0 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
}
.card > h2 { margin-bottom: 3px; }
.card > .card-hint {
  color: var(--muted);
  font-size: var(--fs-sm);
  margin: 0 0 16px;
}

table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th {
  text-align: left;
  font-weight: 600;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 0 10px 7px;
  border-bottom: 1px solid var(--line);
}
td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: none; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.kb-item, .provider-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}
.kb-item:last-child, .provider-item:last-child { border-bottom: none; }
.kb-item .kb-body, .provider-item .provider-body { flex: 1; min-width: 0; }
.kb-item .kb-name { font-weight: 500; }
.kb-item .kb-meta, .provider-item .provider-meta {
  font-size: var(--fs-sm);
  color: var(--muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  background: var(--muted);
}
.status-dot.on { background: var(--success); }
.status-dot.off { background: var(--danger); }

/* ====================================================================== */
/* Auth pages                                                              */
/* ====================================================================== */
.auth-shell {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}
.auth-card .brand-mark { margin-bottom: 20px; font-size: var(--fs-md); }
.auth-card h1 { margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); font-size: var(--fs-sm); margin-bottom: 20px; }
.auth-card button[type="submit"] { width: 100%; justify-content: center; padding: 9px; }
.auth-foot {
  margin-top: 16px;
  font-size: var(--fs-sm);
  color: var(--muted);
  text-align: center;
}

/* ====================================================================== */
/* Modal                                                                   */
/* ====================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 18, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.modal-body { padding: 18px; overflow-y: auto; min-height: 0; }
.modal-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  flex: none;
}

.qr-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}
.qr-row:last-child { border-bottom: none; }
.qr-row .qr-body { flex: 1; min-width: 0; }
.qr-row code {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--brand);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.qr-row .qr-text {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ====================================================================== */
/* Responsive: below 860px the two panes stack and act as separate screens */
/* ====================================================================== */
.back-to-list { display: none; }

@media (max-width: 860px) {
  .sidebar { width: 100%; border-right: none; }
  /* app.js toggles "viewing-chat" on <body>, so the two panes act as separate
     screens on a phone instead of a 50/50 split neither of which is usable. */
  body.viewing-chat .sidebar { display: none; }
  body:not(.viewing-chat) .conversation { display: none; }
  .back-to-list { display: inline-flex; }
  .meta-bar { display: none; }
  .msg { max-width: 88%; }
  .topbar nav a { padding: 6px 8px; }
  .page { padding: 14px; }
  .grid-2 { grid-template-columns: 1fr; }
}
