/* ════════════════════════════════════════════════════════════════
   STORY POT — DARK EDITORIAL THEME (FULL APP)
   Black background. White serif type. Indigo accent.
   Photos and color pops dramatically against dark surfaces.
   Same class names as Folder 2, completely new visual language.
   ════════════════════════════════════════════════════════════════ */

:root {
  /* Surface — graduated darks, never pure black */
  --c-paper:        #0A0A0A;
  --c-paper-2:      #161616;
  --c-paper-3:      #1F1F1F;
  --c-divider:      #2A2A2A;
  --c-divider-strong: #3A3A3A;

  /* Ink — graduated whites, never pure white */
  --c-ink:          #F5F5F5;
  --c-ink-soft:     #A8A8A8;
  --c-muted:        #6B6B6B;

  /* Accent — indigo bright enough to read on black */
  --c-accent:       #7C8FFF;
  --c-accent-deep:  #5048E5;
  --c-accent-soft:  #1A1F3D;

  /* Status */
  --c-danger:       #FF6B6B;
  --c-success:      #4ECDC4;

  /* Type */
  --font-display:   'Fraunces', Georgia, serif;
  --font-body:      'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:      ui-monospace, 'JetBrains Mono', monospace;

  --fs-xs:    0.75rem;
  --fs-sm:    0.875rem;
  --fs-md:    1rem;
  --fs-lg:    1.18rem;
  --fs-xl:    1.5rem;
  --fs-2xl:   2rem;
  --fs-3xl:   2.6rem;
  --fs-mark:  clamp(2.4rem, 11vw, 4.5rem);
  --fs-timer: clamp(3.5rem, 16vw, 6rem);

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-pill: 999px;

  --bw: 1px;
  --bw-thick: 2px;

  --shadow-soft: 0 1px 0 rgba(255, 255, 255, 0.04);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 0 1px var(--c-accent), 0 8px 32px rgba(124, 143, 255, 0.2);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-snap: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
button { background: none; border: none; font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }

body {
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--c-ink);
  background: var(--c-paper);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Stage */
.stage {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-4) calc(var(--sp-8) * 1.5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

@media (min-width: 600px) {
  .stage { padding: var(--sp-6) var(--sp-5) calc(var(--sp-8) * 1.5); }
}

/* ──────────────────────────────────────────────────────────────
   MASTHEAD
   ────────────────────────────────────────────────────────────── */
.masthead {
  background: var(--c-paper);
  padding: var(--sp-3) 0 var(--sp-4);
  border-bottom: 1px solid var(--c-divider);
}

.masthead-stripe { display: none; }

.masthead-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-2);
}

.masthead-mark {
  background: transparent;
  padding: 0;
  border: none;
}

.masthead-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-1);
}

/* Home icon link — small, quiet circle in the masthead. Goes back to the
   welcome page (index.html). Indigo glow on hover matches the FAB and CTA. */
.home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--c-divider);
  background: var(--c-paper-2);
  color: var(--c-ink-soft);
  text-decoration: none;
  transition: all 0.15s ease;
  margin-bottom: var(--sp-1);
}

.home-link:hover,
.home-link:focus-visible {
  color: var(--c-paper);
  background: var(--c-accent);
  border-color: var(--c-accent);
  box-shadow: 0 0 16px rgba(124, 143, 255, 0.4);
}

.home-link:active {
  transform: scale(0.95);
}

/* ───────────────────────────────────────────────────────
   MODE TOGGLE — Family Archive / Team Archive
   Lives in the masthead under the home icon. Compact pill.
   ─────────────────────────────────────────────────────── */
.mode-toggle {
  display: inline-flex;
  background: var(--c-paper-2);
  border: 1px solid var(--c-divider);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
  margin-bottom: var(--sp-1);
}

.mode-toggle-btn {
  font-family: var(--font-mono, ui-monospace, 'JetBrains Mono', monospace);
  font-weight: 500;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--c-ink-soft);
  cursor: pointer;
  transition: all 0.15s ease;
}

.mode-toggle-btn:hover {
  color: var(--c-ink);
}

.mode-toggle-btn--active {
  background: var(--c-accent);
  color: var(--c-paper);
}

.mode-toggle-btn--active:hover {
  color: var(--c-paper);
}

.wordmark {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 600;
  color: var(--c-ink);
  line-height: 0.9;
  letter-spacing: -0.04em;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}

