:root {
  color-scheme: dark;
  --bg: #0a0c10;
  --surface: #12151c;
  --surface-2: #171b24;
  --border: #242a36;
  --text: #e6e9ef;
  --muted: #8b95a7;
  --dim: #5d6779;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --good: #3fcf8e;
  --warn: #f2b544;
  --bad: #f2627a;
  --radius: 12px;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(1100px 600px at 15% -10%, rgba(91, 140, 255, 0.11), transparent 60%),
    radial-gradient(900px 500px at 95% 0%, rgba(63, 207, 142, 0.07), transparent 55%), var(--bg);
  color: var(--text);
  font:
    15px/1.55 ui-sans-serif,
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
  min-height: 100vh;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(10, 12, 16, 0.78);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #8f6bff 55%, var(--good));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  flex: none;
}

.brand h1 {
  font-size: 16px;
  margin: 0;
  letter-spacing: -0.01em;
}

.brand p {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.dev-fast-banner {
  padding: 10px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid rgba(242, 181, 68, 0.35);
  background: rgba(242, 181, 68, 0.12);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.dev-fast-banner[hidden] {
  display: none;
}

.dev-fast-banner strong {
  color: var(--warn);
  font-weight: 600;
}

.dev-fast-banner code {
  font-family: var(--mono);
  font-size: 12px;
}

.conn {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px 5px 22px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  position: relative;
  white-space: nowrap;
}

.conn::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 50%;
  translate: 0 -50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dim);
}

.conn[data-state='online'] {
  color: var(--good);
  border-color: rgba(63, 207, 142, 0.35);
}
.conn[data-state='online']::before {
  background: var(--good);
  box-shadow: 0 0 0 3px rgba(63, 207, 142, 0.18);
}
.conn[data-state='recording'] {
  color: var(--bad);
  border-color: rgba(242, 98, 122, 0.4);
}
.conn[data-state='recording']::before {
  background: var(--bad);
  animation: pulse 1.3s ease-in-out infinite;
}
.conn[data-state='error'] {
  color: var(--bad);
}
.conn[data-state='error']::before {
  background: var(--bad);
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

.link {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.link:hover {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ---------- layout ---------- */

main {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(300px, 380px) 1fr;
  grid-template-areas:
    'setup transcripts'
    'record transcripts'
    'events transcripts';
  align-items: start;
  padding: 22px clamp(16px, 4vw, 40px) 12px;
  max-width: 1500px;
  margin: 0 auto;
}

.setup {
  grid-area: setup;
}
.record {
  grid-area: record;
}
.events {
  grid-area: events;
}
.transcripts {
  grid-area: transcripts;
  min-height: 560px;
  display: flex;
  flex-direction: column;
}

@media (max-width: 1000px) {
  main {
    grid-template-columns: 1fr;
    grid-template-areas:
      'setup'
      'record'
      'transcripts'
      'events';
  }
  .transcripts {
    min-height: 380px;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.hint {
  color: var(--muted);
  font-size: 12.5px;
  margin: 6px 0 14px;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
}

/* ---------- form ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

/* Author `display: flex` would otherwise override the HTML `hidden` attribute. */
.field[hidden] {
  display: none !important;
}

.field label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 550;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
}

.field-row .field {
  flex: 1 1 130px;
}

.field.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex: 1 1 100%;
  margin-bottom: 8px;
}

.field.checkbox label {
  color: var(--text);
  font-size: 13px;
}

.field.checkbox small {
  color: var(--dim);
  font-weight: 400;
}

input[type='password'],
input[type='text'],
input[type='url'],
input[type='number'],
select {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  padding: 9px 11px;
  width: 100%;
}

input[type='password'] {
  font-family: var(--mono);
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input[type='checkbox'] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.btn {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 16px;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    opacity 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover:not(:disabled) {
  border-color: #333c4c;
  background: #1c212c;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06090f;
}

.btn.primary:hover:not(:disabled) {
  background: #7ba1ff;
  border-color: #7ba1ff;
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  font-size: 12px;
  padding: 6px 11px;
}

.capture-mode {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.capture-mode-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 550;
  margin-bottom: 8px;
}

.mode-toggle {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.mode-btn {
  flex: 1 1 120px;
  justify-content: center;
  background: var(--bg);
}

.mode-btn.active {
  background: var(--accent-soft);
  border-color: rgba(91, 140, 255, 0.45);
  color: var(--accent);
}

.capture-separate {
  margin-bottom: 4px;
}

.capture-separate[data-disabled='true'] {
  opacity: 0.45;
}

.speaker-count {
  margin-top: 10px;
  margin-bottom: 4px;
}

.speaker-count[data-disabled='true'] {
  opacity: 0.45;
}

.speaker-count-hint {
  margin: 6px 0 0;
}

.capture-mode-hint {
  margin: 8px 0 0;
}

.session-row {
  margin-top: 12px;
  align-items: end;
}

.session-row .field-actions {
  display: flex;
  align-items: end;
  padding-bottom: 2px;
}

.mic-hint {
  margin: 4px 0 0;
  font-size: 12px;
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
}

.record-btn {
  flex: none;
}

.record-btn .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bad);
  flex: none;
}

.record-btn[data-recording='true'] {
  border-color: rgba(242, 98, 122, 0.5);
  background: rgba(242, 98, 122, 0.12);
}

.record-btn[data-recording='true'] .dot {
  animation: pulse 1.1s ease-in-out infinite;
}

.btn.danger {
  border-color: rgba(242, 98, 122, 0.45);
  color: #ffc0cb;
  background: rgba(242, 98, 122, 0.1);
}

.btn.danger:hover:not(:disabled) {
  background: rgba(242, 98, 122, 0.2);
}

.paused-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: #1a1408;
  background: var(--warn);
}

.meter {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  border: 1px solid var(--border);
}

.meter-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--good), var(--accent));
  transition: width 90ms linear;
}

