:root {
  --bg: #eef7f3;
  --bg-soft: #fbfffd;
  --panel: #ffffff;
  --ink: #0f2722;
  --muted: #536962;
  --line: #cfe1dc;
  --accent: #00766b;
  --accent-dark: #00584f;
  --accent-soft: #daf0e7;
  --sage: #397b65;
  --sun: #ef9f4c;
  --rose: #b94f61;
  --violet: #7a6fa6;
  --shadow: 0 14px 34px rgba(15, 39, 34, .09);
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Plus Jakarta Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  font-weight: 450;
}

body.auth-page {
  background:
    radial-gradient(circle at 15% 20%, rgba(239, 159, 76, .18), transparent 18%),
    radial-gradient(circle at 85% 12%, rgba(0, 118, 107, .18), transparent 22%),
    linear-gradient(135deg, #f7fbf8 0%, #e5f4ec 42%, #fbfffd 100%);
}

a { color: inherit; text-decoration: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  min-height: 58px;
  overflow: hidden;
  background: rgba(248, 251, 252, .86);
  border-bottom: 1px solid rgba(207, 225, 220, .82);
  backdrop-filter: blur(18px);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.notification-link {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--accent-dark);
  font-weight: 850;
}

.notification-link strong,
.mobile-nav strong,
.tile-icon b {
  position: absolute;
  display: grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--rose);
  color: #fff;
  font-size: 11px;
  line-height: 1;
}

.notification-link strong {
  right: -5px;
  top: -5px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  max-width: calc(100vw - 130px);
  font-weight: 850;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-logo {
  display: block;
  flex: 0 0 34px;
  width: 34px !important;
  height: 34px !important;
  max-width: 34px !important;
  max-height: 34px !important;
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-dark);
  color: #fff;
  box-shadow: 0 8px 22px rgba(23, 73, 90, .22);
}

.shell {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 18px 14px 64px;
}

.app-layout {
  width: min(1320px, 100%);
  margin: 0 auto;
}

.sidebar {
  display: none;
}

.side-link {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 9px 10px;
  border-radius: 8px;
  color: #395065;
  font-weight: 780;
}

.side-link:hover {
  background: rgba(255,255,255,.78);
  color: var(--accent-dark);
}

.side-link span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.side-link em {
  min-width: 24px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  text-align: center;
}

.side-link em.alert {
  background: var(--rose);
  border-color: var(--rose);
  color: #fff;
}

.hero-panel,
.patient-hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 8px 0 18px;
  padding: 22px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.97), rgba(218,240,231,.92)),
    linear-gradient(135deg, rgba(0,118,107,.11), rgba(122,111,166,.09));
  box-shadow: var(--shadow);
}

.patient-hero::after,
.hero-panel::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  right: -96px;
  top: -84px;
  border-radius: 50%;
  background: rgba(239,159,76,.18);
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 18px;
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.04;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  margin: 0 0 12px;
}

.hero-copy {
  max-width: 560px;
  margin: 10px 0 0;
  color: #405569;
  line-height: 1.45;
}

.eyebrow,
small,
.muted {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 850;
  letter-spacing: .08em;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.action-tile,
.patient-row,
.panel,
.form-card,
.auth-panel {
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(216,227,232,.92);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(35, 57, 67, .06);
}

.action-tile {
  min-height: 112px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-weight: 800;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.action-tile:hover,
.patient-row:hover {
  transform: translateY(-2px);
  border-color: rgba(0,118,107,.34);
  box-shadow: 0 16px 34px rgba(35, 57, 67, .10);
}

.danger-tile .tile-icon,
.danger-button {
  background: linear-gradient(135deg, #d66f75, #a83d46);
  color: #fff;
}

.tile-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 18px;
}

.tile-icon b {
  right: -7px;
  top: -7px;
}

.action-tile small {
  display: block;
  font-weight: 600;
  line-height: 1.25;
  margin-top: 8px;
}

.patient-list { display: grid; gap: 10px; }

.patient-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
}

.patient-row small {
  display: block;
  margin-top: 4px;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--sage));
  color: #fff;
  font-weight: 850;
  box-shadow: 0 10px 24px rgba(0,118,107,.22);
  text-transform: uppercase;
}

.avatar.large {
  position: relative;
  z-index: 1;
  width: 70px;
  height: 70px;
  font-size: 24px;
}

.chevron { color: var(--muted); font-weight: 900; }

.panel {
  padding: 18px;
  margin: 12px 0;
  overflow: hidden;
}

.two-column {
  display: grid;
  gap: 12px;
}

.metric-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.metric-list span {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}

.metric-list strong {
  font-size: 26px;
  line-height: 1;
}

.invite-panel {
  display: grid;
  gap: 14px;
  border-color: rgba(0,118,107,.22);
  background:
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(238,247,243,.96));
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.invite-status {
  display: grid;
  gap: 5px;
  justify-items: end;
}

.invite-status small {
  max-width: 280px;
  text-align: right;
}

.admin-request {
  gap: 14px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.row-actions form {
  margin: 0;
}

.admin-inline-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.admin-inline-form label {
  display: grid;
  gap: 6px;
  font-weight: 800;
  color: var(--ink);
}

.admin-inline-form select,
.admin-inline-form input,
.invite-admin-row input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

.invite-admin-row {
  gap: 12px;
}

.invite-admin-row input {
  max-width: 520px;
}

.item {
  border-top: 1px solid var(--line);
  padding: 14px 0;
  display: block;
}

.item:first-of-type { border-top: 0; }

.item p {
  margin: 8px 0;
  color: #334155;
  line-height: 1.48;
}

.plan-list-panel,
.appointment-list-panel {
  display: grid;
  gap: 12px;
}

.care-plan-card,
.appointment-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(31, 43, 48, .05);
}

.care-plan-card {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.care-plan-card header {
  display: grid;
  gap: 3px;
}

.care-plan-card h3,
.appointment-card h3 {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.25;
}

.care-plan-card time {
  color: #60717a;
  font-size: 12px;
  font-weight: 760;
}

.care-plan-kicker {
  width: fit-content;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e5f3ef;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.appointment-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px;
}

.appointment-card > time {
  display: grid;
  place-items: center;
  min-height: 54px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  text-transform: uppercase;
}

.appointment-card > time strong {
  font-size: 22px;
  line-height: 1;
}

.appointment-card > time span {
  font-size: 11px;
  font-weight: 850;
}

.appointment-card > div {
  display: grid;
  gap: 6px;
}

.appointment-card small {
  color: #536273;
  font-weight: 760;
}

.appointment-card p {
  margin: 0;
  color: #334155;
  line-height: 1.42;
}

.appointment-card.past {
  background: #f7faf9;
}

.appointment-card.past > time {
  background: #edf1f2;
  color: #6d7b84;
}

.appointment-actions {
  justify-content: flex-start;
  margin-top: 4px;
}

.badge {
  display: inline-flex;
  justify-content: center;
  padding: 5px 9px;
  border-radius: 999px;
  background: #eef1f4;
  color: #526273;
  font-size: 12px;
  font-weight: 800;
}

.badge.ok {
  background: #e1f5eb;
  color: #236348;
}

.muted-badge {
  background: #f2ece8;
  color: #8a5c48;
}

.primary,
.secondary,
.icon-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 850;
}

.primary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  box-shadow: 0 12px 24px rgba(0,118,107,.22);
}

.secondary {
  display: inline-flex;
  justify-content: center;
  padding: 10px 12px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.small {
  padding: 9px 12px;
  font-size: 14px;
}

.icon-button {
  background: transparent;
  color: var(--muted);
  padding: 8px;
}

.form-card,
.auth-panel {
  padding: 18px;
}

.danger-panel {
  border-color: rgba(214, 111, 117, .35);
}

.stack {
  display: grid;
  gap: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-width: 520px;
  margin: 0 0 12px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.72);
}

.segmented a {
  display: grid;
  place-items: center;
  min-height: 40px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 850;
}

.segmented a.active {
  background: var(--accent-dark);
  color: #fff;
}

.day-date-title {
  margin: 2px 0 0;
  text-transform: capitalize;
}

.day-tabs {
  position: sticky;
  top: 58px;
  z-index: 9;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  max-width: 680px;
  margin: 0 0 12px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(14px);
}

.day-tabs button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  text-transform: uppercase;
}

.day-tabs button.active {
  background: var(--accent-dark);
  color: #fff;
}

.form-section {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.form-section:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.hidden-fields {
  display: none;
}

.compact-subform {
  display: grid;
  gap: 8px;
}

.compact-head {
  margin-bottom: 10px;
}

.compact-form {
  max-width: 680px;
  padding: 14px;
}

.compact-form label {
  margin-bottom: 4px;
  color: #32465a;
  font-size: 13px;
}

.compact-form input,
.compact-form textarea,
.compact-form select {
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 15px;
}

.compact-form textarea {
  min-height: 74px;
}

.compact-form p {
  margin: 0;
}

.nap-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.nap-grid .span-2,
.night-grid .span-2 {
  grid-column: 1 / -1;
}

.nap-entry-form input[readonly],
.nap-duration-preview {
  background: #f3f7f8;
  color: var(--muted);
}

.form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
}

