/* ============================================================
   PediQUEST — High Res Prototype design system
   Tokens lifted from Figma "High Res Prototype +Components +
   Design System" (node 543:354 / 442:1597).
   Plus Jakarta Sans · Soft Sanctuary tints · line icons only.
   ============================================================ */

:root {
  /* Brand / ink */
  --ink:        #233037;   /* headings, primary text */
  --muted:      #5c6e76;   /* secondary text */
  --bg-top:     #fdfeff;
  --bg-bottom:  #f1f6fb;
  --white:      #ffffff;

  /* Soft Sanctuary card families */
  --amber-bg:   #fef3e8;  --amber-border: #f3d5b0;  --amber-accent: #e08a2e;  --amber-track: #f3dbbd;
  --blue-bg:    #e8f2fb;  --blue-border:  #ccdef2;  --blue-accent:  #5b7eaf;
  --purple-bg:  #f0eeff;  --purple-border:#d9d4f5;  --purple-accent:#6b62c9;
  --green-bg:   #e1f5ee;  --green-border: #c4e7d9;  --green-accent: #2f9e78;

  /* Lines / surfaces */
  --hairline:   #dce6e3;
  --field-bg:   #f4f7fa;
  --field-border:#dbe5ec;

  /* Radii */
  --r-card: 18px;
  --r-btn:  13px;
  --r-chip: 20px;
  --r-pill: 999px;

  /* Phone frame */
  --frame-w: 390px;
  --frame-h: 844px;

  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 800px at 50% -10%, #eef4fb, #e7edf4) fixed;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 28px 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1;
}

/* ---------- Phone frame ---------- */
.phone {
  position: relative;
  width: var(--frame-w);
  height: var(--frame-h);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  border-radius: 44px;
  box-shadow: 0 26px 70px -28px rgba(27,49,71,.45), 0 0 0 11px #0e1722, 0 0 0 13px #283545;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* full-bleed on small screens */
@media (max-width: 430px) {
  body { padding: 0; }
  .phone {
    width: 100vw; height: 100svh; min-height: 100svh;
    border-radius: 0; box-shadow: none;
  }
}

.screen {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---------- Status bar ---------- */
.statusbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 50px; padding: 14px 24px 0;
  flex: 0 0 auto;
}
.statusbar .time { font-weight: 600; font-size: 15px; color: var(--ink); }
.statusbar .glyphs { display: flex; gap: 7px; align-items: center; color: var(--ink); }
.statusbar .glyphs svg { display: block; }

/* ---------- App header ---------- */
.appbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 44px; padding: 0 20px 0 24px; flex: 0 0 auto;
}
.appbar .brand { display: flex; align-items: center; gap: 8px; }
.appbar .brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--amber-accent); }
.appbar .brand h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.18px; color: var(--ink); }
.appbar .title { font-size: 16px; font-weight: 700; color: var(--ink); }

.iconbtn {
  width: 40px; height: 40px; border-radius: var(--r-chip);
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer; color: var(--ink);
  padding: 0;
}
.iconbtn svg { width: 22px; height: 22px; }
.iconbtn.sm svg { width: 20px; height: 20px; }

/* back button row */
.navrow { display: flex; align-items: center; gap: 4px; padding: 0 14px 0 12px; height: 44px; flex: 0 0 auto; }
.navrow .spacer { flex: 1 1 auto; }

/* ---------- Body scroll area ---------- */
.body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  padding: 10px 20px 24px;
  display: flex; flex-direction: column; gap: 22px;
  -webkit-overflow-scrolling: touch;
}
.body.tight { gap: 16px; }
.body::-webkit-scrollbar { width: 0; }

/* ---------- Typography ---------- */
.greeting { display: flex; flex-direction: column; gap: 4px; }
.h-xl { font-size: 27px; line-height: 32px; font-weight: 800; letter-spacing: -.54px; color: var(--ink); margin: 0; }
.h-lg { font-size: 22px; line-height: 28px; font-weight: 800; letter-spacing: -.4px; color: var(--ink); margin: 0; }
.h-md { font-size: 18px; font-weight: 700; color: var(--ink); margin: 0; }
.sub  { font-size: 14px; color: var(--muted); margin: 0; }
.body-text { font-size: 15px; line-height: 22px; color: var(--muted); margin: 0; }
.eyebrow {
  font-size: 11.5px; font-weight: 600; letter-spacing: .69px;
  text-transform: uppercase; color: var(--muted); margin: 0;
}
.section { display: flex; flex-direction: column; gap: 10px; }
.center { text-align: center; align-items: center; }

