/* Audio Obituary Studio — warm, calm UI matching Sage Funeral Home's brand:
   a cream backdrop with the logo's exact sage green (#4a5c51, sampled
   directly from static/logo.png) as the primary accent, and a second,
   lighter olive-green for highlights (task #112 — was gold; kept the
   --gold* variable names since so much CSS references them, only the
   hex values changed). Shares its palette with the family-facing page. */

:root {
  --bg: #faf6ef;
  --surface: #ffffff;
  --surface-2: #f6f1e6;
  --ink: #2f2b24;
  --ink-2: #6b6357;
  --ink-3: #9c9484;
  --line: #e6ddc9;
  --line-2: #d8cbac;
  --accent: #4a5c51;
  --accent-hover: #3a463e;
  --accent-soft: #eaf0e5;
  --accent-border: #cddcc4;
  --gold: #7a9d5f;
  --gold-deep: #5c7a45;
  --gold-pale: #eef3e6;
  --danger: #b3413a;
  --ok: #3d7a4f;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(47, 43, 36, 0.05);
  --shadow: 0 4px 12px -2px rgba(47, 43, 36, 0.08), 0 2px 4px -2px rgba(47, 43, 36, 0.04);
  --shadow-lg: 0 16px 32px -8px rgba(47, 43, 36, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, .signin-card h1 {
  font-family: "Lora", Georgia, serif;
}

.hidden { display: none !important; }

/* ---------- Sign-in ---------- */

#signin-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 50% -10%, #f2ead9 0%, transparent 60%),
    var(--bg);
}

.signin-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 44px 40px;
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.signin-card h1 {
  font-size: 1.45rem;
  margin: 18px 0 6px;
  letter-spacing: -0.02em;
}

.signin-card p {
  color: var(--ink-2);
  margin: 0 0 26px;
  font-size: 0.92rem;
}

#g_id_signin { display: flex; justify-content: center; }

.logo-mark {
  width: 52px;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.logo-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 5px rgba(47, 43, 36, 0.18));
}

/* ---------- App shell ---------- */

header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 28px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.brand .logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  box-shadow: none;
}

.brand h1 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.85rem;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 6px 5px 13px;
}

.avatar {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 1fr);
  gap: 22px;
  align-items: start;
}

@media (max-width: 940px) {
  main { grid-template-columns: 1fr; padding: 18px; }
}

.col { display: flex; flex-direction: column; gap: 22px; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  overflow: hidden;
}

/* Every section header gets a clean, modern header: a soft tinted icon
   chip, dark title text, and a thin bottom border separating it from the
   card body — clearly marked without turning into a solid color block. */
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -22px -22px 18px -22px;
  padding: 18px 22px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.card-head h2 { color: var(--ink); }
.card-head h2 .sub { color: var(--ink-3); }

.card-head .card-icon {
  background: var(--gold-pale);
  color: var(--gold-deep);
}

.card h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--gold-pale);
  color: var(--gold-deep);
  margin-right: 10px;
  flex-shrink: 0;
}

.card-icon svg { width: 15px; height: 15px; }

.card h2 .sub {
  display: block;
  flex-basis: 100%;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--ink-3);
  margin-top: 2px;
}

/* ---------- Start-of-process card ----------
   Used for the one section that kicks off the whole family-submission
   workflow, so it reads as a distinct starting point rather than just
   another card in the list — everything below it (writing, voice,
   generating) is the second phase, once a family has actually submitted.
   A thin highlight-green top accent + a small pill badge signal "start here" without
   filling the card in solid color. */

.start-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  box-shadow: var(--shadow-sm);
}

.start-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gold-pale);
  color: var(--gold-deep);
  font-family: "Inter", sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid #cfe0bd;
  flex-basis: 100%;
  width: fit-content;
  margin-bottom: 10px;
  order: -1;
}

/* ---------- Form controls ---------- */

label.field-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-2);
  margin: 18px 0 6px;
  letter-spacing: 0.01em;
}

label.field-label:first-of-type { margin-top: 0; }

/* ---------- Page text editor ---------- */