.form-actions .secondary {
  min-height: 38px;
  align-items: center;
}

.link-row {
  display: grid;
  gap: 4px;
}

.night-entry-form {
  max-width: 760px;
}

.night-section h2 {
  margin-bottom: 10px;
  font-size: 16px;
}

.night-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-title-row h2 {
  margin: 0;
}

.range-field {
  display: grid;
  gap: 4px;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr 34px;
  align-items: center;
  gap: 8px;
}

input[type="range"] {
  min-height: 34px;
  padding: 0;
  accent-color: var(--accent);
}

.range-row output {
  display: grid;
  place-items: center;
  min-height: 30px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 850;
}

.duration-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  align-self: end;
}

.duration-presets button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
}

.duration-presets button.active,
.duration-presets button:active {
  background: var(--accent);
  border-color: var(--accent);
  color: #061017;
}

.tag-helper {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.wake-list,
.nap-list {
  display: grid;
  gap: 10px;
}

.wake-card,
.nap-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
}

.entry-card {
  display: grid;
  gap: 10px;
}

.entry-card-head {
  display: grid;
}

.entry-toggle {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.entry-title {
  font-weight: 900;
}

.entry-summary {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.entry-card.is-collapsed {
  gap: 0;
}

.delete-card[data-confirm="true"] {
  background: #ffe4e6;
  color: #9f1239;
}

.delete-card::before {
  content: "🗑";
  margin-right: 6px;
}

.delete-card[data-confirm="true"]::before {
  content: "";
  margin-right: 0;
}

.form-save-status {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #166534;
  font-size: 14px;
  font-weight: 850;
}

.form-save-status[data-kind="error"] {
  border-color: #fecdd3;
  background: #fff1f2;
  color: #be123c;
}

.delete-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.delete-check input {
  display: none;
}

.night-observations {
  margin: 12px 0 0;
}

.observation-field {
  padding: 12px;
  border: 1px solid rgba(31, 79, 74, 0.22);
  border-radius: 14px;
  background: #f4fbf8;
}

.observation-field label {
  display: inline-flex;
  margin-bottom: 7px;
  color: #17443f;
  font-size: 13px;
  font-weight: 900;
}

.observation-field textarea,
textarea.observation-textarea {
  min-height: 92px;
  background: #ffffff;
  border-color: #bad6cf;
}

.observation-field textarea:focus,
textarea.observation-textarea:focus {
  border-color: #1f7a70;
  box-shadow: 0 0 0 3px rgba(31, 122, 112, 0.14);
}

.night-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.night-summary span {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
}

.night-summary strong {
  font-size: 20px;
  line-height: 1;
}

.auth-panel {
  max-width: 480px;
  margin: 44px auto 0;
  box-shadow: var(--shadow);
}

.auth-page .topbar {
  position: relative;
  background: transparent;
  border-bottom-color: transparent;
}

.auth-page .app-layout {
  width: 100%;
}

.auth-page .shell {
  width: 100%;
  max-width: none;
  padding: 0 14px 28px;
}

.auth-stage {
  display: grid;
  gap: 18px;
  min-height: calc(100vh - 68px);
  align-items: stretch;
}

.public-page .shell {
  padding: 14px;
}

.public-page .auth-stage {
  min-height: calc(100dvh - 86px);
  align-items: center;
}

.auth-visual {
  position: relative;
  overflow: hidden;
  min-height: 460px;
  border-radius: 8px;
  background: #10252d;
  box-shadow: 0 22px 56px rgba(19, 31, 36, .16);
  isolation: isolate;
}

.auth-visual-image {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  transform: translateZ(0);
}

.auth-visual::before,
.auth-visual::after {
  display: none;
}

.auth-visual-mask {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,.02), rgba(8, 20, 27, .24)),
    linear-gradient(90deg, rgba(8, 20, 27, .58) 0%, rgba(8, 20, 27, .08) 60%, rgba(8, 20, 27, .30) 100%);
  z-index: 1;
}

.auth-copy {
  position: absolute;
  z-index: 2;
  inset: auto 18px 18px 18px;
  max-width: 640px;
  color: #fff;
}

.auth-copy h1 {
  color: #fff;
  font-size: clamp(32px, 4vw, 56px);
  max-width: 12ch;
}

.auth-copy .hero-copy {
  max-width: 44ch;
  color: rgba(255,255,255,.88);
}

.auth-eyebrow {
  color: rgba(255,255,255,.72);
}

.auth-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.auth-pills span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.22);
  color: #fff;
  backdrop-filter: blur(10px);
}

.auth-open {
  margin-top: 18px;
  min-width: 150px;
}

.auth-panel--glass {
  position: relative;
  z-index: 2;
  margin: -124px 0 0 auto;
  width: min(100%, 420px);
  padding: 22px;
  background: rgba(255,255,255,.84);
  border: 1px solid rgba(255,255,255,.62);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 54px rgba(19, 31, 36, .16);
}

.public-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.login-page {
  background:
    linear-gradient(135deg, rgba(255,255,255,.88), rgba(230,244,246,.92)),
    url("/static/core/landing/sleep-hero-2.jpg") center / cover no-repeat;
}

.login-card {
  margin-top: min(12vh, 90px);
}

.tracking-panel {
  display: grid;
  gap: 12px;
}

.tracking-settings {
  display: grid;
  grid-template-columns: 1fr 92px auto;
  gap: 8px;
}

.tracking-legend,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tracking-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

.tracking-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.state-complete { background: #4f8a72; }
.state-partial { background: #f2b84b; }
.state-missing { background: #d66f75; }
.state-paused { background: #8191a3; }

.week-list {
  display: grid;
  gap: 8px;
}

.tracking-week-nav {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.tracking-week-nav strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 950;
  text-align: center;
}

.tracking-week-nav .secondary.small {
  min-height: 34px;
  padding: 7px 9px;
  white-space: nowrap;
}

.tracking-week-nav .secondary.small:disabled {
  opacity: .42;
  cursor: default;
}

.week-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
  padding-bottom: 2px;
}

.week-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  text-align: center;
}

.day-card {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 48px;
  padding: 5px 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  text-decoration: none;
}

.day-card time {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.05;
  text-transform: uppercase;
}

.day-card time strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1;
}

.day-card.empty {
  border-style: dashed;
  background: transparent;
  opacity: .34;
}

.day-status-dot {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.day-card.complete { border-color: rgba(79,138,114,.45); background: #eef8f2; }
.day-card.partial { border-color: rgba(242,184,75,.55); background: #fff8e8; }
.day-card.missing { border-color: rgba(214,111,117,.5); background: #fff0f1; }
.day-card.paused { border-color: #c5ced8; background: #f2f5f7; }
.day-card.future { opacity: .64; }

.day-card.complete .day-status-dot { color: #4f8a72; }
.day-card.partial .day-status-dot { color: #d6901f; }
.day-card.missing .day-status-dot { color: #c4515a; }
.day-card.paused .day-status-dot { color: #8191a3; }

.day-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  margin-top: 8px;
}

.day-actions a {
  display: grid;
  place-items: center;
  min-height: 28px;
  border-radius: 7px;
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(216,227,232,.9);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 850;
}

.pause-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, .9fr);
  gap: 12px;
}

.pause-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
}

.pause-form h2,
.pause-list h2 {
  margin: 0;
  font-size: 16px;
}

.auth-form input {
  min-height: 42px;
}

.whatsapp-inbox {
  background: #f3f7f4;
}

.chat-avatar {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #256d5a, #8bb69a);
  color: #fff;
  font-weight: 850;
  text-transform: uppercase;
}

.chat-shell {
  display: grid;
  gap: 0;
  overflow: hidden;
  min-height: calc(100vh - 132px);
  border: 1px solid rgba(216,227,232,.92);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(239, 232, 221, .72), rgba(225, 238, 232, .72)),
    repeating-linear-gradient(45deg, rgba(23,73,90,.035) 0 2px, transparent 2px 14px);
  box-shadow: 0 10px 28px rgba(35, 57, 67, .06);
}

.chat-header {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: rgba(255,255,255,.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.chat-header h1 {
  font-size: 20px;
  line-height: 1.1;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 360px;
  padding: 14px;
}

.chat-message {
  display: flex;
}

.chat-message.mine {
  justify-content: flex-end;
}

.chat-message.theirs {
  justify-content: flex-start;
}

.chat-bubble {
  width: fit-content;
  max-width: min(78%, 620px);
  padding: 9px 11px 7px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(35,57,67,.08);
}

.chat-message.mine .chat-bubble {
  background: #d9fdd3;
}

.chat-bubble strong {
  display: block;
  margin-bottom: 3px;
  color: #256d5a;
  font-size: 12px;
}

.chat-bubble p {
  margin: 0;
  color: #172133;
  line-height: 1.42;
}

.chat-bubble small {
  display: block;
  margin-top: 4px;
  text-align: right;
  font-size: 11px;
}

.chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px;
  background: rgba(255,255,255,.86);
  border-top: 1px solid var(--line);
}

.chat-compose textarea {
  min-height: 44px;
  max-height: 120px;
  resize: vertical;
  border-radius: 8px;
}

.chat-compose .primary {
  min-height: 44px;
}

.signup-panel {
  max-width: 640px;
}

.form-card p,
.auth-panel p {
  margin: 0 0 12px;
}

label {
  display: block;
  font-weight: 780;
  margin-bottom: 6px;
}

input,
textarea,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cbd8df;
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0,118,107,.12);
}

textarea {
  min-height: 116px;
  resize: vertical;
}

.subform {
  border: 1px dashed #c9d7dd;
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0;
  background: #fbfdfd;
}

.messages {
  margin: 8px 0 14px;
}

.message {
  background: #e4f5ec;
  color: #1e5d44;
  padding: 11px 12px;
  border: 1px solid #bee4cf;
  border-radius: 8px;
}

.message-bubble {
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
  margin-bottom: 10px;
}

.message-bubble p { margin: 8px 0; }
.empty { color: var(--muted); }
.legal-text { line-height: 1.55; }
canvas { width: 100%; display: block; }

.chart-mode-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 10px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
}

.chart-mode-tabs button {
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
}

.chart-mode-tabs button.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px rgba(0,118,107,.18);
}

.chart-week-nav {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin: 0 0 8px;
}

.chart-week-nav strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  text-align: center;
}

.chart-week-nav button {
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
}

.chart-week-nav button:disabled {
  opacity: .42;
  cursor: default;
}

.chart-table-wrap {
  margin-top: 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.chart-data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
  font-size: 13px;
}

.chart-data-table th,
.chart-data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.chart-data-table th:first-child,
.chart-data-table td:first-child {
  text-align: left;
}

.chart-data-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 850;
}

