/* Care Together prototype. Values mirror the mockups (brag-output/tools/gen_screens.py). */
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("../assets/fonts/PlusJakartaSans-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --bg: #f6f6fb;
  --ink: #1f2340;
  --sub: #555a78;
  --muted: #666b8a;
  --faint: #8a8ea8;
  --line: #e1e3f1;
  --accent: #5b5bd6;
  --accent-ink: #4548b8;
  --tint: #e9ebff;
  --tint-2: #dde0fa;
  --deep: #3b3f70;
  --ok-bg: #e5f6ee;
  --ok: #1f6b4b;
  --warn-bg: #fff6e0;
  --warn: #8a5a00;
  --bad-bg: #fde9e6;
  --bad: #b23a52;
  --font: "Plus Jakarta Sans", "Noto Sans Devanagari", "Kohinoor Devanagari", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  word-spacing: 0.1em;
  color: var(--ink);
  background: #e9eaf3;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
[data-go], [data-tab], [data-back], [data-act] { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Layout: phone frame on desktop, full screen on phones ---------- */
.stage-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  padding: 24px;
}
.phone {
  position: relative;
  width: 418px;
  height: 872px;
  flex-shrink: 0;
  padding: 14px;
  border-radius: 60px;
  background: #1f2340;
  box-shadow: 0 40px 90px rgba(31, 35, 64, 0.28);
}
.device {
  position: relative;
  width: 390px;
  height: 844px;
  overflow: hidden;
  border-radius: 46px;
  background: var(--bg);
  isolation: isolate;
}
@media (max-width: 520px) {
  .stage-wrap { padding: 0; display: block; }
  .phone { width: 100%; height: 100dvh; padding: 0; border-radius: 0; box-shadow: none; background: var(--bg); }
  .device { width: 100%; height: 100%; border-radius: 0; }
}
/* On short screens the phone is scaled to fit by fitPhone() in app.js (CSS can't turn a length
   ratio into a scale factor). zoom also shrinks its layout box, so nothing gets clipped. */

/* ---------- Screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  will-change: transform;
}
.screen-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: var(--gap, 14px);
  padding: 30px 20px 24px;
  scrollbar-width: none;
}
.screen-body::-webkit-scrollbar { display: none; }
.screen.has-nav .screen-body { padding-bottom: 100px; }
.screen.push-enter { transform: translateX(100%); }
.screen.push-enter.go { transform: translateX(0); transition: transform 0.38s cubic-bezier(0.2, 0.8, 0.2, 1); }
.screen.pop-leave { transform: translateX(0); }
.screen.pop-leave.go { transform: translateX(100%); transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1); }
.screen.under { transform: translateX(-24%); transition: transform 0.38s cubic-bezier(0.2, 0.8, 0.2, 1); }
.screen.fade-enter { opacity: 0; }
.screen.fade-enter.go { opacity: 1; transition: opacity 0.18s linear; }
@media (prefers-reduced-motion: reduce) {
  .screen.push-enter.go, .screen.pop-leave.go, .screen.under, .screen.fade-enter.go { transition: none; }
}

/* ---------- Bottom tab bar ---------- */
.nav {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 84px;
  display: flex;
  gap: 2px;
  padding: 8px 8px 24px;
  background: #fff;
  border-top: 1px solid #e8e9f3;
  z-index: 5;
}
.nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.nav button.on { color: var(--accent); font-weight: 800; }

/* ---------- Kit (ported from gen_screens.py helpers) ---------- */
.tab-header { display: flex; align-items: center; gap: 8px; }
.tab-header .t { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; }
.tab-header h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.4px; }
.tab-header p { margin: 0; font-size: 14px; color: var(--muted); }
.topbar { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.topbar h1 { flex-grow: 1; margin: 0; text-align: center; font-size: 17px; font-weight: 800; }
.round-btn {
  width: 40px; height: 40px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: #fff; border: 1px solid var(--line); color: var(--ink);
}
.spacer40 { width: 40px; height: 40px; flex-shrink: 0; }
.card {
  display: flex;
  flex-direction: column;
  gap: var(--g, 12px);
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--ink);
  text-align: left;
  width: 100%;
}
.card.hero { padding: 18px; border-radius: 24px; gap: 8px; }
.label { font-size: 12px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; color: var(--accent-ink); }
.section-title { display: flex; align-items: center; justify-content: space-between; font-size: 16px; font-weight: 800; }
.section-title .r { font-size: 13px; font-weight: 700; color: var(--accent-ink); }
.big { font-size: 24px; font-weight: 800; letter-spacing: -0.3px; line-height: 1.2; }
.lede { font-size: 14px; font-weight: 600; line-height: 1.45; color: var(--sub); }
.small { font-size: 12px; font-weight: 600; color: var(--muted); }
.note { font-size: 13px; font-weight: 600; line-height: 1.4; color: var(--deep); }
.icon-box { flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.row { display: flex; align-items: center; gap: 12px; color: var(--ink); text-align: left; width: 100%; }
.row .rt { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row .rt b { font-size: 15px; font-weight: 700; }
.row .rt b.s14 { font-size: 14px; }
.row .rt b.s13 { font-size: 13px; }
.row .rt span { font-size: 12px; font-weight: 600; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; height: 30px; padding: 0 12px;
  border-radius: 15px; background: #fff; border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--sub); white-space: nowrap;
}
.chip.on { background: var(--tint-2); border: 1.5px solid var(--accent); font-weight: 700; color: var(--accent-ink); }
.mini-chip {
  display: inline-flex; align-items: center; flex-shrink: 0; height: 22px; padding: 0 8px;
  border-radius: 11px; font-size: 11px; font-weight: 700; white-space: nowrap;
  background: var(--tint); color: var(--deep);
}
.checkbox {
  width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%;
  border: 2px solid var(--c, var(--accent)); background: #fff;
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.checkbox.on { background: var(--c, var(--accent)); }
.toggle {
  width: 44px; height: 26px; flex-shrink: 0; padding: 3px; border-radius: 13px;
  background: #d5d7e6; display: flex; justify-content: flex-start; transition: background 0.15s;
}
.toggle::after { content: ""; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(31, 35, 64, 0.25); }
.toggle.on { background: var(--accent); justify-content: flex-end; }
.avatar { flex-shrink: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; }
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 52px; flex-shrink: 0; border-radius: 26px; background: var(--accent); color: #fff;
  font-size: 16px; font-weight: 700; width: 100%;
}
.btn-primary.sm { height: 44px; font-size: 15px; border-radius: 22px; }
.btn-outline {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; border-radius: 21px; border: 1.5px solid var(--accent); color: var(--accent-ink);
  font-size: 14px; font-weight: 700; width: 100%; background: #fff;
}
.btn-dashed {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 48px; flex-shrink: 0;
  border-radius: 24px; border: 1.5px dashed #b9bce8; color: var(--accent-ink); font-size: 15px; font-weight: 700; width: 100%;
}
.progress { height: 8px; border-radius: 4px; background: var(--pb, var(--tint)); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 4px; background: var(--pc, var(--accent)); transition: width 0.3s; }
.meter { display: flex; flex-direction: column; gap: 6px; }
.meter .mh { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; }
.meter .mh .v { color: var(--sub); }
.meter .mh .v em { font-style: normal; font-weight: 600; color: var(--muted); }
.stepper { display: flex; gap: 5px; }
.stepper div {
  flex: 1; display: flex; align-items: center; justify-content: center; height: 30px; border-radius: 15px;
  font-size: 11.5px; font-weight: 800; white-space: nowrap; background: #fff; color: var(--muted); border: 1px solid var(--line);
}
.stepper div.done { background: var(--tint-2); color: var(--accent-ink); border-color: transparent; }
.stepper div.on { background: var(--accent); color: #fff; border-color: transparent; }
.tile {
  flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 18px; text-align: left; color: var(--ink);
}
.tile .v { font-size: 17px; font-weight: 800; }
.tile .k { font-size: 12px; font-weight: 600; color: var(--sub); }
.hstack { display: flex; gap: 10px; }
.bullet { display: flex; gap: 10px; font-size: 14px; font-weight: 600; line-height: 1.4; color: var(--deep); }
.bullet::before { content: ""; width: 8px; height: 8px; margin-top: 6px; flex-shrink: 0; border-radius: 50%; background: var(--accent); }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: #ecedf6; }
.seg button { flex: 1; height: 38px; border-radius: 12px; font-size: 13px; font-weight: 600; color: var(--sub); }
.seg button.on { background: #fff; color: var(--ink); font-weight: 800; box-shadow: 0 1px 4px rgba(31, 35, 64, 0.12); }
.field {
  width: 100%; min-height: 48px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line);
  background: #fff; font-size: 15px; font-weight: 600;
}
textarea.field { min-height: 72px; resize: none; line-height: 1.45; }
.alert { display: flex; gap: 10px; color: #8a2432; }
.alert b { font-size: 14px; font-weight: 800; display: block; }
.alert span { font-size: 13px; font-weight: 600; line-height: 1.4; color: #6e2a33; }
.shield-note { display: flex; gap: 10px; padding: 0 4px; color: var(--ok); }
.shield-note span { font-size: 13px; font-weight: 600; line-height: 1.4; color: var(--sub); }

/* ---------- Toast + sheets ---------- */
.toast {
  position: absolute; left: 50%; bottom: 100px; z-index: 30;
  transform: translate(-50%, 20px); opacity: 0;
  padding: 10px 16px; border-radius: 14px; background: var(--ink); color: #fff;
  font-size: 13px; font-weight: 700; white-space: nowrap; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.sheet-scrim { position: absolute; inset: 0; z-index: 20; background: rgba(31, 35, 64, 0.35); opacity: 0; transition: opacity 0.2s; }
.sheet-scrim.show { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 86%;
  overflow-y: auto; padding: 10px 20px 30px; border-radius: 26px 26px 0 0; background: var(--bg);
  display: flex; flex-direction: column; gap: 14px; transform: translateY(100%); transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet.show { transform: translateY(0); }
.sheet .grab { align-self: center; width: 40px; height: 5px; border-radius: 3px; background: #cfd1e2; }

/* ---------- Demo panel (desktop) ---------- */
.demo {
  width: 300px; flex-shrink: 0; align-self: center;
  display: flex; flex-direction: column; gap: 14px; padding: 20px;
  border-radius: 24px; background: #fff; border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(31, 35, 64, 0.08);
}
.demo h2 { margin: 0; font-size: 15px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.demo .grp { display: flex; flex-direction: column; gap: 8px; }
.demo .grp > b { font-size: 11px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); }
.demo .opts { display: flex; flex-wrap: wrap; gap: 6px; }
.demo .opts button { height: 30px; padding: 0 10px; border-radius: 15px; border: 1px solid var(--line); font-size: 12.5px; font-weight: 700; color: var(--sub); background: #fff; }
.demo .opts button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.demo input[type="range"] { width: 100%; accent-color: var(--accent); }
.demo .val { font-size: 13px; font-weight: 700; color: var(--deep); }
.demo .foot { display: flex; gap: 8px; }
.demo .foot button { flex: 1; height: 34px; border-radius: 17px; border: 1px solid var(--line); font-size: 12.5px; font-weight: 700; }
.demo-fab { display: none; }
@media (max-width: 1000px) {
  .stage-wrap > .demo { display: none; }
  .demo-fab {
    display: flex; position: fixed; right: 12px; bottom: 96px; z-index: 50; width: 40px; height: 40px; opacity: 0.85;
    border-radius: 50%; background: var(--ink); color: #fff; align-items: center; justify-content: center;
    box-shadow: 0 6px 18px rgba(31, 35, 64, 0.3); font-size: 11px; font-weight: 800;
  }
  .demo.floating { display: flex; position: fixed; right: 12px; bottom: 144px; z-index: 50; max-height: calc(100dvh - 160px); overflow-y: auto; }
}

/* ---------- Care-team dashboards (desktop) ---------- */
.dash { min-height: 100%; display: grid; grid-template-columns: 240px 1fr; background: var(--bg); }
.dash-side { padding: 24px 16px; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.dash-main { padding: 28px 32px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
@media (max-width: 800px) { .dash { grid-template-columns: 1fr; } .dash-side { flex-direction: row; flex-wrap: wrap; } .dash-main { padding: 20px 16px; } }

/* ---------- Dashboard details ---------- */
#dash { min-height: 100vh; background: var(--bg); }
#dash[hidden], .stage-wrap[hidden], .demo-fab[hidden] { display: none !important; }
.dash { grid-template-columns: 260px 1fr; }
.dash-side { position: sticky; top: 0; height: 100vh; overflow-y: auto; gap: 4px; }
.dbrand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 16px; font-size: 15px; }
.dbrand span { margin-left: auto; font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--accent-ink); background: var(--tint); padding: 3px 8px; border-radius: 10px; }
.dme { display: flex; align-items: center; gap: 10px; padding: 12px 10px; margin-bottom: 8px; border-radius: 16px; background: var(--bg); }
.dme b { display: block; font-size: 14px; }
.dme span { font-size: 12px; color: var(--muted); font-weight: 600; }
.dnav { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 12px; font-size: 14px; font-weight: 700; color: var(--sub); text-align: left; }
.dnav:hover { background: var(--bg); }
.dnav.on { background: var(--tint); color: var(--accent-ink); }
.dbadge { margin-left: auto; font-style: normal; font-size: 11px; font-weight: 800; color: #fff; background: var(--accent); border-radius: 10px; padding: 1px 7px; }
.dsep { height: 1px; background: var(--line); margin: 10px 0; }
.dlabel { font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); padding: 0 12px 4px; }
.dtop h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.4px; }
.dtop p, .dhead p { margin: 4px 0 0; color: var(--muted); font-weight: 600; font-size: 14px; }
.dhead { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.dback { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--accent-ink); padding: 8px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--line); }
.dtitle { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 260px; }
.dtitle h2 { margin: 0; font-size: 22px; font-weight: 800; }
.dactions { display: flex; gap: 8px; }
.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; align-items: start; }
.dcard { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.dh { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dh h3 { margin: 0; font-size: 16px; font-weight: 800; }
.psub { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.dnote { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0; }
.drow { display: flex; align-items: center; gap: 12px; }
.drow > div { flex: 1; min-width: 0; }
.drow b { display: block; font-size: 14px; }
.drow span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.dicon { width: 32px; height: 32px; flex-shrink: 0; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--tint); color: var(--accent-ink); }
.dicon.warn { background: var(--warn-bg); color: var(--warn); }
.dbtn { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: 19px; background: var(--accent); color: #fff; font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.dbtn.ghost { background: #fff; color: var(--accent-ink); border: 1.5px solid var(--accent); }
.dbtn.sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.dbtns { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.dtable { width: 100%; border-collapse: collapse; }
.dtable th { text-align: left; font-size: 12px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.dtable td { padding: 12px 10px; border-bottom: 1px solid #EEEFF6; vertical-align: middle; font-size: 14px; }
.dtable.small td { padding: 8px 6px; font-size: 13px; }
.dtable tr.live { cursor: pointer; background: #FAFAFF; }
.dtable tr.live:hover { background: var(--tint); }
.pname { font-weight: 800; font-size: 14.5px; }
.livetag { font-size: 10.5px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase; color: #fff; background: var(--accent); padding: 2px 7px; border-radius: 8px; margin-left: 6px; }
.dthread { display: flex; flex-direction: column; gap: 10px; max-height: 52vh; overflow-y: auto; padding: 4px; }
.dmsg { max-width: 70%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.45; font-weight: 500; position: relative; }
.dmsg i { display: block; font-style: normal; font-size: 11px; font-weight: 600; color: var(--muted); margin-top: 4px; }
.dmsg.them { align-self: flex-start; background: #F1F2F8; border-bottom-left-radius: 4px; }
.dmsg.us { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.dmsg.us i { color: #DDE0FA; }
.dmsg.share { align-self: flex-start; display: flex; gap: 6px; align-items: center; background: var(--tint); color: var(--deep); font-weight: 700; font-size: 13px; }
.dmsg .auto { display: block; font-size: 10.5px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; opacity: .8; margin-bottom: 3px; }
.dreply { display: flex; gap: 8px; }
.dreply input { flex: 1; height: 42px; border-radius: 21px; border: 1px solid var(--line); padding: 0 16px; font-size: 14px; }
.dquick { display: flex; gap: 6px; flex-wrap: wrap; }
.dquick button { font-size: 12.5px; font-weight: 600; color: var(--accent-ink); background: var(--tint); padding: 6px 10px; border-radius: 12px; text-align: left; }
.dform { display: flex; flex-direction: column; gap: 10px; }
.dform.inline { flex-direction: row; flex-wrap: wrap; align-items: center; }
.dform.inline input { width: 96px; height: 34px; border-radius: 10px; border: 1px solid var(--line); padding: 0 10px; }
.dfield { display: flex; align-items: center; gap: 10px; }
.dfield span { width: 90px; font-size: 13px; font-weight: 700; }
.dfield input, .dfield select { width: 120px; height: 36px; border-radius: 10px; border: 1px solid var(--line); padding: 0 10px; font-weight: 700; }
.dfield em { font-style: normal; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.dfield.wide { flex-direction: column; align-items: stretch; gap: 6px; }
.dfield.wide span { width: auto; }
.dfield.wide input, .dfield.wide select { width: 100%; height: 42px; }
.dmodal { position: fixed; inset: 0; z-index: 60; background: rgba(31, 35, 64, .35); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dmodal .dcard { width: 420px; max-width: 100%; }
@media (max-width: 800px) { .dash-side { position: static; height: auto; } .dgrid { grid-template-columns: 1fr; } }