.pt-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.pt-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pt-tab.active:hover { background: var(--accent-hover); }

/* #115-118: each box in the Page-text editor is now its own .pt-group with
   its own "Update changes" button (was one giant flat panel + one master
   Save button for ~150 fields at the bottom, easy to miss and easy for a
   stale tab to clobber). #122 turned the flat divider-separated list into
   small bordered cards, so each one has a top edge to carry a per-tab
   accent color and a background to carry the "unsaved changes" highlight. */
.pt-group {
  margin: 16px 0 0;
  padding: 14px 16px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--line-2);
  border-radius: var(--radius);
}

.pt-group:first-child { margin-top: 0; }

/* #122: one accent color per Page-text tab (Studio / Admin / Submission
   page), carried on the tab button, every box's top border in that tab,
   and its "Update changes" button — so staff learn to associate a color
   with a page over time. All three stay inside the site's existing warm
   sage / second-green palette; the third (Submission page) is a warm
   amber-clay from the same earthy family, not an unrelated hue. */
.pt-tab.active[data-pt-tab="studio"] { background: var(--accent); border-color: var(--accent); }
.pt-tab.active[data-pt-tab="studio"]:hover { background: var(--accent-hover); }
#pt-panel-studio .pt-group { border-top-color: var(--accent); }
#pt-panel-studio .pt-update-btn { border-color: var(--accent-border); color: var(--accent); }

.pt-tab.active[data-pt-tab="admin"] { background: var(--gold-deep); border-color: var(--gold-deep); color: #fff; }
.pt-tab.active[data-pt-tab="admin"]:hover { background: #4a6438; }
#pt-panel-admin .pt-group { border-top-color: var(--gold-deep); }
#pt-panel-admin .pt-update-btn { border-color: #c9dab9; color: var(--gold-deep); }

.pt-tab.active[data-pt-tab="submission"] { background: #a8763f; border-color: #a8763f; color: #fff; }
.pt-tab.active[data-pt-tab="submission"]:hover { background: #8c6134; }
#pt-panel-submission .pt-group { border-top-color: #a8763f; }
#pt-panel-submission .pt-update-btn { border-color: #e4cfae; color: #8c6134; }

/* #122: a box with edits waiting to be saved gets a warm highlight — kept
   separate from the tab-accent color above (only background/box-shadow,
   not border-top-color) so "unsaved changes" reads the same on every tab. */
.pt-group.pt-group-dirty {
  background: #fbf3e0;
  box-shadow: var(--shadow-sm), 0 0 0 1px #e8cf94 inset;
}

.hint.dirty { color: #a66b1f; font-weight: 600; }

.pt-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-3);
  margin: 0 0 6px;
}

.pt-group-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.pt-group-actions .pt-group-status {
  margin: 0;
}

/* #120: per-box "Last updated" note, admin-only. Pushed to the right of the
   Update-changes button/status so it reads as metadata, not another action. */
.pt-group-actions .pt-group-updated {
  margin: 0 0 0 auto;
  color: var(--ink-3);
  font-size: 0.72rem;
}

/* Quiet step markers, so the three fields read as a sequence. */
.step {
  display: inline-grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
}

input[type="text"], input[type="password"], input[type="email"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}

textarea {
  resize: vertical;
  min-height: 320px;
  line-height: 1.65;
}

select { cursor: pointer; }

.optional {
  font-weight: 400;
  color: var(--ink-3);
  text-transform: none;
}

textarea.opener-box {
  min-height: 0;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
}

.standard-preview {
  margin-top: 16px;
  padding: 13px 15px;
  background: var(--gold-pale);
  border: 1px solid #cfe0bd;
  border-radius: var(--radius);
}

.standard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.standard-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-hover);
  margin-bottom: 0;
}

.standard-toggle {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gold-deep);
  cursor: pointer;
  flex-shrink: 0;
}

.standard-toggle:hover {
  text-decoration: underline;
}

.standard-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 2px 0;
}

.standard-label {
  font-size: 0.75rem;
  color: var(--ink-3);
  min-width: 74px;
  flex-shrink: 0;
}

