/* Starvto Dialer - console UI
   Brand: bg #06060E, primary #A855F7, Archivo Black display. */

:root {
  --bg:        #06060E;
  --bg-raise:  #0C0C18;
  --bg-sunken: #04040A;
  --surface:   #101021;
  --surface-2: #16162B;
  --line:      #23233F;
  --line-soft: #1A1A30;

  --ink:       #EDEDF5;
  --ink-2:     #B9B9CE;
  --ink-3:     #8A8AA6;

  --primary:   #A855F7;
  --primary-2: #C084FC;
  --primary-d: #7E22CE;

  --live:      #34D399;
  --live-d:    #059669;
  --danger:    #F0526B;
  --danger-d:  #B91C3C;
  --warn:      #F5B544;

  --r:   14px;
  --r-s: 10px;
  --shadow: 0 18px 44px rgba(0,0,0,.55);
  --sans: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Archivo Black', 'Archivo', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(900px 500px at 82% -12%, rgba(168,85,247,.13), transparent 62%),
    radial-gradient(700px 460px at 8% 108%, rgba(52,211,153,.06), transparent 60%);
  background-attachment: fixed;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }

.view { display: none; }
.view.is-active { display: block; }
[hidden] { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

/* ---------------------------------------------------------- brand --- */
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 15px; height: 15px; border-radius: 4px; flex: none;
  background: linear-gradient(140deg, var(--primary-2), var(--primary-d));
  box-shadow: 0 0 16px rgba(168,85,247,.55);
}
.brand-name { font-family: var(--display); font-size: 14px; letter-spacing: .16em; }
.brand-sep { color: var(--line); }
.brand-app { color: var(--ink-2); font-weight: 600; letter-spacing: .02em; }
.brand-sm .brand-name { font-size: 13px; }

/* ---------------------------------------------------------- login --- */
.login-shell {
  min-height: 100dvh; display: grid; place-content: center;
  gap: 18px; padding: 24px; justify-items: center;
}
.login-card {
  width: min(400px, 92vw); background: var(--surface);
  border: 1px solid var(--line); border-radius: 20px;
  padding: 34px 32px 30px; box-shadow: var(--shadow);
}
.login-title { font-family: var(--display); font-size: 34px; margin: 22px 0 4px; letter-spacing: -.02em; }
.login-sub { margin: 0 0 24px; color: var(--ink-2); }
.login-foot { color: var(--ink-3); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; margin: 0; }

.field { display: block; margin-bottom: 15px; }
.field > span { display: block; font-size: 12px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 7px; }
.field input, .field select, textarea, select, .input {
  width: 100%; background: var(--bg-sunken); border: 1px solid var(--line);
  border-radius: var(--r-s); padding: 11px 13px; color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, textarea:focus, select:focus, .input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(168,85,247,.18);
}
.form-error {
  margin: 0 0 14px; padding: 10px 12px; border-radius: var(--r-s);
  background: rgba(240,82,107,.12); border: 1px solid rgba(240,82,107,.4);
  color: #FFC3CC; font-size: 14px;
}

/* --------------------------------------------------------- buttons --- */
.btn {
  border: 1px solid transparent; border-radius: var(--r-s); padding: 11px 18px;
  font-weight: 600; cursor: pointer; transition: transform .08s, filter .15s, background .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-block { width: 100%; }
.btn-primary { background: linear-gradient(160deg, var(--primary), var(--primary-d)); color: #fff;
  box-shadow: 0 8px 22px rgba(126,34,206,.4); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.09); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--primary); color: var(--ink); }
.btn-del-thread:hover { border-color: var(--danger); color: var(--danger); }

/* --------------------------------------------------------- topbar --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 13px 22px; border-bottom: 1px solid var(--line-soft);
  background: rgba(6,6,14,.86); backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 40;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.whoami { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.whoami-name { font-weight: 600; font-size: 14px; }
.whoami-meta { font-size: 11.5px; color: var(--ink-3); letter-spacing: .04em; }

.rtc-pill {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 13px 6px 10px; font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
.rtc-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn);
  box-shadow: 0 0 10px currentColor; color: var(--warn); }
.rtc-pill.is-ready { color: var(--live); border-color: rgba(52,211,153,.4); }
.rtc-pill.is-ready .dot { background: var(--live); color: var(--live); }
.rtc-pill.is-down { color: var(--danger); border-color: rgba(240,82,107,.4); }
.rtc-pill.is-down .dot { background: var(--danger); color: var(--danger); }

/* --------------------------------------------------- sound controls --- */
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  cursor: pointer; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 13px; font-size: 12.5px; font-weight: 600;
  color: var(--ink-2); transition: color .15s, border-color .15s, background .15s;
}
.iconbtn:hover { color: var(--ink); border-color: var(--primary); }
.iconbtn-sq { padding: 0; width: 34px; height: 34px; border-radius: 10px; }
.iconbtn-sq svg { display: block; }
/* The slash is part of the icon and simply hidden while sound is on, so the
   bell never jumps or reflows when it is toggled. */
.mute-slash { opacity: 0; transition: opacity .15s; }
.iconbtn.is-off { color: var(--ink-3); border-color: var(--line-soft); }
.iconbtn.is-off .mute-slash { opacity: 1; }
.iconbtn.is-off:hover { color: var(--danger); border-color: rgba(240,82,107,.45); }

/* ----------------------------------------------------------- tabs --- */
.tabs { display: flex; gap: 4px; padding: 12px 22px 0; border-bottom: 1px solid var(--line-soft); }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer;
  padding: 9px 14px; color: var(--ink-3); font-weight: 600; font-size: 14px;
  border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); border-bottom-color: var(--primary); background: rgba(168,85,247,.07); }

.workspace { padding: 22px; max-width: 1220px; margin: 0 auto; }

/* --------------------------------------------------------- dialer --- */
.panel-dial { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: 22px; align-items: start; }
@media (max-width: 900px) { .panel-dial { grid-template-columns: 1fr; } }

