/* --------------------------------------------------------------------------
   Narrow / embedded
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .msg, .composer-box, .composer-meta { width: 100%; }
  .banner { width: calc(100% - 32px); }
  .msg { padding: 0 16px; }
  .composer { padding: 6px 12px 12px; }
  .msg-user .msg-body { max-width: 88%; }
}

/* --------------------------------------------------------------------------
   Shell overrides

   `.scroll-area` scrolls the page in the segmentation UI. Here the transcript
   owns the scrolling and the composer is pinned, so the outer box must not
   scroll too — two nested scrollbars is the classic chat layout bug.
   -------------------------------------------------------------------------- */

/* The whole page — #view is the only child of body and fills the viewport, so
   the transcript scrolls and the composer stays put. */
#view {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;          /* mobile browsers, where 100vh includes the toolbar */
  overflow: hidden;
  min-height: 0;
}


/* A decided card. It stays on screen as the record of what was approved, but
   must stop looking like a decision that is still open: grey, unless it went
   through, and then green. */
.card-settled {
  border-color: var(--border);
  box-shadow: none;
  padding-bottom: 16px;
}

.card-settled .card-head   { background: var(--surface-sunken); border-bottom-color: var(--border); }
.card-settled .card-badge  { color: var(--text-muted); }
.card-settled .card-summary { color: var(--text-body); font-weight: 500; }
.card-done .card-head      { background: var(--success-soft); }
.card-done .card-badge     { color: var(--pos); }

/* --------------------------------------------------------------------------
   The bar over the conversation: the assistant, and whose programme this is

   Slim and still: Nura's mark and name on the left, the client on the right.
   It replaced a brand line that scrolled away with the conversation — the
   client, the one thing an operator must not have to guess, went with it.
   -------------------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;          /* wraps rather than pushing the client off a narrow screen (WCAG 1.4.10) */
  gap: 8px 12px;
  flex-shrink: 0;
  min-height: 60px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--page-bg);
}

/* The page's h1: the assistant's name, with its line beside it, quieter. */
.topbar-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.015em;
  color: var(--text-strong);
}

.brand-tagline {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-faint);
}

.topbar-name + .brand-tagline {
  padding-left: 10px;
  border-left: 1px solid var(--border-strong);
}

@media (max-width: 520px) {
  .topbar .brand-tagline { display: none; }
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* The client: a pill with its name, and a picker in it when there is more
   than one to open. */
.brand-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  max-width: 100%;
  padding: 2px 4px 2px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
}

.brand-pick:has(.client-button:hover) { border-color: color-mix(in srgb, var(--accent) 50%, var(--border-strong)); }

.brand-pick.is-single {
  padding-right: 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-strong);
}

.brand-pick.is-single svg { color: var(--text-muted); }

/* The client's name, which opens the menu of clients (2026-10-15). */
.brand-pick { position: relative; }

.client-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
  max-width: 240px;
  padding: 2px 6px 2px 4px;
  border-radius: var(--r-pill);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-strong);
  transition: background .15s;
}

.client-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-button svg { flex: none; color: var(--text-muted); transition: transform .15s; }
.client-button:hover { background: color-mix(in srgb, var(--text-strong) 7%, transparent); }
.client-button[aria-expanded="true"] svg { transform: rotate(180deg); }

/* Switching: the pill says to which, its dot pulses, and the conversation
   behind dims — the pause is work, not a click that did nothing. */
.brand-pick.is-switching .client-button { cursor: progress; color: var(--text-muted); }
.brand-pick.is-switching .client-dot { background: var(--accent); animation: blink 1.1s infinite ease-in-out; }
.layout.is-switching .chat { opacity: .45; pointer-events: none; transition: opacity .2s; }

.client-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: 290px;
  max-height: min(60vh, 440px);
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: menu-in .14s var(--ease-out) both;
}

.client-menu[hidden] { display: none; }

.client-menu-title {
  padding: 8px 10px 6px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.client-search {
  margin: 0 4px 6px;
  min-height: 34px;
  padding: 6px 10px;
  /* A text field's outline is the only thing that shows where it is: 3:1. */
  border: 1px solid var(--border-input);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 13px;
  color: var(--text-strong);
}

.client-options {
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

/* The list keeps focus and says which option is active: the ring is drawn on
   that option, where the eye is. */
.client-options:focus-visible { outline: none; }
.client-options:focus-visible .client-option.is-active { outline: 2px solid var(--accent); outline-offset: -2px; }

.client-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 6px 10px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
}

.client-option.is-active { background: var(--surface-sunken); }
.client-option[aria-selected="true"] { font-weight: 650; color: var(--text-strong); }
.client-option-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-check { color: var(--accent); }

.client-badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--hue) 16%, var(--surface));
  color: color-mix(in srgb, var(--hue) 60%, var(--text-strong));
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
}

