/*
 * Thier — extras for /account sub-routes (Wearables + Care Circle).
 *
 * Loaded on top of /styles/auth.css (which already covers
 * .account-shell / .account-grid / .account-section / connected-* /
 * btn / auth-status / auth-input). This sheet only adds patterns
 * specific to the two new sub-pages so we don't have to touch
 * auth.css.
 *
 * Design-language: same cream-bg cards, same teal accents, same
 * rounded-square avatars. Avoids any inline `Color(red:)` style
 * one-offs — every colour comes from /styles/main.css tokens.
 */

/* ───── Sub-nav (back to Account) ──────────────────────────────── */

.account-subnav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  font-size: 0.92rem;
  color: var(--ink-3);
}
.account-subnav a {
  color: var(--ink-3);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.account-subnav a:hover { color: var(--ink); }
.account-subnav__sep {
  color: var(--ink-5);
  font-size: 0.92rem;
}

/* ───── Wearable provider rows ─────────────────────────────────── */

.wearable-list {
  display: grid;
  gap: 12px;
}

.wearable-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-2);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  transition: border-color 160ms ease, background 160ms ease;
}
.wearable-row--connected {
  border-color: rgba(14, 132, 121, 0.32);
  background: var(--teal-50);
}
.wearable-row--unsupported {
  background: var(--surface);
  opacity: 0.75;
}

.wearable-row__icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--teal-700);
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
.wearable-row--connected .wearable-row__icon {
  background: var(--surface);
  border-color: var(--teal-200);
}

.wearable-row__body {
  min-width: 0;
}
.wearable-row__name {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.98rem;
  letter-spacing: -0.005em;
  margin: 0;
}
.wearable-row__meta {
  font-size: 0.84rem;
  color: var(--ink-4);
  margin: 2px 0 0;
  line-height: 1.4;
}
.wearable-row__meta--ok    { color: var(--teal-700); }
.wearable-row__meta--muted { color: var(--ink-5); }

.wearable-row__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.wearable-row__actions .btn {
  height: 36px;
  padding: 0 14px;
  font-size: 0.88rem;
}

/* Compact "Sync now" link inside a connected row */
.wearable-sync-link {
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--teal-700);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  margin-left: 8px;
}
.wearable-sync-link:hover { color: var(--teal-800); }
.wearable-sync-link[disabled] {
  color: var(--ink-5);
  cursor: not-allowed;
}

/* Connect-flow hint shown above the list while the user is mid-OAuth */
.wearable-connect-hint {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 0.88rem;
  line-height: 1.5;
}

/* ───── Care Circle invite rows ────────────────────────────────── */

.care-list {
  display: grid;
  gap: 12px;
}

.care-row {
  display: grid;
  gap: 10px;
  padding: 16px;
  background: var(--bg-2);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
}

.care-row__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}
.care-row__name {
  font-weight: 700;
  color: var(--ink);
  font-size: 0.98rem;
}
.care-row__email {
  color: var(--ink-4);
  font-size: 0.88rem;
}
.care-row__rel {
  color: var(--teal-700);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.care-row__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.84rem;
  color: var(--ink-4);
}
.care-row__meta strong { color: var(--ink-2); font-weight: 600; }

.care-status-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.care-status-pill--pending  { background: var(--bg-2);    color: var(--ink-3);    border-color: var(--line); }
.care-status-pill--accepted { background: var(--teal-50); color: var(--teal-700); border-color: var(--teal-200); }
.care-status-pill--revoked,
.care-status-pill--declined,
.care-status-pill--expired  { background: rgba(201,52,58,0.06); color: var(--crimson-500); border-color: rgba(201,52,58,0.24); }

.care-row__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.care-row__actions .btn {
  height: 32px;
  padding: 0 12px;
  font-size: 0.84rem;
}

