:root {
  color-scheme: light;
  --bg: #f7f6f1;
  --surface: #ffffff;
  --surface-soft: #fbfaf6;
  --ink: #17211f;
  --muted: #64716d;
  --line: #ddd8cb;
  --line-soft: #ebe6da;
  --green: #0d7662;
  --green-dark: #095846;
  --blue: #2f5e9f;
  --amber: #b56f14;
  --red: #b52a20;
  --ok-bg: #e8f4ee;
  --warn-bg: #fff3d6;
  --bad-bg: #fae5e1;
  --shadow: 0 12px 34px rgba(28, 35, 32, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(13, 118, 98, 0.08), transparent 280px),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button,
.button-link {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 16px;
  background: var(--green);
  color: #fff;
  font-weight: 760;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

button:hover,
.button-link:hover {
  background: var(--green-dark);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.secondary {
  background: var(--blue);
}

.secondary:hover {
  background: #244b80;
}

.danger {
  background: var(--red);
}

.danger:hover {
  background: #8f1e17;
}

.ghost {
  background: transparent;
  color: var(--green-dark);
  border-color: var(--line);
}

.ghost:hover {
  background: #f0eee7;
}

a {
  color: var(--green-dark);
}

.topbar {
  min-height: 62px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(247, 246, 241, 0.9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
}

.brand {
  color: var(--ink);
  font-weight: 850;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--green) 0 55%, #d49733 55% 72%, var(--blue) 72%);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topnav a {
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.app-shell {
  width: min(1160px, calc(100vw - 32px));
  margin: 28px auto 52px;
}

.view {
  width: 100%;
}

.narrow {
  max-width: 760px;
  margin: 0 auto;
}

.auth-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
  align-items: start;
}

.intro-panel,
.panel,
.work-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.intro-panel {
  padding: 26px;
}

.intro-panel h1 {
  margin: 0;
  max-width: 720px;
  font-size: clamp(2.2rem, 5.4vw, 4.3rem);
  line-height: 1;
  letter-spacing: 0;
}

.intro-copy {
  max-width: 610px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.55;
  font-weight: 600;
}

.studio-visual {
  margin-top: 24px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 16px;
}

.wave-bars {
  height: 92px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.wave-bars span {
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(180deg, #d89a34, var(--green));
  opacity: 0.9;
}

.wave-bars span:nth-child(1) { height: 30px; }
.wave-bars span:nth-child(2) { height: 58px; }
.wave-bars span:nth-child(3) { height: 42px; }
.wave-bars span:nth-child(4) { height: 82px; }
.wave-bars span:nth-child(5) { height: 48px; }
.wave-bars span:nth-child(6) { height: 68px; }
.wave-bars span:nth-child(7) { height: 34px; }

.language-grid,
.pilot-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.language-grid {
  margin-top: 14px;
}

.language-grid span,
.pilot-strip span {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: #fff;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 720;
}

.pilot-strip {
  margin-top: 16px;
}

.panel,
.work-panel {
  padding: 22px;
}

.access-card,
.code-card {
  background: rgba(255, 255, 255, 0.96);
}

.code-card {
  grid-column: 2;
}

.compact {
  padding: 16px;
  box-shadow: none;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow.invert {
  color: var(--muted);
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.08;
}

h1 {
  font-size: clamp(1.75rem, 4.8vw, 3rem);
}

h2 {
  font-size: clamp(1.3rem, 3vw, 1.8rem);
}

.form-stack,
.profile-grid {
  margin-top: 22px;
  display: grid;
  gap: 14px;
}

.profile-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.profile-span {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

input:focus,
select:focus {
  outline: 3px solid rgba(13, 118, 98, 0.16);
  border-color: var(--green);
}

.check-row {
  display: grid;
  grid-template-columns: 19px minmax(0, 1fr);
  align-items: start;
  color: var(--ink);
  font-weight: 650;
}

.check-row input {
  width: 17px;
  min-height: 17px;
  margin-top: 2px;
}

.consent-copy {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  color: var(--muted);
  line-height: 1.55;
}

.consent-copy p {
  margin: 0;
}

.notice {
  color: var(--green-dark);
  font-weight: 750;
  line-height: 1.4;
}

.recorder-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

.side-stack {
  display: grid;
  gap: 14px;
}

.recorder-panel {
  min-width: 0;
}

.prompt-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

#promptText {
  max-width: 840px;
  font-size: clamp(1.45rem, 3.4vw, 2.35rem);
  line-height: 1.18;
}

.waveform-frame {
  margin: 22px 0;
  border: 1px solid #1f302c;
  border-radius: 8px;
  padding: 8px;
  background: #13231f;
}

.waveform {
  width: 100%;
  height: 164px;
  display: block;
  border-radius: 6px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    #10201d;
  background-size: 28px 28px;
}

.recorder-controls {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
}

.timer {
  margin-left: auto;
  color: var(--green-dark);
  font-size: 1.25rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.playback {
  width: 100%;
  margin-top: 16px;
}

.qc-status {
  margin-top: 12px;
  padding: 11px 12px;
  border-radius: 7px;
  background: var(--ok-bg);
  color: var(--green-dark);
  font-weight: 780;
}

.qc-status.warn {
  background: var(--warn-bg);
  color: #805008;
}

.qc-status.fail {
  background: var(--bad-bg);
  color: var(--red);
}

.qc-list {
  display: grid;
  gap: 7px;
  padding: 0;
  margin: 12px 0 0;
  list-style: none;
}

.qc-list li {
  border-left: 3px solid var(--amber);
  padding: 7px 9px;
  border-radius: 6px;
  background: #fff7e5;
  color: #5d3b09;
  font-size: 0.9rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 12px;
}

.metric-grid.wide {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric-grid > div {
  min-height: 68px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: var(--surface-soft);
  padding: 11px;
  display: grid;
  align-content: center;
}

.metric-grid span {
  font-size: 1.36rem;
  line-height: 1;
  font-weight: 850;
}

.metric-grid small {
  margin-top: 6px;
  color: var(--muted);
  font-weight: 700;
}

.progress-shell {
  margin-top: 14px;
  height: 10px;
  border-radius: 999px;
  background: #e9e4d8;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), #d49733);
  transition: width 180ms ease;
}

.batch-status {
  margin: 11px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.speaker-list {
  margin: 12px 0 0;
  display: grid;
  gap: 9px;
}

.speaker-list div {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 8px;
}

.speaker-list dt {
  color: var(--muted);
  font-weight: 700;
}

.speaker-list dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 750;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px));
  border-radius: 8px;
  padding: 12px 16px;
  background: #14211e;
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 30;
}

.admin-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.admin-hero {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.admin-key-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.admin-key-form input {
  min-width: 250px;
}

.export-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0;
}

.admin-section {
  margin-top: 22px;
}

.admin-section h2 {
  margin-bottom: 12px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  font-size: 0.91rem;
}

td .small {
  display: block;
  max-width: 360px;
  margin-top: 4px;
  color: var(--muted);
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.table-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.84rem;
}

.status-pill {
  min-height: 27px;
  border-radius: 999px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  background: var(--ok-bg);
  color: var(--green-dark);
  font-weight: 780;
  white-space: nowrap;
}

.status-pill.rejected,
.status-pill.failed_qc,
.status-pill.audit_rejected {
  background: var(--bad-bg);
  color: var(--red);
}

.status-pill.review,
.status-pill.pending_audit {
  background: var(--warn-bg);
  color: #805008;
}

.status-pill.payable,
.status-pill.accepted,
.status-pill.audit_accepted,
.status-pill.paid {
  background: var(--ok-bg);
  color: var(--green-dark);
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .topbar {
    padding: 0 16px;
  }

  .app-shell {
    width: min(100vw - 24px, 780px);
    margin-top: 18px;
  }

  .auth-stage,
  .recorder-grid,
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .code-card {
    grid-column: auto;
  }

  .intro-panel,
  .panel,
  .work-panel {
    padding: 18px;
  }

  .intro-panel h1 {
    font-size: clamp(2rem, 10vw, 3.3rem);
  }

  .prompt-head,
  .admin-head {
    display: grid;
  }

  .metric-grid.wide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timer {
    width: 100%;
    margin-left: 0;
  }

  .admin-key-form {
    width: 100%;
  }

  .admin-key-form input {
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .brand {
    font-size: 0.95rem;
  }

  .topnav {
    gap: 8px;
  }

  .studio-visual {
    padding: 12px;
  }

  .wave-bars {
    height: 72px;
  }

  .recorder-controls button {
    flex: 1 1 calc(50% - 8px);
  }
}