.dialer {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 22px; box-shadow: var(--shadow); max-width: 460px; margin: 0 auto; width: 100%;
}
.callerid { margin-bottom: 16px; }
.callerid label { display: block; font-size: 11.5px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.callerid select { font-family: var(--mono); font-size: 14px; }

.readout { position: relative; }
.dial-input {
  width: 100%; background: var(--bg-sunken); border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px 46px 16px 16px;
  font-family: var(--mono); font-size: 25px; font-weight: 500; letter-spacing: .02em;
  color: var(--ink); outline: none; text-align: center;
}
.dial-input::placeholder { font-size: 16px; letter-spacing: 0; color: var(--ink-3); font-family: var(--sans); }
.dial-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(168,85,247,.16); }
.backspace {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--ink-3); font-size: 19px; cursor: pointer;
  padding: 8px 10px; border-radius: 8px;
}
.backspace:hover { color: var(--ink); background: var(--surface-2); }
.readout-hint { margin: 8px 0 14px; text-align: center; font-size: 13px; min-height: 19px; color: var(--ink-3); }
.readout-hint.is-bad { color: #FF9DAC; }
.readout-hint.is-ok { color: var(--ink-2); font-family: var(--mono); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button {
  background: linear-gradient(180deg, var(--surface-2), #0E0E1C);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 0 9px; cursor: pointer; display: grid; gap: 1px; justify-items: center;
  transition: border-color .12s, transform .05s, background .12s;
}
.keypad button:hover { border-color: var(--primary); background: linear-gradient(180deg, #1D1D38, #121224); }
.keypad button:active { transform: translateY(1px); }
.keypad b { font-family: var(--mono); font-size: 22px; font-weight: 500; line-height: 1; }
.keypad i { font-style: normal; font-size: 9.5px; letter-spacing: .16em; color: var(--ink-3); min-height: 12px; }

.btn-call {
  width: 100%; margin-top: 16px; padding: 15px;
  background: linear-gradient(160deg, var(--live), var(--live-d)); color: #04120C;
  font-size: 16px; font-weight: 700; letter-spacing: .01em;
  box-shadow: 0 10px 26px rgba(5,150,105,.32);
}
.btn-call:hover:not(:disabled) { filter: brightness(1.08); }
.ico-phone {
  width: 15px; height: 15px; display: inline-block; background: currentColor;
  -webkit-mask: var(--phone-mask) center/contain no-repeat; mask: var(--phone-mask) center/contain no-repeat;
  --phone-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6.6 10.8c1.4 2.8 3.8 5.1 6.6 6.6l2.2-2.2c.3-.3.7-.4 1-.2 1.2.4 2.4.6 3.6.6.6 0 1 .4 1 1V20c0 .6-.4 1-1 1-9.4 0-17-7.6-17-17 0-.6.4-1 1-1h3.5c.6 0 1 .4 1 1 0 1.3.2 2.5.6 3.6.1.4 0 .7-.2 1l-2.3 2.2z"/></svg>'); }

/* -------------------------------------------------------- sidecar --- */
.sidecar { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.stat { background: var(--bg-sunken); border: 1px solid var(--line-soft); border-radius: var(--r-s);
  padding: 11px 8px; text-align: center; }
.stat-n { display: block; font-family: var(--mono); font-size: 21px; font-weight: 700; color: var(--ink); }
.stat-l { display: block; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin-top: 2px; }
.sidecar-h { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px; }
/* Sound is on but the browser has not released audio yet. It needs one click,
   so it is marked rather than left looking identical to a working speaker. */
#btn-sound.is-locked { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }

/* The alerts button says which of the three states the browser is in, so "on"
   never looks the same as "blocked". Only blocked gets colour, because that is
   the one that needs acting on. */
#btn-alerts[data-alerts="denied"] { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }

/* Which line Recent is showing. It carries real meaning, so it reads at full
   strength rather than as a faint caption, and it drops the shouty tracking. */
.sidecar-scope { margin-left: 8px; letter-spacing: 0; text-transform: none; color: var(--ink); font-weight: 600; }
.sidecar-scope:empty { display: none; }

.reclist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 420px; overflow-y: auto; }
.reclist > li > button {
  width: 100%; text-align: left; background: transparent; border: 1px solid transparent;
  border-radius: var(--r-s); padding: 9px 11px; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center;
}
.reclist > li > button:hover { background: var(--surface-2); border-color: var(--line); }
.rec-who { font-weight: 600; font-size: 14px; }
.rec-num { font-family: var(--mono); font-size: 12px; color: var(--ink-3); grid-column: 1; }
.rec-when { font-size: 11.5px; color: var(--ink-3); grid-row: 1; grid-column: 2; }
.rec-dur { font-family: var(--mono); font-size: 11.5px; grid-row: 2; grid-column: 2; }
.line-tag {
  display: inline-block; vertical-align: 1px; margin-right: 6px; padding: 0 5px; border-radius: 4px;
  font-size: 10.5px; font-weight: 600; line-height: 16px; white-space: nowrap;
  background: rgba(168,85,247,.15); border: 1px solid rgba(168,85,247,.4); color: var(--ink);
}
.h-line { white-space: nowrap; }
.h-line-name { display: block; font-size: 12px; font-weight: 600; color: var(--ink); }
/* The brand a transferred call came in through, under the line it rang. */
.h-line-via { display: block; font-size: 11px; font-weight: 600; color: var(--ink-2); }
.stage-line-via { color: var(--ink); }
.stage-via-k { margin-left: 4px; }
.rec-in .rec-who::before { content: '\2193 '; color: var(--live); }
.rec-out .rec-who::before { content: '\2191 '; color: var(--primary-2); }
.rec-missed .rec-who::before { content: '\2193 '; color: var(--danger); }

/* --------------------------------------------------------- tables --- */
.panel-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { font-size: 19px; }
/* History narrows from the right, out of the way of the heading, and wraps
   under it on a phone rather than squeezing the table. */
.filters { display: flex; gap: 10px; margin-left: auto; flex-wrap: wrap; }
.filter { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.filter select { padding: 6px 10px; font-size: 13px; }
@media (max-width: 720px) { .panel-history .panel-head { flex-wrap: wrap; } .filters { margin-left: 0; } }
.block { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; }
.admin-grid { display: grid; gap: 20px; align-items: start; }
/* minmax(0,1fr), not 1fr. A grid track defaults to min-width:auto, so the
   560px min-width on .tbl pushed the stacked column wider than the phone
   and scrolled the entire page sideways instead of just the table. */
/* One column, always. The workspace is capped at 1220px however wide the
   monitor is, so side by side never gave People more than ~614px while its
   table needs ~650, and the row buttons sat off the edge of the scroll box.
   Full width costs a little scrolling and guarantees nothing is ever cut. */
.admin-grid { grid-template-columns: minmax(0, 1fr); }
.panel-history { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; }

.table-wrap { overflow-x: auto; border-radius: var(--r-s); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }
.tbl th {
  text-align: left; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700; padding: 9px 11px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl td { padding: 10px 11px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tbody tr:hover { background: rgba(168,85,247,.05); }
.tbl tbody tr.is-state:hover { background: none; }
.tbl tbody tr.is-state td { border-bottom: 0; }
.tbl .num, .tbl .mono { font-family: var(--mono); }
.tbl select { padding: 6px 9px; font-size: 13px; }
.tbl input.notecell {
  background: transparent; border: 1px solid transparent; border-radius: 7px;
  padding: 5px 8px; width: 100%; min-width: 150px;
}
.tbl input.notecell:hover { border-color: var(--line); }
.tbl input.notecell:focus { border-color: var(--primary); background: var(--bg-sunken); }

/* People reads as one person per row, so the identity sits in a single cell:
   avatar, name, address. Four columns instead of five also stops the name and
   the buttons from wrapping, which was what made the row heights ragged. */
.tbl-people td { padding: 12px 11px; }
/* Person is the primary column, so it takes the spare width. The other three
   stay exactly as wide as their contents, which keeps the lines sitting next
   to the role instead of drifting halfway across the table. */
.tbl-people th:nth-child(2), .tbl-people td:nth-child(2),
.tbl-people th:nth-child(3), .tbl-people td:nth-child(3),
.tbl-people th:nth-child(4), .tbl-people td:nth-child(4) { width: 1%; white-space: nowrap; }
.tbl-people th:nth-child(4), .tbl-people td:nth-child(4) { text-align: right; }

.person { display: flex; align-items: center; gap: 11px; min-width: 0; }
/* Same circle as Messages and Contacts use, one size down for a table row. */
.person-avatar {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .02em;
  color: var(--primary-2);
  background: rgba(168,85,247,.13); border: 1px solid rgba(168,85,247,.25);
}
.person-id { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.person-id b { font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.person-id > span {
  font-size: 12px; color: var(--ink-3);
  max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* One pill per line, so two numbers never run together as one long string. */
.line-pill {
  display: inline-block; font-family: var(--mono); font-size: 11.5px;
  padding: 3px 7px; margin: 2px 5px 2px 0; border-radius: 7px;
  background: var(--bg-sunken); border: 1px solid var(--line-soft);
  color: var(--ink-2); white-space: nowrap;
}
.line-none { font-size: 12.5px; color: var(--ink-3); }
.line-more { color: var(--ink-3); cursor: default; }


/* Held quiet until the row is hovered or the button is tabbed to: the table is
   for reading, and destructive controls should not be the loudest thing in it. */
/* Square, quiet until the row is hovered or the button is tabbed to: the table
   is for reading, and a destructive control should not be the loudest thing on
   the row. The words "Reset password" cost more width than the table has. */
.row-actions { display: inline-flex; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.rowbtn {
  display: grid; place-items: center; width: 30px; height: 30px; padding: 0;
  border: 1px solid transparent; border-radius: 9px; background: transparent;
  color: var(--ink-3); cursor: pointer; opacity: .75;
  transition: opacity .15s ease, color .15s ease, background .15s ease, border-color .15s ease;
}
tr:hover .rowbtn { opacity: 1; }
.rowbtn:hover { color: var(--ink); background: var(--surface-2); border-color: var(--line); }
.rowbtn:focus-visible { opacity: 1; outline: 2px solid var(--primary); outline-offset: 2px; }
.rowbtn-danger:hover { color: #FDA4AF; background: rgba(240,82,107,.12); border-color: rgba(240,82,107,.38); }

@media (max-width: 620px) {
  .person-id > span { max-width: 18ch; }
}

/* Numbers: a phone number broken across two lines is unreadable, and the E911
   chip was doing the same. Only the label is allowed to wrap. */
#numbers-table td:nth-child(1), #numbers-table td:nth-child(3), #numbers-table td:nth-child(4) { white-space: nowrap; }
#numbers-table td:nth-child(2) { white-space: normal; min-width: 120px; }
#numbers-table select { max-width: 150px; }

/* History has nine columns. Left to shrink, the browser broke every date and
   phone number across three or four lines. Keep those on one line and let the
   table scroll sideways instead; only the name is allowed to wrap. */
#history-table { min-width: 1080px; }
#history-table td { white-space: nowrap; }
#history-table td.h-contact { white-space: normal; min-width: 130px; max-width: 220px; }

.chip { display: inline-block; padding: 2.5px 9px; border-radius: 999px; font-size: 11px;
  font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.chip-ok   { background: rgba(52,211,153,.14); color: #6EE7B7; }
.chip-bad  { background: rgba(240,82,107,.14); color: #FDA4AF; }
.chip-warn { background: rgba(245,181,68,.14); color: #FCD34D; }
.chip-mute { background: rgba(138,138,166,.14); color: var(--ink-2); }
.chip-role { background: rgba(168,85,247,.15); color: var(--primary-2); }

.addform { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.addform h3 { font-size: 15px; margin-bottom: 14px; }
.addgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 620px) { .addgrid { grid-template-columns: 1fr; } }

/* ----------------------------------------------------- call stage --- */
.stage {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px;
  background: rgba(4,4,10,.82); backdrop-filter: blur(9px);
  animation: fade .18s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.stage-card {
  width: min(400px, 94vw); background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; padding: 28px 26px 24px; text-align: center; box-shadow: var(--shadow);
  max-height: 94dvh; overflow-y: auto;
}
.stage.is-live .stage-card { border-color: rgba(52,211,153,.45); box-shadow: 0 0 60px rgba(52,211,153,.14), var(--shadow); }
.stage-state {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .13em;
  text-transform: uppercase; color: var(--primary-2); padding: 4px 12px; border-radius: 999px;
  background: rgba(168,85,247,.12); margin-bottom: 16px;
}
.stage.is-live .stage-state { color: #6EE7B7; background: rgba(52,211,153,.13); }
.stage.is-ringing .stage-state { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.stage-who { font-family: var(--display); font-size: 23px; letter-spacing: -.01em; }
.stage-num { font-family: var(--mono); font-size: 15px; color: var(--ink-2); margin: 5px 0 0; }
/* Which of our numbers was dialled. Loud enough to read across the room. */
.stage-line {
  display: inline-flex; align-items: center; gap: 7px; margin: 12px 0 0;
  padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: rgba(168,85,247,.15); border: 1px solid rgba(168,85,247,.4); color: var(--ink);
}
.stage-line[hidden] { display: none; }
/* A call placed from WhatsApp, named on the card while it rings. */
.stage-wa {
  display: flex; width: max-content; max-width: 100%; align-items: center; gap: 6px; margin: 12px auto 4px;
  padding: 4px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  color: #3FC866; background: rgba(63,200,102,.12); border: 1px solid rgba(63,200,102,.45);
}
.stage-wa[hidden] { display: none; }
.stage-wa .ch-wa { margin-left: 0; width: 15px; height: 15px; vertical-align: 0; }
.h-wa { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; font-size: 12px; font-weight: 600; color: #3FC866; }
.h-wa .ch-wa { margin-left: 0; }
.stage-line-k { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--primary-2); }
.stage-line-n { font-family: var(--mono); }
.stage-timer { font-family: var(--mono); font-size: 34px; font-weight: 500; margin: 14px 0 20px; letter-spacing: .04em; }

.stage-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.rbtn {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 11px 4px 9px; cursor: pointer; display: grid; gap: 4px; justify-items: center;
  font-size: 11px; color: var(--ink-2); font-weight: 600;
}
.rbtn:hover { border-color: var(--primary); color: var(--ink); }
.rbtn.is-on { background: rgba(168,85,247,.16); border-color: var(--primary); color: var(--primary-2); }
.rbtn-ico { font-family: var(--mono); font-size: 15px; }

.stage-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.stage-keypad button {
  background: var(--bg-sunken); border: 1px solid var(--line); border-radius: var(--r-s);
  padding: 11px 0; font-family: var(--mono); font-size: 17px; cursor: pointer;
}
.stage-keypad button:hover { border-color: var(--primary); }

.stage-answer { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.btn-answer { background: linear-gradient(160deg, var(--live), var(--live-d)); color: #04120C; font-weight: 700; padding: 14px; }
.btn-decline, .btn-hangup {
  background: linear-gradient(160deg, var(--danger), var(--danger-d)); color: #fff; font-weight: 700; padding: 14px;
}
.btn-hangup { width: 100%; }
.btn-hangup:hover, .btn-decline:hover { filter: brightness(1.08); }
.btn-hangup.is-wait { background: linear-gradient(160deg, var(--warn), #D48A1E); color: #1A1204; }
.hangup-wait {
  display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px;
  background: rgba(0,0,0,.2); font-variant-numeric: tabular-nums; font-size: .92em;
}
.hangup-hint { margin: 8px 0 0; text-align: center; font-size: 13px; font-weight: 600; color: var(--warn); }
.stage.is-min .hangup-hint { display: none; }

/* Minimize: the call shrinks to a bar at the bottom and the dialer underneath
   works normally, so contacts, Recent and texts stay reachable mid-call. Same
   buttons, same call; only the layout changes. */
.stage-card { position: relative; }
.stage-min {
  position: absolute; top: 14px; right: 14px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
  border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
.stage-min:hover { color: var(--ink); border-color: var(--primary); }
/* An incoming call has to be answered or declined first. */
.stage:has(#stage-answer:not([hidden])) .stage-min { display: none; }

.stage.is-min {
  inset: auto 0 0 0; padding: 0 12px calc(12px + env(safe-area-inset-bottom));
  background: none; backdrop-filter: none; place-items: end center; pointer-events: none; animation: none;
  grid-template-columns: minmax(0, 720px); justify-content: center;
}
.stage.is-min .stage-card {
  pointer-events: auto; cursor: pointer;
  width: 100%; min-width: 0; max-height: none; overflow: visible;
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 9px 10px 9px 16px; border-radius: 16px;
}
.stage.is-min .stage-num, .stage.is-min .stage-line, .stage.is-min .stage-keypad,
.stage.is-min .stage-answer, .stage.is-min .stage-transcript, .stage.is-min .stage-notes,
.stage.is-min #btn-hold, .stage.is-min #btn-keys { display: none !important; }
.stage.is-min .stage-state { margin: 0; padding: 3px 9px; font-size: 10px; flex: none; }
.stage.is-min .stage-who {
  font-size: 15px; margin: 0; flex: 1 1 auto; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stage.is-min .stage-timer { font-size: 15px; margin: 0; flex: none; }
.stage.is-min .stage-actions { display: flex; margin: 0; flex: none; }
.stage.is-min #btn-mute { padding: 7px 12px; grid-auto-flow: column; gap: 6px; font-size: 12px; }
.stage.is-min .btn-hangup { width: auto; padding: 9px 16px; flex: none; }
.stage.is-min .stage-min { position: static; order: 10; flex: none; }
body.call-min { padding-bottom: 84px; }
body.call-min .toasts { bottom: calc(96px + env(safe-area-inset-bottom)); }
@media (max-width: 560px) {
  .stage.is-min .stage-state, .stage.is-min #btn-mute .rbtn-ico { display: none; }
  .stage.is-min .stage-card { gap: 8px; padding-left: 12px; }
  .stage.is-min .stage-who, .stage.is-min .stage-timer { font-size: 14px; }
  .stage.is-min #btn-mute { padding: 7px 9px; }
  .stage.is-min .btn-hangup { padding: 9px 12px; }
  .stage.is-min .stage-min { padding: 4px 9px; }
}

.stage-notes { display: block; text-align: left; margin-top: 18px; }
.stage-notes > span { display: block; font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.stage-notes textarea { resize: vertical; font-size: 14px; }

/* ----------------------------------------------- live transcript --- */
.stage-transcript {
  margin-top: 18px; text-align: left;
  border: 1px solid var(--line); border-radius: var(--r-s);
  background: var(--bg-sunken); overflow: hidden;
}
.tr-head {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-bottom: 1px solid var(--line-soft); background: var(--surface);
}
.tr-title {
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3);
}
.tr-dots { display: flex; gap: 6px; margin-left: auto; }

/* The level pips answer the question he would otherwise have to guess at while
   staring at an empty panel: is it hearing anything at all. A pip that lights
   when someone speaks separates "nobody is talking" from "this is broken". */
.tr-dot {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .04em;
  color: var(--ink-3); transition: color .12s linear;
}
.tr-dot::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--line); transition: background .12s linear, box-shadow .12s linear;
}
.tr-dot.is-on { color: var(--ink-2); }
.tr-dot#tr-dot-you.is-on::before  { background: var(--primary); box-shadow: 0 0 0 3px rgba(168,85,247,.18); }
.tr-dot#tr-dot-them.is-on::before { background: var(--live);    box-shadow: 0 0 0 3px rgba(52,211,153,.18); }

.tr-pause {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
  border-radius: 999px; padding: 3px 11px; font-family: var(--sans);
  font-size: 11.5px; cursor: pointer;
}
.tr-pause:hover { color: var(--ink); border-color: var(--primary-d); }

.tr-body {
  max-height: 190px; overflow-y: auto; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 7px;
  scrollbar-width: thin;
}
.tr-empty { margin: 0; color: var(--ink-3); font-size: 13px; font-style: italic; }

/* A two-column row rather than a text indent, so the second line of a sentence
   sits under the first instead of starting back in the margin, where the eye
   reads it as a new speaker. A negative text-indent does the same thing until
   the panel scrolls, and then it hangs the labels outside the clip. */
.tr-line {
  margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--ink);
  display: flex; gap: 8px; align-items: baseline;
}
.tr-who {
  flex: 0 0 42px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
}
.tr-text { flex: 1 1 auto; min-width: 0; }
.tr-agent    .tr-who { color: var(--primary-2); }
.tr-customer .tr-who { color: var(--live); }
.tr-customer .tr-text { color: var(--ink-2); }

/* --------------------------------------------------------- toasts --- */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 120; display: grid; gap: 9px; justify-items: end; }
.toast {
  background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--primary);
  border-radius: var(--r-s); padding: 11px 15px; max-width: 340px; font-size: 14px;
  box-shadow: var(--shadow); animation: slide .2s ease-out;
}
.toast.is-bad { border-left-color: var(--danger); }
.toast.is-ok  { border-left-color: var(--live); }
.toast.is-warn { border-left-color: var(--warn); }
@keyframes slide { from { opacity: 0; transform: translateX(14px); } }

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

/* ------------------------------------------------------- messaging --- */
.tab-badge {
  display: inline-block; min-width: 18px; padding: 1px 6px; margin-left: 5px;
  border-radius: 999px; background: var(--primary); color: #fff;
  font-family: var(--mono); font-size: 10.5px; font-weight: 700; vertical-align: 1px;
}
.btn-sm { padding: 7px 13px; font-size: 13px; }

.msg-layout {
  display: grid; grid-template-columns: 296px minmax(0, 1fr); gap: 18px;
  height: calc(100dvh - 190px); min-height: 460px;
}
@media (max-width: 860px) {
  .msg-layout { grid-template-columns: 1fr; height: auto; }
  .threads { max-height: 300px; }
  .convo { min-height: 440px; }
}

.threads {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 16px; display: flex; flex-direction: column; overflow: hidden;
}
.threads-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.threads-head h2 { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
/* Which line's texts are showing. One line at a time, never a mixed inbox.
   The search box above it is the same control, so it is cut from the same rule
   rather than a near-copy that drifts a pixel every time one of them changes. */
.msg-line, .msg-search {
  width: 100%; margin: 0 0 12px; padding: 9px 11px; font: inherit; font-size: 14px;
  color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-s);
}
.msg-search::placeholder { color: var(--ink-3); }
.msg-search:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
/* A search box in a 320px column cannot also hold a Person dropdown on one
   line, so on a phone the row wraps and the box takes the width it needs. */
@media (max-width: 720px) { .panel-history .panel-head #history-search { width: 100%; } }

/* New text banner: who, which line, what they said. Click opens the thread. */
.text-banner {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 130;
  width: min(420px, calc(100vw - 32px));
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: start;
  background: var(--surface-2); border: 1px solid rgba(168,85,247,.55); border-left: 4px solid var(--primary);
  border-radius: var(--r-s); padding: 12px 12px 12px 15px; box-shadow: var(--shadow);
  cursor: pointer; animation: drop .2s ease-out;
}
.text-banner[hidden] { display: none; }
.tb-line { grid-column: 1; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: #D4B5FF; font-weight: 700; }
.tb-who  { grid-column: 1; font-size: 15px; font-weight: 700; color: var(--ink); }
.tb-body { grid-column: 1; font-size: 14px; color: var(--ink); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tb-close { grid-column: 2; grid-row: 1 / span 3; background: none; border: 0; color: var(--ink-2);
  font-size: 20px; line-height: 1; padding: 2px 4px; cursor: pointer; }
.tb-close:hover { color: var(--ink); }
@keyframes drop { from { opacity: 0; transform: translate(-50%, -10px); } }

.threadlist { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: grid; gap: 4px; align-content: start; }
.threadlist > li > button {
  width: 100%; text-align: left; background: transparent; border: 1px solid transparent;
  border-radius: var(--r-s); padding: 10px 12px; cursor: pointer; display: grid; gap: 3px;
}
.threadlist > li > button:hover { background: var(--surface-2); border-color: var(--line); }
.threadlist > li > button.is-active { background: rgba(168,85,247,.12); border-color: rgba(168,85,247,.5); }
.th-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.th-who { font-weight: 600; font-size: 14px; }
.th-when { font-size: 11px; color: var(--ink-3); flex: none; }
.th-last { font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-unread {
  display: inline-block; min-width: 17px; text-align: center; padding: 1px 5px;
  border-radius: 999px; background: var(--primary); color: #fff;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
}

.convo {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  display: flex; flex-direction: column; overflow: hidden;
}
/* Just a centring box now. The padding and the colour live on .estate,
   so the two do not stack into 80px of dead space. */
.convo-empty { margin: auto; display: grid; place-items: center; }
.convo-live { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.convo-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--line-soft); flex: none;
}
.convo-id { min-width: 0; margin-right: auto; }
.btn-add-contact { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.btn-add-contact[hidden] { display: none; }
.ac-ico { display: block; flex: none; }
.convo-head h3 { font-size: 16px; }
.convo-sub {
  margin: 2px 0 0; font-family: var(--mono); font-size: 12px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* A letter reads faster than a number, and it gives the header a fixed left
   edge so the name does not start in a different place on every thread. */
.convo-avatar {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 13px; font-weight: 600; letter-spacing: .02em;
  color: var(--primary-2);
  background: rgba(168,85,247,.13);
  border: 1px solid rgba(168,85,247,.25);
}

/* ==================================================== message bubbles ===
   Runs, not rows. Consecutive messages from one side tuck together: only the
   first of a run gets a full outer corner, only the last gets a tail and a
   timestamp. The gap inside a run is a third of the gap between runs, which is
   what makes a burst of three messages read as one turn in the conversation. */
.bubbles {
  flex: 1 1 auto; overflow-y: auto; padding: 18px 18px 22px;
  display: grid; gap: 3px; align-content: start;
  /* Tracks so a bubble can sit at one side without justify-self fighting its
     own max-width, and so nothing exceeds three quarters of the pane. */
  grid-template-columns: minmax(0, 1fr);
}
.bub {
  max-width: min(68%, 46ch);
  padding: 9px 13px; font-size: 14px; line-height: 1.45;
  word-wrap: break-word; overflow-wrap: anywhere;
  position: relative;
}
.bub + .bub.is-first { margin-top: 12px; }   /* the breath between turns */

.bub-in {
  justify-self: start;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 6px 16px 16px 6px;
}
.bub-in.is-first { border-top-left-radius: 16px; }
.bub-in.is-last  { border-bottom-left-radius: 16px; }

/* A flat, slightly deeper purple. The old gradient ran the full width of every
   outbound message, which made a sentence look like a button you should press. */
.bub-out {
  justify-self: end;
  background: #8B3FD9; color: #fff;
  border-radius: 16px 6px 6px 16px;
}
.bub-out.is-first { border-top-right-radius: 16px; }
.bub-out.is-last  { border-bottom-right-radius: 16px; }

.bub-text { display: block; white-space: pre-wrap; }
.bub-link { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.bub-in .bub-link { color: #D4B5FF; }

/* Quiet by default. It is reference, not content: you look for it, it does not
   come to you. Sits on the tail of a run only, so a burst of five messages
   carries one timestamp instead of five. */
.bub-meta {
  display: block; margin-top: 4px;
  font-size: 11px; line-height: 1.2; letter-spacing: .01em;
  color: var(--ink-3);
}
.bub-receipt + .bub { margin-top: 12px; }
.bub-out .bub-meta { color: rgba(255,255,255,.62); }
.bub-out.is-failed .bub-meta { color: rgba(255,255,255,.75); }

.bub.is-pending { opacity: .62; }

/* Under the bubble, not inside it, so it reads as a note about the message. */
.bub-receipt {
  justify-self: end; margin-top: 3px; padding-right: 4px;
  font-size: 11px; line-height: 1.2; font-weight: 500;
  color: var(--ink-2);
}

/* A failure is the only status worth interrupting for, so it gets its own line
   and an action. Red alone said something was wrong without saying what to do. */
.bub-out.is-failed { background: #9E2440; }
.bub-check {
  display: block; margin-top: 6px; padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,.18);
  font-size: 11.5px; color: rgba(255,255,255,.9);
}
.bub-fail {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 6px; padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,.18);
  font-size: 11.5px; color: rgba(255,255,255,.85);
}
.bub-retry {
  border: 1px solid rgba(255,255,255,.4); background: rgba(255,255,255,.1);
  color: #fff; font: inherit; font-size: 11.5px;
  padding: 3px 9px; border-radius: 999px; cursor: pointer;
}
.bub-retry:hover:not(:disabled) { background: rgba(255,255,255,.2); }
.bub-retry:disabled { opacity: .6; cursor: default; }

.bub img { border-radius: 10px; margin-top: 6px; display: block; max-width: 100%; }
/* A picture on its own does not need a frame drawn around it. */
.bub.is-mediaonly { padding: 5px; background: none; border-color: transparent; }
.bub.is-mediaonly img { margin-top: 0; }
.bub.is-mediaonly .bub-meta { padding: 0 6px; color: var(--ink-3); }

/* The picture is a link to the full-size file, with Save sitting on top of it.
   The button stays visible instead of waiting for hover: hover does not exist
   on a phone, and a control nobody can find is the same as one that is not
   there. */
.bub-img { position: relative; display: block; margin-top: 6px; }
.bub.is-mediaonly .bub-img { margin-top: 0; }
.bub-img-open { display: block; }
.bub-img img { margin-top: 0; cursor: zoom-in; }
.bub-img-save {
  position: absolute; right: 8px; bottom: 8px;
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 9px;
  color: #fff;
  background: rgba(10, 13, 18, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(6px);
  transition: background .12s ease, transform .12s ease;
}
.bub-img-save:hover { background: rgba(10, 13, 18, 0.86); transform: translateY(-1px); }
.bub-img-save svg { width: 17px; height: 17px; }

/* WhatsApp voice notes, video and documents, inside the same bubble. */
.bub-audio, .bub-video, .bub-file { display: block; margin-top: 6px; }
.bub.is-mediaonly .bub-audio, .bub.is-mediaonly .bub-video, .bub.is-mediaonly .bub-file { margin-top: 0; }
.bub-audio audio { display: block; width: 260px; max-width: 100%; height: 40px; }
.bub-video video { display: block; width: 100%; max-width: 320px; max-height: 360px; border-radius: 10px; background: #000; }
.bub-file { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.bub-file a:first-child { font-weight: 600; color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.bub-file-save {
  display: inline-block; margin-top: 6px; padding: 4px 10px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: inherit; text-decoration: none;
  border: 1px solid currentColor; opacity: .9;
}
.bub-file .bub-file-save { margin-top: 0; }

/* A hairline through the date, so the break in time is visible at a glance
   rather than being one more line of small grey text among many. */
.bub-day {
  justify-self: stretch; max-width: none; margin: 16px 0 10px;
  display: flex; align-items: center; gap: 12px;
  font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3);
}
.bub-day::before, .bub-day::after {
  content: ''; flex: 1 1 0; height: 1px; background: var(--line);
}
.bub-day:first-child { margin-top: 0; }

.composer {
  flex: none; display: grid; grid-template-columns: auto auto minmax(0,1fr) auto; gap: 10px;
  padding: 14px 18px; border-top: 1px solid var(--line-soft); align-items: end;
}

/* The paperclip sits level with the last line of the textarea rather than the
   top of it, so it stays put as the box grows under a long message. */
.composer-attach {
  height: 40px; width: 40px; display: grid; place-items: center; flex: none;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--sunk);
  color: var(--ink-3); cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.composer-attach:hover:not(:disabled) { color: var(--primary-2); border-color: var(--primary-d); background: var(--surface-2); }
.composer-attach:disabled { opacity: .45; cursor: not-allowed; }
.composer-attach.is-busy { color: var(--primary-2); border-color: var(--primary-d); }

/* Above the composer, not inside it: an attachment survives edits to the text
   and needs to stay visible while the message is written. */
.composer-media {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 12px 18px 0; border-top: 1px solid var(--line-soft);
}
.composer-media[hidden] { display: none; }
/* Voice notes: the mic turns red while it records, and the strip above the box
   shows the clock, then the finished note to listen to before it goes. */
.composer-mic.is-recording { color: #fff; background: var(--danger); border-color: var(--danger); }
.composer-voice {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 12px 18px 0; border-top: 1px solid var(--line-soft);
}
.composer-voice[hidden] { display: none; }
.cv-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: cv-pulse 1s ease-in-out infinite; }
@keyframes cv-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .cv-dot { animation: none; } }
.cv-label { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.cv-time { font-family: var(--mono); font-size: 13px; color: var(--ink-2); }
.cv-limit { font-size: 12px; color: var(--ink-3); }
.composer-voice audio { height: 36px; max-width: 100%; }
.cv-btn {
  height: 32px; padding: 0 12px; border-radius: var(--r); cursor: pointer; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); background: var(--sunk); color: var(--ink-2);
}
.cv-btn:hover { color: var(--ink); border-color: var(--primary-d); }
.cv-btn.is-danger:hover { color: var(--danger); border-color: var(--danger); }
.composer-chip { position: relative; line-height: 0; }
.composer-chip img {
  height: 62px; width: 62px; object-fit: cover; display: block;
  border-radius: var(--r); border: 1px solid var(--line);
}
.composer-chip button {
  position: absolute; top: -6px; right: -6px; height: 20px; width: 20px; padding: 0;
  display: grid; place-items: center; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-raise); color: var(--ink-2);
  font-size: 13px; line-height: 1;
}
.composer-chip button:hover { color: var(--danger); border-color: var(--danger); }
.composer-media .composer-size { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.composer textarea {
  resize: none; max-height: 140px; border-radius: var(--r); padding: 11px 13px; font-size: 14px;
}
.composer-side { display: grid; gap: 5px; justify-items: end; }
.composer-count { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.composer-count.is-warn { color: var(--warn); }
.composer-note {
  margin: 0; padding: 11px 18px 15px; font-size: 13px; color: #FCD34D;
  background: rgba(245,181,68,.07); border-top: 1px solid rgba(245,181,68,.2);
}

/* The Numbers table has four columns and lives in the narrower admin column,
   where the shared 560px min-width overflowed and sliced the left of the phone
   number off. It needs less room than the five-column People table, so give it
   its own floor and let the assignment select shrink with the cell. */
#numbers-table { min-width: 440px; }
#numbers-table select { max-width: 100%; }

/* ======================================================= empty states ===
   One component for the three things a list can be: empty, loading, or
   broken. They used to share a single .empty class, so a failed fetch looked
   identical to a first-run app with no data, and neither looked deliberate.
   .estate is the full-size version for the big message pane; .estate-sm is
   the inline one that sits inside a list or a table cell. */

.estate {
  display: grid; justify-items: center; align-content: center; gap: 4px;
  text-align: center; padding: 40px 28px; margin: auto; max-width: 340px;
}
.estate-ico {
  width: 46px; height: 46px; border-radius: 14px; margin-bottom: 10px;
  display: grid; place-items: center;
  background: rgba(168,85,247,.10); border: 1px solid rgba(168,85,247,.24);
  color: var(--primary-2);
}
.estate-ico svg { width: 21px; height: 21px; }
.estate-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink-2); }
.estate-hint { margin: 0; font-size: 13px; color: var(--ink-3); line-height: 1.55; max-width: 30ch; }
.estate .btn { margin-top: 12px; }

/* Inline variant. Sits in a <li> or a table cell, so it cannot own the box:
   no auto margin, smaller icon, and the text stays on the baseline grid of
   the rows it is standing in for. */
.estate-sm {
  display: grid; justify-items: center; gap: 3px;
  text-align: center; padding: 24px 14px; margin: 0; max-width: none;
}
.estate-sm .estate-ico {
  width: 34px; height: 34px; border-radius: 11px; margin-bottom: 7px;
}
.estate-sm .estate-ico svg { width: 16px; height: 16px; }
.estate-sm .estate-title { font-size: 13.5px; }
.estate-sm .estate-hint { font-size: 12.5px; }

/* Error. Same shape, red, and it keeps the retry affordance because the most
   common cause here is a dropped connection rather than anything permanent. */
.estate.is-error .estate-ico,
.estate-sm.is-error .estate-ico {
  background: rgba(240,82,107,.10); border-color: rgba(240,82,107,.26); color: var(--danger);
}
.estate.is-error .estate-title,
.estate-sm.is-error .estate-title { color: var(--danger); }
.estate-err {
  margin: 0; font-family: var(--mono); font-size: 11.5px; color: var(--ink-3);
  word-break: break-word; max-width: 34ch; margin-top: 2px;
}

/* Loading. Shaped like the rows it is about to become, so the pane does not
   jump when the data lands. Bars only, no text: "Loading." read as content. */
.estate-load { display: grid; gap: 8px; padding: 14px 2px; }
.estate-load i {
  display: block; height: 11px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--line) 50%, var(--surface-2) 100%);
  background-size: 220% 100%; animation: estate-sheen 1.25s ease-in-out infinite;
}
.estate-load i:nth-child(2) { width: 78%; }
.estate-load i:nth-child(3) { width: 55%; }
@keyframes estate-sheen {
  0%   { background-position: 120% 0; }
  100% { background-position: -20% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .estate-load i { animation: none; background: var(--surface-2); }
}

/* A table cell is a layout box we do not control, so the loader has to be
   told how wide to be rather than inheriting it. */
.tbl td .estate-load { padding: 10px 0; }
.tbl td .estate-load i { width: 100%; }
.tbl td .estate-load i:nth-child(2) { width: 84%; }
.tbl td .estate-load i:nth-child(3) { width: 62%; }

/* ============================================================== phone ===
   The app is meant to end up as an Android and iOS build, so the phone
   layout is a requirement rather than a courtesy. Three real breakages at
   375px drove these rules: the top bar overflowed and pushed Sign out clean
   off the screen, the tab row wrapped "Dial pad" onto two lines, and every
   form control sat below 16px, which makes iOS Safari zoom the whole page
   the moment you tap a field. 640px is the cut because that is where the
   top bar stops fitting its full contents, not a device width. */

.btn-ico { display: none; }

@media (max-width: 640px) {

  /* --- top bar. Content is trimmed to what a phone actually needs: the
         brand, a connection dot, the sound toggle, who you are, and a way
         out. The status wording, the "/ Dialer" suffix and the org/role
         line all live in a tooltip or elsewhere in the app. */
  .topbar {
    gap: 9px;
    padding: 10px max(13px, env(safe-area-inset-left)) 10px max(13px, env(safe-area-inset-right));
  }
  .topbar-right { gap: 8px; min-width: 0; }
  .brand-sep, .brand-app { display: none; }
  .brand-sm { flex: none; }

  .rtc-pill { padding: 0; width: 34px; height: 34px; border-radius: 999px; justify-content: center; }
  #rtc-label { display: none; }
  .rtc-pill .dot { width: 9px; height: 9px; }

  /* 38px so these are real touch targets, not desktop chrome. */
  .iconbtn-sq { width: 38px; height: 38px; }
  #btn-logout {
    flex: none; width: 38px; height: 38px; padding: 0;
    border-radius: 10px; gap: 0;
  }
  #btn-logout .btn-label { display: none; }
  /* Icon only on a phone, so it fits beside Call and Delete; the label stays for screen readers via aria-label. */
  .btn-add-contact .btn-label { display: none; }
  /* Three buttons beside an unknown number: keep room for the number itself. */
  .convo-live .convo-head { gap: 6px; }
  .convo-head .btn-sm { padding-left: 9px; padding-right: 9px; }
  .convo-head .btn-add-contact { padding-left: 8px; padding-right: 8px; }
  .btn-ico { display: block; }

  /* Ellipsis instead of a hard clip, so a long name degrades readably. */
  .whoami { min-width: 0; }
  .whoami-name {
    font-size: 13px; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .whoami-meta { display: none; }

  /* --- tabs. One line, always. Scrolls sideways if a fifth tab ever
         appears or the phone is narrower than 375px. */
  .tabs {
    gap: 2px; padding: 8px 8px 0;
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; white-space: nowrap; padding: 9px 12px; font-size: 13.5px; }

  /* --- workspace + panels */
  .workspace { padding: 14px 14px calc(20px + env(safe-area-inset-bottom)); }
  .dialer { padding: 16px; border-radius: 16px; }
  .sidecar { padding: 15px; border-radius: 16px; max-width: 460px; width: 100%; margin: 0 auto; }
  .block, .panel-history { padding: 15px; border-radius: 16px; }

  .dial-input { font-size: 22px; padding: 14px 42px 14px 14px; }
  .keypad { gap: 8px; }
  .keypad button { padding: 11px 0 8px; }
  .stat { padding: 10px 6px; }
  .stat-n { font-size: 19px; }

  /* iOS Safari zooms the page when you focus a control under 16px. Every
     field here was 15px, so tapping the composer or a login box shoved the
     layout sideways. 16px is the floor that stops it. */
  .field input, .field select, textarea, select, .composer textarea { font-size: 16px; }

  /* --- messages */
  .msg-layout { gap: 12px; }
  .threads { max-height: 244px; padding: 13px; border-radius: 16px; }
  /* 62dvh is right for a thread being read and far too much for an empty
     state, which then sits in the middle of a screen-tall void. Only the pane
     with a conversation in it earns the height. */
  .convo { min-height: 62dvh; border-radius: 16px; }
  .convo:has(> .convo-empty:not([hidden])) { min-height: 0; }
  .convo-head { padding: 13px 14px; }
  .bubbles { padding: 14px; }
  .bub { max-width: 82%; }
  .convo-avatar { width: 34px; height: 34px; font-size: 12px; }
  .composer { padding: 12px 14px; gap: 8px; }
  .composer-note { padding: 10px 14px 14px; }

  /* --- login */
  .login-card { padding: 28px 22px 26px; border-radius: 18px; }
  .login-title { font-size: 30px; margin-top: 18px; }

  /* --- call stage. It is the one screen you look at while holding the
         phone to your ear, so the buttons get more room, not less. */
  .stage { padding: 12px; }
  .stage-card { width: min(400px, 96vw); padding: 22px 18px 20px; border-radius: 18px; }
  .stage-who { font-size: 20px; }
  .stage-timer { font-size: 30px; margin: 12px 0 16px; }
  .rbtn { padding: 12px 4px 10px; }
  .stage-keypad button { padding: 13px 0; font-size: 18px; }

  /* --- toasts span the width instead of hugging a corner they overflow. */
  /* The big empty state is 40px of padding on a 375px screen, which pushes
     the hint off the fold inside the message pane. */
  .estate { padding: 30px 18px; max-width: none; }
  .estate-ico { width: 42px; height: 42px; }
  .estate-hint { max-width: 26ch; }
  .estate-sm { padding: 20px 10px; }

  .toasts { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); justify-items: stretch; }
  .toast { max-width: none; }
}

/* ======================================================== contacts ===
   A contact row has four jobs at four different weights: who it is, how to
   reach them, what to do about it, and a letter to find them by. Laid out as a
   grid rather than flex so the name column starts in the same place on every
   row, which is what makes a long list scannable instead of ragged. */
.panel-contacts {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 20px;
  display: flex; flex-direction: column; min-height: 0;
}
.panel-contacts .panel-head { align-items: center; }
.panel-contacts .panel-head h2 { margin-right: auto; }
.input-sm { padding: 7px 11px; font-size: 13px; width: min(300px, 44vw); }

.contacts-wrap { overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.contact-list { list-style: none; margin: 0; padding: 0; }

.contact {
  display: grid; align-items: center; gap: 4px 14px;
  grid-template-columns: auto minmax(0, 1.1fr) minmax(0, 1fr) auto;
  padding: 12px 12px; border-radius: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.contact:last-child { border-bottom: 0; }
.contact:hover { background: var(--surface-2); }

.contact-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  color: var(--primary-2);
  background: rgba(168,85,247,.13); border: 1px solid rgba(168,85,247,.25);
}
.contact-id { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.contact-id strong { font-size: 14.5px; }
.contact-sub {
  font-size: 12px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.contact-nums { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.contact-num {
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
  background: var(--bg-raise); border: 1px solid var(--line);
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.contact-num i { font-style: normal; color: var(--ink-3); }

/* The buttons stay out of the way until the row is under the pointer. On touch,
   where there is no hover, they are always visible: a control you cannot
   summon is a control that does not exist. */
.contact-acts { display: flex; gap: 6px; opacity: 0; transition: opacity .12s; }
.contact:hover .contact-acts, .contact:focus-within .contact-acts { opacity: 1; }
@media (hover: none) { .contact-acts { opacity: 1; } }

.empty { padding: 28px 12px; text-align: center; color: var(--ink-3); font-size: 13.5px; }

/* ---------------------------------------------------------- sheet --- */
.sheet {
  border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); color: var(--ink);
  padding: 0; width: min(520px, 92vw); box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgba(4,4,10,.66); backdrop-filter: blur(2px); }
.sheet-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--line);
}
.sheet-head h3 { margin: 0; font-size: 17px; margin-right: auto; }
.sheet-x {
  border: 0; background: none; color: var(--ink-3);
  font-size: 24px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.sheet-x:hover { color: var(--ink); }
.sheet-body { padding: 18px 20px; max-height: min(62vh, 560px); overflow-y: auto; }
.sheet-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px 18px; border-top: 1px solid var(--line);
}
.sheet-foot .spacer { flex: 1 1 auto; }
.reset-tools { display: flex; gap: 8px; margin: -6px 0 12px; }
.sheet-error {
  margin: 12px 0 0; padding: 9px 12px; border-radius: 10px; font-size: 13px;
  color: #FFD9E0; background: rgba(240,82,107,.14); border: 1px solid rgba(240,82,107,.35);
}

.num-row { display: grid; grid-template-columns: minmax(0,1.6fr) minmax(0,1fr) auto; gap: 8px; margin-bottom: 8px; }
.num-row .input { width: 100%; }
.num-x {
  border: 1px solid var(--line); background: var(--bg-raise); color: var(--ink-3);
  border-radius: 10px; width: 36px; font-size: 18px; line-height: 1; cursor: pointer;
}
.num-x:hover { color: var(--danger); border-color: var(--danger-d); }

@media (max-width: 720px) {
  .contact { grid-template-columns: auto minmax(0, 1fr); }
  .contact-nums, .contact-acts { grid-column: 2; }
  .input-sm { width: 100%; }
  .panel-contacts .panel-head { flex-wrap: wrap; }
}

/* ------------------------------------ a number leads to the person --- */
/* The gutter is held open at all times rather than appearing on hover, so
   the row's time and duration never jump sideways under the cursor. */
.reclist > li { position: relative; }
.reclist > li > button.rec-main { padding-right: 76px; }
.reclist > li > button.rec-add,
.reclist > li > button.rec-text {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  width: 28px; height: 28px; padding: 0; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink-3); cursor: pointer; opacity: 0; transition: opacity .12s, color .12s;
}
.reclist > li > button.rec-add { right: 42px; }
.reclist > li > button.rec-add svg,
.reclist > li > button.rec-text svg { width: 16px; height: 16px; }
.reclist > li:hover > .rec-add, .reclist > li:hover > .rec-text,
.reclist > li:focus-within > .rec-add, .reclist > li:focus-within > .rec-text { opacity: 1; }
.reclist > li > button.rec-add:hover,
.reclist > li > button.rec-text:hover { color: var(--ink); border-color: var(--primary-2); }
@media (hover: none) { .reclist > li > button.rec-add, .reclist > li > button.rec-text { opacity: 1; } }

/* ------------------------------------------------------------ voicemail --- */
.reclist > li > button.rec-vm {
  width: auto; margin: -2px 0 6px 11px; padding: 4px 10px 4px 8px;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink-2); font-size: 12px; font-weight: 600;
}
.reclist > li > button.rec-vm svg { width: 12px; height: 12px; }
.reclist > li > button.rec-vm:hover { color: var(--ink); border-color: var(--primary-2); background: var(--surface-2); }
.rec-vm-len { font-family: var(--mono); font-weight: 500; color: var(--ink-3); }
.rec-vm-new > button.rec-vm { color: #FCD34D; border-color: rgba(245,181,68,.45); background: rgba(245,181,68,.10); }
.trs-audio { display: block; width: 100%; margin: 0 0 14px; }
.trs-audio[hidden] { display: none; }

/* Message shortcut beside the number in History. */
.h-text {
  width: 26px; height: 26px; padding: 0; margin-left: 8px; vertical-align: middle;
  display: inline-grid; place-items: center; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; color: var(--ink-3);
}
.h-text svg { width: 14px; height: 14px; }
.h-text:hover, .h-text:focus-visible { color: var(--ink); border-color: var(--primary-2); }
.h-call + .h-text { margin-left: 4px; }
.h-call:hover, .h-call:focus-visible { color: var(--live); border-color: var(--live); }

.numlink {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; color: inherit; text-align: left;
  border-bottom: 1px dashed transparent;
}
.numlink:hover, .numlink:focus-visible { color: var(--primary-2); border-bottom-color: var(--primary-2); }

.btn-link {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-size: 13px; color: var(--primary-2);
  border-bottom: 1px solid transparent;
}
.btn-link:hover, .btn-link:focus-visible { border-bottom-color: var(--primary-2); }

/* The saved transcript reads with the same speaker colours the live panel used
   during the call, so the record looks like the thing he was watching. */
#transcript-sheet { width: min(760px, calc(100vw - 32px)); }
.trs-head { align-items: flex-start; padding: 20px 22px 16px; }
.trs-heading { min-width: 0; margin-right: auto; }
.trs-kicker {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 3px;
}
.trs-head h3 { font-size: 20px; line-height: 1.25; margin: 0; overflow-wrap: anywhere; }
.trs-meta { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); }
.trs-state {
  align-self: center; flex: none; font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2);
}
.trs-state.is-final { color: var(--live); border-color: rgba(52,211,153,.35); background: rgba(52,211,153,.08); }
.trs-state.is-working { color: var(--warn); border-color: rgba(245,181,68,.35); background: rgba(245,181,68,.08); }
.trs-state.is-working::before {
  content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%;
  background: currentColor; vertical-align: 1px; animation: trs-pulse 1.2s ease-in-out infinite;
}
@keyframes trs-pulse { 50% { opacity: .25; } }

.trs-body { padding: 8px 22px 18px; max-height: min(68vh, 640px); background: var(--bg-raise); }
.trs-read { display: flex; flex-direction: column; }
.trs-note { margin: 14px 0 4px; font-size: 14px; color: var(--ink-2); }
.trs-turn {
  display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--line-soft);
}
.trs-turn:last-child { border-bottom: 0; }
.trs-av {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: #0B0B16; background: var(--live);
}
.trs-agent .trs-av { background: var(--primary-2); }
.trs-top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 3px; }
.trs-name { font-weight: 600; font-size: 14px; color: var(--ink); }
.trs-agent .trs-name { color: var(--primary-2); }
.trs-customer .trs-name { color: var(--live); }
.trs-time { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }
.trs-said { margin: 0; font-size: 15px; line-height: 1.6; color: var(--ink); overflow-wrap: anywhere; }
@media (max-width: 520px) {
  .trs-head, .trs-body { padding-left: 16px; padding-right: 16px; }
  .trs-turn { grid-template-columns: 28px minmax(0, 1fr); gap: 10px; }
  .trs-av { width: 28px; height: 28px; font-size: 12px; }
  .trs-said { font-size: 14.5px; }
}

/* ==========================================================================
   CONSOLE PASS
   Everything above builds the app correctly but draws it flat: one value for
   every surface, a 1px line around each, no direction of light. That reads as
   a competent dark template rather than a tool someone paid for. This block
   gives the app a material (a lit top edge, a graded face, a real shadow), one
   typographic voice for panel titles, and a layout that actually fills the
   page. It is appended rather than merged so it can be reviewed or removed in
   one piece.
   ========================================================================== */

:root {
  /* The face of every panel. Light falls from above, so the top of a surface
     is fractionally warmer than the bottom and carries a hairline highlight. */
  --panel:      linear-gradient(180deg, #14142B 0%, #0E0E1E 58%, #0C0C1A 100%);
  --panel-edge: inset 0 1px 0 rgba(255,255,255,.055);
  --panel-lift: 0 1px 2px rgba(0,0,0,.5), 0 18px 40px -14px rgba(0,0,0,.75);
  --sunk:       linear-gradient(180deg, #080813, #0A0A18);
  --r-lg: 18px;

  /* Was #8A8AA6, which fell under the readable line on small uppercase
     labels. Quiet is fine, faint is not. */
  --ink-3: #9797B4;
  --ink-4: #75758F;
}

/* A light source at the top of the page and a fine grain over the whole
   thing. The grain is barely perceptible on its own; without it large dark
   areas band on cheaper panels and look like plastic. */
body {
  background-image:
    radial-gradient(1100px 620px at 78% -18%, rgba(168,85,247,.16), transparent 64%),
    radial-gradient(760px 500px at 6% 106%, rgba(52,211,153,.055), transparent 62%),
    linear-gradient(180deg, rgba(255,255,255,.022), transparent 340px);
}
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: .5; mix-blend-mode: overlay;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="140" height="140"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.85" numOctaves="3"/><feColorMatrix type="saturate" values="0"/></filter><rect width="140" height="140" filter="url(%23n)" opacity="0.5"/></svg>');
}
#view-app, #view-login { position: relative; z-index: 1; }
@media (prefers-reduced-motion: no-preference) {
  .view.is-active { animation: view-in .22s ease both; }
}
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------- the material --- */
.dialer, .sidecar, .block, .panel-history, .panel-contacts,
.threads, .convo, .login-card, .stage-card {
  background: var(--panel);
  border-color: var(--line-soft);
  box-shadow: var(--panel-edge), var(--panel-lift);
}
.block, .panel-history, .panel-contacts, .threads, .convo { border-radius: var(--r-lg); }
.dialer, .sidecar { border-radius: 20px; }

/* Inputs are holes in the panel, so the light reverses: dark at the top. */
.field input, .field select, textarea, select, .input, .dial-input, .tbl input.notecell {
  background: var(--sunk);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.45);
}
.field input:focus, .field select:focus, textarea:focus, select:focus,
.input:focus, .dial-input:focus {
  box-shadow: inset 0 1px 2px rgba(0,0,0,.45), 0 0 0 3px rgba(168,85,247,.2);
}

/* ------------------------------------------------------------ header --- */
.topbar {
  padding: 14px 26px;
  background: linear-gradient(180deg, rgba(10,10,22,.92), rgba(6,6,14,.78));
  border-bottom: 1px solid rgba(255,255,255,.045);
  box-shadow: 0 1px 0 rgba(0,0,0,.5);
}
.brand-mark { width: 17px; height: 17px; border-radius: 5px; }
.brand-name { font-size: 15px; }

/* A segmented control instead of an underline strip. The active tab is a
   raised, lit surface so the eye reads it as the panel you are standing on. */
.tabs {
  gap: 3px; padding: 10px 26px; border-bottom: 1px solid rgba(255,255,255,.045);
  background: rgba(8,8,18,.5);
}
.tab {
  border-bottom: 0; border-radius: 10px; padding: 8px 15px; font-size: 13.5px;
  letter-spacing: .01em; transition: color .15s, background .15s, box-shadow .15s;
}
.tab:hover { background: rgba(255,255,255,.035); }
.tab.is-active {
  color: #fff; background: linear-gradient(180deg, rgba(168,85,247,.24), rgba(168,85,247,.09));
  box-shadow: inset 0 0 0 1px rgba(168,85,247,.38), inset 0 1px 0 rgba(255,255,255,.1),
              0 6px 18px -8px rgba(168,85,247,.7);
}
.workspace { padding: 24px 26px 40px; }

/* ------------------------------------------------------ panel titles --- */
/* The display face was declared and then used only in the logo. Panel titles
   are the one place it earns its keep: short, set solid, spaced like a label
   on equipment. It gives the app a voice no default stack has. */
.panel-head h2, .block .panel-head h2, .threads-head h2, .sidecar-h, .addform h3 {
  font-family: var(--display); font-weight: 400;
  text-transform: uppercase; letter-spacing: .13em; color: var(--ink);
}
.panel-head h2, .block .panel-head h2 { font-size: 13px; }
.addform h3 { font-size: 11.5px; color: var(--ink-2); }
.threads-head h2, .sidecar-h { font-size: 11px; color: var(--ink-2); }
.panel-head { align-items: center; gap: 14px; margin-bottom: 16px; }
/* A rule running out from the title to the controls, so a panel reads as a
   labelled section rather than some text sitting above a table. */
.panel-head::after {
  content: ''; height: 1px; flex: 1; order: 2; align-self: center;
  background: linear-gradient(90deg, var(--line), transparent);
}
.panel-head > :first-child { order: 1; }
.panel-head > * { order: 3; }
.panel-contacts .panel-head h2 { margin-right: 0; }

/* --------------------------------------------------------- dial pad --- */
/* The keypad is a fixed-size instrument: giving it half of a 1176px page left
   it floating in 350px of nothing. Pin it to its natural width and hand the
   rest to Recent, which is the part that rewards space. */
.panel-dial { grid-template-columns: 468px minmax(0, 1fr); gap: 24px; align-items: stretch; }
@media (max-width: 1040px) { .panel-dial { grid-template-columns: 1fr; } }
.dialer { max-width: none; padding: 24px; }
.sidecar { padding: 22px; display: flex; flex-direction: column; }
.reclist { max-height: none; flex: 1; }

.dial-input { font-size: 28px; padding: 18px 46px 18px 16px; }
.keypad { gap: 11px; }
.keypad button {
  background: linear-gradient(180deg, #1B1B33, #101020);
  border-color: rgba(255,255,255,.07); border-radius: 15px; padding: 14px 0 11px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), 0 2px 6px rgba(0,0,0,.4);
}
.keypad button:hover {
  background: linear-gradient(180deg, #24244A, #14142A);
  border-color: rgba(168,85,247,.55);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 0 0 3px rgba(168,85,247,.12);
}
.keypad b { font-size: 24px; }
.keypad i { color: var(--ink-4); }

/* Green still means call, but the stock mint read as a framework default.
   Deeper, lit from the top, with the glow pulled in tight. */
.btn-call {
  background: linear-gradient(180deg, #10B981 0%, #059669 52%, #04785C 100%);
  color: #03170F; padding: 16px; border-radius: 13px; letter-spacing: .02em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.26), 0 10px 26px -8px rgba(5,150,105,.75);
}
.btn-call:hover:not(:disabled) { filter: brightness(1.06); }
.btn-primary {
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 8px 22px -6px rgba(126,34,206,.62);
}

/* ------------------------------------------------------------ stats --- */
/* These are the only numbers on the screen. They were 21px in a faint box;
   at the width the sidecar now has they can carry the panel. */
.stats { gap: 12px; margin-bottom: 24px; }
.stat {
  background: var(--sunk); border-color: rgba(255,255,255,.055);
  border-radius: 14px; padding: 16px 12px; text-align: left;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.stat-n { font-family: var(--display); font-size: 30px; font-weight: 400; letter-spacing: -.02em; line-height: 1.05; }
.stat-l { font-size: 10px; letter-spacing: .12em; color: var(--ink-4); margin-top: 6px; }

/* ------------------------------------------------------------ table --- */
.tbl th {
  font-size: 10px; letter-spacing: .14em; color: var(--ink-4);
  border-bottom-color: var(--line);
}
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: rgba(168,85,247,.055); }

/* ------------------------------------------------------- small parts --- */
.rtc-pill { background: var(--sunk); box-shadow: inset 0 1px 0 rgba(255,255,255,.05); }
.iconbtn { background: var(--sunk); box-shadow: inset 0 1px 0 rgba(255,255,255,.05); }
.chip { font-weight: 600; letter-spacing: .03em; }
.estate-title { color: var(--ink); }
.estate-hint { color: var(--ink-2); }

/* The default scrollbar is a grey slab that announces the browser. */
* { scrollbar-width: thin; scrollbar-color: #2A2A4A transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #24243F; border: 3px solid transparent; background-clip: content-box; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #33335A; background-clip: content-box; }

@media (max-width: 720px) {
  .topbar, .tabs { padding-left: 16px; padding-right: 16px; }
  .workspace { padding: 18px 16px 32px; }
  .stat-n { font-size: 25px; }
}

/* ------------------------------------------------- filling the page --- */
/* Contacts and History are single panels. Sized to their content they sat as
   a short card on a tall black page, which is the thing that makes an app
   look unfinished. They now own the viewport the way Messages already did. */
.panel-contacts, .panel-history {
  min-height: calc(100dvh - 196px);
  display: flex; flex-direction: column;
}
.contacts-wrap, .panel-history .table-wrap { flex: 1; min-height: 0; }
@media (max-width: 860px) { .panel-contacts, .panel-history { min-height: 0; } }

/* -------------------------------------------------------- recent list --- */
/* Rows carry four facts each. Hairlines and a little more height let the eye
   land on one row at a time instead of reading it as a block of text. */
.reclist { gap: 0; }
.reclist > li + li { border-top: 1px solid var(--line-soft); }
.reclist > li > button { padding: 11px 10px; border-radius: 10px; }
.rec-who::before {
  font-family: var(--mono); font-weight: 700; font-size: 12px;
  display: inline-block; width: 13px; margin-right: 1px;
}
.rec-when, .rec-dur { color: var(--ink-4); text-align: right; }
.rec-dur { color: var(--ink-2); }

/* ----------------------------------------------------- call history --- */
/* Nine columns overflowed by 114px on a 1440 screen, almost all of it the
   Number cell stretched by a long line label. The label is a tag, not the
   data, so it gets a ceiling and an ellipsis; the full text is on the title. */
.line-tag {
  max-width: 92px; overflow: hidden; text-overflow: ellipsis;
  vertical-align: -3px;
}
#history-table td, #history-table th { padding-left: 9px; padding-right: 9px; }
#history-table { min-width: 0; }

/* Every finished call carried a filled green chip, so the one row that needs
   attention did not stand out. Completed is the normal case and reads quietly;
   colour is kept for the exceptions. */
.tbl .chip-ok { background: rgba(255,255,255,.05); color: var(--ink-2); box-shadow: inset 0 0 0 1px rgba(255,255,255,.07); }
.tbl .chip-bad { background: rgba(240,82,107,.13); color: #FDA4AF; box-shadow: inset 0 0 0 1px rgba(240,82,107,.3); }
.tbl .chip-warn { background: rgba(245,181,68,.13); color: #FCD34D; box-shadow: inset 0 0 0 1px rgba(245,181,68,.28); }
/* Last 48px: nine columns at 13.5px did not quite clear a 1440 screen, and a
   horizontal scrollbar under a table is the cheapest-looking thing in an app. */
#history-table { font-size: 13px; }
#history-table td, #history-table th { padding-left: 8px; padding-right: 8px; }
/* The notes box was a fixed 150px whatever room was left. It is the last
   column and the least urgent, so it gives up the final 20px. */
#history-table input.notecell { width: 128px; min-width: 0; }

/* -------------------------------------------------------- contacts --- */
/* The two flexible columns split the row evenly, which left the phone number
   stranded mid-row with 400px of nothing between it and the buttons. Only the
   name column should stretch; the number and the actions hug the right edge,
   so the row reads name ... number, actions with no dead zone. */
.contact { grid-template-columns: auto minmax(0, 1fr) auto auto; padding: 14px 12px; }
.contact-nums { justify-content: flex-end; }
.contact-acts { opacity: .45; }
@media (max-width: 860px) {
  .contact { grid-template-columns: auto minmax(0, 1fr); }
  .contact-nums { justify-content: flex-start; }
}

/* --------------------------------------------------------- bubbles --- */
/* Same light source as every other surface, kept to a hairline so an outbound
   message still reads as a message and not as a button. */
.bub-out { box-shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 2px 8px -3px rgba(0,0,0,.6); }
.bub-in  { border-color: rgba(255,255,255,.07); box-shadow: inset 0 1px 0 rgba(255,255,255,.04); }
.bub.is-mediaonly { box-shadow: none; }

/* History: the Number cell repeated the line name that the From column already
   shows, on every single row. Dropping the duplicate is what finally brings the
   table inside its panel at 1440 instead of shaving font sizes further. */
#history-table .line-tag { display: none; }

/* ---- channel marks -------------------------------------------------------
   WhatsApp and texts share a thread, so the channel has to be readable at a
   glance without becoming the loudest thing on the screen. The glyph is the
   WhatsApp green against this dark panel, held at one size and never used as a
   surface colour: a sent WhatsApp message stays the dialer's purple, because
   recolouring half the bubbles would turn one conversation into two. */
.ch-wa {
  display: inline-flex; vertical-align: -2px; margin-left: 5px;
  width: 13px; height: 13px; flex: 0 0 auto;
}
.ch-wa svg { width: 100%; height: 100%; fill: #3FC866; display: block; }

/* Named once at the head of a run. Reference, like the timestamp, so it reads
   at the same weight as the timestamp rather than competing with the words. */
.bub-ch {
  display: flex; align-items: center; gap: 1px;
  margin-bottom: 3px;
  font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  font-family: var(--mono);
  color: #3FC866;
}
.bub-ch .ch-wa { margin-left: 0; margin-right: 4px; }
.bub-out .bub-ch { color: #BFF3CE; justify-content: flex-end; }
.bub-out .bub-ch .ch-wa svg { fill: #BFF3CE; }

/* ---- which channel the reply takes --------------------------------------
   A quiet bar that only appears when there is genuinely a choice to make or a
   rule to explain. It sits above the composer, reads at metadata weight so it
   never competes with the message being written, and carries its own button
   rather than hiding the switch in a menu. */
.composer-ch {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 18px 0; border-top: 1px solid var(--line-soft);
}
.composer-ch[hidden] { display: none; }

.cch-now {
  display: inline-flex; align-items: center;
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2);
}
.cch-now .ch-wa { margin-left: 0; margin-right: 5px; }
.composer-ch.is-wa .cch-now { color: #3FC866; }

/* The reason, not a warning. It states the rule in the same breath as the
   countdown, because the countdown on its own means nothing to read. */
.cch-why { font-size: 12px; color: var(--ink-3); min-width: 0; }
.composer-ch.is-closed .cch-why { color: var(--ink-2); }

.cch-swap {
  margin-left: auto; flex: none; cursor: pointer;
  background: none; border: 1px solid var(--line); color: var(--ink-2);
  border-radius: 999px; padding: 4px 11px; font: inherit; font-size: 12px;
}
.cch-swap:hover { border-color: var(--primary); color: var(--ink); }

@media (max-width: 800px) {
  .composer-ch { padding: 9px 14px 0; gap: 6px 10px; }
  .cch-swap { margin-left: 0; }
}

/* ---- phones: the list, or a thread, never both ---------------------------
   The stacked layout capped the list at 244px and packed its header, search
   box and line picker into the same box, so the picker was crushed in half and
   the list showed one and a half rows, while an empty "No conversation open"
   pane took the rest of the screen. Now the list gets the whole screen and the
   page scrolls it naturally; opening a thread lays it over everything, full
   screen, sized to the visible area so the keyboard never covers the composer.
   z-index 60 is above the sticky top bar (40) and below the call screen (90),
   so an incoming call is never hidden behind a conversation. */
.convo-back { display: none; }
.lbl-short { display: none; }
#btn-alerts { white-space: nowrap; }

@media (max-width: 860px) {
  .msg-layout { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .threads { max-height: none; overflow: visible; }
  .threads > * { flex-shrink: 0; }
  .threadlist { overflow: visible; }

  .msg-layout:not(.is-reading) .convo { display: none; }
  .msg-layout.is-reading .threads { display: none; }
  .msg-layout.is-reading .convo {
    position: fixed; left: 0; right: 0;
    top: var(--vv-top, 0px); height: var(--vv-h, 100dvh);
    min-height: 0; z-index: 60;
    border: 0; border-radius: 0;
  }
  .msg-layout.is-reading .convo-live { height: 100%; }
  .msg-layout.is-reading .composer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  body.kb-open .msg-layout.is-reading .composer { padding-bottom: 10px; }
  .bubbles { overscroll-behavior: contain; }

  .convo-head { gap: 8px; }
  .convo-back {
    display: inline-grid; place-items: center; flex: none;
    width: 38px; height: 38px; margin-left: -8px;
    background: none; border: 0; border-radius: 10px; color: var(--ink); cursor: pointer;
  }
  .convo-back:active { background: var(--surface-2); }
  .convo-back svg { width: 22px; height: 22px; }
  .convo-head h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-width: 640px) {
  .lbl-long { display: none; }
  .lbl-short { display: inline; }
}

/* On a phone the name had room for two letters ("Sh...") and was squeezing the
   buttons next to it. It is plain text, and on your own phone it says nothing
   you do not know, so below 420px it steps aside. */
@media (max-width: 420px) { .whoami { display: none; } }