/* ---------- stats ---------- */

.stats,
.tenant {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 10px;
  margin: 0;
}

.stats > div,
.tenant > div {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  min-width: 0;
}

.stats dt,
.tenant dt {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dim);
  margin-bottom: 3px;
}

.stats dd,
.tenant dd {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tenant {
  margin-top: 14px;
}

/* ---------- transcripts ---------- */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: -4px -4px 14px;
  padding: 0 4px;
}

.tab {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 9px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--dim);
}

.tab-badge[data-kind='live'],
.tab-badge[data-kind='recording'] {
  color: var(--good);
  border-color: rgba(63, 207, 142, 0.4);
  background: rgba(63, 207, 142, 0.1);
}

.tab-badge[data-kind='draft'] {
  color: var(--warn);
  border-color: rgba(242, 181, 68, 0.4);
  background: rgba(242, 181, 68, 0.1);
}

.tab-badge[data-kind='awaiting'] {
  color: var(--accent);
  border-color: rgba(91, 140, 255, 0.4);
  background: rgba(91, 140, 255, 0.1);
}

.tab-badge[data-kind='ready'] {
  color: var(--good);
  border-color: rgba(63, 207, 142, 0.4);
  background: rgba(63, 207, 142, 0.1);
}

.tab-badge[data-kind='failed'] {
  color: var(--bad);
  border-color: rgba(242, 98, 122, 0.4);
  background: rgba(242, 98, 122, 0.1);
}

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

/* Distinct surfaces so switching tabs is not “the same panel twice”. */
.pane-live .transcript {
  border-left: 3px solid rgba(242, 181, 68, 0.45);
  padding-left: 10px;
  background: linear-gradient(180deg, rgba(242, 181, 68, 0.04), transparent 48px);
}

.pane-final .transcript {
  border-left: 3px solid rgba(91, 140, 255, 0.5);
  padding-left: 10px;
  background: linear-gradient(180deg, rgba(91, 140, 255, 0.05), transparent 48px);
}

.source-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--muted);
}

.source-pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  flex: none;
}

.source-pill[data-source='realtime'] {
  color: var(--warn);
  border: 1px solid rgba(242, 181, 68, 0.4);
  background: rgba(242, 181, 68, 0.1);
}

.source-pill[data-source='canonical'] {
  color: var(--accent);
  border: 1px solid rgba(91, 140, 255, 0.4);
  background: rgba(91, 140, 255, 0.1);
}

.source-status {
  min-width: 0;
  line-height: 1.4;
}

.source-bar[data-phase='recording'] .source-status,
.source-bar[data-phase='live'] .source-status {
  color: var(--good);
}

.source-bar[data-phase='draft'] .source-status {
  color: var(--warn);
}

.source-bar[data-phase='awaiting'] .source-status {
  color: var(--accent);
}

.source-bar[data-phase='ready'] .source-status {
  color: var(--text);
}

.source-bar[data-phase='failed'] .source-status {
  color: var(--bad);
}

.draft-banner {
  font-size: 12px;
  font-weight: 600;
  color: var(--warn);
  border: 1px solid rgba(242, 181, 68, 0.35);
  background: rgba(242, 181, 68, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
}

.rascunho-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--warn);
  border: 1px solid rgba(242, 181, 68, 0.35);
  border-radius: 999px;
  padding: 1px 6px;
  margin-right: 8px;
  vertical-align: 1px;
}

.transcript {
  flex: 1;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.7;
  padding-right: 6px;
  min-height: 200px;
}

.empty {
  color: var(--dim);
  font-size: 13px;
  max-width: 62ch;
}

