:root {
  --canvas: #f7f7f8;
  --surface: #ffffff;
  --surface-subtle: #f3f4f6;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --ink: #111827;
  --text: #374151;
  --muted: #6b7280;
  --positive: #166534;
  --positive-bg: #f0fdf4;
  --positive-border: #bbf7d0;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #ffffff 0%, var(--canvas) 68%, #f3f4f6 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 9em;
  font-size: clamp(2.15rem, 8vw, 3.75rem);
  font-weight: 820;
  letter-spacing: 0;
  line-height: 0.98;
}

h2 {
  font-size: 1.1rem;
  line-height: 1.25;
}

.capture-shell {
  align-items: start;
  display: grid;
  min-height: 100svh;
  padding: clamp(18px, 4vw, 34px) 0;
  width: min(560px, calc(100% - 28px));
  margin: 0 auto;
}

.hosted-home {
  align-items: center;
  display: grid;
  min-height: 100svh;
  padding: clamp(18px, 4vw, 34px) 0;
  width: min(620px, calc(100% - 28px));
  margin: 0 auto;
}

.hosted-home-card {
  background: var(--surface);
  border: 1px solid #d7dce2;
  border-radius: var(--radius);
  box-shadow: 0 18px 60px rgb(17 24 39 / 10%);
  display: grid;
  gap: 18px;
  padding: clamp(24px, 6vw, 42px);
}

.hosted-home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.capture-card {
  background: var(--surface);
  border: 1px solid #d7dce2;
  border-radius: var(--radius);
  box-shadow: 0 18px 60px rgb(17 24 39 / 10%);
  display: grid;
  gap: 20px;
  padding: clamp(22px, 6vw, 38px);
}

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