.chart-data-table tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 520px) {
  .chart-mode-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-week-nav {
    grid-template-columns: 1fr 1fr;
  }

  .chart-week-nav strong {
    grid-column: 1 / -1;
    grid-row: 1;
  }
}

.inbox-panel {
  padding: 8px;
}

.inbox-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border-radius: 8px;
}

.inbox-row + .inbox-row {
  border-top: 1px solid var(--line);
}

.inbox-row p {
  margin: 6px 0 0;
  color: #405569;
  line-height: 1.35;
}

.inbox-row.unread {
  background: #f0f8fa;
}

.unread-dot {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--rose);
  color: #fff;
  font-size: 12px;
  font-style: normal;
  font-weight: 850;
}

.calendar-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.calendar-row:first-child {
  border-top: 0;
}

.calendar-row time {
  display: grid;
  place-items: center;
  width: 54px;
  height: 58px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.calendar-row time strong {
  font-size: 21px;
}

.calendar-row p {
  margin: 6px 0 0;
  color: #405569;
}

.mobile-nav {
  position: fixed;
  z-index: 20;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 7px;
  border: 1px solid rgba(216,227,232,.9);
  border-radius: 8px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 18px 44px rgba(35,57,67,.18);
  backdrop-filter: blur(16px);
}

.mobile-nav a {
  position: relative;
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 48px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mobile-nav span {
  font-size: 18px;
  color: var(--accent-dark);
}

.mobile-nav strong {
  right: 18px;
  top: 3px;
}

body.dark-mode:not(.auth-page):not(.login-page) {
  --bg: #05090c;
  --bg-soft: #111820;
  --panel: #121b24;
  --ink: #f7fbff;
  --muted: #c5d2dc;
  --line: #40515f;
  --accent: #67d6e6;
  --accent-dark: #bdf4fb;
  --accent-soft: #183743;
  background:
    radial-gradient(circle at 15% 0%, rgba(103, 214, 230, .10), transparent 26%),
    linear-gradient(180deg, #05090c 0%, #091117 100%);
}

body.dark-mode:not(.auth-page):not(.login-page) .topbar,
body.dark-mode:not(.auth-page):not(.login-page) .mobile-nav,
body.dark-mode:not(.auth-page):not(.login-page) .sidebar {
  background: rgba(5, 9, 12, .94);
  border-color: var(--line);
}

body.dark-mode:not(.auth-page):not(.login-page) .panel,
body.dark-mode:not(.auth-page):not(.login-page) .form-card,
body.dark-mode:not(.auth-page):not(.login-page) .auth-panel,
body.dark-mode:not(.auth-page):not(.login-page) .patient-row,
body.dark-mode:not(.auth-page):not(.login-page) .action-tile,
body.dark-mode:not(.auth-page):not(.login-page) .patient-hero,
body.dark-mode:not(.auth-page):not(.login-page) .hero-panel {
  background: rgba(18, 27, 36, .98);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .28);
}

body.dark-mode:not(.auth-page):not(.login-page) .hero-copy,
body.dark-mode:not(.auth-page):not(.login-page) .item p,
body.dark-mode:not(.auth-page):not(.login-page) .calendar-row p,
body.dark-mode:not(.auth-page):not(.login-page) .inbox-row p {
  color: #d8e4eb;
}

body.dark-mode:not(.auth-page):not(.login-page) input,
body.dark-mode:not(.auth-page):not(.login-page) textarea,
body.dark-mode:not(.auth-page):not(.login-page) select {
  background: #071016;
  border-color: #58707f;
  color: var(--ink);
}

body.dark-mode:not(.auth-page):not(.login-page) input::placeholder,
body.dark-mode:not(.auth-page):not(.login-page) textarea::placeholder {
  color: #91a4b1;
}

body.dark-mode:not(.auth-page):not(.login-page) .compact-form label,
body.dark-mode:not(.auth-page):not(.login-page) .eyebrow,
body.dark-mode:not(.auth-page):not(.login-page) .tracking-legend span,
body.dark-mode:not(.auth-page):not(.login-page) small,
body.dark-mode:not(.auth-page):not(.login-page) .day-card time {
  color: var(--muted);
}

body.dark-mode:not(.auth-page):not(.login-page) .secondary,
body.dark-mode:not(.auth-page):not(.login-page) .segmented {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-color: var(--line);
}

body.dark-mode:not(.auth-page):not(.login-page) .primary {
  background: #f7fbff;
  color: #061017;
  box-shadow: 0 12px 24px rgba(0, 0, 0, .30);
}

body.dark-mode:not(.auth-page):not(.login-page) .day-card {
  background: #111820;
  border-color: #40515f;
  color: var(--ink);
}

body.dark-mode:not(.auth-page):not(.login-page) .day-card time strong {
  color: var(--ink);
}

body.dark-mode:not(.auth-page):not(.login-page) .day-card.complete {
  background: #0d2f22;
  border-color: #54d58f;
}

body.dark-mode:not(.auth-page):not(.login-page) .day-card.partial {
  background: #322709;
  border-color: #ffd166;
}

body.dark-mode:not(.auth-page):not(.login-page) .day-card.missing {
  background: #361418;
  border-color: #ff7b86;
}

body.dark-mode:not(.auth-page):not(.login-page) .day-card.paused {
  background: #202934;
  border-color: #95a3b3;
}

body.dark-mode:not(.auth-page):not(.login-page) .day-actions a {
  background: rgba(247,251,255,.10);
  border-color: rgba(247,251,255,.22);
  color: #f7fbff;
}

body.dark-mode:not(.auth-page):not(.login-page) .wake-card,
body.dark-mode:not(.auth-page):not(.login-page) .nap-card,
body.dark-mode:not(.auth-page):not(.login-page) .metric-list span,
body.dark-mode:not(.auth-page):not(.login-page) .range-row output,
body.dark-mode:not(.auth-page):not(.login-page) .badge {
  background: #071016;
  border-color: #40515f;
  color: var(--ink);
}

body.dark-mode:not(.auth-page):not(.login-page) .nap-duration-preview,
body.dark-mode:not(.auth-page):not(.login-page) input[readonly] {
  background: #0e1a22;
  color: #d8e4eb;
}

.thumb-actions {
  position: sticky;
  z-index: 15;
  bottom: 72px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 12px;
  padding: 8px;
  border: 1px solid rgba(216,227,232,.24);
  border-radius: 8px;
  background: rgba(8, 19, 24, .78);
  backdrop-filter: blur(16px);
}

.thumb-actions a {
  min-height: 52px;
}

.week-block {
  display: grid;
  gap: 8px;
}

.week-block h3 {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.day-state {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 850;
}

.quick-time {
  width: 100%;
  min-height: 34px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 850;
}

.choice-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.choice-chips button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.choice-chips button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #071317;
}

.tag-source-field textarea,
.tag-source-field input[type="text"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.tag-editor {
  display: grid;
  gap: 8px;
  grid-column: 1 / -1;
}

.selected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 10px;
}

.selected-tag {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid rgba(103, 214, 230, .6);
  border-radius: 999px;
  background: rgba(103, 214, 230, .16);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
}

.tag-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.tag-add-row input {
  min-height: 38px;
}

.tag-add-row button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}

@media (max-width: 520px) {
  .topbar {
    min-height: 50px;
    padding: 8px 10px;
  }
  .brand {
    max-width: calc(100vw - 104px);
    gap: 7px;
    font-size: 14px;
  }
  .brand-logo {
    flex-basis: 28px;
    width: 28px !important;
    height: 28px !important;
    max-width: 28px !important;
    max-height: 28px !important;
    border-radius: 7px;
  }
  .top-actions {
    gap: 6px;
  }
  .notification-link,
  .icon-button {
    min-width: 34px;
    height: 34px;
  }
  .day-tabs {
    top: 50px;
  }
  .duration-presets {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .shell { padding: 14px 14px 54px; }
  .auth-page .shell {
    padding: 0 12px 18px;
  }
  .auth-stage {
    gap: 12px;
  }
  .auth-visual {
    min-height: 420px;
    border-radius: 8px;
  }
  .auth-copy {
    inset: auto 14px 14px 14px;
  }
  .auth-panel--glass {
    margin: 0;
    width: 100%;
  }
  .chat-shell {
    min-height: calc(100vh - 96px);
  }
  .chat-header {
    grid-template-columns: auto 1fr;
  }
  .chat-header .secondary {
    grid-column: 1 / -1;
    justify-self: start;
  }
  .chat-bubble {
    max-width: 88%;
  }
  .chat-compose {
    grid-template-columns: 1fr;
  }
  .public-actions {
    display: grid;
  }
  .tracking-settings,
  .pause-grid {
    grid-template-columns: 1fr;
  }
  .week-row {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
  }
  .day-card {
    min-width: 0;
    min-height: 44px;
  }
  .hero-panel,
  .patient-hero {
    padding: 18px;
    align-items: flex-start;
  }
  .patient-hero .avatar.large { display: none; }
  h1 { font-size: 29px; }
  .inline-form,
  .copy-row,
  .admin-inline-form {
    grid-template-columns: 1fr;
  }
  .invite-status,
  .invite-status small {
    justify-items: start;
    text-align: left;
  }
  .row-actions {
    justify-content: flex-start;
    width: 100%;
  }
  .row-actions .small,
  .row-actions form {
    width: 100%;
  }
  .row-actions button,
  .row-actions a {
    width: 100%;
  }
  .invite-admin-row input {
    max-width: none;
  }
  .inbox-row,
  .calendar-row {
    grid-template-columns: auto 1fr;
  }
  .inbox-row .unread-dot,
  .calendar-row .secondary {
    grid-column: 2;
    justify-self: start;
  }
  .primary.small {
    width: 100%;
  }
  .form-grid,
  .nap-grid,
  .night-grid,
  .metric-list {
    grid-template-columns: 1fr;
  }
  .night-summary {
    grid-template-columns: 1fr;
  }
  .section-title-row {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (min-width: 760px) {
  .app-layout {
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
    gap: 20px;
    padding: 0 18px;
  }
  .sidebar {
    position: sticky;
    top: 72px;
    display: block;
    align-self: start;
    min-height: calc(100vh - 96px);
    padding: 16px;
    border: 1px solid rgba(216,227,232,.8);
    border-radius: 8px;
    background: rgba(248,251,252,.72);
    box-shadow: 0 12px 32px rgba(35,57,67,.07);
    backdrop-filter: blur(14px);
  }
  .sidebar nav {
    display: grid;
    gap: 6px;
  }
  .mobile-nav {
    display: none;
  }
  .shell { padding: 26px 0 64px; }
  .quick-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  h1 { font-size: 38px; }
  .form-card { max-width: 820px; }
  .panel { padding: 20px; }
  .two-column {
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  }
}

.public-page .auth-visual {
  min-height: min(520px, calc(100dvh - 112px));
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}

.public-page .auth-copy {
  max-width: 560px;
}

.public-page .auth-copy h1 {
  font-size: clamp(30px, 7vw, 58px);
}

.public-page .auth-pills {
  display: none;
}

/* Minimal app refresh */
:root {
  --bg: #f5f7f9;
  --bg-soft: #f8fafc;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #5f6b7a;
  --line: #d9e0e7;
  --accent: #176b7f;
  --accent-dark: #0f4f60;
  --accent-soft: #e8f4f7;
  --sage: #3f7f67;
  --sun: #d99b24;
  --rose: #c84654;
  --shadow: 0 8px 24px rgba(15, 23, 42, .06);
}

body,
body.auth-page {
  background: var(--bg);
}

.topbar {
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line);
  box-shadow: none;
}

.shell {
  padding-top: 14px;
}

.hero-panel,
.patient-hero,
.action-tile,
.patient-row,
.panel,
.form-card,
.auth-panel,
.wake-card,
.nap-card {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero-panel,
.patient-hero {
  align-items: center;
  min-height: auto;
  padding: 18px;
}

.hero-panel::after,
.patient-hero::after {
  display: none;
}

.hero-copy {
  color: var(--muted);
}

.quick-grid {
  grid-template-columns: 1fr;
}

.action-tile {
  min-height: 82px;
  padding: 14px;
}

.action-tile:hover,
.patient-row:hover {
  transform: none;
  border-color: #b9c7d3;
  box-shadow: var(--shadow);
}

.tile-icon,
.side-link span,
.calendar-row time {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.primary {
  background: var(--accent-dark);
  color: #fff;
  box-shadow: none;
}

.secondary,
.quick-time,
.duration-presets button,
.tag-add-row button,
.day-actions a {
  background: var(--accent-soft);
  border: 1px solid #c7dfe6;
  color: var(--accent-dark);
  box-shadow: none;
}

.primary,
.secondary,
.quick-time,
.duration-presets button,
.tag-add-row button,
.day-tabs button,
.day-actions a {
  border-radius: 8px;
}

.day-tabs {
  box-shadow: none;
}

.compact-form,
.night-entry-form {
  max-width: 720px;
}

.compact-form input,
.compact-form textarea,
.compact-form select,
input,
textarea,
select {
  border: 1px solid #cfd8e3;
  background: #fff;
  color: var(--ink);
}

.entry-card {
  padding: 0;
  overflow: hidden;
}

.entry-card-head {
  padding: 0 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.entry-card.is-collapsed .entry-card-head {
  border-bottom: 0;
}

.entry-card-body {
  padding: 12px;
}

.entry-toggle {
  min-height: 48px;
}

.entry-summary {
  max-width: 45vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.choice-chips button,
.selected-tag {
  background: #fff;
  border-color: #cfd8e3;
  color: var(--ink);
}

.choice-chips button.active,
.duration-presets button.active,
.selected-tag {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #fff;
}

.delete-card[data-confirm="true"] {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #be123c;
}

/* Visual polish: calmer clinical interface */
h1,
h2,
h3,
.brand,
.entry-title {
  font-weight: 760;
}

.eyebrow,
.side-link,
.day-tabs button,
.primary,
.secondary,
.duration-presets button,
.choice-chips button,
.selected-tag {
  font-weight: 720;
}

.topbar,
.sidebar,
.mobile-nav,
.panel,
.form-card,
.entry-card,
.day-tabs {
  box-shadow: 0 8px 22px rgba(29, 45, 55, .06);
}

.patient-hero,
.hero-panel,
.invite-panel {
  background: #fff;
}

.primary {
  background: var(--accent-dark);
  box-shadow: 0 8px 18px rgba(21, 81, 95, .18);
}

.secondary,
.duration-presets button {
  background: #eef6f7;
  color: var(--accent-dark);
  border: 1px solid #cfe1e6;
}

.choice-chips button {
  min-height: 36px;
  background: #fff;
  border-color: #d4dee5;
  color: #253244;
  box-shadow: none;
}

.choice-chips button.active,
.selected-tag {
  background: #15515f;
  border-color: #15515f;
  color: #fff;
}

.selected-tag {
  padding-right: 13px;
}

.tag-add-row input {
  background: #fff;
}

.form-save-status {
  box-shadow: none;
}

.family-patient-grid {
  margin-top: 8px;
}

.patient-quick-actions {
  margin: -8px 0 16px;
}

.form-actions {
  justify-content: flex-end;
}

.sticky-save {
  justify-content: flex-end;
  gap: 10px;
}

.night-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfd;
}

.night-section + .night-section {
  margin-top: 12px;
}

.nap-day-section .section-title-row h2:empty {
  display: none;
}

.entry-toggle {
  width: 100%;
}

.chat-shell {
  background: #eef4f1;
  border-color: #d7e3dd;
}

.chat-header {
  background: rgba(255, 255, 255, .94);
}

.chat-message {
  align-items: flex-end;
  gap: 8px;
}

.chat-avatar.mini {
  width: 30px;
  height: 30px;
  font-size: 11px;
  flex: 0 0 auto;
}

.chat-message.mine .chat-bubble {
  background: #d7f6cf;
  border-bottom-right-radius: 3px;
}

.chat-message.theirs .chat-bubble {
  background: #fff;
  border-bottom-left-radius: 3px;
}

.inbox-panel {
  padding: 8px;
}

.inbox-row {
  background: #fff;
  border: 1px solid transparent;
}

.inbox-row + .inbox-row {
  margin-top: 8px;
  border-top: 1px solid transparent;
}

.inbox-row.unread {
  border-color: #bcd9e1;
  background: #f4fbfc;
}

@media (max-width: 720px) {
  .public-page .topbar {
    min-height: 52px;
    padding: 8px 12px;
  }
  .public-page .shell {
    padding: 10px 12px;
    padding-bottom: 10px;
  }
  .public-page .auth-stage {
    min-height: calc(100dvh - 72px);
  }
  .public-page .auth-visual {
    min-height: calc(100dvh - 92px);
  }
  .public-page .auth-copy {
    inset: auto 14px 14px 14px;
  }
  .public-page .auth-copy h1 {
    font-size: clamp(28px, 9vw, 38px);
    margin-bottom: 8px;
  }
  .public-page .hero-copy {
    font-size: 15px;
    margin-bottom: 12px;
  }
  .public-actions {
    display: flex;
    gap: 8px;
  }
}

/* Minimal conversation layout */
.chat-shell {
  width: min(760px, 100%);
  height: min(720px, calc(100dvh - 104px));
  min-height: 480px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: 54px minmax(0, 1fr) 58px;
  overflow: hidden;
  border: 1px solid #dfe3e6;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, .10);
}

.chat-header {
  display: grid;
  grid-template-columns: 32px 36px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-height: 54px;
  padding: 6px 12px;
  background: #fff;
  border-bottom: 1px solid #e3e6e8;
}

.chat-back {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #52606d;
  font-size: 29px;
  line-height: 1;
}

.chat-back:hover {
  background: #f1f3f4;
  color: #18212b;
}

.chat-header .chat-avatar {
  width: 36px;
  height: 36px;
  background: #29343d;
  box-shadow: none;
  font-size: 12px;
}

.chat-header h1 {
  margin: 0;
  overflow: hidden;
  color: #242c34;
  font-size: 15px;
  font-weight: 760;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header small {
  display: block;
  margin-top: 2px;
  color: #8a939b;
  font-size: 11px;
}

.chat-panel {
  min-height: 0;
  overflow-y: auto;
  padding: 15px 14px;
  background: #f5f6f7;
  box-shadow: inset 0 14px 20px -22px rgba(0, 0, 0, .35);
}

.chat-message {
  gap: 7px;
  margin: 3px 0;
}

.chat-message .chat-avatar.mini {
  width: 26px;
  height: 26px;
  margin-bottom: 2px;
  background: #7f9289;
  font-size: 9px;
}

.chat-message.mine .chat-avatar.mini {
  background: #29343d;
}

.chat-bubble,
.chat-message.theirs .chat-bubble {
  max-width: min(74%, 520px);
  padding: 8px 11px 6px;
  border: 0;
  border-radius: 14px 14px 14px 3px;
  background: #fff;
  color: #26313a;
  box-shadow: 0 5px 16px rgba(15, 23, 42, .07);
}

.chat-message.mine .chat-bubble {
  border-radius: 14px 14px 3px 14px;
  background: #29343d;
  color: #fff;
}

.chat-bubble p {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
}

.chat-bubble small {
  display: block;
  margin-top: 3px;
  color: #929aa1;
  font-size: 9px;
  text-align: right;
}

.chat-message.mine .chat-bubble small {
  color: #c3cbd0;
}

.chat-compose {
  position: static;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: center;
  min-height: 58px;
  padding: 8px 10px;
  background: #fff;
  border-top: 1px solid #e3e6e8;
}

.chat-compose textarea {
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  padding: 9px 13px;
  overflow: hidden;
  resize: none;
  border: 1px solid #dfe3e6;
  border-radius: 20px;
  background: #f7f8f9;
  box-shadow: none;
  font-size: 14px;
  line-height: 20px;
}

.chat-compose textarea:focus {
  border-color: #8d9aa3;
  box-shadow: 0 0 0 3px rgba(41, 52, 61, .08);
}

.chat-send {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #29343d;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 21px;
  line-height: 1;
}

@media (max-width: 720px) {
  .chat-shell {
    width: 100%;
    height: calc(100dvh - 116px);
    min-height: 0;
    margin: 0 0 66px;
    grid-template-rows: 48px minmax(0, 1fr) 54px;
    border-radius: 0;
    box-shadow: none;
  }

  .chat-header {
    grid-template-columns: 30px 32px minmax(0, 1fr);
    min-height: 48px;
    padding: 4px 8px;
  }

  .chat-header .chat-avatar {
    display: grid;
    width: 32px;
    height: 32px;
  }

  .chat-header small {
    display: none;
  }

  .chat-panel {
    padding: 11px 8px;
  }

  .chat-bubble,
  .chat-message.theirs .chat-bubble {
    max-width: 79%;
  }

  .chat-compose {
    position: static;
    min-height: 54px;
    padding: 6px 8px;
  }
}

/* Headerless family chat must keep exactly two rows. */
.chat-page .chat-shell.family-chat-shell {
  grid-template-rows: minmax(0, 1fr) 58px;
}

.chat-page .family-chat-shell .chat-panel {
  grid-row: 1;
  min-height: 0;
  overflow-y: auto;
}

.chat-page .family-chat-shell .chat-compose {
  grid-row: 2;
}

@media (max-width: 720px) {
  .chat-page .chat-shell.family-chat-shell {
    grid-template-rows: minmax(0, 1fr) 54px;
  }
}

/* Integrated application palette and chat spacing */
:root {
  --bg: #f1f5f6;
  --bg-soft: #f7f9fa;
  --panel: #ffffff;
  --ink: #17232c;
  --muted: #5c6b75;
  --line: #d5e0e3;
  --accent: #1f7180;
  --accent-dark: #15515f;
  --accent-soft: #e5f1f3;
  --sage: #477c68;
}

body:not(.auth-page):not(.login-page) {
  background: var(--bg);
  color: var(--ink);
}

.topbar,
.sidebar,
.mobile-nav {
  border-color: var(--line);
}

.chat-page .shell {
  width: 100%;
}

.chat-page .chat-shell {
  border-color: var(--line);
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(23, 35, 44, .08);
}

.chat-page .chat-header {
  background: var(--panel);
  border-color: var(--line);
}

.chat-page .chat-back {
  color: var(--accent-dark);
}

.chat-page .chat-back:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.chat-page .chat-header .chat-avatar {
  background: var(--accent-dark);
  color: #fff;
}

.chat-page .chat-header h1 {
  color: var(--ink);
}

.chat-page .chat-header small {
  color: var(--muted);
}

.chat-page .chat-panel {
  background: #edf3f4;
}

.chat-page .chat-message.theirs .chat-avatar.mini {
  background: var(--sage);
}

.chat-page .chat-message.mine .chat-avatar.mini {
  background: var(--accent-dark);
}

.chat-page .chat-message.theirs .chat-bubble {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(23, 35, 44, .07);
}

.chat-page .chat-message.mine .chat-bubble {
  background: var(--accent-dark);
  color: #fff;
  box-shadow: 0 5px 16px rgba(21, 81, 95, .18);
}

.chat-page .chat-bubble small {
  color: #71808a;
}

.chat-page .chat-message.mine .chat-bubble small {
  color: #d6e6e9;
}

.chat-page .chat-compose {
  background: var(--panel);
  border-color: var(--line);
}

.chat-page .chat-compose textarea {
  background: var(--bg-soft);
  border-color: var(--line);
  color: var(--ink);
}

.chat-page .chat-compose textarea::placeholder {
  color: #7a8891;
}

.chat-page .chat-send {
  background: var(--accent-dark);
  color: #fff;
}

@media (max-width: 720px) {
  .chat-page .topbar {
    min-height: 50px;
  }

  .chat-page .shell {
    padding: 8px 8px 0;
  }

  .chat-page .chat-shell {
    height: calc(100dvh - 130px - env(safe-area-inset-bottom));
    min-height: 360px;
    margin: 0 0 calc(74px + env(safe-area-inset-bottom));
    border-radius: 8px;
  }

  .chat-page .mobile-nav {
    bottom: calc(6px + env(safe-area-inset-bottom));
  }
}

/* Therapist monthly calendar */
.calendar-panel {
  overflow: hidden;
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.calendar-toolbar h2 {
  margin: 0;
  text-align: center;
  text-transform: capitalize;
}

.calendar-toolbar .secondary {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  font-size: 25px;
}

.calendar-patient-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: -4px 0 12px;
}

.calendar-patient-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid color-mix(in srgb, var(--appointment-color) 28%, transparent);
  border-radius: 999px;
  background: var(--appointment-bg);
  color: var(--appointment-color);
  font-size: 12px;
  font-weight: 850;
}

.calendar-patient-legend i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--appointment-color);
}

.month-calendar-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.month-calendar {
  min-width: 840px;
}

.calendar-weekdays,
.calendar-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
}

.calendar-weekdays span {
  padding: 9px 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

.calendar-week + .calendar-week {
  margin-top: 1px;
}

.calendar-day {
  min-height: 128px;
  padding: 7px;
  background: var(--panel);
}

.calendar-day.outside {
  background: #f5f7f8;
  color: #98a3aa;
}

.calendar-day > time {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  margin: 0 0 6px auto;
  border-radius: 50%;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.calendar-day.today > time {
  background: var(--accent-dark);
  color: #fff;
}

.calendar-events {
  display: grid;
  gap: 5px;
}

.calendar-event {
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: 6px 7px;
  border-left: 3px solid var(--appointment-color, var(--accent));
  border-radius: 5px;
  background: var(--appointment-bg, var(--accent-soft));
  color: var(--ink);
}

.calendar-event-trigger {
  display: grid;
  gap: 1px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.calendar-event-trigger:hover strong,
.calendar-event-trigger:focus-visible strong { text-decoration: underline; }

.appointment-dialog {
  width: min(480px, calc(100% - 28px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(15, 23, 42, .22);
}

.appointment-dialog::backdrop { background: rgba(15, 23, 42, .48); }

.appointment-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.appointment-dialog-head h2 { margin: 2px 0 0; font-size: 20px; }

.dialog-close {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.appointment-description {
  margin: 16px 0;
  padding: 14px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--ink);
}

.appointment-description p { margin: 0; }

.patient-index-head { margin-bottom: 14px; }

.action-tile-form { display: contents; }

.action-tile.archive-tile {
  width: 100%;
  border: 1px solid #b9d8cc;
  background: #f2faf6;
  color: #174f42;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.questionnaire-progress {
  min-width: 58px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  text-align: right;
}

.family-access-group + .family-access-group {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.family-access-group h3 { margin: 0 0 8px; font-size: 16px; }

.family-access-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}

.family-access-row small { display: block; margin-top: 3px; color: var(--muted); }

.generated-access-link {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid #b9d8cc;
  border-radius: 6px;
  background: #f2faf6;
}

.generated-access-link > small { display: block; margin-top: 8px; color: var(--muted); }

.compact-auth-panel { width: min(520px, 100%); margin: 32px auto; }

@media (max-width: 720px) {
  .family-access-row { align-items: flex-start; flex-direction: column; }
  .family-access-row .row-actions { width: 100%; }
  .family-access-row .row-actions form { flex: 1; }
  .family-access-row .row-actions button { width: 100%; }
}

.calendar-event strong {
  color: var(--appointment-color, var(--accent-dark));
  font-size: 12px;
}

.calendar-event span,
.calendar-event small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-event span {
  color: var(--appointment-color, var(--accent-dark));
  font-size: 11px;
  font-weight: 750;
}

.calendar-event small {
  font-size: 10px;
}

@media (max-width: 720px) {
  .calendar-panel {
    padding: 12px 8px;
  }

  .month-calendar-wrap {
    overflow-x: visible;
  }

  .month-calendar {
    min-width: 0;
    width: 100%;
  }

  .calendar-toolbar {
    grid-template-columns: 34px minmax(0, 1fr) 34px;
    gap: 6px;
    margin-bottom: 10px;
  }

  .calendar-toolbar h2 {
    font-size: 18px;
  }

  .calendar-toolbar .secondary {
    width: 34px;
    height: 34px;
    min-height: 34px;
    font-size: 22px;
  }

  .calendar-weekdays span {
    padding: 6px 2px;
    font-size: 10px;
  }

  .calendar-day {
    min-height: 54px;
    padding: 3px;
  }

  .calendar-day > time {
    width: 20px;
    height: 20px;
    margin: 0 auto 3px;
    font-size: 10px;
  }

  .calendar-events {
    gap: 2px;
  }

  .calendar-event {
    padding: 1px 2px;
    border-left: 0;
    border-radius: 4px;
    background: var(--appointment-color, var(--accent-dark));
  }

  .calendar-event-trigger {
    place-items: center;
    text-align: center;
  }

  .calendar-event strong {
    color: #fff;
    font-size: 9px;
    line-height: 1;
  }

  .calendar-event span {
    display: block;
    max-width: 100%;
    color: #fff;
    font-size: 8px;
    line-height: 1.05;
  }

  .calendar-event small {
    display: none;
  }
}

/* Contrast, desktop chat and rich care-plan editor */
.panel,
.form-card,
.patient-row,
.action-tile,
.patient-hero,
.hero-panel {
  background: #fff;
  color: var(--ink);
}

.hero-copy,
.muted,
.item p,
.calendar-row p {
  color: #4d5d68;
}

.chat-page .chat-shell {
  width: min(960px, 100%);
  height: min(780px, calc(100dvh - 96px));
}

.chat-page .chat-panel {
  background: #eef3f4;
}

.chat-page .chat-bubble p {
  color: inherit;
}

.calendar-event > a {
  margin-top: 4px;
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 850;
}

.rich-plan-form {
  max-width: 860px;
}

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 7px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #f5f8f9;
}

.rich-toolbar button {
  min-width: 36px;
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid #cbd8dc;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 750;
}

.rich-toolbar button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.rich-editor {
  min-height: 360px;
  padding: 18px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  background: #fff;
  color: var(--ink);
  line-height: 1.55;
  outline: none;
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: #7b8992;
}

.rich-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 113, 128, .10);
}

.rich-source {
  display: none;
}

.rich-editor img,
.rich-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 12px 0;
  border-radius: 6px;
}

.rich-editor h2,
.rich-content h2 {
  margin: 18px 0 8px;
  font-size: 22px;
}

.rich-editor h3,
.rich-content h3 {
  margin: 15px 0 7px;
  font-size: 17px;
}

.rich-content {
  margin-top: 10px;
  color: var(--ink);
  line-height: 1.55;
}

.rich-content p {
  color: inherit;
}

.publish-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
}

.publish-toggle input {
  width: 20px;
  min-height: 20px;
  margin: 0;
}

@media (max-width: 720px) {
  .chat-page .chat-shell {
    width: 100%;
    height: calc(100dvh - 130px - env(safe-area-inset-bottom));
  }

  .rich-editor {
    min-height: 300px;
    padding: 13px;
  }
}

.field-help {
  margin-top: -3px !important;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.wake-type-field {
  margin: 0;
  padding: 0;
  border: 0;
}

.wake-type-field legend {
  margin-bottom: 7px;
  color: #32465a;
  font-size: 13px;
  font-weight: 780;
}

.wake-type-field > div {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.wake-type-field label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin: 0;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.wake-type-field input {
  width: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: var(--accent-dark);
}

@media (max-width: 520px) {
  .wake-type-field > div {
    grid-template-columns: 1fr;
  }
}

/* Family onboarding and sibling switcher */
.patient-switcher {
  display: flex;
  gap: 7px;
  margin: 0 0 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.patient-switcher::-webkit-scrollbar {
  display: none;
}

.patient-switcher a {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 5px 10px 5px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.patient-switcher a span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 10px;
}

.patient-switcher a.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.patient-switcher a.active span {
  background: var(--accent-dark);
  color: #fff;
}

.intake-required-panel {
  display: grid;
  gap: 12px;
  border-color: #b9d5db;
}

.intake-required-panel p {
  margin: 6px 0 0;
  color: #4d5d68;
  line-height: 1.45;
}

.intake-required-panel .primary {
  width: 100%;
}

.intake-complete-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.intake-complete-panel span {
  display: grid;
  gap: 3px;
}

.intake-progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 8px;
  background: #dfe8ea;
}

.intake-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width .2s ease;
}

.intake-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 12px;
}

.intake-head h1 {
  font-size: 28px;
}

.intake-parent-title {
  display: inline-flex;
  width: fit-content;
  margin: 4px 0 6px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e5f3ef;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.intake-head > strong {
  color: var(--accent-dark);
  font-size: 22px;
}

.intake-form {
  display: grid;
  gap: 10px;
  max-width: 780px;
  margin-top: 14px;
}

.intake-question {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.intake-question > span {
  color: var(--ink);
  font-size: 14px;
  font-weight: 760;
  line-height: 1.35;
}

.intake-question textarea {
  min-height: 68px;
  padding: 10px;
  background: var(--bg-soft);
  color: var(--ink);
  line-height: 1.4;
}

.intake-question textarea[readonly] {
  background: #f3f6f7;
  color: #42515b;
}

.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice-pill {
  position: relative;
  display: inline-flex;
  margin: 0;
}

.choice-pill input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.choice-pill span {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
}

.choice-pill input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px rgba(0,118,107,.18);
}

.choice-pill input:focus-visible + span {
  outline: 3px solid rgba(0,118,107,.18);
  outline-offset: 2px;
}

.choice-other-input {
  min-height: 40px;
  margin-top: 2px;
  border-style: dashed;
  background: var(--bg-soft);
  font-size: 14px;
}

.intake-actions {
  position: sticky;
  z-index: 12;
  bottom: 72px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 10px 26px rgba(23, 35, 44, .12);
}

@media (min-width: 760px) {
  .intake-actions {
    position: static;
    justify-self: end;
    grid-template-columns: auto auto;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
}

.family-chat-shell {
  grid-template-rows: minmax(0, 1fr) 58px;
}

.family-chart-panel {
  padding: 12px;
}

@media (max-width: 720px) {
  .family-chat-shell {
    grid-template-rows: minmax(0, 1fr) 54px;
  }
}

/* Families and editable intake templates */
.admin-tools {
  padding: 8px;
}

.template-settings,
.add-section-form {
  display: grid;
  gap: 10px;
  max-width: 900px;
}

.template-settings .primary,
.add-section-form .primary {
  justify-self: start;
}

.template-sections {
  display: grid;
  gap: 12px;
}

.template-section {
  display: grid;
  gap: 12px;
  max-width: 980px;
}

.template-section-head {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.drag-handle {
  display: inline-grid;
  place-items: center;
  width: 34px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-dark);
  cursor: grab;
  font: inherit;
  font-weight: 900;
  touch-action: none;
  user-select: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.dragging {
  opacity: .54;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.is-sorting {
  cursor: grabbing;
  user-select: none;
}

.template-order-form {
  display: flex;
  justify-content: flex-end;
  max-width: 980px;
  margin: 0 0 10px;
}

.template-questions {
  display: grid;
  gap: 7px;
}

.template-question-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) minmax(180px, .7fr) auto auto 34px;
  gap: 7px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
}

.template-question-row textarea,
.add-question-row textarea {
  min-height: 54px;
  resize: vertical;
}

.question-config {
  display: grid;
  gap: 7px;
}

.question-config textarea {
  min-height: 46px;
  font-size: 13px;
}

.required-check {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  white-space: nowrap;
  font-size: 12px;
}

.required-check input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

.delete-inline {
  color: var(--rose);
  font-size: 20px;
}

.add-question-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, .7fr) auto auto;
  gap: 7px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.delete-section-form {
  justify-self: end;
}

.signup-patient-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 14px;
}

.signup-patient-list span {
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 750;
}

@media (max-width: 720px) {
  .template-section-head {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .template-section-head .secondary {
    grid-column: 1 / -1;
  }

  .template-question-row {
    grid-template-columns: 38px minmax(0, 1fr) 34px;
  }

  .template-question-row textarea {
    grid-column: 2 / 3;
  }

  .template-question-row .question-config { grid-column: 2 / -1; }

  .template-question-row .required-check,
  .template-question-row .secondary {
    grid-column: 2 / -1;
  }

  .add-question-row {
    grid-template-columns: 1fr;
  }
}

.terms-check { display: flex; align-items: flex-start; gap: 9px; color: var(--ink); }
.terms-check input { width: 20px; height: 20px; flex: 0 0 20px; margin-top: 2px; }
.terms-check a { color: var(--accent-dark); font-weight: 800; }
.legal-document { max-width: 820px; margin: 24px auto; }
.legal-body { margin-top: 22px; color: var(--ink); }
.legal-body p { margin-bottom: 14px; }

.mobile-nav {
  background: rgba(255, 255, 255, .98);
  border-color: var(--line);
  box-shadow: 0 10px 30px rgba(15, 23, 42, .12);
}

.therapist-icon-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 14px;
}

.therapist-icon-actions a,
.therapist-icon-actions button {
  display: grid;
  place-items: center;
  gap: 3px;
  width: 62px;
  min-height: 58px;
  padding: 7px 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  box-shadow: 0 8px 20px rgba(15, 39, 34, .06);
}

.therapist-icon-actions form {
  margin: 0;
}

.therapist-icon-actions span {
  font-size: 18px;
  line-height: 1;
}

.therapist-icon-actions small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.therapist-icon-actions .danger,
.therapist-icon-actions .danger small {
  color: var(--rose);
}

.chart-wide-panel {
  max-width: none;
}

.daily-summary-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.daily-summary-table {
  width: 100%;
  min-width: 1220px;
  border-collapse: collapse;
  font-size: 13px;
}

.compact-daily-summary {
  min-width: 0;
  table-layout: fixed;
}

.compact-daily-summary th:first-child,
.compact-daily-summary td:first-child {
  width: 58px;
}

.compact-daily-summary th:nth-child(2),
.compact-daily-summary td:nth-child(2) {
  width: 22%;
}

.compact-daily-summary th:nth-child(3),
.compact-daily-summary td:nth-child(3) {
  width: 22%;
}

.compact-daily-summary th:nth-child(4),
.compact-daily-summary td:nth-child(4) {
  width: 34%;
}

.compact-daily-summary th:nth-child(5),
.compact-daily-summary td:nth-child(5) {
  width: 16%;
}

.compact-daily-summary th,
.compact-daily-summary td {
  padding: 7px 8px;
  white-space: normal;
  vertical-align: top;
}

.summary-line {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 5px;
  align-items: baseline;
  margin: 0 0 3px;
  min-width: 0;
}

.summary-line:last-child {
  margin-bottom: 0;
}

.summary-line small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.summary-line strong {
  color: var(--ink);
  font-size: 11px;
  font-weight: 850;
  line-height: 1.18;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}

.compact-daily-summary td:nth-child(4) .summary-line strong {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.compact-daily-summary tbody tr:hover .summary-line strong {
  -webkit-line-clamp: unset;
}

.mobile-summary-cards {
  display: none;
}

.mobile-summary-card {
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 11px;
  box-shadow: 0 8px 22px rgba(31, 43, 48, .05);
  cursor: pointer;
}

.mobile-summary-card header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.mobile-summary-card header strong {
  color: var(--ink);
  font-size: 17px;
  font-weight: 950;
}

.mobile-summary-card header span {
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 950;
}

.mobile-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.mobile-summary-grid p {
  min-width: 0;
  margin: 0;
  border: 1px solid rgba(18, 35, 45, .08);
  border-radius: 8px;
  background: var(--bg-soft);
  padding: 7px 8px;
}

.mobile-summary-grid p.wide {
  grid-column: 1 / -1;
}

.mobile-summary-grid small {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.mobile-summary-grid b {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.daily-summary-table th,
.daily-summary-table td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.daily-summary-table th {
  position: sticky;
  top: 0;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.daily-summary-table tbody tr {
  cursor: pointer;
}

.daily-summary-table tbody tr:hover {
  background: var(--bg-soft);
}

.plan-pager {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.plan-pager em {
  font-style: normal;
}

.plan-pager .secondary.small {
  min-width: 34px;
  padding: 6px 9px;
  font-size: 18px;
  line-height: 1;
}

.clinical-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.clinical-metrics article {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 13px;
  box-shadow: 0 8px 24px rgba(18, 35, 45, .06);
}

.clinical-metrics strong {
  display: block;
  color: var(--ink);
  font-size: 22px;
  font-weight: 950;
  line-height: 1.05;
}

.clinical-metrics span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.diary-review-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.diary-review-card {
  color: var(--ink);
}

.info-chip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.info-chip-grid p,
.clinical-detail-list div,
.sleep-event-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
}

.info-chip-grid p {
  margin: 0;
  padding: 10px;
}

.info-chip-grid small,
.clinical-detail-list dt,
.sleep-event-card dt {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.info-chip-grid strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 950;
}

.clinical-detail-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.clinical-detail-list div {
  padding: 10px;
}

.clinical-detail-list dd,
.sleep-event-card dd {
  margin: 3px 0 0;
  color: var(--ink);
  font-weight: 750;
  white-space: pre-wrap;
}

.sleep-event-grid {
  display: grid;
  gap: 10px;
}

.sleep-event-card {
  padding: 12px;
}

.sleep-event-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.sleep-event-card header strong {
  color: var(--accent-dark);
  font-size: 17px;
  font-weight: 950;
}

.sleep-event-card header span {
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 950;
}

.sleep-event-card dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.diary-review-head {
  margin-bottom: 10px;
}

.diary-clinical-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.compact-event-list {
  display: grid;
  gap: 8px;
}

.compact-event-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  padding: 10px;
}

.compact-event-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.compact-event-card header strong {
  color: var(--accent-dark);
  font-size: 17px;
  font-weight: 950;
}

.compact-event-card header span {
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 950;
}

.compact-data-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.compact-data-grid p {
  margin: 0;
  border: 1px solid rgba(18, 35, 45, .08);
  border-radius: 9px;
  background: #fff;
  padding: 7px 8px;
}

.compact-data-grid small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
}

.compact-data-grid b {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.clinical-note {
  margin: 8px 0 0;
  border-left: 3px solid var(--accent);
  padding: 6px 0 6px 9px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
  white-space: pre-wrap;
}

.therapist-comment-form {
  margin-top: 12px;
}

.plotly-dashboard-panel {
  display: grid;
  gap: 14px;
}

.plotly-patient-select {
  display: grid;
  gap: 6px;
  max-width: 420px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.plotly-patient-select select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  text-transform: none;
}

.plotly-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.plotly-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 12px;
  box-shadow: 0 10px 28px rgba(31, 43, 48, .05);
}

.plotly-card header {
  display: grid;
  gap: 2px;
  margin-bottom: 8px;
}

.plotly-card h2 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
}

.plotly-card small {
  color: var(--muted);
  font-weight: 750;
}

.plotly-chart {
  width: 100%;
  min-height: 320px;
}

@media (min-width: 760px) {
  .quick-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .clinical-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .diary-review-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sleep-event-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .diary-clinical-layout {
    grid-template-columns: minmax(250px, .78fr) minmax(0, 1.25fr);
    align-items: start;
  }

  .diary-naps-block {
    grid-row: span 2;
  }

  .diary-wakes-block {
    grid-column: 2;
  }

  .wake-event-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .night-main-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .plotly-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .plotly-card.wide {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1100px) {
  .diary-clinical-layout {
    grid-template-columns: minmax(250px, .9fr) minmax(320px, 1fr) minmax(360px, 1.15fr);
    gap: 12px;
  }

  .diary-naps-block {
    grid-row: auto;
  }

  .diary-wakes-block {
    grid-column: auto;
  }

  .wake-event-list {
    grid-template-columns: 1fr;
  }

  .diary-review-card {
    padding: 14px;
  }

  .diary-review-card .compact-data-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .diary-night-block .night-main-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 759px) {
  .daily-summary-wrap {
    display: none;
  }

  .mobile-summary-cards {
    display: grid;
    gap: 10px;
  }
}

/* Latest UX pass */
.night-subtabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  max-width: 720px;
  margin: 0 0 12px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(29, 45, 55, .06);
}

.night-subtabs button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 850;
}

.night-subtabs button.active {
  background: var(--accent-dark);
  color: #fff;
}

@media (min-width: 760px) {
  .public-page .shell {
    display: grid;
    min-height: calc(100dvh - 58px);
    place-items: center;
    padding: 28px;
  }

  .public-page .auth-stage {
    width: min(1120px, 100%);
    min-height: auto;
  }

  .public-page .auth-visual {
    min-height: clamp(420px, calc(100dvh - 132px), 620px);
    max-width: 1120px;
  }

  .public-page .auth-copy {
    inset: auto auto 42px 42px;
    max-width: 620px;
  }
}

@media (max-width: 520px) {
  .night-subtabs {
    position: sticky;
    top: 102px;
    z-index: 8;
  }
}

/* Inbox/chat/navigation correction */
.public-page .app-layout {
  display: block;
  width: 100%;
  padding: 0;
}

.public-page .shell {
  width: 100%;
  max-width: none;
}

@media (min-width: 760px) {
  .public-page .auth-stage {
    width: min(1040px, 100%);
  }

  .public-page .auth-visual {
    min-height: min(540px, calc(100dvh - 130px));
  }
}

.whatsapp-inbox {
  margin-top: 0;
}

.inbox-row {
  min-height: 74px;
}

.chat-header {
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 8px;
  padding: 7px 9px;
}

.chat-header .secondary {
  min-height: 34px;
  padding: 7px 9px;
}

.chat-header .chat-avatar {
  width: 34px;
  height: 34px;
  font-size: 12px;
}

.chat-header .eyebrow {
  margin-bottom: 2px;
}

.chat-header h1 {
  font-size: 17px;
  line-height: 1.05;
}

.chat-panel {
  padding: 10px;
}

.chat-compose {
  padding: 8px;
}

.chat-compose textarea {
  min-height: 40px;
}

.chat-send {
  width: 42px;
  min-width: 42px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

@media (max-width: 720px) {
  .public-page .topbar {
    min-height: 46px;
  }

  .public-page .shell {
    padding: 8px 10px 8px;
  }

  .public-page .auth-stage {
    min-height: calc(100dvh - 62px);
  }

  .public-page .auth-visual {
    min-height: calc(100dvh - 78px);
  }

  .public-page .auth-copy {
    inset: auto 12px 12px 12px;
  }

  .public-page .auth-copy h1 {
    font-size: clamp(25px, 8vw, 34px);
    margin-bottom: 6px;
  }

  .public-page .hero-copy {
    font-size: 14px;
    line-height: 1.32;
    margin: 6px 0 10px;
  }

  .public-actions .primary,
  .public-actions .secondary {
    min-height: 40px;
    padding: 9px 12px;
  }

  .chat-shell {
    min-height: calc(100dvh - 116px);
    margin-bottom: 68px;
  }

  .chat-header {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 6px 8px;
  }

  .chat-header .secondary {
    min-height: 32px;
    padding: 6px 8px;
  }

  .chat-header .chat-avatar {
    display: none;
  }

  .chat-header .eyebrow {
    display: none;
  }

  .chat-header h1 {
    font-size: 16px;
  }

  .chat-compose {
    position: sticky;
    bottom: 64px;
    z-index: 18;
    grid-template-columns: minmax(0, 1fr) 42px;
    align-items: center;
    padding: 7px;
  }

  .chat-compose textarea {
    min-height: 40px;
    height: 40px;
    max-height: 40px;
    resize: none;
    overflow: hidden;
  }
}

.mobile-nav {
  grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
}

.mobile-nav a {
  min-height: 46px;
  font-size: 11px;
}

@media (max-width: 520px) {
  .mobile-nav {
    left: 6px;
    right: 6px;
    bottom: 6px;
    gap: 4px;
    padding: 5px;
  }

  .mobile-nav span {
    font-size: 17px;
  }
}

/* Final chat cascade */
.chat-shell {
  height: min(720px, calc(100dvh - 104px));
  min-height: 480px;
  grid-template-rows: 54px minmax(0, 1fr) 58px;
}

.chat-header {
  grid-template-columns: 32px 36px minmax(0, 1fr);
  gap: 9px;
  padding: 6px 12px;
}

.chat-compose {
  position: static;
  grid-template-columns: minmax(0, 1fr) 38px;
  padding: 8px 10px;
}

.chat-send {
  width: 38px;
  min-width: 38px;
  height: 38px;
}

@media (max-width: 720px) {
  .chat-shell {
    height: calc(100dvh - 116px);
    min-height: 0;
    margin-bottom: 66px;
    grid-template-rows: 48px minmax(0, 1fr) 54px;
  }

  .chat-header {
    grid-template-columns: 30px 32px minmax(0, 1fr);
    padding: 4px 8px;
  }

  .chat-header .chat-avatar {
    display: grid;
    width: 32px;
    height: 32px;
  }

  .chat-compose {
    position: static;
    bottom: auto;
    grid-template-columns: minmax(0, 1fr) 38px;
    padding: 6px 8px;
  }
}

/* Keyboard-aware mobile chat */
@media (max-width: 720px) {
  body.chat-page.chat-composing {
    overflow: hidden;
  }

  body.chat-page.chat-composing .mobile-nav {
    display: none;
  }

  body.chat-page.chat-composing .shell {
    padding-bottom: 0;
  }

  body.chat-page.chat-composing .chat-shell {
    height: calc(var(--chat-visible-height, 100dvh) - 58px);
    min-height: 0;
    margin-bottom: 0;
    border-radius: 8px;
    grid-template-rows: 48px minmax(0, 1fr) 54px;
  }

  body.chat-page.chat-composing .family-chat-shell {
    grid-template-rows: minmax(0, 1fr) 54px;
  }

  body.chat-page.chat-composing .chat-compose {
    position: static;
    bottom: auto;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    border-bottom: 0;
  }
}
