/* The app is dark throughout: it sits next to a phone, mid-call, and should not glare. */

body { background: var(--black); color: var(--d-text); font-size: 16px; }

.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: var(--s4); height: 52px; padding: 0 var(--gutter);
  background: rgba(10, 10, 10, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--d-hairline);
}
.brand { font-family: var(--display); font-weight: 600; font-size: 17px; letter-spacing: -0.02em; }
.tabs { display: flex; gap: var(--s3); }
.tabs a { padding: var(--s2) 0; font-size: 13px; color: var(--d-muted); border-bottom: 1px solid transparent; transition: color 200ms var(--ease); }
.tabs a:hover { color: var(--d-text); }
.tabs a[aria-current='page'] { color: var(--d-text); border-bottom-color: var(--d-text); }
.lic { margin-left: auto; font-size: 12px; color: var(--d-dim); }

.banner { margin: 0; padding: 12px var(--gutter); background: var(--d-surface); border-bottom: 1px solid var(--d-hairline); font-size: 14px; line-height: 1.5; color: var(--d-text); }
.banner.warn { border-bottom-color: var(--accent); }

main { max-width: 760px; margin: 0 auto; padding: clamp(48px, 8vw, 96px) var(--gutter) var(--s12); }
.view h1 { font-size: clamp(2.5rem, 6vw, 4rem); }
.view-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); }
.sub { margin-top: var(--s2); max-width: 560px; color: var(--d-muted); line-height: 1.6; }
.saved { font-size: 13px; color: var(--d-dim); }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s3); margin-top: var(--s4); }
.hint { margin-top: var(--s1); font-size: 14px; line-height: 1.5; color: var(--d-muted); min-height: 1.5em; }

.nudge { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s1) var(--s3); margin-bottom: var(--s5); padding: 14px var(--s2); border: 1px solid var(--accent); border-radius: 12px; font-size: 15px; line-height: 1.45; color: var(--d-text); }
.nudge a { flex: none; font-weight: 500; color: var(--accent); transition: opacity 200ms var(--ease); }
.nudge a::after { content: ' ›'; }
.nudge a:hover { opacity: 0.75; }
.flash { margin-top: var(--s3); padding: var(--s2); border: 1px solid var(--d-hairline); border-radius: 12px; background: var(--d-surface); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.flash.error { border-color: var(--accent); }

/* ---- Forms ---- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); margin-top: var(--s5); }
.field { position: relative; display: block; }
.field > span { display: block; margin-bottom: var(--s1); font-size: 13px; line-height: 1.4; color: var(--d-muted); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 12px var(--s2);
  background: var(--d-surface); border: 1px solid var(--d-hairline); border-radius: 12px;
  font-size: 16px; line-height: 1.4; color: var(--d-text);
  transition: border-color 200ms var(--ease);
}
.field textarea { resize: vertical; display: block; }
.field select { appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23a1a1a6' stroke-width='1.5'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: #3a3a3d; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field [aria-invalid='true'] { border-color: var(--accent); }
.field input[data-limit] { padding-right: 64px; }
.count { position: absolute; right: var(--s2); top: 42px; font-style: normal; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--d-dim); pointer-events: none; }
.count.over { color: var(--accent); }
.group { margin-top: var(--s6); padding-top: var(--s3); border-top: 1px solid var(--d-hairline); font-size: 22px; }
.group + .basics { margin-top: var(--s3); }
.profile-status { margin-top: var(--s3); font-size: 14px; line-height: 1.5; color: var(--accent); }
.profile-status.done { color: var(--d-muted); }
.field-note { display: block; margin-top: 6px; font-size: 13px; line-height: 1.4; color: var(--d-dim); }
.field-msg { display: block; margin-top: 6px; font-size: 13px; line-height: 1.4; color: var(--accent); }

/* ---- Consent rule ---- */
.rule { margin-top: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--d-hairline); border-bottom: 1px solid var(--d-hairline); }
.rule-kind { font-family: var(--display); font-weight: 600; font-size: 22px; letter-spacing: -0.02em; line-height: 1.2; }
.rule-why { margin-top: 4px; font-size: 14px; line-height: 1.5; color: var(--d-muted); }
.rule-line { margin-top: var(--s2); font-size: 15px; line-height: 1.5; color: var(--d-text); }
.rule-line:empty { display: none; }