.standard-value {
  font-size: 0.86rem;
  color: var(--ink);
}

.standard-value.missing {
  color: var(--ink-3);
  font-style: italic;
}

.music-controls {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.music-controls .field-label { margin-top: 14px; }
.music-controls .field-label:first-child { margin-top: 0; }

input[type="file"] {
  font-size: 0.82rem;
  color: var(--ink-2);
  padding: 6px 0;
  flex: 1;
  min-width: 150px;
}

.admin-only-block {
  margin-top: 16px;
  padding: 12px 14px;
  background: #fffcf5;
  border: 1px solid #fedf89;
  border-radius: var(--radius);
}

.admin-only-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #b54708;
  margin-bottom: 6px;
}

.admin-only-block .hint { margin-top: 8px; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 26px;
}

.settings-grid code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.92em;
}

.char-count {
  text-align: right;
  font-size: 0.75rem;
  color: var(--ink-3);
  margin-top: 7px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Buttons ---------- */

button {
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  padding: 9px 16px;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
}

button:active { transform: translateY(1px); }

button:disabled { opacity: 0.55; cursor: default; transform: none; }

button.primary {
  background: var(--accent);
  color: white;
  width: 100%;
  padding: 12px 16px;
  font-size: 0.94rem;
  font-weight: 600;
  box-shadow: 0 2px 8px -2px rgba(74, 92, 81, 0.5);
}

button.primary:hover:not(:disabled) { background: var(--accent-hover); }

button.secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-2);
  box-shadow: var(--shadow-sm);
}

button.secondary:hover:not(:disabled) { background: var(--surface-2); }

button.star {
  font-size: 1.05rem;
  line-height: 1;
  padding: 8px 12px;
  color: var(--ink-3);
}

button.star.active { color: var(--gold); border-color: var(--gold); background: #f5f9ef; }

button.link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 4px 6px;
  font-size: 0.85rem;
}

button.link:hover { text-decoration: underline; }

/* ---------- Voice controls ---------- */

.row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 11px;
  flex-wrap: wrap;
}

.row.tight { margin-top: 8px; }

.row input[type="text"] { flex: 1; min-width: 150px; }

audio {
  width: 100%;
  height: 38px;
  margin-top: 11px;
  border-radius: var(--radius);
}

.hint {
  font-size: 0.78rem;
  color: var(--ink-3);
  margin: 9px 0 0;
  line-height: 1.5;
}

.hint.ok { color: var(--ok); }
.hint.err { color: var(--danger); }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--ink-2);
  margin-top: 12px;
  cursor: pointer;
}

.checkbox-label input {
  width: auto;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---------- Result ---------- */

#result {
  margin-top: 18px;
  padding: 16px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
}

#result .result-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-hover);
  margin: 0 0 4px;
}

#result .result-file {
  font-size: 0.78rem;
  color: var(--ink-2);
  margin: 0;
  word-break: break-all;
}

#download-link {
  display: inline-block;
  margin-top: 12px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
}

#download-link:hover { background: var(--accent-hover); }

button.block-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.75);
  border-color: var(--accent-border);
  color: var(--accent-hover);
  font-weight: 600;
}

button.block-btn:hover:not(:disabled) { background: #ffffff; }

/* ---------- Library ---------- */

.library-list { display: flex; flex-direction: column; gap: 2px; }

.library-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius);
  transition: background 0.12s;
}

.library-item:hover { background: var(--surface-2); }