.wordmark-big {
  font-size: clamp(3rem, 8vw, 3.6rem);
  font-weight: 600;
  text-transform: none;
}

.wordmark-small {
  font-size: clamp(2rem, 8vw, 2.6rem);
  font-weight: 600;
  text-transform: none;
  color: var(--c-ink);
  opacity: 0.5;
  letter-spacing: -0.04em;
}

.tagline {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  color: var(--c-ink-soft);
  text-transform: uppercase;
}

.topbar { display: none; }

.topbar-meta {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--fs-xs);
  color: var(--c-muted);
  text-transform: none;
}

.dot {
  width: 6px;
  height: 6px;
  background: var(--c-success);
  border-radius: 50%;
  display: inline-block;
}

/* ──────────────────────────────────────────────────────────────
   SEARCH
   ────────────────────────────────────────────────────────────── */
.search-section {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--c-paper-2);
  border: 1px solid var(--c-divider);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  transition: border-color 0.15s var(--ease-snap);
}

.search-section:focus-within {
  border-color: var(--c-accent);
}

.search-label {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--fs-xs);
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: var(--fs-sm);
  color: var(--c-ink);
}

.search-input::placeholder { color: var(--c-muted); }

.search-clear {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--c-paper-3);
  color: var(--c-ink);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid var(--c-divider);
}

.search-clear[hidden] { display: none; }

/* ──────────────────────────────────────────────────────────────
   SECTION HEADERS
   ────────────────────────────────────────────────────────────── */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0;
  border-bottom: 1px solid var(--c-divider);
  padding-bottom: var(--sp-2);
}

.section-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-xl);
  letter-spacing: -0.02em;
  color: var(--c-ink);
  text-transform: none;
}

.section-count {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--fs-xs);
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.link-btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--c-accent);
  background: transparent;
  padding: 4px 0;
  border-radius: 0;
  cursor: pointer;
  text-transform: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s var(--ease-snap);
}

.link-btn:hover, .link-btn:focus-visible {
  border-bottom-color: var(--c-accent);
  outline: none;
}

/* ──────────────────────────────────────────────────────────────
   FAMILY ROW
   ────────────────────────────────────────────────────────────── */
.people-row {
  display: flex;
  gap: var(--sp-3);
  overflow-x: auto;
  overflow-y: visible;
  padding: 12px 4px 14px;
}

.person-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
  cursor: pointer;
}

.person-cell.is-selected .person-avatar {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
}

.person-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  color: var(--c-paper);
  flex-shrink: 0;
}

.person-name {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--fs-xs);
  color: var(--c-ink);
  max-width: 70px;
  text-align: center;
  word-break: break-word;
}

.person-add .person-avatar {
  background: var(--c-paper-2);
  border: 1px dashed var(--c-muted);
  font-size: 22px;
  font-weight: 400;
  color: var(--c-ink-soft);
}

/* ──────────────────────────────────────────────────────────────
   FILTER PILLS
   ────────────────────────────────────────────────────────────── */
.filter-section { display: flex; flex-direction: column; gap: var(--sp-2); }

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
}

.filter-btn {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--fs-sm);
  color: var(--c-ink);
  background: var(--c-paper-2);
  padding: 6px 14px;
  border: 1px solid var(--c-divider);
  border-radius: var(--r-pill);
  cursor: pointer;
  text-transform: none;
  transition: all 0.15s var(--ease-snap);
}

.filter-btn:hover {
  border-color: var(--c-accent);
}

.filter-btn.is-active {
  background: var(--c-accent);
  color: var(--c-paper);
  border-color: var(--c-accent);
}

/* ──────────────────────────────────────────────────────────────
   RECORDINGS LIST
   ────────────────────────────────────────────────────────────── */
.recordings-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.recording-item {
  background: transparent;
  border-radius: 0;
  padding: var(--sp-4) 0;
  cursor: pointer;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: var(--sp-3);
  align-items: center;
  border-bottom: 1px solid var(--c-divider);
  transition: background 0.15s var(--ease-snap);
}

.recording-item:hover {
  background: var(--c-paper-2);
}

.recording-cat-pill {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  display: inline-block;
  text-transform: uppercase;
  color: var(--c-paper);
  background: var(--c-accent);
  margin-bottom: 4px;
}

.recording-title {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 600;
  font-size: var(--fs-lg);
  color: var(--c-ink);
  word-break: break-word;
  letter-spacing: -0.02em;
  text-transform: none;
}