/* ---------- Cards ---------- */
.card {
  border-radius: var(--r-card); padding: 16px; border: 1.5px solid var(--hairline);
  background: var(--white); display: flex; flex-direction: column; gap: 12px;
}
.card.amber  { background: var(--amber-bg);  border-color: var(--amber-border); }
.card.blue   { background: var(--blue-bg);   border-color: var(--blue-border); }
.card.purple { background: var(--purple-bg); border-color: var(--purple-border); }
.card.green  { background: var(--green-bg);  border-color: var(--green-border); }
.card.row    { flex-direction: row; align-items: center; gap: 12px; }
.card.lg     { padding: 18px; gap: 14px; }

.card-icon {
  width: 40px; height: 40px; flex: 0 0 auto; border-radius: var(--r-chip);
  background: var(--white); display: inline-flex; align-items: center; justify-content: center; color: var(--ink);
}
.card-icon svg { width: 22px; height: 22px; }
.card-icon.green  { background: var(--green-bg);  color: var(--green-accent); }
.card-icon.amber  { background: var(--amber-bg);  color: var(--amber-accent); }
.card-icon.blue   { background: var(--blue-bg);   color: var(--blue-accent); }
.card-icon.purple { background: var(--purple-bg); color: var(--purple-accent); }

.card-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.card-text .t { font-size: 16px; font-weight: 700; color: var(--ink); margin: 0; }
.card-text .d { font-size: 13px; color: var(--muted); margin: 0; }
.check { color: var(--blue-accent); font-weight: 600; font-size: 13px; }

