/* Family dashboard. Brand tokens come from /assets/brand.css. */

body {
  font-size: 17px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  max-width: 880px;
  margin: 0 auto;
  padding: 14px 16px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-variation-settings: "opsz" 48;
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
}

.logo-face {
  width: 38px;
}

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.btn.small {
  --edge: 3px;
  min-height: 40px;
  padding: 7px 16px;
  font-size: 0.88rem;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 16px 60px;
}

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

.flash {
  background: var(--calm-soft);
  border-radius: 12px;
  padding: 12px 16px;
  margin: 8px 0 16px;
}

.error {
  color: var(--danger);
  margin: 0;
  font-size: 0.9rem;
}

.small {
  font-size: 0.85rem;
}

.center {
  text-align: center;
}

/* Auth */
.auth {
  display: grid;
  gap: 22px;
  max-width: 440px;
  margin: 24px auto 0;
}

.auth-intro {
  text-align: center;
}

.auth-face {
  display: block;
  width: 130px;
  margin: 0 auto 8px;
}

.auth-intro h1 {
  font-size: 1.8rem;
  margin: 0 0 8px;
}

/* Forms */
.form {
  display: grid;
  gap: 14px;
}

.form label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  font-size: 0.95rem;
}

.form label .muted {
  font-weight: 400;
}

.form input:not([type="checkbox"]):not([type="radio"]),
.form select,
.form textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-weight: 400;
}

.form textarea {
  resize: vertical;
}

.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

fieldset {
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px 12px;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

legend {
  font-weight: 600;
  padding: 0 4px;
}

.choice {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 400 !important;
}

.consent {
  display: grid !important;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px !important;
  font-weight: 400 !important;
  background: var(--calm-soft);
  border-radius: 12px;
  padding: 12px 14px;
}

.consent input {
  margin-top: 4px;
  width: 18px;
  height: 18px;
  accent-color: var(--calm);
}

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

/* Senior cards */
#seniors {
  display: grid;
  gap: 20px;
  margin-bottom: 18px;
}

.senior-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.senior-head h2 {
  margin: 0;
  font-size: 1.5rem;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--tint);
}

.badge.paid {
  background: var(--calm-soft);
}

.badge.ended {
  background: var(--tint);
  color: var(--danger);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.stat {
  background: var(--bg);
  border-radius: 14px;
  padding: 14px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 4px;
}

.stat-value {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
}

.meter {
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}

.summary {
  margin: 4px 0 0;
  font-size: 0.95rem;
}

.panels {
  display: grid;
  gap: 10px;
}

details.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 16px;
}