.recording-meta {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--fs-xs);
  color: var(--c-muted);
  margin-top: 4px;
  text-transform: none;
}

.recording-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  flex-shrink: 0;
  color: var(--c-paper);
}

.recording-arrow {
  font-size: 16px;
  color: var(--c-muted);
}

/* Empty state */
.empty-state {
  background: transparent;
  padding: var(--sp-7) var(--sp-4);
  text-align: left;
  border-top: 1px solid var(--c-divider);
}

.empty-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-2xl);
  color: var(--c-ink);
  margin-bottom: var(--sp-2);
  letter-spacing: -0.02em;
}

.empty-sub {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--fs-md);
  color: var(--c-ink-soft);
  line-height: 1.55;
  max-width: 480px;
}

/* Storage meter */
.storage-section {
  background: transparent;
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--c-divider);
}

.storage-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--fs-xs);
  color: var(--c-muted);
  margin-bottom: var(--sp-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.storage-bar {
  width: 100%;
  height: 4px;
  background: var(--c-divider);
  border-radius: 0;
  overflow: hidden;
}

.storage-fill {
  height: 100%;
  background: var(--c-accent);
  width: 0%;
  transition: width 0.4s var(--ease-snap);
}

/* ──────────────────────────────────────────────────────────────
   FAB
   ────────────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--sp-5) + env(safe-area-inset-bottom, 0));
  right: var(--sp-4);
  width: 60px;
  height: 60px;
  background: var(--c-accent);
  color: var(--c-paper);
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  z-index: 50;
  box-shadow: 0 0 32px rgba(124, 143, 255, 0.4);
  transition: transform 0.15s var(--ease-snap), box-shadow 0.15s var(--ease-snap);
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab:hover {
  transform: scale(1.05);
  box-shadow: 0 0 48px rgba(124, 143, 255, 0.6);
}

.fab:active { transform: scale(0.96); }

/* ──────────────────────────────────────────────────────────────
   FAB TOOLTIP — "Record" label
   ──────────────────────────────────────────────────────────────
   First-time users see only a single dot on the FAB and don't
   know it's the record button. This tooltip appears on hover
   (desktop), focus (keyboard), and tap (touch — because touch
   triggers :hover on most mobile browsers) so the button's
   purpose is always discoverable.

   Built as a pseudo-element using data-tooltip="Record" on the
   button. No JavaScript needed. The arrow is a second pseudo-
   element forming a small triangle below the bubble.
   ────────────────────────────────────────────────────────────── */
.fab[data-tooltip] { position: fixed; }

.fab[data-tooltip]::before,
.fab[data-tooltip]::after {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.18s var(--ease-snap), transform 0.18s var(--ease-snap);
}

/* Tooltip bubble */
.fab[data-tooltip]::before {
  content: attr(data-tooltip);
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translate(-50%, 4px);
  background: var(--c-ink);
  color: var(--c-paper);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 7px 14px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

/* Tooltip arrow */
.fab[data-tooltip]::after {
  content: '';
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translate(-50%, 4px);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--c-ink);
}

/* Show on hover, focus, or active (covers touch on most devices) */
.fab[data-tooltip]:hover::before,
.fab[data-tooltip]:hover::after,
.fab[data-tooltip]:focus-visible::before,
.fab[data-tooltip]:focus-visible::after,
.fab[data-tooltip].fab-show-tooltip::before,
.fab[data-tooltip].fab-show-tooltip::after {
  opacity: 1;
}

.fab[data-tooltip]:hover::before,
.fab[data-tooltip]:focus-visible::before,
.fab[data-tooltip].fab-show-tooltip::before {
  transform: translate(-50%, 0);
}

.fab[data-tooltip]:hover::after,
.fab[data-tooltip]:focus-visible::after,
.fab[data-tooltip].fab-show-tooltip::after {
  transform: translate(-50%, 0);
}

@media (min-width: 600px) {
  .fab { bottom: var(--sp-5); right: calc(50% - 350px); width: 64px; height: 64px; }
}

/* ──────────────────────────────────────────────────────────────
   BUTTONS
   ────────────────────────────────────────────────────────────── */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--fs-sm);
  letter-spacing: 0;
  padding: 12px 24px;
  border: 1px solid var(--c-divider);
  border-radius: var(--r-pill);
  background: var(--c-paper-2);
  color: var(--c-ink);
  cursor: pointer;
  transition: all 0.15s var(--ease-snap);
}

