/* Hallmark · component-scope: application shell · genre: modern-minimal
 * theme: custom · states: default · hover · focus · active · disabled ·
 *         loading · error · success
 * contrast: pass
 *
 * Structure follows function, not symmetry:
 *   app bar   — identity, live state, call duration
 *   stage     — the assistant is the SUBJECT and dominates; the screen
 *               self-view is CONFIRMATORY and subordinate to it
 *   controls  — a real command bar with one primary verb at a time
 *
 * An earlier revision gave both panes equal weight because "mutual exchange"
 * was a tidy idea. It was symmetry imposed over hierarchy: you WATCH the
 * assistant and GLANCE at your own screen to check what is shared.
 */

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

html, body {
  height: 100%;
  /* clip, never hidden: hidden on the root kills position:sticky children */
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-ui);
  font-size: var(--text-body);
  line-height: 1.5;
  font-weight: var(--weight-regular);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
}

/* ── App bar ─────────────────────────────────────────────────────────────
   The product lockup is a wordmark with weight contrast rather than a glyph.
   A generic two-shape icon says nothing; the name set properly says it is a
   product. */
.appbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: var(--rule-hair) solid var(--color-line);
  background: var(--color-paper);
}
.lockup {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  min-width: 0;
}
.lockup b {
  font-size: var(--text-body);
  font-weight: var(--weight-semi);
  letter-spacing: -0.012em;
}
.lockup span {
  font-size: var(--text-small);
  color: var(--color-ink-3);
}
.appbar-fill { flex: 1 1 auto; }

/* Live state reads in the bar, where a status belongs, rather than floating
   as a chip. The dot is the only ornament and it carries real information. */
.live {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-small);
  font-weight: var(--weight-medium);
  color: var(--color-ink-2);
  white-space: nowrap;
}
.live::before {
  content: "";
  inline-size: 7px; block-size: 7px;
  border-radius: var(--radius-pill);
  background: var(--color-ink-3);
  flex: none;
}
.live[data-state="live"]    { color: var(--color-ink); }
.live[data-state="live"]::before  { background: var(--color-live); }
.live[data-state="busy"]    { color: var(--color-warn); }
.live[data-state="busy"]::before  { background: var(--color-warn); }
.live[data-state="fault"]   { color: var(--color-danger); }
.live[data-state="fault"]::before { background: var(--color-danger); }

.clock {
  font-family: var(--font-mono);
  font-size: var(--text-small);
  font-variant-numeric: tabular-nums;
  color: var(--color-ink-3);
  padding-inline-start: var(--space-3);
  border-inline-start: var(--rule-hair) solid var(--color-line);
}
.clock[hidden] { display: none; }

/* ── Stage ───────────────────────────────────────────────────────────────
   Asymmetric on purpose: 1fr for the subject, a fixed 272px rail for the
   confirmatory column. minmax(0,…) so a video track can never force the
   grid wider than its container. */
.stage {
  flex: 1 1 auto;
  min-block-size: 0;              /* let the grid shrink inside the flex column */
  width: 100%;
  max-width: 1400px;
  margin-inline: auto;
  padding: var(--space-4) var(--space-5);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: var(--space-5);
  /* Both columns take the full height between the bars.
     An earlier version capped the well at a fraction of the viewport and
     centred it, which left roughly 190px of dead space above and below on a
     1280x800 screen. A video surface should FILL its space and letterbox
     inside, the way every video tool does — the black is the frame, not a gap
     in the layout. */
  align-items: stretch;
}

.well {
  position: relative;
  background: var(--color-paper-inset);
  border: var(--rule-hair) solid var(--color-line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  /* Named single area so the video and the empty state STACK in one cell.
     With a bare `display:grid` they auto-flow into separate rows, and on the
     short self-view well that pushed the caption past the bottom edge where
     overflow:hidden clipped it — invisible, not merely misplaced. */
  display: grid;
  grid-template-areas: "stack";
}
.well > * { grid-area: stack; }

/* Used for the agent's audio element, which must be in the DOM to play but
   must not be seen. A class rather than an inline style, so the CSP can
   forbid style-src 'unsafe-inline'. */
.is-hidden { display: none !important; }
/* Fills the column. The video letterboxes inside it against the well's own
   dark surface, so there is never an empty region that reads as broken
   layout. */
/* Fills its column, within a sane range. The cap stops a very tall window
   turning a portrait into a column; the floor stops a short one collapsing
   it to a strip. */
.well--subject { block-size: 100%; min-block-size: 220px; max-block-size: 72vh; }
.well--check   { aspect-ratio: 16 / 10; flex: none; }
.well video {
  inline-size: 100%; block-size: 100%;
  display: block;
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease-out);
}