details.panel > summary {
  cursor: pointer;
  padding: 14px 0;
  font-weight: 700;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

details.panel > summary::after {
  content: "+";
  color: var(--muted);
  font-weight: 400;
}

details.panel[open] > summary::after {
  content: "–";
}

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

.panel-body {
  padding: 0 0 16px;
  display: grid;
  gap: 12px;
}

.panel-body p {
  margin: 0;
}

.highlight {
  border: 2px solid var(--accent);
}

.pair-box {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
}

.qr {
  width: 140px;
  height: 140px;
  background: #fff;
  border-radius: 12px;
  padding: 8px;
}

.qr svg,
.qr img {
  width: 100%;
  height: 100%;
}

.pair-link {
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  word-break: break-all;
  background: var(--bg);
  border-radius: 10px;
  padding: 10px;
}

.plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.plan {
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 6px;
}

.plan.current {
  border-color: var(--calm);
  background: var(--calm-soft);
}

.plan h3 {
  margin: 0;
  font-size: 1.05rem;
}

.plan .price {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
}

.convo {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.convo:first-child {
  border-top: none;
  padding-top: 0;
}

.convo-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.transcript {
  margin-top: 8px;
  display: grid;
  gap: 4px;
  font-size: 0.9rem;
}

.transcript .who {
  font-weight: 700;
}

.memory-notes {
  white-space: pre-wrap;
  background: var(--bg);
  border-radius: 12px;
  padding: 12px;
  font-size: 0.9rem;
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-strong);
  text-decoration: underline;
  cursor: pointer;
  justify-self: start;
}

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

/* ---------- Story book ---------- */

.ask {
  background: var(--tint);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.ask-form {
  display: grid;
  gap: 6px;
}

.ask-label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.ask-row {
  display: flex;
  gap: 8px;
}

.ask-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-weight: 400;
  padding: 10px 12px;
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
}

.questions {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.questions li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border-radius: 10px;
  padding: 8px 6px 8px 12px;
}

.questions .remove {
  flex: none;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.questions .remove:hover {
  background: var(--bg);
  color: var(--ink);
}

.story-empty {
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  padding: 14px 16px;
  display: grid;
  gap: 4px;
}

.chapters {
  display: grid;
  gap: 20px;
}

.chapter {
  display: grid;
  gap: 10px;
}

.chapter-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* A dotted line out to the edge, like a contents page. */
.chapter-title::after {
  content: "";
  flex: 1;
  border-bottom: 3px dotted var(--pop);
  opacity: 0.45;
}

.chapter-count {
  order: 2;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.story {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--sun);
  border-radius: 6px 14px 14px 6px;
  padding: 14px 16px;
  display: grid;
  gap: 8px;
  box-shadow: var(--shadow);
}

.story.writing,
.story.failed {
  box-shadow: none;
  border-left-color: var(--line-strong);
}

.story-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 650;
  line-height: 1.25;
  text-wrap: balance;
}

.story-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.story-answer {
  color: var(--calm);
  font-weight: 700;
}

.story-text {
  display: grid;
  gap: 0.7em;
  font-size: 1.02rem;
  line-height: 1.6;
  text-wrap: pretty;
}

.story-text.clamped {
  max-height: 11em;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, #000 60%, transparent);
}

.story-tags {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.story-tags li {
  font-size: 0.8rem;
  background: var(--sky);
  border-radius: 999px;
  padding: 3px 10px;
}

.story .pulse {
  display: inline-block;
  vertical-align: middle;
}

@media (max-width: 520px) {
  .pair-box {
    grid-template-columns: 1fr;
    justify-items: center;
  }
}

/* Loading, before we know whether someone is signed in. */
.loading {
  text-align: center;
  color: var(--muted);
  padding: var(--s8) 0;
}

/* Password with a show/hide toggle. */
.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 76px !important;
}

.reveal {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  min-height: 36px;
  padding: 4px 12px;
  border: none;
  border-radius: 10px;
  background: var(--tint);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

.hint {
  font-weight: 400;
  font-size: 0.85rem;
}

/* Setup progress: two steps, so the end always feels close. */
.steps {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s5);
  list-style: none;
  padding: 0;
  margin: 0 0 var(--s4);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.steps li {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
}

.step-dot {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  font-size: 0.8rem;
}

.steps li.current {
  color: var(--ink);
}

.steps li.current .step-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.steps li.done .step-dot {
  background: var(--calm);
  border-color: var(--calm);
  color: #fff;
}

h2 {
  font-size: 1.6rem;
}

/* ---------- Setup flow ---------- */

.setup {
  padding: var(--s6);
}

@media (max-width: 560px) {
  .setup {
    padding: var(--s5) var(--s4);
  }
}

.setup-body {
  display: grid;
  gap: var(--s3);
}

.setup-body h2 {
  margin: var(--s2) 0 0;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  outline: none;
}

.lead {
  margin: 0 0 var(--s3);
  font-size: 1.05rem;
}

.field-group {
  display: grid;
  gap: var(--s4);
}

.form-heading {
  margin: var(--s4) 0 0;
  font-size: 1.2rem;
}

/* Progress: numbered dots joined by a line; finished steps get a tick. */
.steps {
  gap: 0;
  flex-wrap: nowrap;
  margin-bottom: var(--s3);
}

.steps li {
  flex: 1;
  position: relative;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 13px;
  left: 34px;
  right: 8px;
  height: 2px;
  background: var(--line);
}

.steps li.done:not(:last-child)::after {
  background: var(--calm);
}

.step-label {
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

@media (max-width: 560px) {
  .steps li:not(.current) .step-label {
    visibility: hidden;
  }
}

/* A woman's or a man's voice: two big, obvious choices. */
.voice-choice {
  border: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
}

.voice-choice legend {
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0;
  margin-bottom: var(--s2);
}

.choice-card {
  position: relative;
  display: flex !important;
  align-items: center;
  gap: var(--s3) !important;
  padding: var(--s4);
  border: 2px solid var(--line-strong);
  border-radius: 18px;
  background: var(--surface);
  cursor: pointer;
  font-weight: 400 !important;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out, background-color 150ms ease-out;
}

.choice-card input {
  width: 22px;
  height: 22px;
  margin: 0;
  flex: none;
  accent-color: var(--accent);
}

.choice-card > span {
  display: grid;
  gap: 2px;
}

.choice-card strong {
  font-size: 1.02rem;
}

.choice-card .muted {
  font-size: 0.85rem;
}

.choice-card:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  box-shadow: 0 3px 0 var(--accent);
}

.choice-card:active {
  transform: translateY(2px);
}

@media (max-width: 460px) {
  .voice-choice {
    grid-template-columns: 1fr;
  }
}

.more-options > summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.95rem;
  padding: var(--s1) 0;
  width: fit-content;
}

.more-options[open] > summary {
  margin-bottom: var(--s3);
}

/* Tap-to-start ideas above the "about them" box. */
.starters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

.starter {
  min-height: 40px;
  border: 1.5px dashed var(--line-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 150ms ease-out, background-color 150ms ease-out;
}

.starter:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.starter:active {
  transform: scale(0.97);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Waiting for their device to connect. */
.waiting {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin: var(--s2) 0 0;
  color: var(--muted);
  font-weight: 700;
}

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

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .pulse {
    animation: none;
  }
}

.pair-details {
  display: grid;
  gap: var(--s3);
}

/* The happy ending. */
.setup-done {
  text-align: center;
  justify-items: center;
  padding: var(--s4) 0;
}

.done-face {
  width: 150px;
}

.setup-done .actions {
  justify-content: center;
}

/* Character faces on the companion choice and next to each person's name. */
.choice-face {
  width: 56px;
  flex: none;
}

.senior-title {
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.senior-title h2 {
  margin: 0;
}

.senior-title p {
  margin: 0;
}

.senior-face {
  width: 52px;
  flex: none;
}

/* Help card alerts: hard to miss, at the top of the person's card. */
.alert {
  display: grid;
  gap: var(--s2);
  justify-items: start;
  background: color-mix(in srgb, var(--danger) 9%, var(--surface));
  border: 2px solid var(--danger);
  border-radius: 16px;
  padding: var(--s4);
  margin-bottom: var(--s4);
}

.alert-title {
  margin: 0;
  font-weight: 700;
  color: var(--danger);
}

.alert ul {
  margin: 0;
  padding-left: 1.1em;
}

.alert p {
  margin: 0;
}

/* Deleting the account: tucked away at the very bottom. */
.account-delete {
  margin-top: var(--s7, 48px);
  display: grid;
  justify-items: start;
  gap: 12px;
}

.account-delete .form {
  max-width: 520px;
}

.account-delete .form p {
  margin: 0;
}