.btn:hover { border-color: var(--c-accent); color: var(--c-accent); }

.btn-solid {
  background: var(--c-accent);
  color: var(--c-paper);
  border-color: var(--c-accent);
}

.btn-solid:hover {
  background: var(--c-accent-deep);
  border-color: var(--c-accent-deep);
  color: var(--c-ink);
}

.btn-ghost {
  background: transparent;
  color: var(--c-ink);
  border: 1px solid var(--c-divider);
}

.btn-ghost:hover {
  background: var(--c-paper-2);
  border-color: var(--c-accent);
}

.btn-danger {
  color: var(--c-danger);
  border-color: var(--c-divider);
}

.btn-danger:hover {
  background: var(--c-danger);
  color: var(--c-paper);
  border-color: var(--c-danger);
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--c-paper-2);
  color: var(--c-ink);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid var(--c-divider);
  transition: all 0.15s var(--ease-snap);
}

.icon-btn:hover {
  background: var(--c-accent);
  color: var(--c-paper);
  border-color: var(--c-accent);
}

/* ──────────────────────────────────────────────────────────────
   MODAL
   ────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: var(--sp-3);
  animation: fadeIn 0.15s var(--ease-out);
  overflow-y: auto;
}

.modal-backdrop[hidden] { display: none !important; }

/* Camera modal opens from INSIDE the recording setup (.rec-modal at z-index 200),
   so it must stack above it. Same for any modal that can open from within
   the recording flow. */
#cameraModal { z-index: 300; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--c-paper-2);
  border: 1px solid var(--c-divider);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 480px;
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin: var(--sp-3) auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.modal-large { max-width: 560px; }

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--c-divider);
}

.modal-head h2 {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 600;
  font-size: var(--fs-xl);
  color: var(--c-ink);
  letter-spacing: -0.02em;
  text-transform: none;
}

.modal-body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--c-ink);
}

.modal-body--strong {
  font-weight: 600;
  background: var(--c-paper-3);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  border-left: 3px solid var(--c-accent);
  color: var(--c-ink);
}

.modal-helper {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--fs-sm);
  color: var(--c-ink-soft);
  line-height: 1.55;
}

.modal-actions {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
  margin-top: var(--sp-2);
  flex-wrap: wrap;
}

.modal-actions--space { justify-content: space-between; }

/* ───────────────────────────────────────────────────────
   v2 FEATURES — detail action buttons, pencil edit, etc.
   ─────────────────────────────────────────────────────── */

/* Group of icon+text buttons inside detail actions */
.detail-actions-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* Small icon+text buttons used in the detail action row */
.btn-icon-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid var(--c-divider);
  background: var(--c-paper-2);
  color: var(--c-ink-soft);
  transition: all 0.15s ease;
  cursor: pointer;
}

.btn-icon-text:hover,
.btn-icon-text:focus-visible {
  color: var(--c-accent);
  border-color: var(--c-accent);
  background: var(--c-paper-3);
}

.btn-icon-text svg {
  flex-shrink: 0;
}

.btn-icon-text span {
  white-space: nowrap;
}

/* Pencil edit button on person avatars */
.person-cell {
  position: relative;
}