.item-left {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.lib-check {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

button.danger {
  color: var(--danger);
  border-color: #fda29b;
  background: #fffbfa;
}

button.danger:hover:not(:disabled) { background: #fef3f2; }

.library-item .meta { min-width: 0; }

.library-item .name {
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-item .detail {
  font-size: 0.76rem;
  color: var(--ink-3);
  margin-top: 1px;
}

.empty-state {
  text-align: center;
  padding: 30px 16px;
  color: var(--ink-3);
  font-size: 0.87rem;
}

/* ---------- Pronunciation tester ---------- */

.pron-list { margin-top: 16px; }

.pron-block {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.pron-heading {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-3);
  padding-top: 12px;
  border-top: 1px solid var(--line);
  margin-bottom: 4px;
}

.pron-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
}

button.pron-text {
  background: none;
  border: none;
  padding: 5px 0;
  text-align: left;
  font-size: 0.84rem;
  color: var(--ink-2);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-card {
  border-color: #fec84b;
  background: #fffcf5;
  margin-bottom: 22px;
}

/* Read-only rendering of a family's rich-text obituary (already sanitized
   server-side to a small safe tag allowlist before it's ever stored). */
.rich-text-view {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px;
  background: var(--surface);
  font-size: 0.92rem;
  line-height: 1.65;
  max-height: 340px;
  overflow-y: auto;
}
.rich-text-view p, .rich-text-view div { margin: 0 0 0.9em; }
.rich-text-view p:last-child, .rich-text-view div:last-child { margin-bottom: 0; }
.rich-text-view ul, .rich-text-view ol { margin: 0 0 0.9em 1.3em; padding: 0; }

.request-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid #fdf0d5;
  flex-wrap: wrap;
}

.request-row:last-child { border-bottom: none; }

.request-row .name { font-size: 0.9rem; }
.request-row .name span { font-style: italic; color: var(--ink-2); }

.request-row .detail {
  font-size: 0.77rem;
  color: var(--ink-3);
  margin-top: 2px;
}

.request-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 270px;
}

input.decision-reason {
  font-size: 0.83rem;
  padding: 7px 10px;
}

.removal-form {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin: 8px 0;
}

.removal-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 7px;
}

.removal-form textarea { min-height: 0; font-size: 0.85rem; }

.decision-note {
  font-size: 0.77rem;
  color: #b54708;
  background: #fffcf5;
  border-left: 2px solid #fec84b;
  padding: 5px 9px;
  margin: 2px 0 8px 6px;
  border-radius: 0 4px 4px 0;
}

.decision-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
}

.decision-row:last-child { border-bottom: none; }
.decision-row .name { font-size: 0.87rem; font-weight: 500; }
.decision-row .detail { font-size: 0.76rem; color: var(--ink-3); margin-top: 1px; }
.decision-row .detail.quote { font-style: italic; color: var(--ink-2); }

.badge.removed { background: #fef3f2; color: var(--danger); border-color: #fda29b; }
.badge.kept { background: #ecfdf3; color: var(--ok); border-color: #abefc6; }

.pending-tag {
  color: #b54708;
  font-size: 0.75rem;
  font-style: italic;
}

button.pending-tag { opacity: 1; }

button.share-toggle {
  background: none;
  border: none;
  padding: 4px 6px;
  font-size: 0.95rem;
  line-height: 1;
  color: var(--ink-3);
  flex-shrink: 0;
}

button.share-toggle.on { color: var(--ok); }
button.share-toggle:hover { transform: scale(1.15); }

button.pron-text:hover { color: var(--accent); }
button.pron-text strong { color: var(--ink); font-weight: 600; }
button.pron-text span { font-style: italic; }

/* ---------- Admin ---------- */

.nav-link {
  font-size: 0.82rem;
  color: var(--ink-2);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  margin-left: 6px;
}

.nav-link:hover { background: var(--surface-2); color: var(--ink); }

.admin-main {
  display: block;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px;
}

.admin-cols {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 1fr);
  gap: 22px;
  margin-bottom: 22px;
  align-items: start;
}

@media (max-width: 940px) {
  .admin-cols { grid-template-columns: 1fr; }
  .admin-main { padding: 18px; }
}

.create-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr);
  gap: 22px;
  align-items: start;
}

.create-grid textarea { min-height: 220px; }

@media (max-width: 940px) {
  .create-grid { grid-template-columns: 1fr; }
}

.cost-summary {
  display: flex;
  gap: 34px;
  flex-wrap: wrap;
  padding-bottom: 4px;
}

.cost-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.cost-value.small { font-size: 1.35rem; color: var(--ink-2); }