.client-empty { padding: 10px; font-size: 13px; color: var(--text-faint); }

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .client-menu, .brand-pick.is-switching .client-dot { animation: none; }
}

/* The client's status, in its pill: open (the dot), and — when campaigns
   cannot go out — an amber chip (2026-10-15). */
.client-dot {
  flex: none;
  width: 8px;
  height: 8px;
  margin-right: 2px;
  border-radius: 50%;
  background: var(--pos);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--pos) 18%, transparent);
}

.client-off {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  margin-left: 2px;
  padding: 3px 9px 3px 7px;
  border: 1px solid var(--warn-border);
  border-radius: var(--r-pill);
  background: var(--warn-soft);
  font-size: 11.5px;
  font-weight: 650;
  color: var(--warn);
  white-space: nowrap;
}

.brand-pick.is-single .client-off { margin-right: -8px; }

@media (max-width: 520px) {
  .client-off-label { display: none; }
  .client-off { padding: 4px; }
}

/* Light or dark, the operator's choice (main.js). */
.theme-switch { color: var(--text-muted); }

@media (max-width: 900px) {
  .topbar { padding: 8px 12px; min-height: 56px; }
}

/* --------------------------------------------------------------------------
   The history — this page's conversations with the client, on the left

   Dsquares' wordmark at its head, then New conversation, a search, the
   conversations by day, and Sign out at its foot.

   Hidden, it folds to a rail that keeps the way back, "New conversation" and
   Sign out in the same place; it never disappears on a wide screen. On a
   narrow one it is a drawer over the chat, with a scrim that closes it.
   -------------------------------------------------------------------------- */

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

.main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.history {
  display: flex;
  flex-direction: column;
  flex: none;
  width: var(--sidebar-w);
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  transition: width .18s ease;
  overflow: hidden;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 60px;
  padding: 10px 10px 6px 18px;
}

.history-brand { display: flex; align-items: center; min-width: 0; }

.ds-logo { display: block; height: 24px; width: auto; }
.ds-logo.is-compact { display: none; height: 24px; }

/* Navy on the dark theme's navy would vanish: the wordmark goes white there,
   as a logo does on a dark ground. The squares alone stay blue. */
:root[data-theme="dark"] .ds-logo:not(.is-compact) { filter: brightness(0) invert(.94); }

/* The icon buttons: the toggle, and the drawer's opener in the bar. */
.history-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.history-icon:hover,
.history-icon:focus-visible {
  background: var(--surface-sunken);
  color: var(--text-strong);
}