.person-edit-btn {
  position: absolute;
  top: -2px;
  right: 4px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  background: var(--c-paper-2);
  border: 1px solid var(--c-divider);
  color: var(--c-ink-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
  transition: all 0.15s ease;
  z-index: 2;
}

.person-edit-btn:hover,
.person-edit-btn:focus-visible {
  background: var(--c-accent);
  color: var(--c-paper);
  border-color: var(--c-accent);
  opacity: 1;
  transform: scale(1.1);
}

.person-edit-btn svg {
  pointer-events: none;
}

/* The Add person cell shouldn't show the edit pencil (no data-personId).
   buildAddPersonCell doesn't add the pencil so this is just defensive. */
.person-add .person-edit-btn { display: none; }

/* Stack the detail actions group on small screens so they don't crowd */
@media (max-width: 540px) {
  .modal-actions--space {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .detail-actions-group {
    justify-content: center;
  }
}
.modal-actions .btn { flex: 1; min-width: 110px; }

/* ──────────────────────────────────────────────────────────────
   FORMS
   ────────────────────────────────────────────────────────────── */
.form-label {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  color: var(--c-ink-soft);
  text-transform: uppercase;
  display: block;
  margin-top: var(--sp-3);
  margin-bottom: var(--sp-1);
}

.form-input {
  width: 100%;
  background: var(--c-paper-3);
  border: 1px solid var(--c-divider);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--fs-sm);
  color: var(--c-ink);
  outline: none;
  transition: border-color 0.15s var(--ease-snap);
}

.form-input:focus {
  border-color: var(--c-accent);
  background: var(--c-paper-2);
}

.form-input::placeholder { color: var(--c-muted); }

.form-textarea {
  resize: vertical;
  min-height: 160px;
  line-height: 1.6;
}

.form-hint {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--fs-xs);
  background: var(--c-paper-3);
  color: var(--c-ink-soft);
  border-radius: var(--r-sm);
  padding: 4px 10px;
  margin-top: 4px;
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-hint[hidden] { display: none !important; }

.form-select {
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--c-ink) 50%),
                    linear-gradient(135deg, var(--c-ink) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 2px),
                       calc(100% - 13px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

.form-select option {
  background: var(--c-paper-2);
  color: var(--c-ink);
}

.swatch-row {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s var(--ease-snap);
  border: 2px solid transparent;
}

.swatch:hover { transform: scale(1.1); }

.swatch.is-active {
  border-color: var(--c-ink);
  outline: 2px solid var(--c-paper);
  outline-offset: -4px;
}

/* ──────────────────────────────────────────────────────────────
   RECORDING SCREEN
   ────────────────────────────────────────────────────────────── */
.rec-modal {
  position: fixed;
  inset: 0;
  background: var(--c-paper);
  z-index: 200;
  overflow-y: auto;
  padding: var(--sp-4);
  animation: fadeIn 0.2s var(--ease-out);
}

.rec-modal[hidden] { display: none !important; }

.rec-setup, .rec-active {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.rec-setup[hidden], .rec-active[hidden], .save-discard-section[hidden] { display: none !important; }

.rec-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--sp-3);
  margin-bottom: var(--sp-2);
  border-bottom: 1px solid var(--c-divider);
}

.rec-head h2 {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 600;
  font-size: var(--fs-xl);
  color: var(--c-ink);
  text-transform: none;
  letter-spacing: -0.02em;
}

.rec-head--live { border-bottom-color: var(--c-accent); }

.rec-pulse-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.rec-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-danger);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.rec-status {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--fs-xs);
  color: var(--c-ink);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Mode picker */
.mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
}

.mode-btn {
  background: var(--c-paper-2);
  border: 1px solid var(--c-divider);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s var(--ease-snap);
}

.mode-btn:hover {
  border-color: var(--c-accent);
}

.mode-btn.is-active {
  background: var(--c-accent);
  color: var(--c-paper);
  border-color: var(--c-accent);
}

.mode-icon { font-size: 22px; }

.mode-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-md);
  text-transform: none;
  letter-spacing: -0.01em;
}

.mode-sub {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--fs-xs);
  opacity: 0.85;
}

/* Transcribe toggle */
.transcribe-row { display: flex; }

.transcribe-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--c-paper-2);
  border: 1px solid var(--c-divider);
  border-radius: var(--r-pill);
  padding: 8px 16px;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--fs-xs);
  color: var(--c-ink);
  text-transform: none;
  transition: all 0.15s var(--ease-snap);
}

.transcribe-toggle.is-active {
  background: var(--c-accent);
  color: var(--c-paper);
  border-color: var(--c-accent);
}

.transcribe-pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-muted);
}

.transcribe-toggle.is-active .transcribe-pip { background: var(--c-paper); }

/* Active recording context */
.rec-context {
  background: var(--c-paper-2);
  border: 1px solid var(--c-divider);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.rec-context-line {
  display: flex;
  gap: var(--sp-2);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  color: var(--c-ink);
  word-break: break-word;
}

.rec-context-label {
  font-family: var(--font-mono);
  font-weight: 500;
  flex-shrink: 0;
  min-width: 50px;
  color: var(--c-muted);
  text-transform: uppercase;
  font-size: var(--fs-xs);
  letter-spacing: 0.05em;
  align-self: center;
}

/* Video preview */
.rec-video-wrap {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--c-paper-3);
  border: 1px solid var(--c-divider);
  border-radius: var(--r-md);
  overflow: hidden;
}