.row-free td { color: var(--ink-3); }

.data-table th.num, .data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cost-free {
  color: var(--ok);
  font-size: 0.78rem;
}

td.row-actions {
  white-space: nowrap;
}

td.row-actions button { margin-right: 4px; }

/* ---------- Family submissions ---------- */

.case-form {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 6px;
  margin-bottom: 6px;
}

.case-code {
  display: inline-block;
  font-family: Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--accent-soft);
  color: var(--accent-hover);
  border: 1px solid var(--accent-border);
  padding: 3px 10px;
  border-radius: 6px;
}

.sub-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 4px;
  white-space: normal;
}

.sub-actions button.link { margin: 0; padding: 4px 7px; }

#library-player { margin-bottom: 4px; }

.tier-rate {
  font-size: 0.72rem;
  color: var(--ink-3);
  margin-left: 7px;
  font-variant-numeric: tabular-nums;
}

.tier-rate.pricey { color: #b54708; font-weight: 600; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 22px 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--ink-2);
  margin-top: 2px;
}

.table-wrap {
  overflow: auto;
  max-height: 380px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 14px;
}

.table-wrap.tall { max-height: 520px; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  z-index: 1;
}

.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  text-transform: capitalize;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}

.badge.owner { background: #fef0c7; color: #93370d; border-color: #fedf89; }
.badge.admin { background: var(--accent-soft); color: var(--accent-hover); border-color: var(--accent-border); }
.badge.staff { background: #ecfdf3; color: var(--ok); border-color: #abefc6; }
.badge.ok { background: #ecfdf3; color: var(--ok); border-color: #abefc6; }

td .badge + .badge { margin-left: 5px; }

.by-user {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.pill {
  font-size: 0.76rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 11px;
  color: var(--ink-2);
}

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

.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}

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

.forgot-box {
  margin-top: 12px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
}

.signin-card form input { margin-bottom: 10px; }
.signin-card a { color: var(--accent); }

/* ---------- Two-handle music range ---------- */

.dual-range {
  position: relative;
  height: 42px;
  margin-top: 10px;
}

.dual-track {
  position: absolute;
  top: 17px;
  left: 0;
  right: 0;
  height: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

/* Where the spoken words sit, for context */
.dual-voice {
  position: absolute;
  top: 0;
  height: 100%;
  background: repeating-linear-gradient(
    90deg, var(--line-2) 0 4px, transparent 4px 8px);
}

/* The stretch of recording the music covers */
.dual-band {
  position: absolute;
  top: 0;
  height: 100%;
  background: var(--accent);
  opacity: 0.65;
  border-radius: 999px;
}

.dual-range input[type="range"] {
  position: absolute;
  top: 10px;
  left: 0;
  width: 100%;
  margin: 0;
  background: none;
  pointer-events: none;   /* only the handles are interactive */
  -webkit-appearance: none;
  appearance: none;
  height: 22px;
}

.dual-range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  pointer-events: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--accent);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.25);
  cursor: grab;
}

.dual-range input[type="range"]::-webkit-slider-thumb:active { cursor: grabbing; }

.dual-range input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--accent);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.25);
  cursor: grab;
}

.dual-range input[type="range"]::-moz-range-track { background: none; }

.range-caption {
  font-size: 0.78rem;
  color: var(--ink-2);
  margin-top: -4px;
  font-variant-numeric: tabular-nums;
}

.range-legend {
  display: flex;
  gap: 14px;
  font-size: 0.72rem;
  color: var(--ink-3);
  margin-top: 6px;
}

.range-legend span { display: flex; align-items: center; gap: 5px; }

.swatch {
  width: 14px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}

.swatch.music { background: var(--accent); opacity: 0.65; }
.swatch.voice {
  background: repeating-linear-gradient(90deg, var(--line-2) 0 4px, transparent 4px 8px);
  border: 1px solid var(--line);
}


/* ---------- Readability checks ---------- */

.text-checks { margin-top: 12px; }