/* Inline link copy bar */
.care-link {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.care-link__field {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 0.82rem;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

/* ───── Premium gate (Care Circle) ─────────────────────────────── */

.premium-gate {
  text-align: center;
  padding: 32px 22px;
}
.premium-gate__title {
  font-size: 1.18rem;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.premium-gate__body {
  margin: 0 auto 18px;
  max-width: 460px;
  color: var(--ink-3);
  font-size: 0.95rem;
  line-height: 1.55;
}
.premium-gate__features {
  display: grid;
  gap: 8px;
  margin: 18px auto 22px;
  max-width: 380px;
  text-align: left;
  font-size: 0.92rem;
  color: var(--ink-2);
}
.premium-gate__features li {
  list-style: none;
  padding-left: 22px;
  position: relative;
  line-height: 1.5;
}
.premium-gate__features li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--teal-700);
  font-weight: 700;
}

/* ───── Modal-ish invite form ──────────────────────────────────── */

.invite-form {
  display: grid;
  gap: 14px;
  margin-top: 6px;
  padding: 18px;
  background: var(--bg-2);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
}
.invite-form[hidden] { display: none; }
.invite-form .field { display: grid; gap: 6px; }
.invite-form label {
  font-size: 0.82rem;
  color: var(--ink-2);
  font-weight: 600;
  letter-spacing: -0.005em;
}
.invite-form select.auth-input {
  height: 48px;
  padding: 0 36px 0 14px;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 1px),
    calc(100% - 13px) calc(50% - 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

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

/* ───── Cap counter (5 active invites) ─────────────────────────── */

.care-cap {
  font-size: 0.82rem;
  color: var(--ink-4);
  margin-top: 6px;
}
.care-cap--full { color: var(--crimson-500); font-weight: 600; }

/* ───── Empty state ────────────────────────────────────────────── */

.section-empty {
  text-align: center;
  padding: 28px 18px;
  color: var(--ink-4);
  font-size: 0.95rem;
  background: var(--bg-2);
  border-radius: var(--r-md);
  border: 1px dashed var(--line-strong);
}
.section-empty p { margin: 0; }

/* ═══════════════════════════════════════════════════════════════
   /account/memory — "What your AI knows" page
   Web port of Thier/Profile/DoctorMemoryView.swift.
   ═══════════════════════════════════════════════════════════════ */

.memory-header-avatar {
  background: linear-gradient(140deg, var(--teal-500, #0E8479), var(--teal-700, #07564F));
  color: #fff;
  display: grid;
  place-items: center;
}

/* Stats strip */
.memory-stats { padding: 1.4rem 1.6rem; }
.memory-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
.memory-stat {
  text-align: center;
  padding: 0.6rem 0.4rem;
  border-radius: var(--r-md, 14px);
  background: var(--bg-2, #F3F1EA);
}
.memory-stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink, #0E1E1E);
  line-height: 1;
}
.memory-stat-label {
  margin-top: 0.4rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3, #4A5757);
  font-weight: 600;
}

/* Toolbar */
.memory-toolbar-section { padding: 1rem 1.6rem; }
.memory-toolbar {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.memory-filter-select {
  min-width: 200px;
  padding: 0.55rem 0.9rem;
  font-size: 0.92rem;
  background: var(--surface, #fff);
}
.memory-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
}

/* Empty state */
.memory-empty-section { padding: 0; }
.memory-empty {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 3.4rem 1.5rem;
  gap: 1.1rem;
  background: var(--surface, #fff);
  border: 1px solid var(--line, rgba(14,30,30,0.08));
  border-radius: var(--r-lg, 20px);
}
.memory-empty.memory-empty--inline {
  padding: 1.4rem 1.2rem;
  text-align: left;
}
.memory-empty-art { color: var(--teal-500, #0E8479); }
.memory-empty h2 { margin: 0; font-size: 1.2rem; letter-spacing: -0.01em; }
.memory-empty p {
  margin: 0;
  max-width: 36ch;
  color: var(--ink-3, #4A5757);
  font-size: 0.95rem;
  line-height: 1.5;
}
.memory-empty-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* Loading skeleton */
.memory-loading-section { padding: 0; }
.memory-skeleton {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
}
.memory-skel-row {
  height: 56px;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(14,30,30,0.05) 0%, rgba(14,30,30,0.10) 50%, rgba(14,30,30,0.05) 100%);
  background-size: 200% 100%;
  animation: memory-skel 1.4s ease-in-out infinite;
}
@keyframes memory-skel {
  0%   { background-position: 100% 50%; }
  100% { background-position: -100% 50%; }
}

/* Memory groups */
.memory-list-section { padding: 1.2rem 1.6rem; }
.memory-groups {
  display: grid;
  gap: 1.2rem;
}

.memory-group {
  border: 1px solid var(--line, rgba(14,30,30,0.08));
  border-radius: var(--r-lg, 20px);
  background: var(--surface, #fff);
  overflow: hidden;
}
.memory-group-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--line, rgba(14,30,30,0.08));
  background: color-mix(in srgb, var(--cat-color, #4A5757) 6%, transparent);
}
.memory-group-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--cat-color, #4A5757) 14%, transparent);
  color: var(--cat-color, #4A5757);
}
.memory-group-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--ink, #0E1E1E);
  flex: 1;
  min-width: 0;
}
.memory-group-count {
  background: color-mix(in srgb, var(--cat-color, #4A5757) 14%, transparent);
  color: var(--cat-color, #4A5757);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.memory-group-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0;
}

.memory-row {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: 0.8rem;
  align-items: start;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--line, rgba(14,30,30,0.06));
}
.memory-row:last-child { border-bottom: 0; }
.memory-row-bullet {
  width: 8px;
  height: 8px;
  margin-top: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--cat-color, #4A5757) 35%, transparent);
}
.memory-row-body { min-width: 0; }
.memory-row-fact {
  margin: 0 0 0.35rem;
  font-size: 0.96rem;
  line-height: 1.45;
  color: var(--ink, #0E1E1E);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.memory-row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--ink-3, #4A5757);
}
.memory-pill {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
}
.memory-pill--confirmed { background: rgba(38, 168, 119, 0.14); color: #1a8b56; }
.memory-pill--inferred  { background: rgba(242, 169, 59, 0.18); color: #b46a00; }
.memory-pill--outdated  { background: rgba(118, 129, 129, 0.14); color: #4A5757; }
.memory-pill--neutral   { background: rgba(118, 129, 129, 0.14); color: #4A5757; }
.memory-row-source { color: var(--ink-4, #768181); }
.memory-row-date   { color: var(--ink-4, #768181); }

.memory-row-actions {
  display: flex;
  gap: 0.3rem;
}
.memory-icon-btn {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-3, #4A5757);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.memory-icon-btn:hover {
  background: var(--bg-2, #F3F1EA);
  color: var(--ink, #0E1E1E);
  border-color: var(--line-strong, rgba(14,30,30,0.14));
}
.memory-icon-btn--danger:hover {
  background: rgba(201, 52, 58, 0.10);
  color: var(--crimson-500, #C9343A);
  border-color: rgba(201, 52, 58, 0.25);
}

.link-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--teal-700, #07564F);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.muted { color: var(--ink-3, #4A5757); margin: 0; }

/* ═══════════════════════════════════════════════════════════════
   Modal host (used by /account/memory's add-fact + confirm)
   Generic enough to be reused by other account sub-pages.
   ═══════════════════════════════════════════════════════════════ */
.modal-host {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 1.2rem;
}
.modal-host[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 30, 30, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.modal-card {
  position: relative;
  width: min(540px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background: var(--surface, #fff);
  border-radius: var(--r-lg, 20px);
  box-shadow: 0 24px 60px rgba(14,30,30,0.20), 0 4px 12px rgba(14,30,30,0.06);
  border: 1px solid var(--line, rgba(14,30,30,0.08));
}
.modal-card--narrow { width: min(420px, 96vw); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--line, rgba(14,30,30,0.08));
}
.modal-head h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}
.modal-close {
  appearance: none;
  border: 0;
  background: transparent;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--ink-3, #4A5757);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--bg-2, #F3F1EA); color: var(--ink, #0E1E1E); }

.modal-body {
  padding: 1.2rem 1.4rem 1.4rem;
  display: grid;
  gap: 0.95rem;
}
.modal-actions {
  display: flex;
  gap: 0.55rem;
  justify-content: flex-end;
  margin-top: 0.4rem;
}
.confirm-text {
  margin: 0;
  color: var(--ink-3, #4A5757);
  font-size: 0.95rem;
  line-height: 1.5;
}

.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;
}

/* ═══════════════════════════════════════════════════════════════
   /account "Personalisation" section — goals + interests + lifestyle
   ═══════════════════════════════════════════════════════════════ */

.account-personalisation { padding: 1.4rem 1.6rem 1.7rem; }
.section-help { margin: 0 0 0.8rem; color: var(--ink-3, #4A5757); font-size: 0.92rem; line-height: 1.5; }

.persona-fieldset {
  border: 0;
  margin: 0 0 1.2rem;
  padding: 0;
}
.persona-fieldset:last-of-type { margin-bottom: 0; }
.persona-fieldset legend {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3, #4A5757);
  font-weight: 700;
  padding: 0;
  margin: 0 0 0.5rem;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
}
.persona-chip {
  appearance: none;
  border: 1px solid var(--line-strong, rgba(14,30,30,0.14));
  background: var(--surface, #fff);
  color: var(--ink-2, #1F2D2D);
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.12s;
  user-select: none;
}
.persona-chip:hover { transform: translateY(-1px); border-color: var(--teal-500, #0E8479); }
.persona-chip[aria-pressed="true"] {
  background: var(--teal-500, #0E8479);
  color: #fff;
  border-color: var(--teal-500, #0E8479);
  font-weight: 600;
}
.persona-chip:focus-visible {
  outline: 2px solid var(--teal-500, #0E8479);
  outline-offset: 2px;
}

.persona-grid {
  display: grid;
  gap: 0.85rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.persona-grid label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.84rem;
  color: var(--ink-3, #4A5757);
  font-weight: 600;
}
.persona-grid select,
.persona-grid input {
  width: 100%;
}

.persona-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.persona-status {
  font-size: 0.85rem;
  color: var(--ink-3, #4A5757);
}
.persona-status.is-success { color: #1a8b56; }
.persona-status.is-error   { color: var(--crimson-500, #C9343A); }

/* ───── Responsive ─────────────────────────────────────────────── */

@media (max-width: 540px) {
  .wearable-row {
    grid-template-columns: 40px 1fr;
    grid-template-rows: auto auto;
  }
  .wearable-row__actions {
    grid-column: 1 / -1;
    justify-self: end;
  }
  .care-row__actions .btn { flex: 1; min-width: 120px; }
  .care-link { flex-direction: column; }

  .memory-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .memory-toolbar { flex-direction: column; align-items: stretch; }
  .memory-filter-select { min-width: 0; width: 100%; }
  .memory-add-btn { width: 100%; justify-content: center; }
  .memory-row { grid-template-columns: 12px 1fr; }
  .memory-row-actions { grid-column: 1 / -1; justify-self: end; margin-top: 0.4rem; }
}

/* ═══════════════════════════════════════════════════════════════
   /account/privacy — privacy dashboard
   ═══════════════════════════════════════════════════════════════ */
.privacy-summary {
  display: grid;
  gap: 6px;
  background: var(--bg-2, #F3F1EA);
  border-radius: var(--r-md, 14px);
  padding: 12px 14px;
}
.privacy-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--line, rgba(14,30,30,0.06));
  font-size: 0.92rem;
}
.privacy-row:last-child { border-bottom: 0; }
.privacy-row-table { color: var(--ink-2, #1F2D2D); }
.privacy-row-count { color: var(--ink, #0E1E1E); font-weight: 600; font-variant-numeric: tabular-nums; }

.privacy-toggle-list {
  display: grid;
  gap: 12px;
  margin-top: 0.6rem;
}
.privacy-toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  background: var(--bg-2, #F3F1EA);
  border-radius: var(--r-md, 14px);
  cursor: pointer;
}
.privacy-toggle input[type="checkbox"] {
  margin-top: 4px;
  width: 18px; height: 18px;
  cursor: pointer;
}
.privacy-toggle-text {
  display: grid;
  gap: 4px;
  font-size: 0.92rem;
  color: var(--ink-3, #4A5757);
}
.privacy-toggle-text strong {
  color: var(--ink, #0E1E1E);
  font-size: 0.96rem;
}
.privacy-toggle-text span { line-height: 1.5; }
.privacy-toggle-text a { color: var(--teal-700, #07564F); }

.privacy-source-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 6px;
}
.privacy-source-row {
  padding: 8px 12px;
  background: var(--bg-2, #F3F1EA);
  border-radius: var(--r-md, 14px);
  font-size: 0.92rem;
}

.auth-status--warning {
  background: rgba(242, 169, 59, 0.12);
  color: #b46a00;
  border: 1px solid rgba(242, 169, 59, 0.30);
  padding: 14px 16px;
  border-radius: var(--r-md, 14px);
  font-size: 0.92rem;
}
.auth-status--warning strong { display: block; margin-bottom: 4px; }