@media (max-width: 599px) { .rec-video-wrap { aspect-ratio: 3 / 4; } }

#recVideo { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Big timer */
.rec-timer {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-timer);
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--c-accent);
  line-height: 1;
  padding: var(--sp-3) 0;
  letter-spacing: -0.04em;
}

/* Live waveform */
.rec-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 60px;
  padding: var(--sp-2) 0;
}

.rec-wave-bar {
  width: 3px;
  background: var(--c-accent);
  border-radius: 0;
  transition: height 0.1s linear;
  min-height: 4px;
}

/* Live transcription preview */
.rec-transcript-wrap {
  background: var(--c-paper-2);
  border: 1px solid var(--c-divider);
  border-radius: var(--r-md);
  padding: var(--sp-3);
}

.rec-transcript-label {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  color: var(--c-ink-soft);
  text-transform: uppercase;
  margin-bottom: var(--sp-1);
}

.rec-transcript {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--c-ink);
  max-height: 120px;
  overflow-y: auto;
}

/* Recording controls */
.rec-controls {
  display: flex;
  gap: var(--sp-3);
  justify-content: center;
  align-items: center;
  padding: var(--sp-3) 0;
}

.rec-pause-btn, .rec-stop-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s var(--ease-snap);
  border: none;
}

.rec-pause-btn {
  width: 52px;
  height: 52px;
  background: var(--c-paper-2);
  border: 1px solid var(--c-divider);
  color: var(--c-ink);
  font-size: 20px;
}

.rec-pause-btn:hover { background: var(--c-paper-3); border-color: var(--c-accent); }

.rec-stop-btn {
  width: 76px;
  height: 76px;
  background: var(--c-accent);
  color: var(--c-paper);
  font-size: 30px;
  box-shadow: 0 0 32px rgba(124, 143, 255, 0.4);
}

.rec-stop-btn:hover { transform: scale(1.05); }
.rec-stop-btn:active { transform: scale(0.96); }

.rec-controls-hint {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--fs-xs);
  text-align: center;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ──────────────────────────────────────────────────────────────
   DETAIL VIEW
   ────────────────────────────────────────────────────────────── */
.detail-view {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.detail-cat-pill {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  background: var(--c-accent);
  color: var(--c-paper);
  border-radius: var(--r-sm);
  align-self: flex-start;
  text-transform: uppercase;
}

.detail-title {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 600;
  font-size: var(--fs-2xl);
  line-height: 1.05;
  color: var(--c-ink);
  word-break: break-word;
  letter-spacing: -0.03em;
  text-transform: none;
}

.detail-attribution {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--fs-sm);
  color: var(--c-ink-soft);
  text-transform: none;
}

.detail-media-wrap { margin: var(--sp-2) 0; }

.detail-media {
  width: 100%;
  display: block;
  border-radius: var(--r-md);
}

.detail-audio { height: 44px; }
.detail-video { max-height: 280px; background: var(--c-paper-3); }

.detail-meta-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--fs-xs);
  color: var(--c-muted);
  padding: var(--sp-2) 0;
  border-top: 1px solid var(--c-divider);
  border-bottom: 1px solid var(--c-divider);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-transcript-section {
  margin-top: var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.detail-transcript-label {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  color: var(--c-ink-soft);
  text-transform: uppercase;
  padding-bottom: var(--sp-1);
}

.detail-transcript {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--fs-md);
  line-height: 1.65;
  color: var(--c-ink);
  background: var(--c-paper-3);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border-left: 3px solid var(--c-accent);
  max-height: 280px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ──────────────────────────────────────────────────────────────
   TOAST
   ────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--sp-5) + env(safe-area-inset-bottom, 0));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--c-ink);
  color: var(--c-paper);
  border-radius: var(--r-pill);
  padding: 10px 20px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--fs-sm);
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s var(--ease-out), transform 0.3s var(--ease-out);
  max-width: calc(100vw - 32px);
  text-transform: none;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[hidden] { display: none !important; }

/* ──────────────────────────────────────────────────────────────
   PHOTO FEATURE
   ────────────────────────────────────────────────────────────── */