.check-ok {
  font-size: 0.8rem;
  color: var(--ok);
  padding: 8px 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
}

.check-heading {
  font-size: 0.78rem;
  font-weight: 600;
  color: #b54708;
  margin-bottom: 8px;
}

.check-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: #fffcf5;
  border: 1px solid #fedf89;
}

.check-item.bad {
  background: #fffbfa;
  border-color: #fda29b;
}

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

.check-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #b54708;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.check-item.bad .check-label { color: var(--danger); }

.check-quote {
  font-size: 0.82rem;
  color: var(--ink-2);
  font-style: italic;
  margin: 3px 0;
  overflow-wrap: anywhere;
}

.check-advice {
  font-size: 0.8rem;
  color: var(--ink);
}

button.check-fix {
  flex-shrink: 0;
  font-size: 0.78rem;
  padding: 6px 12px;
  margin-top: 0;
}

.auto-tag {
  color: var(--ok);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 600;
}

/* ---------- Pronunciation suggestions ---------- */

.hint-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.hint-label {
  font-size: 0.75rem;
  color: var(--ink-3);
  margin-right: 2px;
}

button.hint-chip {
  font-size: 0.78rem;
  padding: 4px 10px;
  margin-top: 0;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  color: var(--ink);
}

button.hint-chip:hover { background: var(--accent-soft); border-color: var(--accent); }

button.hint-chip.code {
  font-family: Consolas, monospace;
  font-size: 0.74rem;
  color: var(--accent);
}

/* Selected state — used by the AI writing helper's topic chips (#106),
   where clicking toggles a topic on/off rather than firing an action. */
button.hint-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.hint-chip.active:hover { background: var(--accent); border-color: var(--accent); }

/* AI-generated example cards — shared by the family page's per-section
   "Show me examples" and the Studio/Admin "test your draft" box (#107). */
.ai-example-card {
  background: #fffefb;
  border: 1px solid #cfe0bd;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.ai-example-card:last-child { margin-bottom: 0; }
.ai-example-card p {
  margin: 0 0 10px;
  font-size: 0.94rem;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
}

.debug-output {
  margin-top: 10px;
  padding: 12px;
  background: #1f2430;
  color: #e6e6e6;
  border-radius: var(--radius);
  font-family: Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.5;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Phones ----------
   The 940px breakpoint above covers tablets. This one is for handsets, where
   three things need attention: iOS zooms the page in whenever you tap a text
   field whose font is under 16px, the admin tables are wider than the screen,
   and touch targets need to be finger-sized rather than cursor-sized. */

@media (max-width: 600px) {

  /* 16px exactly — the threshold below which iOS Safari zooms on focus. */
  input[type="text"], input[type="password"], input[type="email"],
  textarea, select {
    font-size: 16px;
  }

  main { padding: 14px; gap: 16px; }
  .col { gap: 16px; }
  .card { padding: 16px; border-radius: 12px; }

  header { padding: 0 16px; height: 56px; }
  .brand h1 { font-size: 0.9rem; }
  .user-chip { padding: 4px 5px 4px 10px; font-size: 0.78rem; }
  .user-chip #user-email { display: none; }  /* the avatar identifies you well enough */

  /* Obituary text: tall enough to work in, short enough to still see the
     buttons underneath without hunting for them. */
  textarea { min-height: 240px; }

  /* Buttons go full width and stack, so nothing lands half off-screen. */
  .row { flex-direction: column; align-items: stretch; }
  .row button, .row .btn { width: 100%; }

  /* Except the tight rows, where a ▶ sits beside its input and should stay. */
  .row.tight { flex-direction: row; align-items: center; }
  .row.tight button { width: auto; min-width: 46px; flex-shrink: 0; }

  /* Comfortable thumb targets. */
  button, .hint-chip { min-height: 44px; }
  .hint-chip { min-height: 36px; }

  /* Tables scroll sideways rather than crushing their columns. */
  .data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .settings-grid { grid-template-columns: 1fr; gap: 18px; }

  audio { width: 100%; }

  .debug-output { font-size: 0.68rem; max-height: 240px; }
}