/* The avatar is a centred portrait, so filling the frame and cropping the
   edges looks like a video call. Letterboxing a 16:9 face into a squarer
   well produced heavy black bands above and below — the thing that made the
   page look broken rather than designed. */
.well--subject video { object-fit: cover; }

/* The shared screen is the opposite: it is CONTENT, and cropping it would
   hide the very thing the agent is being asked to look at. Never cover. */
.well--check video { object-fit: contain; }
.well.is-live video { opacity: 1; }
.well.is-live { box-shadow: var(--shadow-raised); }

/* Empty states are left-aligned and set quietly. Centred grey text in a box
   reads as a placeholder waiting to be replaced. */
.well-empty {
  padding: var(--space-6);
  max-inline-size: 34ch;
  color: var(--color-on-inset-2);
  font-size: var(--text-small);
  justify-self: start;
  align-self: end;
}
.well--check .well-empty { font-size: var(--text-caption); padding: var(--space-4); }
.well-empty b {
  display: block;
  color: var(--color-on-inset);
  font-weight: var(--weight-medium);
  font-size: var(--text-body);
  margin-block-end: var(--space-1);
  letter-spacing: -0.008em;
}
.well--check .well-empty b { font-size: var(--text-small); }
.well.is-live .well-empty { display: none; }

.rail {
  display: flex; flex-direction: column;
  gap: var(--space-3);
  min-width: 0; min-height: 0;
}
.rail-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--text-label);
  font-weight: var(--weight-medium);
  color: var(--color-ink-2);
}
.rail-head .dims {
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  color: var(--color-ink-3);
  font-variant-numeric: tabular-nums;
}

/* ── Contextual guidance ─────────────────────────────────────────────────
   Replaces a static numbered-steps card. One line, and only the line that is
   true right now. Guidance the customer has already completed is noise. */
/* Guidance, not an alarm. An earlier version used a full tinted panel with a
   border, which made a routine "allow your microphone" message the loudest
   thing on the page. A left rule carries the same state at a fraction of the
   weight. */
.hint {
  font-size: var(--text-small);
  line-height: 1.5;
  color: var(--color-ink-2);
  padding: var(--space-2) 0 var(--space-2) var(--space-3);
  border-inline-start: 2px solid var(--color-accent);
}
.hint[data-tone="warn"]  { border-inline-start-color: var(--color-warn); }
.hint[data-tone="fault"] { border-inline-start-color: var(--color-danger); color: var(--color-ink); }
.hint[hidden] { display: none; }

/* Technical detail is reachable, not displayed. The customer runs a salon,
   not a terminal.
   It is NOT pushed to the bottom of the rail: `margin-block-start: auto` left
   a 197px hole between the last real content and the disclosure, which read
   as a layout that had lost something. Content flows from the top; the rail
   simply ends where it ends. */
.tech { margin-block-start: var(--space-1); }
.tech > summary {
  font-size: var(--text-caption);
  color: var(--color-ink-3);
  cursor: pointer;
  padding-block: var(--space-2);
  list-style: none;
}
.tech > summary::-webkit-details-marker { display: none; }
.tech > summary::before { content: "▸ "; }
.tech[open] > summary::before { content: "▾ "; }
.tech > summary:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; border-radius: var(--radius-sm); }
.feed {
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  line-height: 1.7;
  color: var(--color-ink-3);
  max-block-size: 168px;
  overflow-y: auto;
  border-block-start: var(--rule-hair) solid var(--color-line);
  padding-block-start: var(--space-2);
}
.feed p { margin: 0; overflow-wrap: anywhere; }
.feed .is-warn { color: var(--color-warn); }
.feed .is-bad  { color: var(--color-danger); }

/* ── Control bar ─────────────────────────────────────────────────────────
   A real command bar pinned to the bottom of the shell, with one primary
   verb visible at a time. */
.controls {
  border-block-start: var(--rule-hair) solid var(--color-line);
  background: var(--color-paper-raised);
  padding: var(--space-3) var(--space-5);
}
.controls-inner {
  max-width: 1240px; margin-inline: auto;
  display: flex; align-items: center; gap: var(--space-2);
  flex-wrap: wrap;
}
.controls-fill { flex: 1 1 auto; }

