/* Family Portal — tokens from design/HANDOFF.md */
:root {
  --ink: #1C2426;
  --sidebar: #1E2A2C;
  --sidebar-2: #27373A;
  --sidebar-active: #314245;
  --page: #F4F1EA;
  --card: #FFFFFF;
  --soft: #FBF9F4;
  --soft-2: #F7F5F0;
  --border: #E2DCD0;
  --border-2: #CFC8BB;
  --rule: #ECE7DD;
  --muted: #56605F;
  --muted-2: #3F4847;
  --accent: #1F5F5B;
  --accent-hover: #16453F;
  --warn: #8A4209;
  --warn-bg: #FBE7D3;
  --warn-border: #F0C9A3;
  --danger: #9A2B1E;
  --danger-border: #E2C2BC;
  --seg: #E8E3D9;
  --serif: Fraunces, Georgia, serif;
  --sans: 'Instrument Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.4; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
button, input, select, textarea { font-family: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0; }
h1 { font-size: 34px; letter-spacing: -0.01em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; }
[hidden] { display: none !important; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn { height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--card);
  color: var(--ink); font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { color: var(--ink); background: var(--soft); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-danger { color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { color: var(--danger); background: #FDF5F3; }
.btn-warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn-warn:hover { background: #6F3507; color: #fff; }
.btn-sm { height: 36px; padding: 0 14px; font-size: 13px; border-radius: 8px; }
.icon-btn { width: 44px; height: 44px; padding: 0; border-radius: 10px; border: 1px solid var(--border); background: var(--card);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink); }
.fab { width: 44px; height: 44px; border-radius: 22px; background: var(--accent); color: #fff; display: inline-flex;
  align-items: center; justify-content: center; }
.fab:hover { color: #fff; background: var(--accent-hover); }
.inline-form { display: inline; margin: 0; }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--seg); flex-wrap: wrap; }
.seg button, .seg label { height: 38px; padding: 0 14px; border-radius: 8px; border: none; background: transparent; color: #4A5352;
  font-size: 14px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; }
.seg [aria-pressed="true"], .seg label:has(input:checked) { background: #fff; color: var(--ink); font-weight: 600; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }

/* ── Shell ───────────────────────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar { width: 248px; flex-shrink: 0; background: var(--sidebar); color: #EDE8DF; display: flex; flex-direction: column;
  gap: 32px; padding: 28px 18px; position: sticky; top: 0; height: 100vh; height: 100dvh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px; font-family: var(--serif); font-size: 21px; font-weight: 600;
  color: #EDE8DF; text-decoration: none; }
.brand:hover { color: #fff; }
.side-links { display: flex; flex-direction: column; gap: 4px; }
.side-links a { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; border-radius: 10px; color: #C9D1CE;
  text-decoration: none; font-size: 15px; font-weight: 500; }
.side-links a:hover { background: #2A3A3D; color: #fff; }
.side-links a[aria-current="page"] { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.me-card { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--sidebar-2); }
.me-card .name { font-size: 14px; font-weight: 600; }
.linkish { background: none; border: none; padding: 0; font-size: 13px; color: #B9C7C4; text-decoration: underline; cursor: pointer; }
.linkish:hover { color: #fff; }
.build { font-size: 11px; color: #7F8F8C; padding: 0 12px; margin-top: -20px; }
.main { flex-grow: 1; min-width: 0; padding: 32px 36px; display: flex; flex-direction: column; gap: 20px; }
.tabbar { display: none; }

.avatar { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; background: var(--t); color: var(--c); font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
.avatar.sm { width: 28px; height: 28px; font-size: 13px; }
.avatar.xs { width: 24px; height: 24px; font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex-shrink: 0; display: inline-block; }
.dot.sm { width: 8px; height: 8px; }
.tag { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px; background: var(--t);
  font-size: 13px; font-weight: 500; white-space: nowrap; }
.pill-status { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 14px; font-size: 13px; font-weight: 600; white-space: nowrap; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .sub { margin: 6px 0 0; font-size: 15px; color: var(--muted); }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 500; text-decoration: none; }
.head-actions { display: flex; gap: 10px; }

.flash-stack { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.flash { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(20, 28, 30, .25); animation: flash-out 5s forwards; }
@keyframes flash-out { 0%, 85% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; }
.errors { background: var(--warn-bg); border: 1px solid var(--warn-border); color: #5E2D06; border-radius: 12px; padding: 12px 16px;
  font-size: 14px; }
.errors ul { margin: 0; padding-left: 18px; }

/* ── Sign in ─────────────────────────────────────────────────────────────── */
.signin { display: flex; min-height: 100vh; min-height: 100dvh; }
.signin-hero { width: 560px; flex-shrink: 0; background: var(--sidebar); color: #EDE8DF; padding: 56px; display: flex;
  flex-direction: column; justify-content: space-between; }
.signin-hero .brand { padding: 0; font-size: 24px; }
.signin-hero h1 { font-size: 48px; line-height: 1.1; letter-spacing: -0.02em; }
.signin-hero p { margin: 20px 0 0; font-size: 18px; line-height: 1.5; color: #C9D1CE; }
.signin-private { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #B9C7C4; }
.signin-body { flex-grow: 1; display: flex; align-items: center; justify-content: center; padding: 32px; }
.signin-form { width: 520px; max-width: 100%; display: flex; flex-direction: column; gap: 28px; }
.signin-form h2 { font-size: 36px; }
.signin-form .sub { margin: 8px 0 0; font-size: 16px; color: var(--muted); }
.profiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.profile { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 20px 8px 16px; border-radius: 16px;
  background: #fff; border: 2px solid var(--border); cursor: pointer; font-size: 16px; font-weight: 600; }
.profile:has(input:checked) { border-color: var(--c); }
.profile input { position: absolute; opacity: 0; pointer-events: none; }
.profile:focus-within { outline: 2px solid var(--c); outline-offset: 2px; }
.profile .avatar { width: 64px; height: 64px; font-family: var(--serif); font-size: 26px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.field .hint { font-weight: 400; color: var(--muted); }
.input, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
  height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border-2); background: #fff; font-size: 15px;
  font-weight: 400; color: var(--ink); width: 100%; min-width: 0; }
.field select { padding: 0 10px; }
.field textarea { height: 72px; padding: 10px 14px; resize: vertical; }
.field input[readonly] { background: var(--soft-2); }
.field.sub-label { font-size: 13px; font-weight: 400; color: var(--muted); gap: 4px; }
.input-lg { height: 52px !important; border-radius: 12px !important; font-size: 16px !important; }
.signin-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.signin-actions .btn { height: 52px; padding: 0 32px; border-radius: 12px; font-size: 16px; }
.forgot { font-size: 15px; font-weight: 500; }
.forgot-note { font-size: 14px; color: var(--muted-2); background: var(--soft); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin: 0; }

/* ── Calendar ────────────────────────────────────────────────────────────── */
.cal-page { display: flex; flex-grow: 1; min-width: 0; }
.cal-main { flex-grow: 1; min-width: 0; padding: 32px 36px; display: flex; flex-direction: column; gap: 20px; height: 100vh; height: 100dvh; }
.cal-aside { width: 340px; flex-shrink: 0; background: var(--soft); border-left: 1px solid var(--border); padding: 36px 24px;
  display: flex; flex-direction: column; gap: 28px; overflow-y: auto; height: 100vh; height: 100dvh; position: sticky; top: 0; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.cal-head-left, .cal-head-right { display: flex; align-items: center; gap: 12px; }
.cal-head h1 { min-width: 250px; }
.nav-arrows { display: flex; gap: 4px; }
.chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip { height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--t); background: var(--t); font-size: 14px;
  font-weight: 500; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.chip[aria-pressed="false"] { background: #fff; border-color: var(--border-2); color: var(--muted); }

.reminders { display: flex; flex-direction: column; gap: 6px; }
.reminder { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 14px; border-radius: 12px; background: #EAF1EF;
  border: 1px solid #C9DCD8; font-size: 14px; }
.reminder a { color: var(--ink); text-decoration: none; flex-grow: 1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.reminder strong { font-weight: 600; }
.reminder .when { color: var(--muted-2); }
.reminder .x { width: 36px; height: 36px; border: none; background: transparent; border-radius: 8px; cursor: pointer; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; }
.reminder .x:hover { background: rgba(0,0,0,.05); }

.cal-frame { flex-grow: 1; min-height: 0; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; background: #fff; }
.month-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--soft); border-bottom: 1px solid var(--border); }
.month-head div { padding: 10px; font-size: 12px; font-weight: 600; letter-spacing: .06em; color: var(--muted); }
.month-grid { flex-grow: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.day { padding: 8px 6px; display: flex; flex-direction: column; gap: 4px; min-height: 0; min-width: 0; overflow: hidden;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: #fff; }
.day:nth-child(7n) { border-right: none; }
.day.last-row { border-bottom: none; }
.day.other { background: var(--soft-2); }
.day-num { height: 26px; padding-left: 5px; font-size: 13px; font-weight: 600; display: flex; align-items: center; background: none;
  border: none; cursor: pointer; align-self: flex-start; border-radius: 13px; }
.day.other .day-num { color: #6E7472; }
.day-num.today { width: 26px; padding: 0; justify-content: center; background: var(--accent); color: #fff !important; }
.pill { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 24px; border: none; background: var(--t); border-radius: 6px;
  padding: 3px 7px; font-size: 12px; font-weight: 500; text-align: left; white-space: nowrap; overflow: hidden; cursor: pointer; flex-shrink: 0; }
.pill .dot { width: 7px; height: 7px; }
.pill span:last-child { overflow: hidden; text-overflow: ellipsis; }
.more { border: none; background: none; font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; padding: 2px 7px; cursor: pointer; }

.week-head, .week-allday, .week-body { display: grid; grid-template-columns: 64px repeat(7, minmax(0, 1fr)); }
.week-head { background: var(--soft); border-bottom: 1px solid var(--border); }
.week-head > div { display: flex; align-items: baseline; gap: 6px; padding: 10px; border-left: 1px solid var(--border); }
.week-head > div:first-child { border-left: none; }
.week-head .dow { font-size: 12px; font-weight: 600; letter-spacing: .06em; color: var(--muted); }
.week-head .num { font-family: var(--serif); font-size: 20px; font-weight: 600; }
.week-head .is-today .num { color: var(--accent); }
.week-allday { border-bottom: 1px solid var(--border); }
.week-allday .label { display: flex; align-items: center; justify-content: flex-end; padding-right: 10px; font-size: 12px; color: var(--muted); }
.allday-bars { grid-column: 2 / span 7; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: 30px;
  row-gap: 4px; padding: 6px 0; min-height: 42px; }
.bar { margin: 0 4px; border: none; border-radius: 6px; background: var(--t); font-size: 13px; font-weight: 600; display: flex;
  align-items: center; gap: 8px; padding: 0 10px; text-align: left; cursor: pointer; overflow: hidden; white-space: nowrap; }
.week-scroll { flex-grow: 1; min-height: 0; overflow-y: auto; }
.hours { display: flex; flex-direction: column; }
.hours div { height: 50px; flex-shrink: 0; padding: 4px 10px 0 0; text-align: right; font-size: 12px; color: var(--muted); }
.week-col { position: relative; border-left: 1px solid var(--border);
  background: repeating-linear-gradient(to bottom, #ECE7DD 0, #ECE7DD 1px, transparent 1px, transparent 50px); }
.week-col.is-today { background-color: #FCFBF7; }
.block { position: absolute; border: none; border-radius: 8px; background: var(--t); padding: 6px 8px; display: flex; flex-direction: column;
  align-items: flex-start; gap: 1px; text-align: left; overflow: hidden; cursor: pointer; box-shadow: 0 0 0 1px #fff; }
.block .t { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.block .dot { width: 7px; height: 7px; }
.block .time { font-size: 12px; color: var(--muted-2); }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: #C0392B; z-index: 2; }

.list-scroll { flex-grow: 1; min-height: 0; overflow-y: auto; }
.list-group { display: grid; grid-template-columns: 88px minmax(0, 1fr); border-bottom: 1px solid var(--rule); }
.list-group:last-child { border-bottom: none; }
.list-date { display: flex; flex-direction: column; align-items: center; padding: 16px 0; background: var(--soft); }
.list-date .small { font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--muted); }
.list-date .big { font-family: var(--serif); font-size: 26px; font-weight: 600; }
.list-items { display: flex; flex-direction: column; padding: 6px 0; }
.list-item { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto 24px; gap: 16px; align-items: center; min-height: 60px;
  padding: 8px 16px 8px 20px; border: none; background: transparent; text-align: left; cursor: pointer; width: 100%; }
.list-item:hover { background: var(--soft); }
.list-item .time { font-size: 14px; font-weight: 600; color: var(--muted-2); }
.list-item .title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.list-item .dot { width: 9px; height: 9px; }
.list-item .where { font-size: 13px; color: var(--muted); padding-left: 17px; }
.list-item .tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.empty { margin: 0; padding: 32px; font-size: 15px; color: var(--muted); }

.side-section { display: flex; flex-direction: column; gap: 14px; }
.side-section h2 { font-size: 22px; }
.up-card { display: flex; gap: 14px; padding: 14px; border-radius: 12px; background: #fff; border: 1px solid var(--border); text-align: left;
  cursor: pointer; width: 100%; }
.up-card:hover { border-color: var(--border-2); }
.up-date { width: 48px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 10px; background: var(--t); padding: 6px 0; }
.up-date .small { font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--c); }
.up-date .big { font-family: var(--serif); font-size: 22px; font-weight: 600; }
.up-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.up-text .title { font-size: 15px; font-weight: 600; }
.up-text .sub { font-size: 13px; color: var(--muted); }
.away-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 0 10px; margin: 0 -10px;
  border: none; border-radius: 8px; background: transparent; font-size: 14px; cursor: pointer; text-align: left; width: calc(100% + 20px); }
.away-row:hover { background: #F1EDE4; }
.away-row .left { display: flex; align-items: center; gap: 8px; }

/* Phone calendar (hidden on desktop) */
.pcal { display: none; }

/* Event details dialog / sheet */
.overlay { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; }
.overlay-bg { position: absolute; inset: 0; border: none; padding: 0; background: rgba(28, 36, 38, .5); cursor: pointer; }
.dialog { position: relative; width: 560px; max-width: calc(100vw - 32px); max-height: calc(100vh - 48px); overflow-y: auto; border-radius: 20px;
  background: #fff; box-shadow: 0 24px 60px rgba(20, 28, 30, .3); display: flex; flex-direction: column; }
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 24px 24px 22px 28px; background: var(--t); }
.dlg-grip { display: none; }
.dlg-type { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.dlg-title { font-size: 30px; letter-spacing: -.01em; line-height: 1.15; margin: 6px 0; }
.dlg-when { font-size: 15px; font-weight: 500; color: #2E3736; }
.dlg-close { width: 44px; height: 44px; flex-shrink: 0; border-radius: 22px; border: none; background: #fff; display: flex;
  align-items: center; justify-content: center; cursor: pointer; }
.dlg-body { padding: 22px 28px; display: flex; flex-direction: column; gap: 18px; }
.dlg-row { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 12px; align-items: start; }
.dlg-row > svg { margin-top: 2px; }
.person-tag { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px 0 4px; border-radius: 14px; background: var(--t);
  font-size: 14px; font-weight: 600; }
.person-tag .ini { width: 22px; height: 22px; border-radius: 11px; background: var(--c); color: #fff; display: flex; align-items: center;
  justify-content: center; font-size: 11px; }
.doc-line { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.doc-line .name { font-size: 15px; font-weight: 600; text-decoration: none; }
.call-btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border-2);
  font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.notes-box { padding: 14px 16px; border-radius: 12px; background: var(--soft); border: 1px solid var(--rule); display: flex; flex-direction: column; gap: 4px; }
.notes-box .body { font-size: 15px; line-height: 1.5; white-space: pre-wrap; }
.dlg-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 24px 16px 28px; border-top: 1px solid var(--rule); }
.dlg-foot .meta { font-size: 13px; color: var(--muted); }
.dlg-foot .actions { display: flex; gap: 8px; }

/* ── Doctors ─────────────────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 10px; width: 360px; max-width: 100%; height: 44px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border-2); background: #fff; color: var(--muted); }
.search input { flex-grow: 1; min-width: 0; border: none; outline: none; background: transparent; font-size: 15px; color: var(--ink); }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.doc-card { display: flex; flex-direction: column; gap: 14px; padding: 22px; scroll-margin-top: 24px; }
.doc-card:target { box-shadow: 0 0 0 3px var(--accent); }
.doc-card .spec { font-size: 12px; font-weight: 600; letter-spacing: .06em; color: var(--warn); text-transform: uppercase; }
.doc-card h2 { font-size: 21px; margin: 4px 0; }
.doc-card .practice { font-size: 14px; color: var(--muted); }
.doc-lines { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.doc-lines > * { display: flex; align-items: center; gap: 10px; }
.doc-lines .addr { color: var(--muted-2); }
.doc-lines a { text-decoration: none; font-weight: 500; }
.doc-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.doc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 14px; border-top: 1px solid var(--rule); margin-top: auto; }
.doc-foot .next { font-size: 13px; color: var(--muted); }
.doc-foot .acts { display: flex; gap: 6px; }
.doc-phone-acts { display: none; }
.doc-notes { font-size: 13px; color: var(--muted-2); }

/* ── Prescriptions ───────────────────────────────────────────────────────── */
.alert { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 20px; border-radius: 14px;
  background: var(--warn-bg); border: 1px solid var(--warn-border); }
.alert.quiet { background: var(--soft); border-color: var(--border); }
.alert .left { display: flex; align-items: center; gap: 14px; }
.alert .title { font-size: 15px; font-weight: 600; color: #5E2D06; }
.alert .body { font-size: 14px; color: #6B3A10; }
.alert.quiet .title { color: var(--ink); }
.alert.quiet .body { color: var(--muted); }
.alert .acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.rx-table { border-radius: 14px; background: #fff; border: 1px solid var(--border); overflow: hidden; }
.rx-row { display: grid; grid-template-columns: 120px 1.6fr 1.8fr 1.2fr 80px 120px 130px; gap: 16px; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--rule); font-size: 14px; color: var(--ink); text-decoration: none; scroll-margin-top: 24px; }
a.rx-row:hover { background: var(--soft); color: var(--ink); }
.rx-row:target { background: #EAF1EF; }
.rx-row.head { padding: 12px 20px; background: var(--soft); border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 600;
  letter-spacing: .06em; color: var(--muted); }
.rx-row:last-child { border-bottom: none; }
.rx-who { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.rx-med { display: flex; flex-direction: column; gap: 2px; }
.rx-med .name { font-weight: 600; }
.rx-med .form { font-size: 13px; color: var(--muted); }
.rx-row .soft { color: var(--muted-2); }
.rx-row .strong { font-weight: 600; }
.rx-cards { display: none; }
.rx-count { font-size: 14px; color: var(--muted); }
.show-finished { font-size: 14px; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.show-finished input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }

.renew-dialog .dlg-head { background: var(--warn-bg); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-layout { display: flex; gap: 24px; align-items: flex-start; }
.form-card { flex-grow: 1; min-width: 0; padding: 26px 28px; display: flex; flex-direction: column; gap: 16px; }
.form-aside { width: 340px; flex-shrink: 0; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 24px; }
.panel { padding: 22px; border-radius: 16px; background: var(--soft); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.panel h2 { font-size: 20px; }
.panel .txt { font-size: 14px; line-height: 1.5; color: var(--muted-2); margin: 0; }
fieldset { margin: 0; padding: 0; border: none; min-width: 0; }
legend { padding: 0; margin-bottom: 8px; font-size: 14px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid-addr { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
.grid-med { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.radios { display: flex; align-items: center; gap: 18px; min-height: 44px; font-size: 14px; flex-wrap: wrap; }
.checks-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding-top: 4px; }
.checks-row select { height: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--border-2); background: #fff; font-size: 14px; }

.typebtns { display: flex; gap: 8px; flex-wrap: wrap; }
.typebtn { height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border-2); background: #fff; font-size: 14px;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; }
.typebtn:has(input:checked) { background: var(--ink); color: #fff; border-color: var(--ink); }
.typebtn input { position: absolute; opacity: 0; pointer-events: none; }
.typebtn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.pchips { display: flex; gap: 8px; flex-wrap: wrap; }
.pchip { height: 40px; padding: 0 14px 0 6px; border-radius: 20px; border: 1px solid var(--border-2); background: #fff; font-size: 14px;
  font-weight: 600; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.pchip .avatar { width: 28px; height: 28px; font-size: 13px; }
.pchip:has(input:checked) { background: var(--t); border-color: var(--c); }
.pchip:has(input:checked) .avatar { background: var(--c); color: #fff; }
.pchip input { position: absolute; opacity: 0; pointer-events: none; }
.pchip:focus-within { outline: 2px solid var(--c); outline-offset: 2px; }

.preview-chip { display: flex; align-items: center; gap: 8px; background: var(--t); border-radius: 8px; padding: 8px 10px; font-size: 14px; font-weight: 500; }
.warn-text { font-size: 14px; color: var(--warn); }
.form-bottom { display: none; }
.form-danger { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 8px; border-top: 1px solid var(--rule); margin-top: 4px; }

/* ── Settings ────────────────────────────────────────────────────────────── */
.settings-section { padding: 24px 28px; display: flex; flex-direction: column; gap: 16px; max-width: 900px; scroll-margin-top: 24px; }
.settings-section h2 { font-size: 24px; }
.person-row { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 16px; padding: 16px 0; border-top: 1px solid var(--rule); }
.person-row:first-of-type { border-top: none; }
.person-forms { display: flex; flex-direction: column; gap: 10px; }
.person-forms form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin: 0; }
.person-forms .field { flex: 1 1 180px; }
.swatches { display: flex; gap: 6px; height: 44px; align-items: center; }
.swatch { width: 28px; height: 28px; border-radius: 50%; background: var(--c); cursor: pointer; display: inline-block; position: relative; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch:has(input:checked) { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c); }
.pw-state { font-size: 13px; color: var(--muted); font-weight: 400; }
.backup-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.backup-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--rule); font-size: 14px; }
.backup-list > div:first-child { border-top: none; }
details.danger summary { cursor: pointer; font-size: 13px; color: var(--danger); font-weight: 600; }

.account-card { padding: 24px; display: flex; flex-direction: column; gap: 16px; max-width: 520px; }

/* ── Mid widths ──────────────────────────────────────────────────────────── */
@media (max-width: 1240px) {
  .cal-aside { display: none; }
  .rx-row { grid-template-columns: 100px 1.6fr 1.6fr 1fr 60px 90px 120px; gap: 12px; }
}
@media (max-width: 1080px) {
  .form-aside { display: none; }
  .sidebar { width: 210px; }
  .main, .cal-main { padding: 28px 24px; }
}

/* ── Phone ───────────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .sidebar { display: none; }
  .shell { flex-direction: column; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .tabbar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--border); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 50px;
    text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500; }
  .tabbar a[aria-current="page"] { color: var(--accent); font-weight: 600; }
  .tabbar .avatar { width: 24px; height: 24px; font-size: 12px; }
  .main { padding: 20px 20px 24px; padding-top: max(20px, env(safe-area-inset-top)); gap: 14px; }
  h1 { font-size: 30px; }
  .page-head { align-items: center; flex-wrap: nowrap; }
  .page-head .sub { display: none; }
  .desk-only { display: none !important; }
  .phone-only { display: revert; }
  .btn-add-label { display: none; }
  .page-head .btn-add { width: 44px; padding: 0; border-radius: 22px; }
  .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea, .input, .search input { font-size: 16px; }

  /* Sign in */
  .signin { flex-direction: column; }
  .signin-hero { width: auto; padding: 56px 24px 32px; border-radius: 0 0 28px 28px; gap: 20px; justify-content: flex-start; }
  .signin-hero .brand { font-size: 19px; }
  .signin-hero h1 { font-size: 30px; line-height: 1.15; letter-spacing: -.01em; }
  .signin-hero p, .signin-private { display: none; }
  .signin-body { padding: 28px 24px 34px; align-items: stretch; }
  .signin-form { gap: 22px; }
  .signin-form h2 { font-size: 24px; }
  .signin-form .sub { display: none; }
  .profiles { gap: 10px; }
  .profile { padding: 14px 4px 12px; gap: 8px; font-size: 14px; border-radius: 14px; }
  .profile .avatar { width: 48px; height: 48px; font-size: 20px; }
  .signin-actions { flex-direction: column-reverse; align-items: stretch; gap: 8px; }
  .signin-actions .btn { height: 54px; border-radius: 14px; font-size: 17px; }
  .forgot { align-self: center; padding: 8px; }

  /* Calendar: swap desktop views for the week strip + agenda */
  .cal-main { display: none; }
  .pcal { display: flex; flex-direction: column; flex-grow: 1; min-width: 0; }
  .pcal-top { padding: 20px 20px 14px; padding-top: max(20px, env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 16px; }
  .pcal-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .pcal-title .left { display: flex; align-items: center; gap: 4px; min-width: 0; }
  .pcal-title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pcal-arrow { width: 36px; height: 44px; border: none; background: none; display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--muted); flex-shrink: 0; }
  .strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
  .strip button { height: 64px; border-radius: 14px; border: none; background: transparent; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 2px; cursor: pointer; padding: 0; }
  .strip .dow { font-size: 11px; font-weight: 600; letter-spacing: .06em; opacity: .85; }
  .strip .num { font-size: 18px; font-weight: 600; }
  .strip .mark { width: 5px; height: 5px; border-radius: 3px; background: transparent; }
  .strip .has .mark { background: var(--accent); }
  .strip .is-today { background: #fff; }
  .strip [aria-pressed="true"] { background: var(--ink); color: #fff; }
  .strip [aria-pressed="true"] .mark { background: transparent; }
  .strip .has[aria-pressed="true"] .mark { background: #fff; }
  .pcal-body { padding: 4px 20px 20px; display: flex; flex-direction: column; gap: 18px; }
  .pcal-sec { display: flex; flex-direction: column; gap: 10px; }
  .pcal-sec h2 { font-family: var(--sans); font-size: 13px; font-weight: 600; letter-spacing: .06em; color: var(--muted); }
  .day-item { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 14px; border: none; background: var(--t);
    text-align: left; cursor: pointer; width: 100%; }
  .day-item .t { font-size: 16px; font-weight: 600; display: block; }
  .day-item .s { font-size: 14px; color: var(--muted-2); display: block; }
  .day-empty { margin: 0; padding: 14px; border-radius: 14px; border: 1px dashed var(--border-2); font-size: 15px; color: var(--muted); }
  .up-group { display: flex; flex-direction: column; gap: 6px; }
  .up-group .label { font-size: 14px; font-weight: 600; color: var(--muted-2); padding-top: 4px; }
  .agenda-item { display: grid; grid-template-columns: 72px minmax(0, 1fr) 18px; gap: 10px; align-items: center; padding: 12px 12px 12px 14px;
    border-radius: 14px; border: 1px solid var(--border); background: #fff; text-align: left; cursor: pointer; width: 100%; }
  .agenda-item .st { font-size: 13px; font-weight: 600; color: var(--muted-2); }
  .agenda-item .t { display: flex; align-items: center; gap: 7px; font-size: 15px; font-weight: 600; }
  .agenda-item .w { font-size: 13px; color: var(--muted); padding-left: 15px; display: block; }
  .reminders { padding: 0 20px; }

  /* Details as a bottom sheet */
  .overlay { align-items: flex-end; }
  .dialog { width: 100%; max-width: none; max-height: 92vh; border-radius: 24px 24px 0 0; box-shadow: 0 -12px 40px rgba(20, 28, 30, .25); }
  .dlg-head { flex-direction: column; gap: 8px; padding: 10px 20px 20px; }
  .dlg-grip { display: block; align-self: center; width: 40px; height: 5px; border-radius: 3px; background: rgba(28, 36, 38, .25); }
  .dlg-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-top: 6px; width: 100%; }
  .dlg-title { font-size: 26px; }
  .dlg-body { padding: 20px; }
  .dlg-foot { flex-direction: column; align-items: stretch; padding: 0 20px calc(24px + env(safe-area-inset-bottom)); border-top: none; }
  .dlg-foot .actions { display: grid; grid-template-columns: 1fr 2fr; }
  .dlg-foot .actions .btn { height: 50px; border-radius: 12px; font-size: 16px; }

  /* Doctors */
  .toolbar { flex-direction: column; align-items: stretch; gap: 14px; }
  .search { width: 100%; border-radius: 12px; }
  .toolbar .seg { background: none; padding: 0; gap: 6px; }
  .toolbar .seg button { height: 36px; border-radius: 18px; border: 1px solid var(--border-2); background: #fff; font-weight: 600; }
  .toolbar .seg [aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
  .doc-grid { grid-template-columns: 1fr; gap: 12px; }
  .doc-card { padding: 18px; gap: 12px; }
  .doc-card h2 { font-size: 19px; }
  .doc-lines .tel-line { display: none; }
  .doc-phone-acts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .doc-phone-acts a { height: 44px; border-radius: 10px; background: var(--page); display: flex; align-items: center; justify-content: center;
    gap: 8px; font-size: 15px; font-weight: 600; text-decoration: none; }

  /* Prescriptions */
  .alert { flex-direction: column; align-items: stretch; padding: 16px; gap: 12px; }
  .alert .left { align-items: flex-start; }
  .alert .acts { justify-content: stretch; }
  .alert .acts .btn { flex: 1; }
  .rx-table { display: none; }
  .rx-cards { display: flex; flex-direction: column; gap: 12px; }
  .rx-card { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; color: var(--ink); text-decoration: none; scroll-margin-top: 16px; }
  .rx-card:target { box-shadow: 0 0 0 3px var(--accent); }
  .rx-card .top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .rx-card h2 { font-size: 20px; }
  .rx-card h2 small { font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--muted); }
  .rx-card .dir { font-size: 15px; color: var(--muted-2); }
  .rx-card .facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding-top: 12px; border-top: 1px solid var(--rule); }
  .rx-card .facts span { display: block; font-size: 14px; }
  .rx-card .facts .eyebrow { font-size: 11px; }
  .rx-count { display: none; }

  /* Forms: single column, sticky save */
  .form-layout { flex-direction: column; }
  .form-card { padding: 0; border: none; background: none; gap: 18px; }
  .grid-2, .grid-3, .grid-med { grid-template-columns: 1fr; }
  .grid-addr { grid-template-columns: 1fr 1fr; }
  .grid-addr > :first-child { grid-column: 1 / -1; }
  .grid-3.keep, .grid-2.keep { grid-template-columns: 1fr 1fr; }
  .head-actions { display: none; }
  .form-bottom { display: flex; flex-direction: column; gap: 8px; position: fixed; left: 0; right: 0;
    bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 20; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--page); }
  .form-bottom .summary { font-size: 13px; color: var(--muted); text-align: center; }
  .form-bottom .btn { height: 52px; border-radius: 14px; font-size: 17px; }
  .form-page { padding-bottom: 150px; }
  .typebtn { height: 44px; }
  .pchip { height: 44px; }

  .settings-section { padding: 20px; }
}
@media (min-width: 761px) {
  .phone-only { display: none !important; }
}

/* ── Deleted items ───────────────────────────────────────────────────────── */
.del-section { display: flex; flex-direction: column; gap: 10px; max-width: 900px; }
.del-section h2 { font-size: 22px; margin-top: 6px; }
.del-item { overflow: hidden; }
.del-item summary, .del-summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px;
  cursor: pointer; list-style: none; }
.del-summary { cursor: default; }
.del-item summary::-webkit-details-marker { display: none; }
.del-item[open] summary { border-bottom: 1px solid var(--rule); }
.del-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.del-title { font-size: 16px; font-weight: 600; }
.del-sub { font-size: 13px; color: var(--muted); }
.del-body { padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.del-field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
@media (max-width: 760px) {
  .del-item summary, .del-summary { align-items: flex-start; }
}