.committed {
  color: var(--text);
}

.partial {
  color: var(--dim);
  font-style: italic;
}

.seg-final {
  display: flex;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(36, 42, 54, 0.6);
}

.seg-final:last-child {
  border-bottom: none;
}

.seg-time {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--dim);
  padding-top: 3px;
  flex: none;
  width: 58px;
}

.seg-body {
  min-width: 0;
}

.speaker {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 7px;
  border-radius: 999px;
  margin-right: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(91, 140, 255, 0.3);
  vertical-align: 1px;
}

/* Marks a speaker label that was just applied retroactively, so the correction reads as a
   change rather than appearing silently. */
.speaker-new {
  animation: speaker-in 1.6s ease-out;
}

@keyframes speaker-in {
  0% {
    transform: scale(0.82);
    box-shadow: 0 0 0 0 rgba(91, 140, 255, 0.55);
  }
  35% {
    transform: scale(1.06);
    box-shadow: 0 0 0 6px rgba(91, 140, 255, 0);
  }
  100% {
    transform: scale(1);
  }
}

.speaker[data-speaker$='1'] {
  background: rgba(63, 207, 142, 0.14);
  color: var(--good);
  border-color: rgba(63, 207, 142, 0.3);
}

.speaker[data-speaker$='2'] {
  background: rgba(242, 181, 68, 0.14);
  color: var(--warn);
  border-color: rgba(242, 181, 68, 0.3);
}

.speaker[data-speaker$='3'] {
  background: rgba(242, 98, 122, 0.14);
  color: var(--bad);
  border-color: rgba(242, 98, 122, 0.32);
}

.final-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 12px;
  color: var(--muted);
  padding: 0 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.final-summary b {
  color: var(--text);
  font-weight: 600;
}

.final-actions {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  flex-wrap: wrap;
}

.notice {
  font-size: 12.5px;
  border-radius: 8px;
  padding: 9px 11px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
}

.notice.warn {
  border-color: rgba(242, 181, 68, 0.35);
  color: var(--warn);
  background: rgba(242, 181, 68, 0.07);
}

/* ---------- log ---------- */

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 230px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
}

.log li {
  display: flex;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(36, 42, 54, 0.5);
  word-break: break-word;
}

.log time {
  color: var(--dim);
  flex: none;
}

.log .lvl {
  flex: none;
  width: 42px;
  font-weight: 700;
}

.log .info .lvl {
  color: var(--accent);
}
.log .ok .lvl {
  color: var(--good);
}
.log .warn .lvl {
  color: var(--warn);
}
.log .err .lvl {
  color: var(--bad);
}

footer {
  padding: 14px clamp(16px, 4vw, 40px) 30px;
  max-width: 1500px;
  margin: 0 auto;
  color: var(--dim);
  font-size: 12px;
}

footer code {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0;
}

/* Shows what the engine is doing, because a live tier that has fallen behind looks exactly
   like one that is broken. */
.engine-state {
  font-size: 12px;
  font-weight: 600;
}

.engine-state[data-state='waiting'] {
  color: var(--muted);
}

.engine-state[data-state='live'] {
  color: var(--ok, #3fcf8e);
}

.engine-state[data-state='behind'] {
  color: var(--warn, #e0a34a);
}

/* Inline help under each setting: the panel is where someone decides what a value should be, so
   the explanation belongs next to the input rather than in a document they have not opened. */
.field-help {
  margin: 2px 0 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.field-help code {
  font-size: 11px;
}

/* Each setting is its own column: label, help, then that field's input.
   Naked number inputs are inline, so without this they sit beside the next label. */
.settings fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 8px 0 16px;
  padding: 4px 14px 10px;
  min-width: 0;
}

.settings legend {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 6px;
}

.settings .field {
  width: 100%;
  min-width: 0;
}

.settings .field label small,
.settings .check small {
  color: var(--dim);
  font-weight: 400;
}

.settings .check {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  color: var(--text);
  font-size: 13.5px;
}

.settings .check input {
  margin-top: 3px;
  flex: none;
}

/* Says whether a limit is this tenant's or the server's. A filled input hides its placeholder, so
   the distinction needs somewhere of its own to live. */
.source {
  margin-left: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 999px;
  vertical-align: 1px;
}

.source[data-source='inherited'] {
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.source[data-source='override'] {
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(91, 140, 255, 0.3);
}

/* Live transcript rows, deliberately the same shape as the canonical list: seeing utterances
   arrive one at a time is what tells you the engine is still working. */
.seg-live {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.seg-live:last-child {
  border-bottom: none;
}

/* The in-flight partial: present so there is feedback between commits, greyed so it is obviously
   not final text. */
.seg-live.draft .seg-body {
  color: var(--muted);
  font-style: italic;
}