.photo-controls {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.photo-btn {
  flex: 1;
  min-width: 130px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.photo-btn-icon { font-size: 1.05em; }

.photo-preview {
  position: relative;
  margin-top: var(--sp-2);
  background: var(--c-paper-2);
  border: 1px solid var(--c-divider);
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
}

.photo-preview img {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  display: block;
}

.photo-preview-clear {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.8);
  color: var(--c-ink);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid var(--c-divider);
}

.camera-modal { max-width: 600px; }

.camera-stage {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--c-paper-3);
  border: 1px solid var(--c-divider);
  border-radius: var(--r-md);
  overflow: hidden;
  margin: var(--sp-3) 0;
}

#cameraVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@media (max-width: 599px) {
  .camera-stage { aspect-ratio: 3 / 4; }
}

.recording-item.has-photo {
  grid-template-columns: 40px 56px 1fr auto;
}

.recording-thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--c-paper-2);
  flex-shrink: 0;
}

.recording-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.view-toggle {
  display: inline-flex;
  background: var(--c-paper-2);
  border: 1px solid var(--c-divider);
  border-radius: var(--r-pill);
  padding: 2px;
  gap: 0;
}

.view-toggle-btn {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--fs-xs);
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--c-ink-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s var(--ease-snap);
}

.view-toggle-btn:hover { color: var(--c-ink); }

.view-toggle-btn.is-active {
  background: var(--c-accent);
  color: var(--c-paper);
}

.view-toggle-icon {
  font-size: 0.95em;
  line-height: 1;
}

.recordings-section .section-head {
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.recordings-list.view-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}

@media (min-width: 600px) {
  .recordings-list.view-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.recording-tile {
  background: var(--c-paper-2);
  border: 1px solid var(--c-divider);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: all 0.15s var(--ease-snap);
}

.recording-tile:hover {
  border-color: var(--c-accent);
  transform: translateY(-2px);
}

.recording-tile-photo,
.recording-tile-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--c-paper-3);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.recording-tile-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.recording-tile-placeholder {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 600;
  font-size: 2.5rem;
  color: var(--c-accent);
  opacity: 0.4;
}

.recording-tile-caption {
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.recording-tile-title {
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 600;
  font-size: var(--fs-md);
  color: var(--c-ink);
  line-height: 1.2;
  letter-spacing: -0.01em;
  word-break: break-word;
}

.recording-tile-sub {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--fs-xs);
  color: var(--c-muted);
}

.detail-photo {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: var(--r-md);
  display: block;
  margin-bottom: var(--sp-2);
}

.detail-photo[hidden] { display: none; }

/* ──────────────────────────────────────────────────────────────
   ACCESSIBILITY
   ────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@supports (padding: max(0px)) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ════════════════════════════════════════════════════════════════
   TEAM ARCHIVE — LIGHT MODE OVERRIDES (recorder.html + card.html)
   ─────────────────────────────────────────────────────────────────
   When the user toggles to Team Archive, app.js adds the class
   `mode-team` to <body>. The selectors below ONLY apply when that
   class is present, so Family Archive stays dark and unchanged.

   Same strategy as home.css: redefine the color variables and
   every component re-skins itself. The variable names differ from
   home.css (--c-paper here vs --paper there) because the two
   stylesheets were authored independently — that's fine, we just
   match each file's own naming.

   Indigo accent (--c-accent) is intentionally NOT overridden so
   the brand color stays consistent between Family and Team modes.
   ════════════════════════════════════════════════════════════════ */
body.mode-team {
  /* Surfaces: Variant B — Studio Gray (true neutral mid-gray) */
  --c-paper:           #D9D9D9;   /* page background */
  --c-paper-2:         #E8E8E8;   /* card / panel background */
  --c-paper-3:         #CDCDCD;   /* deepest surface (e.g. inputs, tiles) */
  --c-divider:         #B8B8B8;   /* hairline borders */
  --c-divider-strong:  #9F9F9F;   /* stronger borders (focus rings, dividers) */

  /* Ink: from near-white to near-black */
  --c-ink:             #1A1A1A;   /* primary text */
  --c-ink-soft:        #4A4A4A;   /* secondary text */
  --c-muted:           #7A7A7A;   /* tertiary text / captions */

  /* Card shadow: softer on the slightly darker surface, but still
     present enough to give cards lift. Tuned for Studio Gray. */
  --shadow-card: 0 4px 24px rgba(20, 20, 20, 0.10);
  --shadow-soft: 0 1px 0 rgba(0, 0, 0, 0.05);

  /* Accent (--c-accent, --c-accent-deep, --c-accent-soft) and status
     colors (--c-danger, --c-success) are intentionally NOT overridden. */
}