.label,
.field-label {
  color: var(--muted);
  display: block;
  font-size: 0.74rem;
  font-weight: 760;
  letter-spacing: 0;
  line-height: 1.2;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.support-code {
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 5px 9px;
}

.hero-line,
.body-copy,
.capture-footer,
.account-handoff p {
  color: var(--text);
}

.hero-line {
  font-size: 1.08rem;
}

.capture-progress {
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  list-style: none;
  margin: 2px 0 0;
  padding: 10px 0;
}

.capture-progress li {
  align-items: center;
  color: var(--muted);
  display: grid;
  gap: 6px;
  justify-items: center;
  min-width: 0;
}

.capture-progress span {
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 850;
  height: 28px;
  justify-content: center;
  width: 28px;
}

.capture-progress strong {
  font-size: 0.82rem;
}

.capture-progress .is-active {
  color: var(--ink);
}

.capture-progress .is-active span {
  border-color: var(--ink);
}

.capture-progress .is-complete {
  color: var(--positive);
}

.capture-progress .is-complete span {
  background: #dcfce7;
  border-color: var(--positive-border);
}

.capture-note {
  background: var(--surface-subtle);
  border-left: 3px solid var(--ink);
  color: var(--text);
  padding: 10px 12px;
}

label {
  display: grid;
  gap: 8px;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

select {
  width: 100%;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

input:focus,
select:focus {
  border-color: var(--ink);
  outline: 2px solid rgb(17 24 39 / 14%);
  outline-offset: 2px;
}

.owner-shell {
  display: grid;
  gap: 18px;
  margin: 0 auto;
  min-height: 100svh;
  padding: clamp(18px, 4vw, 34px) 0;
  width: min(880px, calc(100% - 28px));
}

.owner-header,
.owner-toolbar,
.owner-section-heading,
.owner-item,
.owner-row {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.owner-header-actions,
.owner-item-actions,
.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.owner-header h1 {
  font-size: clamp(2.1rem, 6vw, 3.2rem);
}

.owner-panel,
.owner-section {
  background: var(--surface);
  border: 1px solid #d7dce2;
  border-radius: var(--radius);
  box-shadow: 0 14px 42px rgb(17 24 39 / 8%);
  display: grid;
  gap: 16px;
  padding: clamp(18px, 4vw, 28px);
}

.owner-drawer {
  box-shadow: none;
  gap: 12px;
  padding: 0;
}

.owner-drawer > summary {
  cursor: pointer;
  list-style: none;
  padding: clamp(16px, 4vw, 22px);
}

.owner-drawer > summary::-webkit-details-marker {
  display: none;
}

.owner-drawer > summary::after {
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--muted);
  content: "+";
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 1rem;
  font-weight: 850;
  height: 30px;
  justify-content: center;
  width: 30px;
}

.owner-drawer[open] > summary::after {
  content: "-";
}

.owner-drawer > :not(summary) {
  margin: 0 clamp(16px, 4vw, 22px) clamp(16px, 4vw, 22px);
}

.owner-drawer .capture-footer {
  border-top: 0;
  padding-top: 3px;
}

.owner-toolbar {
  align-items: end;
}

.owner-toolbar label {
  flex: 1 1 260px;
}

.metric-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: grid;
  gap: 4px;
  min-height: 74px;
  padding: 12px;
}

.metric span,
.owner-item-main span,
.owner-helper,
.empty-copy {
  color: var(--muted);
}

.metric span {
  font-size: 0.74rem;
  font-weight: 760;
  text-transform: uppercase;
}

.metric strong {
  font-size: 1.35rem;
  line-height: 1.1;
}

.owner-list,
.owner-sublist,
.batch-form,
.family-form,
.auth-card {
  display: grid;
  gap: 10px;
}

.batch-form,
.family-form {
  align-items: end;
  grid-template-columns: minmax(90px, 0.35fr) 1fr auto;
}

.auth-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.auth-card summary {
  cursor: pointer;
  font-weight: 850;
  margin: -2px 0 2px;
}

.owner-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.owner-item-small {
  padding: 10px 12px;
}

.owner-item-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.owner-item-main input {
  font-size: 0.9rem;
  min-height: 40px;
}

.owner-helper,
.link-result-header {
  font-size: 0.93rem;
}

.owner-helper {
  border-left: 3px solid var(--border-strong);
  padding-left: 10px;
}

.link-result-header {
  align-items: center;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 10px 12px;
}

.link-result-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 12px;
}

.owner-row-compact {
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  padding-top: 8px;
}

.text-danger,
.text-button {
  background: transparent;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 850;
  padding: 6px 0;
}

.text-danger {
  color: #991b1b;
}

.text-button {
  color: var(--ink);
}

.button {
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font-size: 0.95rem;
  font-weight: 800;
  text-decoration: none;
}

.button-secondary {
  background: transparent;
  color: var(--ink);
}

.button:disabled {
  cursor: default;
  opacity: 0.55;
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.record-actions[hidden],
.upload-status[hidden],
.saved-panel[hidden],
.account-handoff[hidden],
.audio-preview[hidden] {
  display: none;
}

.audio-preview {
  width: 100%;
}

.upload-form {
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.upload-status {
  align-items: center;
  color: var(--text);
  display: grid;
  gap: 8px;
  grid-template-columns: auto minmax(0, 1fr);
}

.upload-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: upload-spin 0.8s linear infinite;
}

.upload-progress {
  grid-column: 1 / -1;
  width: 100%;
  height: 8px;
  accent-color: var(--ink);
}

@keyframes upload-spin {
  to {
    transform: rotate(360deg);
  }
}

.saved-panel {
  background: var(--positive-bg);
  border: 1px solid var(--positive-border);
  border-radius: 8px;
  color: var(--positive);
  display: grid;
  gap: 2px;
  padding: 12px;
}

.saved-panel span {
  color: var(--positive);
}

.account-handoff {
  border-top: 1px solid var(--border);
  display: grid;
  gap: 7px;
  padding-top: 18px;
}

.capture-footer {
  border-top: 1px solid var(--border);
  display: grid;
  gap: 6px;
  padding-top: 14px;
  font-size: 0.93rem;
}

@media (max-width: 540px) {
  .owner-header,
  .owner-toolbar,
  .owner-section-heading,
  .owner-item,
  .link-result-header {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid,
  .batch-form,
  .family-form {
    grid-template-columns: 1fr;
  }

  .owner-row-compact {
    grid-template-columns: 1fr;
  }

  .owner-header-actions,
  .owner-item-actions,
  .backup-actions {
    justify-content: stretch;
  }

  .link-result-actions {
    justify-content: space-between;
  }

  .owner-drawer > summary::after {
    align-self: end;
  }

  .capture-card {
    border-radius: 12px;
  }

  .capture-header {
    display: grid;
  }

  .record-actions {
    display: grid;
  }

  .button {
    width: 100%;
  }
}
