:root {
  color-scheme: light;
  --ink: #18212b;
  --muted: #5f6b78;
  --paper: #ffffff;
  --surface: #f6f7f9;
  --surface-strong: #eef1f4;
  --line: #d9dee5;
  --line-strong: #b8c1cc;
  --blue: #1769c2;
  --blue-dark: #12559e;
  --blue-pale: #eaf2fb;
  --green: #28784b;
  --green-dark: #1f623d;
  --green-pale: #eaf5ee;
  --amber: #865b16;
  --red: #a43636;
  --red-pale: #fff0f0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
}
button, input { font: inherit; }
button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 6px 11px;
  cursor: pointer;
  font-weight: 600;
}
button:disabled { cursor: wait; opacity: .62; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.app-main:focus { outline: none; }

.skip-link {
  position: fixed;
  left: 8px;
  top: -80px;
  z-index: 100;
  border-radius: 4px;
  background: var(--ink);
  color: white;
  padding: 8px 12px;
}
.skip-link:focus { top: 8px; }

.top-bar {
  height: 46px;
  flex: 0 0 46px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.brand {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 3px 4px 3px 0;
  white-space: nowrap;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 4px;
  background: var(--blue);
  color: white;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: -.03em;
}
.brand strong { font-size: 13px; line-height: 1; }
.environment {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  padding: 3px 7px;
  font-size: 11px;
  line-height: 18px;
  white-space: nowrap;
}
.top-bar__future { flex: 1 1 auto; min-width: 8px; }
.session-controls { display: flex; align-items: center; gap: 7px; min-width: 0; }
.session-label { color: var(--muted); font-size: 11px; white-space: nowrap; }
.session-controls .secondary { min-height: 30px; padding: 4px 9px; }

.app-layout { flex: 1 1 auto; min-width: 0; min-height: 0; }
.app-layout.is-authenticated { display: grid; grid-template-columns: 176px minmax(0, 1fr); }
.app-nav {
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 8px;
}
.nav-menu-toggle { display: none; }
.nav-items { display: grid; gap: 2px; }
.nav-item {
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border-color: transparent;
  background: transparent;
  color: #354252;
  text-align: left;
}
.nav-item:hover { background: var(--surface-strong); }
.nav-item.is-selected { border-color: #cbdcf0; background: var(--blue-pale); color: #0f4f91; }

.app-main { min-width: 0; }
.app-main--gate {
  width: 100%;
  min-height: calc(100vh - 83px);
  display: grid;
  place-items: start center;
  padding: clamp(42px, 11vh, 100px) 16px 40px;
  background: var(--surface);
}
.app-main--workspace {
  width: 100%;
  max-width: 1380px;
  padding: 20px 24px 48px;
  background: #fff;
}

.auth-panel {
  width: min(360px, 100%);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 20px;
  box-shadow: 0 2px 7px rgb(26 43 61 / 6%);
}
.auth-panel h1, .utility-view h1 {
  margin: 0;
  font-size: 18px;
  line-height: 24px;
  font-weight: 650;
  letter-spacing: -.01em;
}
.auth-copy { margin: 5px 0 16px; color: var(--muted); line-height: 19px; }
.auth-panel form { display: grid; gap: 12px; }
.auth-panel label { display: grid; gap: 5px; font-size: 12px; font-weight: 650; }
.auth-panel input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 7px 9px;
  background: white;
  color: var(--ink);
}
.auth-panel input:focus { border-color: var(--blue); }
.sign-in-submit { width: 100%; margin-top: 2px; }
.auth-link {
  min-height: 28px;
  justify-self: center;
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 3px 6px;
  font-weight: 600;
}
.auth-link:hover { color: var(--blue-dark); text-decoration: underline; }
.password-policy { margin: -6px 0 0; color: var(--muted); font-size: 11px; line-height: 16px; }
.form-status:empty { display: none; }
.inline-message { margin: 0; color: var(--muted); font-size: 12px; line-height: 17px; }
.inline-message--error { color: var(--red); }
.inline-message--success { color: var(--green); }
.auth-boundary {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 16px;
}
.auth-status, .workspace-loading { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.auth-actions { margin-top: 16px; }

.primary { border-color: var(--blue); background: var(--blue); color: white; }
.primary:hover { border-color: var(--blue-dark); background: var(--blue-dark); }
.secondary { border-color: var(--line); background: white; color: #2f3c4b; }
.secondary:hover { background: var(--surface); }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.workspace-loading { padding: 24px 0; }
.spinner {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border: 2px solid #cad2dc;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.utility-view, .recordings { width: 100%; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 45px;
  margin-bottom: 16px;
}
.section-head h1 {
  margin: 0;
  font-size: 19px;
  line-height: 25px;
  font-weight: 650;
  letter-spacing: -.01em;
}
.section-copy {
  margin: 2px 0 0;
  color: var(--muted);
  line-height: 18px;
}
.workspace-badge, .compact-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.workspace-badge--success {
  border-color: #c7e0d2;
  background: var(--green-pale);
  color: var(--green-dark);
}
.workspace-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
}
.panel-heading {
  min-height: 57px;
  display: flex;
  align-items: center;
  padding: 10px 13px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.panel-heading h2 {
  margin: 0;
  font-size: 13px;
  line-height: 18px;
  font-weight: 650;
}
.panel-heading p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 16px;
}
.conversation-panel { min-height: 360px; }
.conversation-panel .empty-state { border: 0; }
.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.details-list { margin: 0; }
.details-list > div {
  display: grid;
  grid-template-columns: 145px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--line);
}
.details-list > div:last-child { border-bottom: 0; }
.details-list dt { color: var(--muted); }
.details-list dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.capability-block { margin-top: 12px; }
.capability-block ul {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 12px 13px;
  list-style: none;
}
.capability-block li {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: #465363;
  padding: 4px 8px;
  font-size: 11px;
}
.quiet-boundary {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.muted { color: var(--muted); line-height: 1.45; }
.recording-notice {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  line-height: 16px;
}
.recording-notice strong { color: #3e4b59; font-weight: 650; white-space: nowrap; }
.recording-grid {
  display: grid;
  grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}
.capture-card { padding: 14px; }
.consent-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0;
  color: #354252;
  font-size: 12px;
  font-weight: 550;
  line-height: 18px;
}
.consent-check input { width: 16px; height: 16px; margin: 1px 0 0; flex: 0 0 auto; accent-color: var(--blue); }
.capture-actions { margin-top: 15px; }
.capture-actions .primary { width: 100%; }
.capture-hint { margin: 9px 0 0; color: var(--muted); font-size: 11px; line-height: 16px; }
.capture-state-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.recording-live { display: flex; align-items: center; gap: 9px; }
.recording-live span { display: block; color: var(--red); font-weight: 800; }
.recording-time { margin-top: 2px; font-size: 20px; line-height: 24px; font-variant-numeric: tabular-nums; }
.recording-dot { width: 9px; aspect-ratio: 1; border-radius: 50%; background: var(--red); animation: pulse 1.25s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.recording-audio { display: block; width: 100%; height: 36px; margin-top: 12px; }
.recording-library { min-height: 238px; }
.library-loading { display: flex; align-items: center; gap: 8px; padding: 18px 14px; }
.recording-item {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
}
.recording-item:last-child { border-bottom: 0; }
.recording-item__copy { min-width: 0; display: grid; gap: 2px; }
.recording-item__copy strong { overflow-wrap: anywhere; }
.recording-item__copy span { color: var(--muted); font-size: 11px; line-height: 15px; }
.recording-item__actions {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 0;
}
.recording-item__actions button {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 11px;
  white-space: nowrap;
}
.transcription-status {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.transcription-status--queued { background: #fff8e7; border-color: #e7d4a4; color: #72520e; }
.transcription-status--canceled { background: var(--surface); color: var(--muted); }
.danger { border: 1px solid #e0aaa5; background: white; color: var(--red); }
.danger:hover { background: var(--red-pale); }
.error { margin-top: 12px; border: 1px solid #efcaca; border-radius: 4px; padding: 8px 10px; background: var(--red-pale); color: var(--red); line-height: 18px; }
.empty-state {
  min-height: 238px;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 28px 18px;
  background: #fff;
  color: var(--muted);
  text-align: center;
}
.empty-state--roomy { min-height: 300px; }
.empty-state__mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  margin-bottom: 9px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: #8a96a3;
  font-size: 16px;
}
.empty-state strong { color: #3c4856; font-weight: 650; }
.empty-state p { margin: 3px 0 0; font-size: 12px; line-height: 18px; }

footer {
  min-height: 37px;
  flex: 0 0 auto;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  font-size: 11px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1200px) and (min-width: 621px) {
  .recording-item { grid-template-columns: minmax(0, 1fr); align-items: stretch; }
  .recording-item__actions { justify-content: flex-start; }
}

@media (max-width: 980px) and (min-width: 621px) {
  .recording-grid { grid-template-columns: minmax(0, 1fr); }
  .recording-item__actions { flex-wrap: wrap; }
}

@media (max-width: 620px) {
  .session-label { display: none; }
  .app-layout.is-authenticated { display: block; }
  .app-nav { border-right: 0; border-bottom: 1px solid var(--line); padding: 6px 8px; }
  .nav-menu-toggle {
    width: 100%;
    min-height: 44px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 9px;
    border-color: var(--line);
    background: #fff;
    color: var(--muted);
    text-align: left;
  }
  .nav-menu-toggle strong { color: var(--ink); font-size: 13px; }
  .nav-items { padding-top: 5px; }
  .app-nav[data-open="false"] .nav-items { display: none; }
  .nav-item { min-height: 44px; }
  .app-main--workspace { padding: 14px 12px 40px; }
  .recording-grid, .admin-grid { grid-template-columns: minmax(0, 1fr); }
  .recording-notice { align-items: flex-start; flex-direction: column; gap: 2px; }
  .details-list > div { grid-template-columns: 130px minmax(0, 1fr); }
  .recording-item { grid-template-columns: minmax(0, 1fr); align-items: stretch; }
  .recording-item__actions { align-self: stretch; flex-wrap: wrap; justify-content: flex-start; }
  .recording-item__actions button { flex: 1 1 auto; }
}

@media (max-width: 470px) {
  button, .brand, .session-controls .secondary { min-height: 44px; }
  .top-bar { gap: 6px; padding: 0 7px; }
  .brand { gap: 6px; }
  .brand strong { font-size: 12px; }
  .brand-mark { width: 26px; height: 26px; }
  .environment { padding-inline: 5px; font-size: 10px; }
  .top-bar__future { min-width: 0; }
  .session-controls .secondary { padding-inline: 8px; }
  .app-main--gate { min-height: calc(100vh - 83px); padding: 28px 12px 36px; }
  .auth-panel { padding: 18px; }
  .auth-panel input { min-height: 44px; }
  .section-head { align-items: flex-start; }
  .workspace-badge { min-height: 26px; }
  .recording-grid { gap: 10px; }
  .workspace-panel { border-radius: 4px; }
  .capture-card { padding: 13px; }
  .details-list > div { grid-template-columns: 1fr; gap: 3px; }
  .recording-item__actions button, .transcription-status { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner, .recording-dot { animation: none; }
}