.source { margin: var(--s4) 0 0; padding: 0; border: 0; }
.source legend { padding: 0; margin-bottom: var(--s1); font-size: 13px; color: var(--d-muted); }
.radio { display: flex; gap: var(--s2); align-items: flex-start; padding: var(--s2) 0; border-top: 1px solid var(--d-hairline); cursor: pointer; }
.radio:last-child { border-bottom: 1px solid var(--d-hairline); }
.radio input { appearance: none; flex: none; width: 18px; height: 18px; margin: 3px 0 0; border: 1px solid #55555a; border-radius: 50%; transition: border-color 200ms var(--ease); }
.radio input:checked { border: 6px solid var(--d-text); }
.radio:hover input:not(:disabled) { border-color: var(--d-text); }
.radio b { display: block; font-weight: 500; font-size: 16px; line-height: 1.4; }
.radio small { display: block; font-size: 14px; line-height: 1.5; color: var(--d-muted); }
.radio:has(input:disabled) { cursor: not-allowed; }
.radio:has(input:disabled) b { color: var(--d-dim); }

/* ---- Sign in ---- */
.auth { display: grid; gap: var(--s2); max-width: 420px; margin-top: var(--s5); }
.auth .row { margin-top: var(--s1); }
.auth-more { margin-top: 0; }
.bar-link { min-height: 44px; padding: 0; background: none; border: 0; font-size: 13px; color: var(--d-muted); transition: color 200ms var(--ease); }
.bar-link:hover { color: var(--d-text); }
.bar-profile {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 32px; height: 32px; margin-left: var(--s2);
  border: 1px solid var(--d-hairline); border-radius: 50%; color: var(--d-muted);
  transition: color 200ms var(--ease), border-color 200ms var(--ease), transform 150ms var(--ease);
}
.bar-profile:hover, .bar-profile[aria-current='page'] { color: var(--d-text); border-color: var(--d-text); }
.bar-profile:active { transform: scale(0.95); }
.bar-profile + .bar-link { margin-left: var(--s2); }

/* ---- Listening minutes ---- */
.usage { margin-top: var(--s5); padding-top: var(--s3); border-top: 1px solid var(--d-hairline); }
.usage-line { font-family: var(--display); font-weight: 600; font-size: 22px; letter-spacing: -0.02em; line-height: 1.2; }
.usage.low .usage-line { color: var(--accent); }
.usage-bar { height: 4px; margin-top: var(--s2); border-radius: 2px; background: var(--d-hairline); overflow: hidden; }
.usage-bar i { display: block; height: 100%; border-radius: 2px; background: var(--d-text); }
.usage.low .usage-bar i { background: var(--accent); }
.usage-note { margin-top: var(--s1); font-size: 14px; line-height: 1.5; color: var(--d-muted); }

/* ---- Licence ---- */
.licence { margin-top: var(--s8); padding-top: var(--s4); border-top: 1px solid var(--d-hairline); }
.licence h2 { font-size: 28px; }
.licence > p { margin-top: var(--s1); max-width: 520px; color: var(--d-muted); line-height: 1.6; overflow-wrap: anywhere; }
.licence code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 13px; color: var(--d-text); }
.restore { display: grid; grid-template-columns: 1fr auto; gap: var(--s2); align-items: end; margin-top: var(--s4); }
.restore .btn { height: 48px; }
.restore .field-msg { grid-column: 1 / -1; margin: 0; }

/* ---- Playbook ---- */
.basics { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s2); margin-top: var(--s5); }
.entries { margin-top: var(--s5); }
.entry { padding: var(--s4) 0; border-top: 1px solid var(--d-hairline); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s2); }
.entry-head { display: flex; align-items: center; gap: var(--s2); }
.entry-key { flex: none; width: 28px; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--d-dim); }
.entry-name {
  flex: 1; min-width: 0; height: 44px; padding: 0; background: transparent; border: 0; border-bottom: 1px solid transparent; border-radius: 0;
  font-family: var(--display); font-weight: 600; font-size: 24px; letter-spacing: -0.02em; color: var(--d-text);
  transition: border-color 200ms var(--ease);
}
.entry-name:hover { border-bottom-color: #3a3a3d; }
.entry-name:focus-visible { outline: 0; border-bottom-color: var(--accent); }
.entry-del { min-height: 44px; padding: 0 var(--s1); background: none; border: 0; font-size: 13px; color: var(--d-dim); transition: color 200ms var(--ease); }
.entry-del:hover { color: var(--accent); }

.empty { margin-top: var(--s5); padding: var(--s8) 0; border-top: 1px solid var(--d-hairline); border-bottom: 1px solid var(--d-hairline); }
.empty h2 { font-size: 28px; }
.empty p { margin-top: var(--s1); max-width: 440px; color: var(--d-muted); line-height: 1.6; }

/* ---- Log ---- */
.table-wrap { margin-top: var(--s5); overflow-x: auto; border-top: 1px solid var(--d-hairline); }
table { width: 100%; border-collapse: collapse; font-size: 14px; white-space: nowrap; }
th, td { padding: 14px var(--s2) 14px 0; text-align: left; border-bottom: 1px solid var(--d-hairline); font-variant-numeric: tabular-nums; }
th { font-weight: 400; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--d-dim); }
td { color: var(--d-muted); }
td:first-child, td:nth-child(5) { color: var(--d-text); }

/* ---- Screen 4: the live call ---- */
.live {
  position: fixed; inset: 0; z-index: 100;
  display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: minmax(0, 1fr);
  background: var(--black); padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.live-bar { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--gutter); }
