/* Agent Relay dashboards. One stylesheet for the associate's pages at /app, the
   owner's pages at /admin, and the sign in screen at /login.

   The palette, radii, shadows and motion are the ones Alvin's own WhatsApp Lead
   Engine uses, so the two apps read as one family (PLAN 16.5). Light only, by
   house rule: there is no dark theme here. Phone first at 390px, and the layout
   turns into a sidebar app from 881px up. */

:root {
  color-scheme: light;

  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #14201c;
  --muted: #6b7a78;
  --line: #e4e9e8;
  --line-strong: #cdd8d5;
  --hover: #eef2f1;

  --brand: #128c7e;
  --brand-dark: #075e54;
  --brand-soft: #e7f4f1;
  --accent: #25d366;
  --danger: #d64545;
  --warn: #c9851a;

  --r-lg: 12px;
  --r-sm: 8px;
  --r-pill: 20px;

  --shadow: 0 1px 3px rgba(20, 32, 28, .06), 0 8px 24px rgba(20, 32, 28, .05);
  --shadow-sm: 0 1px 2px rgba(20, 32, 28, .06);

  --ease: cubic-bezier(.22, 1, .36, 1);
  --fast: .15s;

  --topbar-h: 56px;
  --nav-w: 208px;
  --rail-w: 56px;
}

* { box-sizing: border-box; }