/* ── Button — all eight states ───────────────────────────────────────── */
.btn {
  font: inherit;
  font-size: var(--text-small);
  font-weight: var(--weight-medium);
  line-height: 1;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: var(--rule-hair) solid var(--color-control-line);
  background: var(--color-paper-raised);
  color: var(--color-ink);
  cursor: pointer;
  white-space: nowrap;              /* never a two-line clickable label */
  display: inline-flex; align-items: center; gap: var(--space-2);
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.btn:hover:not(:disabled), .btn.is-hover  { background: var(--color-paper-sunk); border-color: var(--color-ink-3); }
.btn:focus-visible, .btn.is-focus {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;              /* never animated — must appear instantly */
}
.btn:active:not(:disabled), .btn.is-active { transform: translateY(1px); background: var(--color-paper-sunk); }
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: .45; cursor: not-allowed; transform: none;
}

.btn--primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-ink-invert);
  padding-inline: var(--space-5);
}
.btn--primary:hover:not(:disabled), .btn--primary.is-hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
.btn--primary:active:not(:disabled), .btn--primary.is-active { background: var(--color-accent-press); }

.btn--quiet { border-color: transparent; background: transparent; color: var(--color-ink-2); }
.btn--quiet:hover:not(:disabled), .btn--quiet.is-hover { background: var(--color-paper-sunk); border-color: var(--color-line); color: var(--color-ink); }

.btn[data-state="loading"] { pointer-events: none; }
.btn[data-state="loading"] .btn-spin { display: inline-block; }

/* Outline variants carry state in the BORDER and LABEL... */
.btn[data-state="error"]   { border-color: var(--color-danger); color: var(--color-danger); }
.btn[data-state="success"] { border-color: var(--color-live);   color: var(--color-live); }

/* ...but a FILLED button must carry it in the FILL. Recolouring only the
   label left dark red text on the teal background — illegible, and caught
   the moment the eight states were rendered side by side. */
.btn--primary[data-state="error"] {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: var(--color-ink-invert);
}
.btn--primary[data-state="success"] {
  background: var(--color-live);
  border-color: var(--color-live);
  color: var(--color-ink-invert);
}

.btn-spin {
  display: none;
  inline-size: 11px; block-size: 11px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: var(--radius-pill);
  animation: spin 620ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Notice ──────────────────────────────────────────────────────────── */
.notice {
  max-width: 1240px; margin: var(--space-5) auto 0;
  padding: var(--space-3) var(--space-4);
  background: var(--color-warn-wash);
  border: var(--rule-hair) solid var(--color-warn);
  border-radius: var(--radius-md);
  font-size: var(--text-small);
}
.notice b { font-weight: var(--weight-semi); }
.notice[hidden] { display: none; }

/* ── Responsive — verified at 320 / 375 / 414 / 768 ─────────────────── */
/* ── Tablet and below: one column ──────────────────────────────────────── */
@media (max-width: 900px) {
  .stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(220px, 1fr) auto;
    padding: var(--space-4);
    gap: var(--space-4);
  }
  /* Stacked, the subject shares the height with the rail, so it takes a fixed
     share rather than filling. */
  .well--subject { block-size: auto; aspect-ratio: 16 / 9; max-block-size: 42vh; }
  .well--check   { aspect-ratio: 16 / 8; }
  .rail { flex-direction: row; flex-wrap: wrap; align-items: flex-start; gap: var(--space-4); }
  /* Side by side on a tablet: the self-view and the guidance read as a row
     rather than a tall stack that pushes the controls off screen. */
  .rail-head { flex-basis: 100%; }
  .rail > .well--check { flex: 1 1 260px; max-inline-size: 360px; }
  .rail > .hint        { flex: 2 1 260px; }
  .tech { flex-basis: 100%; }
}
@media (max-width: 460px) {
  .appbar { padding: var(--space-3) var(--space-4); }
  .controls { padding: var(--space-3) var(--space-4); }
  .lockup span { display: none; }      /* keep the bar to one line */
  .btn { padding-inline: var(--space-3); }
  .btn--primary { flex: 1 1 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 120ms !important;   /* opacity crossfade only */
  }
  .btn:active { transform: none; }
}
