/* ==========================================================================
   MindeLine app theme layer. Loaded last.
   Values come from the landing's design tokens (Guía de diseño MindeLine v1.0):
   navy #192436, teal #237873, Montserrat headings, Inter text, 8px controls,
   2px teal focus ring, and the dark "mar profundo" surfaces.
   ========================================================================== */

/* ---------- Shared fixes ---------- */

/* Global heading color (navy) made the hero titles invisible on the navy hero. */
.hero-panel h1, .hero-panel h2 { color: #fff; }

:focus-visible { outline: 2px solid var(--teal-700, #237873); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Accent-colored text follows the patient's accent (and its light tone in dark mode). */
.patient-workspace .eyebrow { color: var(--pz-accent-text, var(--teal-700)); }
.patient-workspace .care-sidebar nav button.active { color: var(--pz-accent-text, var(--teal-700)); }
.patient-workspace .text-link { color: var(--pz-accent-text, var(--teal-700)); }

/* Phone: the patient menu is a scrollable row of pills. A width:100% rule elsewhere
   made each pill fill the row, so only "Overview" was visible. */
@media (max-width: 760px) {
  .patient-workspace .care-sidebar nav { gap: 6px; padding-bottom: 2px; scroll-snap-type: x proximity; scrollbar-width: none;
    mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .patient-workspace .care-sidebar nav::-webkit-scrollbar { display: none; }
  .patient-workspace .care-sidebar nav button { width: auto; flex: 0 0 auto; scroll-snap-align: start; min-height: 40px;
    border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; }
  .patient-workspace .care-sidebar nav button.active { border-color: transparent; }
  .patient-workspace .care-sidebar .portal-brand, .patient-workspace .care-sidebar .portal-nav-label { display: none; }
  .patient-workspace .care-section-heading { flex-wrap: wrap; gap: 12px; }
}

/* ---------- Home shortcuts: cards or list ---------- */
.patient-action-card[hidden], .patient-workspace [data-patient-tab][hidden] { display: none !important; }
.patient-workspace.pz-layout-list .patient-quick-grid { grid-template-columns: 1fr; gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--white, #fff); }
.patient-workspace.pz-layout-list .patient-action-card { display: grid; grid-template-columns: 140px minmax(0, 1fr) auto; align-items: center; gap: 4px 16px;
  min-height: 0; padding: 14px 18px; border: 0; border-radius: 0; border-bottom: 1px solid var(--line); box-shadow: none; text-align: left; }
.patient-workspace.pz-layout-list .patient-action-card:last-child { border-bottom: 0; }
.patient-workspace.pz-layout-list .patient-action-card .eyebrow { margin: 0; }
.patient-workspace.pz-layout-list .patient-action-card::after { content: "›"; grid-column: 3; grid-row: 1 / span 2; font-size: 22px; color: var(--muted); }
.patient-workspace.pz-layout-list .patient-action-card strong { grid-column: 2; }
.patient-workspace.pz-layout-list .patient-action-card small { grid-column: 2; }
.patient-workspace.pz-layout-list .patient-action-card .eyebrow { grid-row: 1 / span 2; }
@media (max-width: 640px) {
  .patient-workspace.pz-layout-list .patient-action-card { grid-template-columns: minmax(0, 1fr) auto; }
  .patient-workspace.pz-layout-list .patient-action-card .eyebrow { grid-row: auto; grid-column: 1; }
  .patient-workspace.pz-layout-list .patient-action-card strong, .patient-workspace.pz-layout-list .patient-action-card small { grid-column: 1; }
  .patient-workspace.pz-layout-list .patient-action-card::after { grid-column: 2; grid-row: 1 / span 3; }
}

/* ---------- Personalize entry points ---------- */
.pz-open-button { gap: 8px; }
.pz-heading-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------- Personalize sheet ---------- */
.pz-sheet { width: min(520px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0 0 0 auto; padding: 0;
  border: 0; border-left: 1px solid var(--line); border-radius: 0; background: var(--white, #fff); color: var(--ink, #192436);
  box-shadow: 0 24px 48px -16px rgba(25,36,54,.22), 0 8px 16px -8px rgba(25,36,54,.1); }
.pz-sheet::backdrop { background: rgba(14, 21, 34, .28); }
.pz-sheet[open] { animation: pz-slide 240ms cubic-bezier(.25,1,.5,1); }
@keyframes pz-slide { from { transform: translateX(24px); opacity: 0; } }
.pz-form { display: flex; flex-direction: column; height: 100%; margin: 0; }
.pz-head { display: flex; justify-content: space-between; gap: 16px; padding: 24px 24px 16px; border-bottom: 1px solid var(--line); }
.pz-head h2 { margin: 4px 0 4px; }
.pz-head p { margin: 0; color: var(--muted); }
.pz-body { flex: 1; overflow: auto; padding: 8px 24px 24px; }
.pz-group { margin: 18px 0 0; padding: 0; border: 0; min-width: 0; }
.pz-group legend { margin-bottom: 8px; padding: 0; font: 600 15px/1.4 var(--font-display, Montserrat, sans-serif); color: var(--navy-800, #192436); }
.pz-help { margin: 0 0 10px; color: var(--muted); }
.pz-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px;
  background: transparent; color: inherit; font-size: 16px; cursor: pointer; }
.pz-icon:hover:not(:disabled) { background: var(--navy-50, #F1F4F9); }
.pz-icon:disabled { opacity: .35; cursor: default; }
.pz-close { font-size: 22px; }

.pz-sections { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.pz-section { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--white, #fff); }
.pz-section.is-hidden .pz-section-name { opacity: .6; }
.pz-section[draggable="true"] { cursor: grab; }
.pz-section.is-dragging { opacity: .5; }
.pz-section.is-drop-target { border-color: var(--teal-700); box-shadow: 0 0 0 2px var(--teal-50); }
.pz-handle { color: var(--muted); letter-spacing: -3px; user-select: none; }
.pz-section-name strong { display: block; }
.pz-section-name small { display: block; color: var(--muted); }
.pz-lock { padding: 2px 8px; border-radius: 999px; background: var(--navy-50, #F1F4F9); color: var(--muted); font-weight: 600; }
.pz-move { display: inline-flex; gap: 4px; }

.pz-switch { position: relative; display: inline-flex; cursor: pointer; }
.pz-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.pz-switch span[aria-hidden] { width: 40px; height: 24px; border-radius: 999px; background: #AAB3C1; position: relative; transition: background 160ms; }
.pz-switch span[aria-hidden]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(25,36,54,.3); transition: transform 160ms cubic-bezier(.25,1,.5,1); }
.pz-switch input:checked + .sr-only + span[aria-hidden] { background: var(--teal-700); }
.pz-switch input:checked + .sr-only + span[aria-hidden]::after { transform: translateX(16px); }
.pz-switch input:focus-visible + .sr-only + span[aria-hidden] { outline: 2px solid var(--teal-700); outline-offset: 2px; }

.pz-segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 10px; background: var(--navy-50, #F1F4F9); }
.pz-segmented label { position: relative; }
.pz-segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pz-segmented span { display: block; min-height: 36px; padding: 8px 14px; border-radius: 7px; font-weight: 600; color: var(--muted); cursor: pointer; }
.pz-segmented input:checked + span { background: var(--white, #fff); color: var(--pz-accent-text, var(--teal-700)); box-shadow: 0 1px 3px rgba(25,36,54,.12); }
.pz-segmented input:checked + span::before { content: "✓ "; }
.pz-segmented input:focus-visible + span { outline: 2px solid var(--teal-700); outline-offset: 2px; }

.pz-swatches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pz-swatch, .pz-face { position: relative; cursor: pointer; }
.pz-swatch input, .pz-face input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pz-swatch { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.pz-swatch span { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--swatch); }
.pz-swatch:has(input:checked) { border-color: var(--swatch-border, var(--ink)); box-shadow: 0 0 0 2px var(--teal-50); }
.pz-swatch:has(input:checked) span { box-shadow: 0 0 0 2px var(--white, #fff), 0 0 0 4px var(--swatch); }
.pz-swatch:has(input:checked) small::after { content: " ✓"; }
.pz-swatch:has(input:focus-visible), .pz-face:has(input:focus-visible) { outline: 2px solid var(--teal-700); outline-offset: 2px; }
.pz-faces { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.pz-face span[aria-hidden] { display: grid; place-items: center; height: 44px; border: 1px solid var(--line); border-radius: 8px; font-size: 22px; }
.pz-face:has(input:checked) span[aria-hidden] { border-color: var(--teal-700); background: var(--teal-50); box-shadow: inset 0 0 0 1px var(--teal-700); }
.pz-check { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.pz-check input { width: 18px; height: 18px; accent-color: var(--teal-700); }

.pz-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; padding: 14px 24px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--white, #fff); }
.pz-status { flex: 1; min-width: 120px; color: var(--muted); }
.pz-status[data-tone="ok"] { color: var(--stable-fg, #1E6443); }
.pz-status[data-tone="error"] { color: var(--risk-fg, #A12C2C); }
.pz-status[data-tone="ok"]::before { content: "✓ "; }
.pz-foot .text-link { font-size: 14px; line-height: 20px; }
.pz-actions { display: inline-flex; gap: 8px; margin-left: auto; }
@media (max-width: 520px) {
  .pz-swatches { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pz-section { grid-template-columns: 14px minmax(0, 1fr) auto; }
  .pz-move { grid-column: 2 / -1; justify-content: flex-end; }
  .pz-actions { width: 100%; }
  .pz-actions .button { flex: 1; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  .pz-sheet[open] { animation: none; }
  .pz-switch span[aria-hidden], .pz-switch span[aria-hidden]::after { transition: none; }
}

/* ==========================================================================
   Dark theme ("mar profundo" from the landing), only for the patient space.
   Surfaces: page #121B2A, raised #1F2C42, chrome #192436. Text #FFF / #C9D1DE / #9AA3B2.
   ========================================================================== */
body.pz-dark {
  color-scheme: dark;
  --white: #1F2C42;
  --bg: #121B2A;
  --line: rgba(201, 209, 222, .16);
  --muted: #B8C1CF;
  --ink: #E8EDF4;
  --navy-50: rgba(255, 255, 255, .06);
  --blue: rgba(141, 180, 232, .14);
  --amber: rgba(232, 145, 58, .16);
  --amber-ink: #F2C08E;
  --red: rgba(214, 69, 69, .18);
  --red-ink: #F3A5A5;
  background: #121B2A;
  color: #C9D1DE;
}
body.pz-dark .topbar, body.pz-dark .app-footer { background: #192436; border-color: var(--line); }
body.pz-dark .topbar .button, body.pz-dark .breadcrumbs strong, body.pz-dark .signed-in-name { color: #FFFFFF; }
body.pz-dark .breadcrumbs, body.pz-dark .secure-label, body.pz-dark .reset-link { color: #B8C1CF; }
body.pz-dark .page-content, body.pz-dark .main-area, body.pz-dark .app-shell { background: #121B2A; }
body.pz-dark .patient-workspace .care-sidebar, body.pz-dark .patient-workspace.portal-workspace .care-sidebar { background: #192436; border-color: var(--line); }
body.pz-dark .patient-workspace .care-sidebar nav button { color: #C9D1DE; }
body.pz-dark .patient-workspace .care-sidebar nav button:hover { background: rgba(255,255,255,.06); }
body.pz-dark .patient-workspace .care-sidebar nav button.active { background: rgba(255,255,255,.08); }
body.pz-dark .patient-workspace .brand-logo { filter: brightness(0) invert(1); }
body.pz-dark .patient-workspace h1, body.pz-dark .patient-workspace h2, body.pz-dark .patient-workspace h3,
body.pz-dark .patient-workspace h4, body.pz-dark .patient-workspace strong, body.pz-dark .pz-sheet h2 { color: #FFFFFF; }
body.pz-dark .patient-workspace p, body.pz-dark .patient-workspace small, body.pz-dark .patient-workspace label,
body.pz-dark .patient-workspace li, body.pz-dark .patient-workspace td { color: #C9D1DE; }
body.pz-dark .patient-workspace .quiet-note, body.pz-dark .patient-workspace .care-section-heading p { color: #B8C1CF; }

body.pz-dark .patient-workspace :is(.panel, .stat-card, .patient-action-card, .appointment-card, .agenda-task, .patient-week-day,
  .patient-course-quiz, .patient-course-reflection, .patient-share-option, .patient-ai-audio-composer, .consent-copy, .notice,
  .empty-state, .response-card, .message, .participant-message, .choice, .patient-ai-starters button, .cn-patient-card,
  .patient-course-card, .patient-program-row, .event-tag, .tag) {
  background: #1F2C42; border-color: var(--line); color: #C9D1DE; box-shadow: none;
}
body.pz-dark .patient-workspace .hero-panel { background: #0E1522; }
body.pz-dark .patient-workspace .notice { background: rgba(255,255,255,.05); }
body.pz-dark .patient-workspace :is(.field, .select, .textarea, input[type="text"], input[type="email"], input[type="tel"], input[type="date"], input[type="time"], select, textarea) {
  background: #121B2A; border-color: #7E8798; color: #FFFFFF;
}
body.pz-dark .patient-workspace :is(.field, .textarea)::placeholder { color: #9AA3B2; }
body.pz-dark :is(.patient-workspace, .pz-sheet) .button:not(.button-primary):not(.button-danger) { background: transparent; border-color: #C9D1DE; color: #FFFFFF; }
body.pz-dark :is(.patient-workspace, .pz-sheet) .button-soft { background: rgba(255,255,255,.08); border-color: transparent; color: var(--pz-accent-text); }
body.pz-dark .patient-workspace .button-danger { background: transparent; border-color: #F3A5A5; color: #F3A5A5; }
body.pz-dark .patient-workspace .choice.selected { background: rgba(255,255,255,.1); border-color: var(--pz-accent-text); color: #FFFFFF; }
body.pz-dark .patient-workspace .patient-ai-message { background: #1F2C42; border-color: var(--line); }
body.pz-dark .patient-workspace .patient-ai-message-own { background: rgba(255,255,255,.1); }
body.pz-dark .patient-workspace .status { background: rgba(255,255,255,.08); color: #E8EDF4; }
body.pz-dark .patient-workspace .status.teal { color: #7CC4A0; }
body.pz-dark .patient-workspace :is(.status.review, .status.amber) { color: #F2C08E; }
body.pz-dark .patient-workspace .status.red { color: #F3A5A5; }
body.pz-dark .patient-workspace .status.blue { color: #A9C3E8; }
body.pz-dark .patient-workspace .cn-avatar { background: rgba(255,255,255,.1); color: #FFFFFF; }
body.pz-dark .patient-workspace .cn-chip { background: rgba(255,255,255,.08); color: var(--pz-accent-text); }
body.pz-dark .patient-workspace.pz-layout-list .patient-quick-grid { background: #1F2C42; }
body.pz-dark .pz-sheet { background: #192436; color: #C9D1DE; border-color: var(--line); }
body.pz-dark .pz-sheet :is(.pz-section, .pz-foot) { background: #1F2C42; }
body.pz-dark .pz-sheet .pz-segmented input:checked + span { background: #33425E; color: #FFFFFF; }
body.pz-dark .pz-sheet .pz-group legend, body.pz-dark .pz-sheet strong { color: #FFFFFF; }
body.pz-dark .pz-sheet .pz-swatch:has(input:checked) { border-color: #FFFFFF; }
body.pz-dark .pz-sheet .pz-swatch:has(input:checked) span { box-shadow: 0 0 0 2px #192436, 0 0 0 4px var(--swatch); }
body.pz-dark .pz-sheet .pz-status[data-tone="ok"] { color: #7CC4A0; }
body.pz-dark .pz-sheet .pz-status[data-tone="error"] { color: #F3A5A5; }
body.pz-dark .pz-switch span[aria-hidden] { background: #566076; }
body.pz-dark .pz-sheet .text-link { color: var(--pz-accent-text); }

/* Dark mode: chrome and decorations that use fixed light colors elsewhere. */
body.pz-dark .topbar .button { background: transparent; border-color: #C9D1DE; color: #FFFFFF; }
body.pz-dark .patient-workspace .hero-panel::after { background: #121B2A; }
body.pz-dark .patient-workspace .care-sidebar nav button.active,
body.pz-dark .patient-workspace .care-sidebar nav button.active * { color: var(--pz-accent-text); }
body.pz-dark .patient-workspace .care-sidebar nav button.active .care-nav-icon svg { stroke: currentColor; }

/* The week calendar scrolls inside its panel instead of widening the page. */
.patient-care-view, .patient-care-view > .panel, .patient-week-calendar, .patient-week-grid { min-width: 0; max-width: 100%; }

/* Dark mode: rules elsewhere set heading and tile colors with higher specificity. */
body.pz-dark .portal-workspace.patient-workspace :is(h1, h2, h3, h4),
body.pz-dark .portal-workspace.care-workspace.patient-workspace .care-section-heading h1 { color: #FFFFFF; }
body.pz-dark .patient-workspace .appointment-time { background: rgba(255, 255, 255, .08); color: #FFFFFF; }
body.pz-dark .patient-workspace .appointment-time strong { color: #FFFFFF; }
body.pz-dark .patient-workspace .appointment-time span { color: #C9D1DE; }
body.pz-dark .patient-workspace .patient-activity-mark { background: rgba(255, 255, 255, .1); color: var(--pz-accent-text); border-color: transparent; }
body.pz-dark .patient-workspace .patient-week-day h4 strong { color: #FFFFFF; }
body.pz-dark .patient-workspace .patient-week-day h4 { color: #C9D1DE; }
body.pz-dark .patient-workspace :is(.patient-course-hero, .patient-course-intro > .patient-course-evidence:first-child)::after {
  background: radial-gradient(circle, rgba(92, 194, 186, .14) 0%, rgba(92, 194, 186, 0) 72%);
}
body.pz-dark .patient-workspace :is(.patient-course-progress, .patient-checkin-progress > div, .progress-track) { background: rgba(255, 255, 255, .12); }

/* Visual parts of the custom controls let clicks reach the real input underneath. */
.pz-switch span[aria-hidden], .pz-segmented span, .pz-swatch > span, .pz-swatch small, .pz-face span { pointer-events: none; }
.pz-segmented input, .pz-swatch input, .pz-face input, .pz-switch input { z-index: 1; }

/* ---------- Demo mode top bar: view switcher ---------- */
.demo-view-switch { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; }
.demo-view-switch .select { width: auto; min-height: 36px; padding: 6px 30px 6px 10px; }
@media (max-width: 760px) { .demo-view-switch span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } }
#authForm[aria-busy="true"] input { opacity: .7; }

/* Dialogs use the same type, controls, and spacing as the portal. */
.action-dialog { width: min(480px, calc(100% - 32px)); max-height: min(720px, calc(100dvh - 32px)); overflow: auto; padding: 24px; color: var(--ink, #192436); background: var(--white, #fff); }
.action-dialog__form { margin: 0; }
.action-dialog .modal-head { margin-bottom: 10px; }
.action-dialog .modal-head h2 { margin-top: 4px; }
.action-dialog__description { margin: 0; color: var(--muted, #768398); font-size: 14px; line-height: 1.6; }
.action-dialog__field { margin-top: 18px; }
.action-dialog__field[hidden] { display: none; }
.action-dialog__field .field-label { margin: 0 0 7px; color: var(--ink, #192436); font-size: 13px; }
.action-dialog__field .field, .action-dialog__field .textarea { width: 100%; font-size: 14px; }
.action-dialog__field .textarea { min-height: 112px; }
.action-dialog__actions { justify-content: flex-end; margin-top: 22px; }
.action-dialog .button-danger { background: var(--risk-bg, #fff0ee); border-color: var(--risk, #a5483c); color: var(--risk-fg, #a12c2c); }
body.pz-dark .action-dialog { color: #E8EDF4; background: #192436; }
body.pz-dark .action-dialog .modal-head h2, body.pz-dark .action-dialog__field .field-label { color: #FFFFFF; }
body.pz-dark .action-dialog__description { color: #C9D1DE; }
body.pz-dark .action-dialog .icon-button { background: rgba(255,255,255,.08); color: #FFFFFF; }
@media (max-width: 520px) {
  .action-dialog { padding: 20px; }
  .action-dialog__actions { flex-direction: column-reverse; }
  .action-dialog__actions .button { width: 100%; justify-content: center; }
}

/* The patient area keeps readable body and control text at the standard setting. */
.patient-workspace .patient-care-view :is(p, label) { font-size: 1em; line-height: 1.6; }
.patient-workspace .patient-care-view :is(small, time, .patient-info-list dt) { font-size: .86em; line-height: 1.5; }
.patient-workspace .patient-care-view :is(.patient-activity-title strong, .patient-questionnaire-head strong,
  .patient-info-list dd, .patient-community-event strong, .patient-share-option strong) { font-size: 1em; line-height: 1.45; }
.patient-workspace .patient-care-view :is(.patient-questionnaire-options legend, .patient-program-row details) { font-size: 1em; }
.patient-workspace .patient-care-view :is(.field, .select, .textarea, input, select, textarea) { font-size: 1em; }

/* ---------- Patient assistant: one conversation across portal and WhatsApp ---------- */
.patient-ai-context { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin: 14px 0 4px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--navy-50, #F1F4F9); }
.patient-ai-context p { margin: 0; max-width: 62ch; }
.patient-ai-context .action-row { margin: 0; }
.patient-ai-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-bottom: 6px; }
.patient-ai-meta strong { font: 600 .9em/1.3 var(--font-body, Inter, sans-serif); color: var(--navy-800, #192436); }
.patient-ai-meta time { margin-left: auto; color: var(--muted); font-size: .85em; }
.patient-ai-channel { display: inline-flex; align-items: center; padding: 1px 8px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--white, #fff); color: var(--muted); font-size: .78em; font-weight: 600; letter-spacing: .02em; }
.patient-ai-channel-ai { border-color: transparent; background: var(--teal-50, #E9F5F4); color: var(--pz-accent-text, var(--teal-700)); }
.patient-ai-kind { display: inline-block; margin-bottom: 4px; color: var(--muted); font-size: .85em; font-style: italic; }
.patient-ai-day { display: flex; align-items: center; gap: 10px; margin: 6px 0; color: var(--muted); font-size: .82em; font-weight: 600; text-transform: capitalize; }
.patient-ai-day::before, .patient-ai-day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.patient-ai-message-pending { opacity: .85; }
.patient-ai-starters { margin-top: 10px; }
body.pz-dark .patient-workspace .patient-ai-context { background: rgba(255,255,255,.05); border-color: var(--line); }
body.pz-dark .patient-workspace .patient-ai-meta strong { color: #FFFFFF; }
body.pz-dark .patient-workspace .patient-ai-channel { background: transparent; border-color: var(--line); color: #C9D1DE; }
body.pz-dark .patient-workspace .patient-ai-channel-ai { background: rgba(255,255,255,.08); color: var(--pz-accent-text); }
@media (max-width: 640px) { .patient-ai-context .action-row { width: 100%; } .patient-ai-context .action-row .button { flex: 1; justify-content: center; } }
.demo-assistant-steps { display: grid; gap: 10px; margin: 4px 0 16px; padding-left: 22px; }
.demo-assistant-steps li strong { display: block; }
.demo-assistant-steps li span { color: var(--muted); }

/* ---------- Profile menu (top bar) ---------- */
.pz-profile { position: relative; display: inline-flex; }
.pz-profile-button { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 50%;
  background: var(--white, #fff); cursor: pointer; transition: box-shadow 160ms cubic-bezier(.25,1,.5,1); }
.pz-profile-button:hover, .pz-profile-button[aria-expanded="true"] { box-shadow: 0 0 0 3px var(--teal-50, #E9F5F4); }
.pz-profile-menu { position: absolute; z-index: 80; top: calc(100% + 8px); right: 0; width: min(300px, calc(100vw - 24px)); padding: 6px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--white, #fff);
  box-shadow: 0 8px 24px -8px rgba(25,36,54,.18), 0 2px 6px -2px rgba(25,36,54,.1); }
.pz-profile-head { display: flex; align-items: center; gap: 12px; padding: 10px 10px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.pz-profile-head strong { display: block; color: var(--navy-800, #192436); font: 600 15px/1.3 var(--font-body, Inter, sans-serif); overflow-wrap: anywhere; }
.pz-profile-head small { display: block; margin-top: 2px; color: var(--muted); }
.pz-demo-tag { padding: 1px 6px; border-radius: 5px; background: var(--amber, #FDF0E2); color: var(--amber-ink, #8C4A0E); font-weight: 600; }
.pz-profile-item { display: flex; width: 100%; min-height: 40px; align-items: center; padding: 8px 10px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink, #192436); font: 500 14px/1.3 var(--font-body, Inter, sans-serif); text-align: left; cursor: pointer; }
.pz-profile-item:hover, .pz-profile-item:focus-visible { background: var(--navy-50, #F1F4F9); }
.pz-profile-signout { margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0 0 6px 6px; color: var(--muted); }

/* Avatar: photo, illustrated avatar or initials, always circular. */
.pz-avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; }
.pz-avatar-initials { background: var(--teal-50, #E9F5F4); color: var(--pz-accent-text, var(--teal-700)); font: 600 13px/1 var(--font-body, Inter, sans-serif); letter-spacing: .02em; }
.pz-avatar-emoji { font-size: 20px; line-height: 1; }
.pz-avatar-lg { width: 48px; height: 48px; }
.pz-avatar-lg.pz-avatar-initials { font-size: 16px; }
.pz-avatar-lg.pz-avatar-emoji { font-size: 26px; }
.pz-avatar-xl { width: 88px; height: 88px; border: 1px solid var(--line); }
.pz-avatar-xl.pz-avatar-initials { font-size: 28px; }
.pz-avatar-xl.pz-avatar-emoji { font-size: 44px; background: var(--navy-50, #F1F4F9); }

/* Personalize sheet: grouped blocks, photo, start page and per-section toggles. */
.pz-block { padding: 18px 0 6px; border-bottom: 1px solid var(--line); }
.pz-block:last-child { border-bottom: 0; }
.pz-block h3 { margin: 0; font: 600 17px/1.3 var(--font-display, Montserrat, sans-serif); color: var(--navy-800, #192436); }
.pz-label { display: block; margin-bottom: 6px; font: 600 15px/1.4 var(--font-display, Montserrat, sans-serif); color: var(--navy-800, #192436); }
.pz-label span { color: var(--muted); font: 400 13px/1 var(--font-body, Inter, sans-serif); }
.pz-group .select, .pz-group .field { width: 100%; max-width: 360px; }
.pz-photo { display: flex; gap: 16px; align-items: flex-start; margin-top: 14px; }
.pz-photo-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
.pz-photo-actions .pz-help { flex-basis: 100%; margin: 4px 0 0; }
.pz-file { position: relative; overflow: hidden; }
.pz-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.pz-file:has(input:focus-visible) { outline: 2px solid var(--teal-700); outline-offset: 2px; }
.pz-status-line { flex-basis: 100%; margin: 0; color: var(--ink, #192436); font-weight: 500; }
.pz-status-line:empty { display: none; }
.pz-section { grid-template-columns: 18px minmax(0, 1fr) auto auto; }
.pz-section-toggles { display: inline-flex; align-items: center; gap: 10px; }
.pz-mini-check { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; cursor: pointer; }
.pz-mini-check input { width: 16px; height: 16px; accent-color: var(--teal-700); }
.pz-mini-check:has(input:disabled) { opacity: .45; cursor: default; }
@media (max-width: 520px) {
  .pz-photo { flex-direction: column; }
  .pz-section { grid-template-columns: 14px minmax(0, 1fr); }
  .pz-section-toggles, .pz-move { grid-column: 2; }
}

/* Card style: raised cards keep their border for structure and add a soft shadow. */
.patient-workspace.pz-cards-raised :is(.patient-care-view .panel, .patient-action-card, .cn-patient-card, .patient-ai-message) {
  box-shadow: 0 8px 24px -10px rgba(25,36,54,.22), 0 2px 6px -2px rgba(25,36,54,.08); }
body.pz-dark .patient-workspace.pz-cards-raised :is(.patient-care-view .panel, .patient-action-card, .cn-patient-card, .patient-ai-message) {
  box-shadow: 0 10px 24px -8px rgba(5,10,20,.55); background: #24334C; }

/* Reduce motion (user choice) mirrors the device setting for the patient space and its menus. */
body.pz-reduce-motion .patient-workspace *, body.pz-reduce-motion .pz-sheet, body.pz-reduce-motion .pz-sheet *,
body.pz-reduce-motion .pz-profile * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) { .pz-profile-button { transition: none; } }

body.pz-dark .pz-profile-button { background: #1F2C42; border-color: var(--line); }
body.pz-dark .pz-profile-menu { background: #192436; border-color: var(--line); box-shadow: 0 12px 28px -8px rgba(5,10,20,.6); }
body.pz-dark .pz-profile-head strong, body.pz-dark .pz-profile-item { color: #FFFFFF; }
body.pz-dark .pz-profile-head small, body.pz-dark .pz-profile-signout { color: #C9D1DE; }
body.pz-dark .pz-profile-item:hover, body.pz-dark .pz-profile-item:focus-visible { background: rgba(255,255,255,.08); }
body.pz-dark .pz-sheet :is(.pz-block h3, .pz-label) { color: #FFFFFF; }
body.pz-dark .pz-sheet .pz-status-line { color: #E8EDF4; }
body.pz-dark .pz-sheet .pz-avatar-xl.pz-avatar-emoji { background: rgba(255,255,255,.06); }
.pz-segmented input:disabled + span { opacity: .45; cursor: not-allowed; text-decoration: line-through; }
body.pz-dark .pz-sheet :is(.field, .select), body.pz-dark .demo-view-switch .select { background: #121B2A; border-color: #7E8798; color: #FFFFFF; }
body.pz-dark .demo-view-switch { color: #C9D1DE; }
.pz-mini-label { margin-left: -4px; color: var(--muted); font-size: 13px; }

/* ---------- Extreme personalization: boats, header art, fonts, width, menu, cards, greeting ---------- */
.pz-avatar-boat { background: var(--teal-50, #E9F5F4); color: var(--pz-accent-text, var(--teal-700)); }
.pz-avatar-boat svg { width: 62%; height: 62%; }
.pz-boats .pz-face span[aria-hidden] { color: var(--pz-accent-text, var(--teal-700)); }
.pz-boats .pz-face svg { width: 26px; height: 26px; }

.care-section-heading.pz-has-art { position: relative; overflow: hidden; padding-bottom: 56px; border-radius: 12px; }
.care-section-heading.pz-has-art > :not(.pz-header-art) { position: relative; z-index: 1; }
.pz-header-art { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 52px; pointer-events: none; z-index: 0; }
.pz-header-art path, .pz-horizon-sun { fill: var(--teal-50, #E9F5F4); }
.pz-header-art .pz-wave-back { fill: var(--pz-accent-text, var(--teal-700)); opacity: .12; }
.pz-horizon-line { fill: none !important; stroke: var(--pz-accent-text, var(--teal-700)); stroke-width: 1.5; opacity: .35; }
.pz-horizon-boat { fill: none !important; stroke: var(--pz-accent-text, var(--teal-700)); stroke-width: 2; stroke-linejoin: round; opacity: .7; }
.pz-wave-track { animation: pz-wave 18s linear infinite; }
@keyframes pz-wave { to { transform: translateX(-300px); } }
@media (prefers-reduced-motion: reduce) { .pz-wave-track { animation: none; } }
body.pz-dark .pz-header-art path, body.pz-dark .pz-horizon-sun { fill: rgba(255, 255, 255, .06); }

.patient-workspace.pz-font-atkinson :not(h1, h2, h3, h4, svg, svg *) { font-family: "Atkinson Hyperlegible", Inter, system-ui, sans-serif !important; }
.patient-workspace.pz-font-system :not(h1, h2, h3, h4, svg, svg *) { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif !important; }

.portal-workspace.care-workspace.patient-workspace.pz-width-narrow .care-content { width: min(820px, 100%); }
.portal-workspace.care-workspace.patient-workspace.pz-width-wide .care-content { width: min(1600px, 100%); max-width: none; }

@media (min-width: 761px) {
  .portal-workspace.care-workspace.patient-workspace.pz-nav-icons { grid-template-columns: 88px minmax(0, 1fr); }
  .patient-workspace.pz-nav-icons .care-sidebar { padding-inline: 12px; }
  .patient-workspace.pz-nav-icons .care-sidebar nav button { justify-content: center; padding: 12px 0; }
  .patient-workspace.pz-nav-icons :is(.portal-nav-label, .care-sidebar-foot) { display: none; }
  .patient-workspace.pz-nav-icons .portal-brand img { width: 44px; height: 32px; object-fit: cover; object-position: left center; }
}
.patient-workspace.pz-nav-icons .care-sidebar nav button > span:not(.care-nav-icon) {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.patient-workspace.pz-cards-large .patient-quick-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.patient-workspace.pz-cards-large .patient-action-card { min-height: 150px; padding: 24px; }
.patient-workspace.pz-cards-large .patient-action-card strong { font-size: 1.2em; }
.patient-workspace.pz-cards-large.pz-layout-list .patient-action-card { min-height: 0; padding: 20px 22px; }

.pz-greeting { margin: 0 0 4px; font: 600 16px/1.3 var(--font-display, Montserrat, sans-serif); color: var(--pz-accent-text, var(--teal-700)); }
.pz-greeting[hidden] { display: none; }
.patient-workspace:not(:has([data-patient-view="overview"]:not([hidden]))) .pz-greeting { display: none; }
.care-section-heading p.pz-greeting { color: var(--pz-accent-text, var(--teal-700)); }

/* ==========================================================================
   Patient type and spacing scale.
   One set of variables drives text, controls, cards, chat, calendar and menus, so
   "Text size", "Spacing" and "Home card size" change everything together.
   dashboard-polish.css fixes 14px on most elements with "#app [class] …" (specificity up to
   1,2,0). Repeating .patient-workspace raises these rules above it without !important.
   ========================================================================== */
/* Defaults; personalization sets them on <body> and the shell classes override them. */
:root { --pz-scale: 1; --pz-space: 1; }
.patient-workspace, .pz-sheet, .pz-profile {
  --pz-text: calc(15px * var(--pz-scale));
  --pz-small: calc(13px * var(--pz-scale));
  --pz-h1: calc(28px * var(--pz-scale));
  --pz-h2: calc(22px * var(--pz-scale));
  --pz-h3: calc(18px * var(--pz-scale));
  --pz-h4: calc(16px * var(--pz-scale));
  --pz-stat: calc(24px * var(--pz-scale));
  --pz-control-h: max(40px, calc(40px * var(--pz-scale)));
  --pz-pad: calc(20px * var(--pz-space));
  --pz-gap: calc(16px * var(--pz-space));
}
@media (pointer: coarse) { .patient-workspace, .pz-sheet, .pz-profile { --pz-control-h: max(44px, calc(40px * var(--pz-scale))); } }
@media (max-width: 760px) { .patient-workspace { --pz-h1: calc(24px * var(--pz-scale)); --pz-h2: calc(20px * var(--pz-scale)); } }

/* Base text: every element in the patient space, then the smaller roles. */
#app .patient-workspace.patient-workspace,
#app .patient-workspace.patient-workspace [class],
#app .patient-workspace.patient-workspace :is(p, li, label, button, input, select, textarea, td, th, summary, span, strong, a, dd, dt, legend) {
  font-size: var(--pz-text); line-height: 1.5; }
#app .patient-workspace.patient-workspace :is(small, time, .quiet-note, .eyebrow, .status, .tag, .event-tag, .pz-help, .cn-chip,
  .patient-ai-meta strong, .patient-ai-meta time, .patient-ai-channel, .patient-ai-kind, .patient-ai-day, .care-nav-group-label, .portal-nav-label,
  .care-sidebar-foot, .patient-week-day li small, .patient-week-day li span, .appointment-time span) { font-size: var(--pz-small); line-height: 1.45; }
#app .patient-workspace.patient-workspace.patient-workspace :is(h1, .care-section-heading h1) { font-size: var(--pz-h1); line-height: 1.25; }
#app .patient-workspace.patient-workspace.patient-workspace h2 { font-size: var(--pz-h2); line-height: 1.3; }
#app .patient-workspace.patient-workspace.patient-workspace h3 { font-size: var(--pz-h3); line-height: 1.35; }
#app .patient-workspace.patient-workspace.patient-workspace h4 { font-size: var(--pz-h4); line-height: 1.4; }
#app .patient-workspace.patient-workspace.patient-workspace :is(.stat-card strong, .appointment-time strong) { font-size: var(--pz-stat); line-height: 1.3; }
#app .patient-workspace.patient-workspace.patient-workspace .pz-greeting { font-size: calc(16px * var(--pz-scale)); }

/* Controls: height follows the scale, never below 40px (44px on touch screens). */
#app .patient-workspace.patient-workspace :is(.button, .field, .select, .choice, .care-sidebar nav button) { min-height: var(--pz-control-h); }
#app .patient-workspace.patient-workspace .button-small { min-height: max(32px, calc(32px * var(--pz-scale))); }
@media (pointer: coarse) { #app .patient-workspace.patient-workspace .button-small { min-height: 44px; } }
#app .patient-workspace.patient-workspace .textarea { min-height: calc(96px * var(--pz-scale)); }
#app .patient-workspace.patient-workspace :is(.status, .tag, .patient-ai-channel, .cn-chip) { padding: .2em .65em; }

/* Spacing: panels, cards, chat, calendar. */
#app .patient-workspace.patient-workspace .patient-care-view > .panel { padding: var(--pz-pad); margin-bottom: var(--pz-gap); }
#app .patient-workspace.patient-workspace :is(.patient-quick-grid, .patient-ai-thread) { gap: calc(12px * var(--pz-space)); }
#app .patient-workspace.patient-workspace .patient-action-card { min-height: calc(112px * var(--pz-scale) * var(--pz-space)); padding: calc(18px * var(--pz-space)); }
#app .patient-workspace.patient-workspace.pz-cards-large .patient-action-card { min-height: calc(150px * var(--pz-scale) * var(--pz-space)); padding: calc(24px * var(--pz-space)); }
#app .patient-workspace.patient-workspace.pz-cards-large .patient-action-card strong { font-size: calc(var(--pz-text) * 1.2); }
#app .patient-workspace.patient-workspace.pz-cards-large .patient-quick-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(260px * var(--pz-scale))), 1fr)); }
#app .patient-workspace.patient-workspace .patient-ai-message { padding: calc(12px * var(--pz-space)) calc(14px * var(--pz-space)); }
#app .patient-workspace.patient-workspace .patient-week-grid { grid-template-columns: repeat(7, minmax(calc(138px * var(--pz-scale)), 1fr)); }
#app .patient-workspace.patient-workspace .patient-week-day { min-height: calc(150px * var(--pz-space)); padding: calc(10px * var(--pz-space)); }
#app .patient-workspace.patient-workspace .care-sidebar nav button { padding-block: calc(10px * var(--pz-space)); }

/* Avatars and boats follow the scale in the top bar and the sheet. */
.pz-profile-button { width: calc(40px * var(--pz-scale)); height: calc(40px * var(--pz-scale)); }
.main-area .pz-avatar.pz-avatar-initials { font-size: calc(13px * var(--pz-scale)); }
.pz-profile-button .pz-avatar { width: calc(36px * var(--pz-scale)); height: calc(36px * var(--pz-scale)); }
.pz-boats .pz-face svg { width: calc(26px * var(--pz-scale)); height: calc(26px * var(--pz-scale)); }
.pz-face span[aria-hidden] { height: max(44px, calc(44px * var(--pz-scale))); }

/* Sheet and profile menu: same scale (they live outside #app). */
.pz-sheet, .pz-profile-menu { font-size: var(--pz-text); }
.pz-sheet :is(.pz-help, .pz-section-name small, .pz-mini-check, .pz-mini-label, .pz-status, .pz-label span, .pz-swatch small), .pz-profile-head small { font-size: var(--pz-small); }
.pz-sheet :is(.pz-group legend, .pz-label) { font-size: calc(15px * var(--pz-scale)); }
.pz-sheet .pz-block h3 { font-size: calc(17px * var(--pz-scale)); }
.pz-sheet .pz-head h2 { font-size: var(--pz-h2); }
.pz-sheet :is(.button, .field, .select, .pz-segmented span, .pz-icon), .pz-profile-item { min-height: var(--pz-control-h); font-size: var(--pz-text); }
.pz-sheet .pz-icon { width: var(--pz-control-h); }
.pz-sheet .pz-foot .text-link { font-size: var(--pz-text); }

/* Long words and enlarged text spacing wrap instead of being clipped (WCAG 1.4.12). */
.patient-workspace :is(p, li, strong, small, .patient-ai-message, .patient-action-card), .pz-sheet :is(p, strong, small) { overflow-wrap: anywhere; }

/* Narrow screens: the top bar wraps instead of widening the page (WCAG 1.4.10). The name is
   already in the profile menu, so it is hidden here when that menu exists. */
@media (max-width: 760px) {
  .topbar { height: auto; min-height: 56px; flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .topbar-right { flex-wrap: wrap; justify-content: flex-end; gap: 8px; min-width: 0; margin-left: auto; }
  .topbar-right:has(.pz-profile) .signed-in-name { display: none; }
  .demo-view-switch .select { max-width: 9.5rem; }
}
.patient-workspace :is(.eyebrow, h1, h2, h3, h4, button, label) { overflow-wrap: anywhere; }
.patient-workspace :is(select, .select, .hero-panel, .patient-quick-grid > *) { max-width: 100%; min-width: 0; }