/* A page that hides an element expects it to go. The browser's own rule for
   [hidden] is weaker than any display rule written here, so it is restated. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
        "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* --- top bar --------------------------------------------------------------*/
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mark {
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  background: var(--brand);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; letter-spacing: .04em;
}
.brandname { font-weight: 700; letter-spacing: -0.01em; }
.topright { display: flex; align-items: center; gap: 10px; min-width: 0; }
.whoami {
  color: var(--muted);
  max-width: 40vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* --- shell ----------------------------------------------------------------*/
.shell {
  display: flex;
  align-items: flex-start;
  padding-top: var(--topbar-h);
  min-height: 100%;
}

.sidenav {
  position: sticky;
  top: var(--topbar-h);
  width: var(--nav-w);
  flex: 0 0 var(--nav-w);
  height: calc(100vh - var(--topbar-h));
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  /* The rail snaps rather than animating: sliding the width would relayout the
     whole content column on every frame, and the tables inside it are long. */
}
.sidenav nav { display: flex; flex-direction: column; gap: 2px; }

.navitem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.navitem .ico { width: 20px; text-align: center; font-size: 15px; flex: 0 0 20px; }
.navitem:hover { background: var(--hover); }
.navitem.on { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }

.railtoggle {
  margin-top: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border: 0; background: none;
  border-radius: var(--r-sm);
  color: var(--muted);
  font: inherit; font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.railtoggle:hover { background: var(--hover); color: var(--ink); }
.railtoggle .ico { width: 20px; text-align: center; flex: 0 0 20px; }

/* The saved rail state is a DESKTOP setting and is guarded by this query, so a
   phone can never inherit a collapsed menu from a laptop (PLAN 16.7). Every
   body.rail rule in this file lives inside it. */
@media (min-width: 881px) {
  body.rail .sidenav { width: var(--rail-w); flex-basis: var(--rail-w); padding: 12px 8px; }
  body.rail .navitem .lbl, body.rail .railtoggle .lbl { display: none; }
  body.rail .navitem, body.rail .railtoggle { justify-content: center; padding-left: 6px; padding-right: 6px; }
}

.main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 24px 20px 72px;
  max-width: 980px;
}
.main.wide { max-width: 1240px; }

/* --- type -----------------------------------------------------------------*/
h1 { font-size: 22px; line-height: 1.25; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 16px 0 6px; color: var(--muted); }
p { margin: 0 0 12px; }
.lede { color: var(--muted); margin-bottom: 20px; }
.quiet { color: var(--muted); }
.small { font-size: 13px; }
a { color: var(--brand-dark); }

/* --- cards ----------------------------------------------------------------*/
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px 16px;
  margin: 0 0 16px;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.card > :last-child { margin-bottom: 0; }
/* A long web address in a card (the privacy page's policy links) wraps instead of widening a phone screen. */
.card p, .card li { overflow-wrap: break-word; }
.cards { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .cards.two { grid-template-columns: 1fr 1fr; } }

/* The Home Screen hint on an iPhone. A quiet card, tinted so it reads as an
   offer rather than a warning, and it removes itself once she says not now. */
.a2hs { background: var(--brand-soft); border-color: #cbe7e0; }
.a2hs h2 { margin-top: 0; }

.facts { display: grid; grid-template-columns: 1fr; gap: 2px 16px; margin: 0; }
@media (min-width: 560px) { .facts { grid-template-columns: max-content 1fr; } }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0 0 8px; font-weight: 600; }

/* --- a prepared set of ads, as a tree (PHASE 3b) --------------------------
   Her assistant's own words are rendered as quoted text, indented and inset,
   so they read as something somebody wrote rather than as part of the page. */
.bundle-adset {
  border-top: 1px solid var(--line);
  margin: 18px 0 0;
  padding: 14px 0 0;
}
.bundle-adset h3 { margin: 0 0 10px; font-size: 17px; }
.bundle-ad {
  border-left: 3px solid var(--line-strong);
  margin: 14px 0 0;
  padding: 0 0 0 14px;
}
.bundle-ad h4 { margin: 0 0 4px; font-size: 15px; }
.bundle-copy {
  background: var(--hover);
  border-radius: var(--r-sm);
  margin: 8px 0 10px;
  padding: 12px 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Her ad files (PHASE 3b B7). A picture is shown at a fixed size so a tall one
   and a wide one make the same shaped row; a video is a POSTER rather than a
   player, because a list that starts playing at her is not a list. */
.assetlist { list-style: none; margin: 10px 0 0; padding: 0; }
.assetrow {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  border-top: 1px solid var(--line);
  padding: 14px 0;
}
.assetrow:first-child { border-top: 0; }
.assetfacts { flex: 1 1 auto; min-width: 0; }
.assetfacts p { margin: 0 0 2px; overflow-wrap: anywhere; }
.assetact { flex: 0 0 auto; }
.assetthumb {
  width: 96px;
  height: 96px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  object-fit: cover;
  background: var(--hover);
}
.assetthumb.poster {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
@media (max-width: 480px) {
  .assetrow { flex-wrap: wrap; }
  .assetact { width: 100%; }
}

.meter { height: 8px; background: var(--hover); border-radius: var(--r-pill); overflow: hidden; margin: 8px 0 0; }
.meter span { display: block; height: 100%; background: var(--brand); }

.stat { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }

/* --- checklist ------------------------------------------------------------*/
.todo { list-style: none; margin: 0; padding: 0; }
.todo li { padding: 12px 0 12px 28px; border-top: 1px solid var(--line); position: relative; }
.todo li:first-child { border-top: 0; padding-top: 0; }
.todo li::before {
  content: "";
  position: absolute; left: 0; top: 16px;
  width: 15px; height: 15px;
  border: 2px solid var(--line-strong); border-radius: 4px;
}
.todo li:first-child::before { top: 4px; }
.todo b { display: block; }
.todo .why { color: var(--muted); font-size: 13px; }

/* What she needs on her Mac before the kit installer will run. */
.needs { margin: 0 0 12px; padding-left: 20px; }
.needs li { margin: 0 0 4px; }

/* --- pills ----------------------------------------------------------------*/
.badge {
  display: inline-block;
  font-size: 11.5px; font-weight: 700; letter-spacing: .01em;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  background: var(--hover); color: var(--muted);
  white-space: nowrap;
  vertical-align: middle;
}
.badge.good { background: #dcfce7; color: #15803d; }
.badge.bad { background: #fee2e2; color: #b91c1c; }
.badge.info { background: #eef2ff; color: #4338ca; }
.badge.warn { background: #fef3c7; color: #b45309; }
.badge.dry { margin-right: 2px; }

/* --- buttons and forms ----------------------------------------------------*/
button, .btn {
  font: inherit; font-weight: 600;
  background: var(--brand); color: #fff;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  transition: background var(--fast) var(--ease), transform var(--fast) var(--ease);
}
button:hover, .btn:hover { background: var(--brand-dark); }
button:active, .btn:active { transform: translateY(1px); }
button[disabled] { background: var(--line-strong); cursor: default; }
button.ghost, .btn.ghost, button.quietbtn, .btn.quietbtn {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line-strong);
}
button.ghost:hover, .btn.ghost:hover, button.quietbtn:hover, .btn.quietbtn:hover { background: var(--hover); }
button.danger { background: var(--danger); }
button.danger:hover { background: #b93a3a; }
button.small, .btn.small { padding: 6px 11px; font-size: 13px; }
.wide { width: 100%; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.row > * { flex: 0 1 auto; }
.row.stretch > * { flex: 1 1 auto; }

.link {
  background: none; border: 0; font: inherit; font-size: 13px;
  color: var(--brand-dark); cursor: pointer; padding: 0; text-decoration: underline;
}
.link:hover { color: var(--brand); background: none; }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
/* A tick box with its words beside it, for a setting that is on or off. */
.checkline { display: flex; align-items: center; gap: 10px; min-height: 42px; margin: 0; font-size: 15px; color: var(--ink); cursor: pointer; }
.checkline input[type="checkbox"] { flex: 0 0 18px; width: 18px; height: 18px; accent-color: var(--brand-dark); }
input[type=text], input[type=password], input[type=email], input[type=search], select, textarea {
  font: inherit;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand-soft); outline-offset: 1px; border-color: var(--brand);
}
.hint { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }

/* --- notices --------------------------------------------------------------*/
.notice { padding: 10px 12px; border-radius: var(--r-sm); font-size: 14px; margin: 12px 0 0; }
.notice.info { background: var(--brand-soft); color: var(--brand-dark); }
.notice.good { background: #dcfce7; color: #15803d; }
.notice.bad { background: #fee2e2; color: #b91c1c; }
.notice.warn { background: #fef3c7; color: #b45309; }

.secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  word-break: break-all;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px;
  margin: 10px 0;
}
pre.snippet {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px;
  overflow-x: auto;
  white-space: pre;
  margin: 8px 0 0;
}
/* The one line she copies by hand. A snippet she has to scroll sideways on a
   phone is a line she copies half of, so this one wraps instead. Wrapping does
   not change what a copy picks up. The multi line blocks below it keep their
   own line breaks, so they stay as they are. */
pre.snippet.one-line { white-space: pre-wrap; overflow-wrap: anywhere; overflow-x: visible; }

/* --- tables ---------------------------------------------------------------*/
.scroller { overflow-x: auto; margin: 0 0 4px; max-height: 70vh; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 700;
  padding-top: 8px; padding-bottom: 8px;
}
tbody tr { transition: background var(--fast) var(--ease); }
tbody tr:hover { background: var(--bg); }
tbody tr:last-child td { border-bottom: 0; }
.nowrap { white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }

/* --- template folders -----------------------------------------------------*/
/* The heading of a card and the control that sits opposite it. On a phone the
   control drops onto its own line rather than squeezing the heading. */
.cardhead {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px 12px; margin: 0 0 10px;
}
.cardhead h2 { margin: 0; }

/* The two way switch: List or Folders. One control, two halves, and the half
   she is on is filled in. */
.viewtabs {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  background: var(--hover);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
}
.viewtabs .viewtab {
  background: none; color: var(--muted);
  border: 0; border-radius: var(--r-pill);
  padding: 6px 16px;
  font-size: 13px; font-weight: 600;
  min-height: 32px;
}
.viewtabs .viewtab:hover { background: rgba(255, 255, 255, .7); color: var(--ink); }
.viewtabs .viewtab.on {
  background: var(--panel); color: var(--brand-dark);
  box-shadow: var(--shadow-sm);
}
.viewtabs .viewtab.on:hover { background: var(--panel); }

/* The folder view: cards, two across on a phone and as many as fit on a
   laptop. Each card is one tap target with the name and the count inside it. */
.foldergrid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  margin: 14px 0 4px;
}
.foldercard {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 14px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.foldercard:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.foldercardlink {
  display: block;
  text-decoration: none;
  color: inherit;
  /* The whole width of the card is the target, and the padding above keeps it
     well over the size of a fingertip. */
  min-height: 44px;
}
.foldercardlink:hover .fname { color: var(--brand-dark); }
.foldericon { width: 26px; height: 26px; display: block; fill: var(--brand); margin: 0 0 6px; }
.foldercard.unfiled .foldericon { fill: var(--line-strong); }
.foldercard .fname {
  margin: 0; font-size: 14px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
/* flex is spelled out on both because a card stacks its children, so the
   flex-basis those two carry for the list's folder heading would become a
   height here: .folderacts is widened by the phone rule below, and .renamebox
   carries a 220px basis. */
.foldercard .folderacts { flex: 0 0 auto; margin: 8px 0 0; gap: 12px; }
.foldercard .renamebox { flex: 0 0 auto; }

/* While a card is being renamed it takes the whole width, so the box and its
   two buttons sit on one line instead of stacking inside a narrow card. */
.foldercard.renaming { grid-column: 1 / -1; }

/* The way back out of one folder. */
.uprow { margin: 0 0 10px; }
.uplink { font-size: 13px; }

.newfolder { align-items: center; margin: 14px 0 0; }
/* The box and the button share one line: the input's own width: 100% would
   otherwise push the button onto a line of its own at every width. */
.newfolder input { flex: 1 1 180px; width: auto; min-width: 0; }
/* align-self so the button matches the box's height rather than sitting 9px
   shorter beside it. */
.newfolder button { flex: 0 0 auto; align-self: stretch; }

.folder { margin: 18px 0 0; }
.folder:first-child { margin-top: 8px; }
.folderhead {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px;
  padding: 0 0 6px; border-bottom: 1px solid var(--line);
}
.folderhead .fname {
  margin: 0; font-size: 14px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em;
}
.folderhead .count { flex: 1 1 auto; min-width: 0; }
.folderacts { flex: 0 0 auto; gap: 12px; }
/* On a phone the two controls take a line of their own, so neither one ends up
   against the right edge of the card. */
@media (max-width: 560px) {
  .folderhead .count { flex: 0 0 auto; }
  .folderacts { flex: 1 1 100%; }
}
.renamebox { flex: 1 1 220px; align-items: center; gap: 6px; }
.renamebox input { flex: 1 1 120px; min-width: 0; padding: 5px 8px; font-size: 13.5px; }
.renamebox button { flex: 0 0 auto; }
.movesel { min-width: 130px; padding: 5px 8px; font-size: 13px; }
.tplbody { display: block; min-width: 26ch; max-width: 52ch; }

/* --- inbox ----------------------------------------------------------------*/
.inbox { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 881px) { .inbox { grid-template-columns: 380px minmax(0, 1fr); } }

.chats { list-style: none; margin: 0; padding: 0; max-height: 68vh; overflow-y: auto; }
.chats li { border-top: 1px solid var(--line); }
.chats li:first-child { border-top: 0; }
.chats a { display: block; padding: 12px 10px; text-decoration: none; color: inherit; border-radius: var(--r-sm); }
.chats a:hover { background: var(--hover); }
.chats a.on { background: var(--brand-soft); }
.chats .name { font-weight: 700; }
.chats .snip {
  color: var(--muted); font-size: 13.5px; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.chats .when { float: right; color: var(--muted); font-size: 12px; }

.chatpanel { display: flex; flex-direction: column; }
/* On a laptop both columns stay on screen, so there is nothing to go back to. */
.backlink { display: none; }
.chathead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.thread { list-style: none; margin: 0 0 12px; padding: 8px 2px; display: flex; flex-direction: column; gap: 8px;
  max-height: 56vh; overflow-y: auto; background: var(--bg); border-radius: var(--r-sm); }
.thread li { display: flex; }
.thread li.out { justify-content: flex-end; }
.thread li.system { justify-content: center; }
.bubble {
  max-width: 78%;
  padding: 8px 11px;
  border-radius: var(--r-lg);
  background: #fff;
  border: 1px solid var(--line);
  font-size: 14.5px;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: var(--shadow-sm);
}
.thread li.out .bubble { background: #d9fdd3; border-color: #cdeec6; }
.thread li.system .bubble {
  background: #fdf6d8; border-color: #f0e4ae; color: #6b5a12;
  font-size: 13px; text-align: center; max-width: 90%; box-shadow: none;
}
.stamp { display: block; margin-top: 4px; font-size: 11.5px; color: var(--muted); }
.thread li.out .stamp { color: #4a6b45; }

/* --- composer -------------------------------------------------------------*/
.composer { border-top: 1px solid var(--line); padding-top: 12px; }
.composer textarea { min-height: 70px; }
.window-note {
  background: #fef3c7; color: #b45309;
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 13.5px;
  margin: 0 0 10px;
}
.paramrow { display: grid; gap: 6px; margin: 8px 0 0; }

/* --- sign in --------------------------------------------------------------*/
body.signin {
  background: linear-gradient(135deg, #075e54, #128c7e);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.signincard {
  width: 320px;
  max-width: 100%;
  background: var(--panel);
  border-radius: 16px;
  padding: 26px 24px 24px;
  box-shadow: var(--shadow);
}
.signinbrand { margin: 0 0 12px; }
.signincard h1 { font-size: 20px; margin: 0 0 4px; }
.signincard .lede { font-size: 13.5px; margin-bottom: 16px; }
.signincard button { width: 100%; margin-top: 16px; }
.errorline { color: #b91c1c; background: #fee2e2; border-radius: var(--r-sm); padding: 9px 11px; font-size: 13.5px; margin: 14px 0 0; }
.signinfoot { margin: 16px 0 0; font-size: 12.5px; color: var(--muted); }

/* --- phone ----------------------------------------------------------------*/
@media (max-width: 880px) {
  .shell { display: block; }
  .sidenav {
    position: static;
    width: auto; flex-basis: auto; height: auto;
    border-right: 0; border-bottom: 1px solid var(--line);
    padding: 8px 10px;
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidenav nav { flex-direction: row; gap: 4px; }
  .navitem { padding: 8px 12px; }
  /* Nothing to collapse on a phone: the strip is already one row. */
  .railtoggle { display: none; }
  /* The strip scrolls sideways, so the right edge fades to say there is more of
     it. A sticky pseudo element rides the edge instead of scrolling away with
     the items. */
  .sidenav::after {
    content: '';
    position: sticky;
    right: 0;
    align-self: stretch;
    flex: 0 0 32px;
    margin-left: -32px;
    background: linear-gradient(to right, rgba(255, 255, 255, 0), var(--panel));
    pointer-events: none;
  }
  .main { padding: 18px 14px 64px; max-width: none; }
  .whoami { display: none; }
  .thread { max-height: none; }
  .chats { max-height: none; }
  /* A phone shows one column: the list, or the chat with a way back to it. */
  body.viewing .chatlist { display: none; }
  .backlink { display: inline-block; }
}

/* Google and Zoom share the existing shell and control vocabulary. */
.integrations-surface { --muted: #52645e; overflow-wrap: anywhere; }
.integrations-surface p { max-width: 72ch; }
.integrations-surface h3 { margin: 0 0 8px; font-size: 17px; }
.integrations-surface h4 { margin: 18px 0 8px; font-size: 15px; }
.integrations-surface input::placeholder,
.integrations-surface textarea::placeholder { color: #52645e; opacity: 1; }
.integration-provider-list { margin: 18px 0 28px; }
.integration-provider { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 0; }
.integration-provider + .integration-provider { border-top: 1px solid var(--line); }
.integration-provider p { margin: 0; color: var(--muted); }
.integration-provider .btn { flex-shrink: 0; }
.integration-section { border-top: 1px solid var(--line); padding-top: 22px; margin-top: 24px; }
.integration-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 18px 0; }
.integration-actions button, .integration-actions .btn { min-height: 42px; }
.integration-operation-list { padding: 0; list-style: none; margin: 8px 0 0; }
.integration-operation-list li { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.integration-operation-list span { color: var(--muted); }
.integration-details { display: grid; grid-template-columns: minmax(110px, 160px) minmax(0, 1fr); gap: 12px 18px; margin: 22px 0; }
.integration-details dt { color: var(--muted); }
.integration-details dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.integration-form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 18px; }
.integration-form-grid > div { min-width: 0; }
.integration-form-grid input { width: 100%; min-width: 0; }
.integration-fieldset { border: 1px solid var(--line-strong); border-radius: var(--r-sm); margin: 18px 0; padding: 16px; }
.integration-fieldset legend { padding: 0 6px; }
.integration-check { display: flex; align-items: flex-start; gap: 10px; min-height: 42px; margin: 10px 0; font-weight: 500; cursor: pointer; }
.integration-check input[type="checkbox"] { flex: 0 0 18px; width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--brand-dark); }
.integration-state { color: var(--brand-dark); font-weight: 650; }
.integration-exact { white-space: pre-wrap; overflow-wrap: anywhere; }
.integration-reference { overflow-wrap: anywhere; }
.integration-disclosure { margin-top: 18px; }
.integration-disclosure summary { cursor: pointer; min-height: 42px; padding: 8px 0; color: var(--brand-dark); font-weight: 600; }
.integrations-surface :is(button, a, input, select, textarea, summary):focus-visible { outline: 3px solid var(--brand-dark); outline-offset: 3px; }
.integrations-surface [aria-busy="true"] { color: var(--muted); }
#keys td:last-child > :is(button, a) { display: inline-block; margin-inline-start: 12px; }
@media (max-width: 600px) {
  .badge.dry { max-width: 90px; white-space: normal; line-height: 1.25; text-align: center; }
  .integration-provider { align-items: flex-start; flex-direction: column; gap: 12px; }
  .integration-operation-list li { flex-direction: column; gap: 3px; }
  .integration-form-grid { grid-template-columns: minmax(0, 1fr); }
  .integration-details { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .integration-details dd { margin-bottom: 12px; }
  .integration-actions { align-items: stretch; flex-direction: column; }
  .integration-actions :is(button, .btn) { width: 100%; text-align: center; }
}
@media (max-width: 360px) { .brandname { display: none; } }

/* The catalogue keeps the existing light shell. Setup stays on its own tab. */
.integration-tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line-strong); margin: 24px 0; }
.integration-tabs a { display: inline-flex; align-items: center; min-height: 48px; padding: 8px 10px 12px; color: #52645e; font-weight: 600; text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.integration-tabs a:hover { color: var(--brand-dark); }
.integration-tabs a[aria-current="page"] { color: var(--brand-dark); border-bottom-color: var(--brand); }
.integration-tabs a:focus-visible { outline: 3px solid var(--brand-dark); outline-offset: 3px; }
.catalogue-toolbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 24px; flex-wrap: wrap; }
.catalogue-filters { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 1px; }
.catalogue-filters button { min-height: 44px; padding: 8px 13px; font-size: 14px; font-weight: 500; }
.catalogue-filters button[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }
.catalogue-filters span { margin-left: 6px; font-variant-numeric: tabular-nums; }
.catalogue-search { flex: 1 1 250px; max-width: 350px; }
.catalogue-search label { color: var(--muted); margin: 0 0 5px; }
.catalogue-search-input { position: relative; }
.catalogue-search-input svg { position: absolute; width: 20px; height: 20px; top: 13px; left: 13px; fill: none; stroke: var(--muted); stroke-width: 1.8; pointer-events: none; }
.catalogue-search-input input { padding-left: 42px; min-height: 46px; }
.catalogue-result-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin: 12px 0 18px; min-height: 23px; }
.catalogue-result-line p { margin: 0; }
.catalogue-result-line .link { min-height: 28px; }
/* The Assistant setup tile sits above the catalogue toolbar, so it is the
   first thing a tenant with no key reads, and it is not one of the four
   connections the filters and the search count. */
.assistant-first-tile { margin: 0 0 24px; }
.integration-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.integration-tile { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--panel); }
.integration-tile-body { display: flex; align-items: flex-start; gap: 20px; padding: 26px 24px 22px; flex: 1 0 auto; min-height: 155px; }
.integration-tile-body > div { min-width: 0; }
.integration-service-mark { width: 48px; height: 48px; flex: 0 0 48px; }
.integration-tile h2 { font-size: 17px; line-height: 1.4; margin: 0 0 8px; text-wrap: balance; }
.integration-tile p { margin: 0; line-height: 1.5; }
.integration-tile .integration-shared { color: var(--muted); margin-top: 12px; font-size: 13px; }
.integration-tile-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 22px; border-top: 1px solid var(--line); min-height: 72px; }
.integration-tile-footer .btn { flex: 0 0 auto; color: var(--brand-dark); border-color: var(--brand); min-height: 42px; padding: 8px 15px; font-size: 14px; }
.catalogue-state { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: #52645e; line-height: 1.4; }
.catalogue-state::before { content: ''; width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%; background: #74827f; }
.catalogue-state.good::before { background: var(--brand); }
.catalogue-state.warn::before { background: #c17a0e; }
.integration-tile .catalogue-detail { padding: 0 22px 14px; color: var(--muted); font-size: 13px; }
.catalogue-empty { padding: 40px 24px; text-align: center; border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--panel); }
.catalogue-empty p { margin: 0 auto; }
.catalogue-retry { margin-top: 12px; }
.catalogue-recent { margin-top: 32px; }
.catalogue-recent > h2 { font-size: 17px; margin-bottom: 12px; }
.catalogue-recent .integration-operation-list { border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--panel); }
.catalogue-recent .integration-operation-list li { padding: 18px 22px; align-items: center; }
.catalogue-recent .integration-operation-list li:first-child { border-top: 0; }
.operation-summary { flex: 1 1 42%; min-width: 0; }
.operation-summary > a { color: var(--ink); font-weight: 600; text-decoration: none; }
.operation-summary > a:hover { text-decoration: underline; }
.operation-summary p { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.operation-review { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 0 8px 12px; text-decoration: none; font-weight: 600; white-space: nowrap; }
.operation-review span { font-size: 20px; color: var(--brand-dark); }
.assistant-setup { max-width: 880px; }
.assistant-setup .card { margin-bottom: 20px; }
.assistant-setup #makekey { margin-top: 12px; }
.assistant-setup .other-ways { margin: 32px 0 4px; font-size: 18px; }
.assistant-setup .connect-steps { margin: 14px 0; padding-left: 22px; line-height: 1.7; }
.integration-section[id] { scroll-margin-top: 80px; }
@media (max-width: 1100px) and (min-width: 881px) {
  .integration-tile-body { padding: 22px 18px; gap: 14px; }
  .integration-tile-footer { padding-inline: 18px; flex-wrap: wrap; }
}
@media (max-width: 700px) {
  .integration-tabs { gap: 16px; margin: 20px 0; }
  .integration-tabs a { padding-inline: 4px; }
  .catalogue-toolbar { flex-direction: column-reverse; align-items: stretch; gap: 18px; }
  .catalogue-search { flex: 0 0 auto; max-width: none; }
  .catalogue-filters { gap: 7px; }
  .catalogue-filters button { padding-inline: 11px; font-size: 13px; }
  .catalogue-filters span { margin-left: 4px; }
  .integration-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .integration-tile-body { min-height: 0; padding: 22px 18px; gap: 16px; }
  .integration-tile-footer { padding: 13px 18px; }
  .integration-tile .catalogue-detail { padding-inline: 18px; }
  .catalogue-recent .integration-operation-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; padding: 16px 18px; }
  .operation-summary { grid-column: 1 / -1; }
  .catalogue-result-line { margin-bottom: 14px; }
}
@media (max-width: 360px) { .integration-tile-footer { flex-wrap: wrap; } }