.live-state { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: var(--d-muted); }
.live-state i { width: 8px; height: 8px; border-radius: 50%; background: var(--d-dim); }
.live-state.on i { background: var(--accent); animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.live-meta { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--d-dim); }
.live-bar-actions { display: flex; gap: var(--s1); margin-left: auto; }
.live-bar .btn { min-height: 40px; padding: 0 var(--s2); font-size: 14px; }
.live-state { min-width: 0; }
.live-state span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Transcript on the left, the line to say in the middle. */
.live-body { display: grid; grid-template-columns: minmax(240px, 340px) minmax(0, 1fr); min-height: 0; border-top: 1px solid var(--d-hairline); }
.transcript { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: var(--s3) var(--s3) var(--s4) var(--gutter); border-right: 1px solid var(--d-hairline); scrollbar-width: thin; scrollbar-color: #2a2a2c transparent; }
.transcript h2 { font-family: var(--body); font-size: 12px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--d-dim); margin-bottom: var(--s2); }
.transcript ol { display: grid; gap: 12px; margin-top: auto; }
.transcript li { font-size: 15px; line-height: 1.45; color: var(--d-dim); overflow-wrap: anywhere; }
.transcript li:last-child { color: var(--d-text); }
.transcript li.interim { color: var(--d-muted); }
.transcript-empty { font-size: 14px; line-height: 1.45; color: var(--d-dim); }
.live-cue { container-type: inline-size; align-self: center; width: 100%; max-width: 860px; margin: 0 auto; padding: var(--s3) var(--gutter); }
/* The handled objection. Readable at a glance, but not a billboard. */
.live .cue-label { font-size: 13px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.live .cue-label:empty, .live .cue-heard:empty, .live .cue-then:empty { display: none; }
.live .cue-heard { margin-top: var(--s1); font-size: 18px; line-height: 1.45; color: var(--d-muted); overflow-wrap: anywhere; }
.live .cue-say {
  margin-top: var(--s3);
  font-family: var(--display); font-weight: 600; letter-spacing: -0.025em; line-height: 1.08;
  font-size: clamp(2rem, 7.4cqw, 4rem); color: #fff; text-wrap: balance; overflow-wrap: anywhere;
}
.live .cue-say.long { font-size: clamp(1.5rem, 4.8cqw, 2.5rem); line-height: 1.16; letter-spacing: -0.02em; }
/* Nothing to handle: a quiet status line, not a headline. */
.live .cue-say.idle { margin-top: 0; font-family: var(--body); font-weight: 400; letter-spacing: 0; font-size: 1.125rem; line-height: 1.5; color: var(--d-dim); }
.live .cue-then { margin-top: var(--s2); font-size: clamp(1rem, 2.2cqw, 1.1875rem); line-height: 1.45; color: var(--d-muted); }
.live .cue-rate { margin-top: var(--s3); }
.live-cue.swap > p, .live-cue.swap > .cue-rate { animation: rise 600ms var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(20px); } }
.live-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s5); }
.live-actions:empty { display: none; }
.live-actions .btn { min-height: 52px; font-size: 16px; }

.live-foot { padding: 0 var(--gutter) var(--s3); }
.live .tail {
  display: flex; justify-content: flex-end; overflow: hidden; white-space: nowrap; min-height: 1.7em;
  font-size: 15px; color: var(--d-dim);
  -webkit-mask-image: linear-gradient(to right, transparent, #000 40%); mask-image: linear-gradient(to right, transparent, #000 40%);
}
.keys { display: flex; gap: var(--s1); margin-top: var(--s2); padding-top: var(--s2); border-top: 1px solid var(--d-hairline); overflow-x: auto; scrollbar-width: none; }
.keys::-webkit-scrollbar { display: none; }
.keys:empty { display: none; }
.keys button {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; white-space: nowrap;
  background: transparent; border: 1px solid transparent; border-radius: 999px; font-size: 13px; color: var(--d-muted);
  transition: color 200ms var(--ease), border-color 200ms var(--ease);
}
.keys button:hover { color: var(--d-text); border-color: #3a3a3d; }
.keys button:active { transform: scale(0.97); }
.keys button[disabled] { opacity: 0.35; cursor: not-allowed; }

@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
  .bar { gap: var(--s2); }
  .bar .brand { font-size: 15px; white-space: nowrap; }
  .tabs { gap: var(--s2); }
  .lic { display: none; }
  .restore { grid-template-columns: 1fr; }
  .row .btn { width: 100%; }
  .live-actions .btn { width: 100%; }
  .live-meta { display: none; }
  /* Phone: status on the first row, the three buttons on a row of their own. */
  .live-bar { flex-wrap: wrap; row-gap: var(--s1); }
  .live-bar-actions { width: 100%; margin-left: 0; }
  .live-bar-actions .btn { flex: 1; padding: 0 var(--s1); }
  .live-bar-actions .btn kbd { display: none; }
  /* Phone: the line stays on top, the transcript sits underneath it. */
  .live-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 32vh); }
  .live-cue { order: 1; }
  .transcript { order: 2; padding: var(--s2) var(--gutter) var(--s3); border-right: 0; border-top: 1px solid var(--d-hairline); }
}