.history-new {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 12px 8px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.history-new svg { flex: none; }

.history-new:hover,
.history-new:focus-visible {
  border-color: var(--accent);
}

.history-search {
  position: relative;
  margin: 0 12px 6px;
  color: var(--text-faint);
}

.history-search svg {
  position: absolute;
  top: 50%;
  left: 11px;
  transform: translateY(-50%);
  pointer-events: none;
}

.history-search-input {
  width: 100%;
  min-height: 36px;
  padding: 6px 10px 6px 33px;
  /* A text field's outline is the only thing that shows where it is: 3:1. */
  border: 1px solid var(--border-input);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 13px;
  color: var(--text-strong);
}

.history-search-input::placeholder { color: var(--text-faint); }
.history-search-input:focus-visible { outline-offset: 1px; }

.history-nav {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.history-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px 16px;
}

.history-day {
  margin: 16px 10px 6px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.history-items {
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-row {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: var(--r-md);
  transition: background .12s;
}

.history-row + .history-row { margin-top: 1px; }
.history-row:hover { background: var(--surface-raised); }
.history-row.is-deleting { opacity: .45; pointer-events: none; }
.history-row.is-current { background: var(--surface-sunken); }

/* The current conversation, marked on its edge as well as by its fill. */
.history-row.is-current::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.history-item {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 8px 10px 8px 12px;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  font: inherit;
  font-size: 13.5px;
  color: var(--text-body);
  text-align: start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.history-row.is-current .history-item { color: var(--text-strong); font-weight: 600; }
.history-item:focus-visible { outline-offset: -2px; }

/* Shown on the row the pointer or focus is on, and on the current one; always
   on a touch screen, which has no hover to reveal it. */
.history-delete {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-right: 3px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s, color .12s, background .12s;
}

.history-row:hover .history-delete,
.history-row:focus-within .history-delete,
.history-row.is-current .history-delete { opacity: 1; }

.history-delete:hover,
.history-delete:focus-visible {
  color: var(--neg);
  background: var(--danger-soft);
}

@media (hover: none) {
  .history-delete { opacity: 1; }
}

.history-empty {
  margin: 14px 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-faint);
}

.history-foot {
  flex: none;
  padding: 8px 12px 12px;
  border-top: 1px solid var(--border);
}

.history-foot-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background .15s, color .15s;
}

.history-foot-btn:hover,
.history-foot-btn:focus-visible {
  background: var(--surface-sunken);
  color: var(--text-strong);
}

/* --- folded: the rail ---------------------------------------------------- */

.layout.is-folded .history { width: 64px; }

.layout.is-folded .history-head {
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 14px 0 6px;
}

.layout.is-folded .ds-logo:not(.is-compact),
.layout.is-folded .history-new-label,
.layout.is-folded .history-search,
.layout.is-folded .history-nav { display: none; }

.layout.is-folded .ds-logo.is-compact { display: block; }

.layout.is-folded .history-new,
.layout.is-folded .history-foot-btn {
  justify-content: center;
  width: 40px;
  margin: 4px auto 8px;
  padding: 0;
}

.layout.is-folded .history-foot { margin-top: auto; padding: 8px 0 12px; }
.layout.is-folded .history-foot-btn { margin: 0 auto; }

/* The drawer's opener belongs to narrow screens; a wide one has the rail. */
.brand-history { display: none; margin: 0 -2px 0 -6px; }

.history-scrim { display: none; }

/* --- narrow: a drawer ---------------------------------------------------- */

@media (max-width: 900px) {
  .history,
  .layout.is-folded .history {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(300px, 86vw);
    box-shadow: var(--shadow-lg);
    transform: translateX(0);
    transition: transform .2s ease;
  }

  .layout.is-folded .history {
    transform: translateX(-105%);
    box-shadow: none;
  }

  /* In the drawer, folded or not, it is always the full list. */
  .layout.is-folded .history-new-label { display: inline; }
  .layout.is-folded .history-search { display: block; }
  .layout.is-folded .history-nav { display: flex; }
  .layout.is-folded .ds-logo:not(.is-compact) { display: block; }
  .layout.is-folded .ds-logo.is-compact { display: none; }
  .layout.is-folded .history-head { flex-direction: row; justify-content: space-between; padding: 10px 10px 6px 18px; }
  .layout.is-folded .history-new { justify-content: flex-start; width: auto; margin: 6px 12px 8px; padding: 8px 12px; }
  .layout.is-folded .history-foot { margin-top: 0; padding: 8px 12px 12px; }
  .layout.is-folded .history-foot-btn { justify-content: flex-start; width: 100%; padding: 8px 10px; }

  .history-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 29;
    background: var(--scrim);
  }

  .layout.is-folded .history-scrim { display: none; }

  .brand-history { display: inline-flex; }
}

/* --------------------------------------------------------------------------
   Asking before something is deleted
   -------------------------------------------------------------------------- */

.confirm-dialog {
  /* Centred explicitly: base.css zeroes every margin, which is how a modal
     dialog centres itself, and it opened in the top-left corner. */
  position: fixed;
  inset: 0;
  margin: auto;
  height: fit-content;
  width: min(420px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  color: var(--text);
}

.confirm-dialog::backdrop { background: var(--scrim); }

.confirm-title {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text-strong);
}

.confirm-copy {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-body);
  overflow-wrap: anywhere;
}

.confirm-copy strong { font-weight: 600; color: var(--text-strong); }

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.confirm-actions .btn { cursor: pointer; }

.btn-danger {
  background: var(--danger-fill);
  color: var(--text-on-accent);
  border: 1px solid var(--danger-fill);
}

.btn-danger:hover, .btn-danger:focus-visible { opacity: .9; }

/* --------------------------------------------------------------------------
   The keyboard's ways around (views/shortcuts.js, 2026-10-16)
   -------------------------------------------------------------------------- */

/* Past the sidebar to the message box: the first Tab stop, seen only then. */
.skip-link {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top, 0px));
  left: calc(8px + env(safe-area-inset-left, 0px));
  z-index: 60;
  padding: 10px 16px;
  border-radius: var(--r-md);
  background: var(--accent-fill);
  color: var(--text-on-accent);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-lg);
  transform: translateY(-160%);
}

.skip-link:focus { transform: none; }
.skip-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.history-foot { display: grid; gap: 2px; }

/* The list of shortcuts. */
.shortcuts-dialog { width: min(480px, calc(100vw - 32px)); }

.shortcuts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.shortcuts-head .confirm-title { margin: 0; }

.shortcuts-list { display: grid; margin: 0; }

.shortcut {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.shortcut dt { color: var(--text); }
.shortcut dd { margin: 0; display: flex; align-items: center; flex: none; }
.shortcut-or { color: var(--text-faint); }
.shortcut-keys { display: inline-flex; gap: 4px; }

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-raised);
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-strong);
}