/* progress segments */
.progress { display: flex; gap: 6px; width: 100%; }
.progress .seg { flex: 1 1 0; height: 6px; border-radius: 3px; background: var(--amber-track); }
.progress .seg.on { background: var(--amber-accent); }
.progress.blue .seg { background: #cfe0f2; } .progress.blue .seg.on { background: var(--blue-accent); }

/* ---------- Buttons ---------- */
.btn {
  width: 100%; border: none; cursor: pointer; border-radius: var(--r-btn);
  padding: 14px 16px; font-family: var(--font); font-size: 15px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--white); background: var(--ink); text-decoration: none;
}
.btn.amber  { background: var(--amber-accent); }
.btn.blue   { background: var(--blue-accent); }
.btn.green  { background: var(--green-accent); }
.btn.ghost  { background: transparent; color: var(--ink); border: 1.5px solid var(--hairline); }
.btn.subtle { background: var(--field-bg); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.danger { background: #d65745; }

/* ---------- Bottom nav ---------- */
.tabbar {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  height: 86px; padding: 14px 22px calc(18px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--hairline); background: rgba(255,255,255,.7);
  backdrop-filter: blur(8px);
}
.tabbar a { text-decoration: none; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.tabbar .ic { width: 40px; height: 40px; border-radius: var(--r-chip); display: flex; align-items: center; justify-content: center; color: var(--muted); }
.tabbar .ic svg { width: 22px; height: 22px; }
.tabbar span { font-size: 11px; font-weight: 500; color: var(--muted); }
.tabbar a.active .ic { background: var(--green-bg); color: var(--green-accent); }
.tabbar a.active span { font-weight: 600; color: var(--ink); }
.tabbar a:nth-child(2).active .ic { background: var(--amber-bg); color: var(--amber-accent); }
.tabbar a:nth-child(3).active .ic { background: var(--purple-bg); color: var(--purple-accent); }
.tabbar a:nth-child(4).active .ic { background: var(--blue-bg); color: var(--blue-accent); }

/* ---------- Form fields ---------- */
.field {
  width: 100%; border: 1.5px solid var(--field-border); background: var(--field-bg);
  border-radius: var(--r-btn); padding: 14px 16px; font-family: var(--font);
  font-size: 15px; color: var(--ink); resize: none;
}
.field:focus { outline: none; border-color: var(--blue-accent); background: var(--white); }
textarea.field { min-height: 120px; }

/* selectable option rows */
.option {
  width: 100%; display: flex; align-items: center; gap: 12px; cursor: pointer;
  border: 1.5px solid var(--field-border); background: var(--white);
  border-radius: var(--r-btn); padding: 15px 16px; font-size: 15px; color: var(--ink); font-weight: 600;
  text-align: left;
}
.option .tick { margin-left: auto; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--field-border); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.option.selected { border-color: var(--blue-accent); background: var(--blue-bg); }
.option.selected .tick { background: var(--blue-accent); border-color: var(--blue-accent); color: #fff; }
.option .tick svg { width: 14px; height: 14px; display: none; }   /* empty circle until selected */
.option.selected .tick svg { display: block; }

/* help link / chip */
.help-link { background: none; border: none; color: var(--blue-accent); font-weight: 600; font-size: 13px; cursor: pointer; font-family: var(--font); display: inline-flex; gap: 6px; align-items: center; padding: 0; }

/* spacer pushes footer content down */
.grow { flex: 1 1 auto; }

/* ---------- Help bottom sheet ---------- */
.sheet-scrim {
  position: absolute; inset: 0; background: rgba(20,34,46,.38);
  display: none; align-items: flex-end; z-index: 20;
}
.sheet-scrim.open { display: flex; }
.sheet {
  width: 100%; background: var(--white); border-radius: 24px 24px 0 0; padding: 22px 22px calc(28px + env(safe-area-inset-bottom,0px));
  box-shadow: 0 -10px 40px -12px rgba(20,34,46,.4);
  transform: translateY(100%); transition: transform .28s cubic-bezier(.22,.61,.36,1);
  display: flex; flex-direction: column; gap: 14px;
}
.sheet-scrim.open .sheet { transform: translateY(0); }
.sheet .grip { width: 40px; height: 4px; border-radius: 2px; background: #d8e0e6; align-self: center; }

/* generic modal/alert dialog */
/* validation alerts / confirm modals = frosted-glass overlay (design system) */
.dialog-scrim { position: absolute; inset: 0; background: rgba(255,255,255,0.32); backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px); display: none; align-items: center; justify-content: center; padding: 28px; z-index: 30; }
.dialog-scrim.open { display: flex; }
.dialog { width: 100%; background: var(--white); border: 2px solid #2f7e6e; border-radius: 20px; padding: 20px 18px 16px; display: flex; flex-direction: column; gap: 12px; text-align: center; box-shadow: 0 18px 50px -16px rgba(20,40,30,.42); }
.dialog .ag-icon { width: 40px; height: 40px; border-radius: 20px; background: #fbe8d4; color: var(--amber-accent); display: inline-flex; align-items: center; justify-content: center; align-self: center; }
.dialog .ag-icon svg { width: 20px; height: 20px; }
.dialog .ag-msg { font-size: 13.5px; font-weight: 600; color: var(--ink); margin: 0; }
.dialog .btn.ag-ok { background: #e1f5ee; border: 1.5px solid #2f7e6e; color: #216657; }

/* faces / rating row */
.faces { display: flex; justify-content: space-between; gap: 8px; }
.face { flex: 1 1 0; aspect-ratio: 1; border-radius: 16px; border: 1.5px solid var(--field-border); background: var(--white); display: flex; align-items: center; justify-content: center; font-size: 26px; cursor: pointer; }
.face.selected { border-color: var(--amber-accent); background: var(--amber-bg); transform: scale(1.04); }

/* numeric stepper */
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.stepper button { width: 56px; height: 56px; border-radius: 18px; border: 1.5px solid var(--field-border); background: var(--white); font-size: 26px; color: var(--ink); cursor: pointer; }
.stepper .val { font-size: 40px; font-weight: 800; color: var(--ink); }

/* range / VAS */
input[type=range] { width: 100%; accent-color: var(--blue-accent); outline: none; }
input[type=range]:focus, input[type=range]:focus-visible { outline: none; }

/* graded "tap the scale to choose" slider — frequency / severity / degree questions.
   Accent defaults to teal (Section 1); override --scale-accent per screen if needed. */
.scale-slider { --scale-accent: var(--teal); position: relative; width: 100%; height: 30px; display: flex; align-items: center; }
.scale-slider .track { position: absolute; left: 9px; right: 9px; height: 4px; border-radius: 2px; background: #e2e8ee; display: flex; align-items: center; justify-content: space-between; }
.scale-slider .track .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #4f80c8 0%, #ffffff 50%, #e58a2c 100%); background-repeat: no-repeat; border-radius: 2px; pointer-events: none; }
.scale-slider .track span { position: relative; width: 5px; height: 5px; border-radius: 50%; background: #c4cfd9; }
.scale-slider input[type=range] { position: relative; width: 100%; height: 30px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; z-index: 2; cursor: pointer; }
.scale-slider input[type=range]::-webkit-slider-runnable-track { height: 30px; background: transparent; }
.scale-slider input[type=range]::-moz-range-track { height: 30px; background: transparent; }
.scale-slider input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; margin-top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 2.5px solid #4a5760; box-shadow: 0 1px 4px rgba(20,40,30,.2); cursor: pointer; }
.scale-slider input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 2.5px solid #4a5760; box-shadow: 0 1px 4px rgba(20,40,30,.2); cursor: pointer; }

/* segmented severity */
.scale { display: flex; gap: 8px; }
.scale .step { flex: 1 1 0; height: 46px; border-radius: 12px; border: 1.5px solid var(--field-border); background: var(--white); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); cursor: pointer; }
.scale .step.selected { color: #fff; }

/* list rows (settings) */
.list { display: flex; flex-direction: column; background: var(--white); border: 1.5px solid var(--hairline); border-radius: var(--r-card); overflow: hidden; }
.list a, .list .li { display: flex; align-items: center; gap: 14px; padding: 16px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--hairline); font-size: 15px; }
.list a:last-child, .list .li:last-child { border-bottom: none; }
.list .li .grow { font-weight: 600; }
.list .chev { color: var(--muted); }

/* ---------- Survey section accents ----------
   §1 Pain & physical = teal · §2 Quality of life = steel-blue
   §3 = lavender · §4 = amber.  Used on buttons, progress, "Saved" chip. */
:root { --teal:#2f7e6e; --steel:#4e6f9d; --lav:#6b62c9; }
.btn.teal  { background: var(--teal); }
.btn.steel { background: var(--steel); }
.btn.lav   { background: var(--lav); }
.progress.teal  .seg { background:#cfe7e0; } .progress.teal  .seg.on { background: var(--teal); }
.progress.steel .seg { background:#d2dded; } .progress.steel .seg.on { background: var(--steel); }
.progress.lav   .seg { background:#ddd9f4; } .progress.lav   .seg.on { background: var(--lav); }
.chip { display:inline-flex; align-items:center; gap:5px; font-size:13px; font-weight:600; padding:6px 12px; border-radius:var(--r-pill); }
.chip.saved { background: var(--green-bg); color: var(--green-accent); }
.badge { display:inline-flex; align-items:center; gap:6px; font-size:12px; font-weight:700; letter-spacing:.4px; padding:6px 12px; border-radius:var(--r-pill); text-transform:uppercase; }
.badge.teal  { background:#d8ece6; color:var(--teal); }
.badge.steel { background:#dde7f3; color:var(--steel); }
.badge.lav   { background:#e7e3f7; color:var(--lav); }
.badge.amber { background:var(--amber-bg); color:var(--amber-accent); }

/* footer button row (Back / Next) sits at bottom of flow screens */
.footer-actions { display:flex; gap:12px; padding-top:6px; }
.footer-actions .btn { flex:1 1 0; }   /* Back and Next share width equally (matches Figma) */

/* ---------- Shared swipeable symptom carousel (rendered into [data-symptom-carousel]) ---------- */
.symcar { display:flex; flex-direction:column; gap:8px; }
.symcar .scar { display:flex; flex:0 0 auto; width:100%; overflow-x:auto; scroll-snap-type:x mandatory; scrollbar-width:none; -webkit-overflow-scrolling:touch; }
.symcar .scar::-webkit-scrollbar { display:none; }
.symcar .sslide { flex:0 0 100%; scroll-snap-align:center; display:flex; flex-direction:column; gap:8px; cursor:pointer; }
.symcar .stitle { font-size:12.5px; color:var(--muted); margin:0; }
.symcar .scard { background:var(--white); border:1.5px solid #dbe0e5; border-radius:18px; padding:14px 10px 12px; display:flex; flex-direction:column; gap:8px; align-items:center; }
.symcar .scard svg { width:100%; height:84px; }
.symcar .sdays { display:flex; justify-content:space-between; width:100%; font-size:10.5px; color:var(--muted); font-weight:500; }
.symcar .smeta { display:flex; align-items:baseline; justify-content:space-between; width:100%; }
.symcar .smeta .v { font-size:20px; font-weight:800; color:var(--ink); }
.symcar .smeta .sev { font-size:13.5px; font-weight:500; margin-left:6px; }
.symcar .smeta .rng { font-size:12px; color:var(--muted); }
.symcar .sdots { display:flex; gap:6px; justify-content:center; }
.symcar .sdots span { width:7px; height:7px; border-radius:50%; background:#cdd5db; }
.symcar .sdots span.on { width:8px; height:8px; background:var(--blue-accent); }
.symcar .snote { font-size:11.5px; color:#66737a; text-align:center; }

/* pill toggle */
.toggle { width: 46px; height: 28px; border-radius: 999px; background: #cfd8de; position: relative; cursor: pointer; flex: 0 0 auto; }
.toggle::after { content:""; position:absolute; top:3px; left:3px; width:22px; height:22px; border-radius:50%; background:#fff; transition:.2s; }
.toggle.on { background: var(--green-accent); }
.toggle.on::after { left: 21px; }
