/* Hafez OS — demo styles. RTL, mobile first. */
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap");

:root {
  --navy: #0f1b34;
  --navy-2: #1b2a4a;
  --ink: #14203a;
  --muted: #5d6779;
  --paper: #f4f2ec;
  --surface: #ffffff;
  --line: #e5e0d5;
  --gold: #d99b3d;
  --gold-soft: #fbf1de;
  --green: #0f6b57;
  --red: #b02a22;
  --red-deep: #7d1c16;
  --orange: #b8541b;
  --orange-deep: #8a3d10;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 12px 28px -18px rgba(16, 24, 40, .35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: #e9e6de;
  color: var(--ink);
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; justify-content: center; min-height: 100dvh; }

.app {
  position: relative;
  width: 100%;
  max-width: 460px;
  min-height: 100dvh;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  box-shadow: 0 0 0 1px rgba(16,24,40,.06);
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px 10px;
  background: linear-gradient(180deg, var(--paper) 72%, rgba(244,242,236,0));
}
.topbar.plain { background: var(--paper); border-bottom: 1px solid var(--line); }

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  letter-spacing: -.2px;
  color: var(--navy);
}
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--navy);
  display: grid; place-items: center;
  color: #f6e7c6; font-size: 13px; font-weight: 700;
}
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0; }

.spacer { flex: 1; }

.iconbtn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  width: 38px; height: 38px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 16px;
  cursor: pointer;
  font-family: inherit;
}
.iconbtn:active { transform: scale(.96); }

/* ---------- generic screen ---------- */
.screen { padding: 4px 18px 32px; flex: 1; display: flex; flex-direction: column; }
.screen.center { justify-content: center; }

h1 { font-size: 26px; line-height: 1.35; margin: 8px 0 6px; letter-spacing: -.4px; font-weight: 700; }
h2 { font-size: 19px; margin: 0 0 8px; font-weight: 600; }
p { margin: 0 0 12px; }
.lead { color: var(--muted); font-size: 15px; }
.muted { color: var(--muted); }
.tiny { font-size: 12.5px; }

/* ---------- home ---------- */
.hero { padding: 18px 0 6px; }
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--green);
  background: #e6efe9; border-radius: 999px; padding: 4px 11px; margin-bottom: 12px;
}
.hero h1 { font-size: 30px; }
.hero p { color: var(--muted); font-size: 15px; }

.pick { display: grid; gap: 12px; margin-top: 18px; }
.pick button {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  text-align: right;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.pick button:active { transform: scale(.985); border-color: var(--navy); }
.pick .ico {
  width: 46px; height: 46px; flex: none;
  border-radius: 14px;
  background: var(--navy);
  display: grid; place-items: center;
}
.pick .ico svg { width: 26px; height: 26px; stroke: #f4e6c8; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.pick .meta { flex: 1; }
.pick .meta span { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.pick .chev { color: #b9b2a3; font-size: 18px; }

.footnote {
  margin-top: auto;
  padding-top: 22px;
  font-size: 12px;
  color: #8b8477;
  text-align: center;
}

/* ---------- intake ---------- */
.progress {
  display: flex; gap: 4px; padding: 6px 18px 0;
}
.progress i {
  height: 4px; flex: 1; border-radius: 99px; background: #ded9cc;
  transition: background .25s ease;
}
.progress i.done { background: var(--navy); }
.progress i.now { background: var(--gold); }

.qmeta {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; color: var(--muted); font-weight: 600;
  padding: 16px 0 4px;
}
.qmeta .tag {
  background: #eae5d9; color: #6b6455; border-radius: 999px; padding: 3px 10px; font-weight: 600;
}
.question { font-size: 23px; line-height: 1.45; font-weight: 600; letter-spacing: -.3px; margin: 6px 0 22px; }

.options { display: grid; gap: 10px; }
.options button {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 15px 16px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  font-family: inherit; font-size: 16px; font-weight: 500;
  color: var(--ink); text-align: right; cursor: pointer;
  line-height: 1.5;
  transition: border-color .12s, background .12s, transform .1s;
}
.options button:active { transform: scale(.99); }
.options button .dot {
  width: 20px; height: 20px; flex: none; border-radius: 50%;
  border: 1.5px solid #cbc4b4;
}
.options button.on { border-color: var(--navy); background: #eef1f7; }
.options button.on .dot { border-color: var(--navy); background: var(--navy); box-shadow: inset 0 0 0 3px #eef1f7; }

.scale { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.scale button {
  aspect-ratio: 1; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--surface); font-family: inherit; font-size: 17px; font-weight: 600;
  color: var(--ink); cursor: pointer;
}
.scale button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.scale-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 10px; }

/* ---------- free text ---------- */
textarea {
  width: 100%; min-height: 150px; resize: vertical;
  border: 1.5px solid var(--line); border-radius: 16px;
  padding: 14px; font-family: inherit; font-size: 16px; line-height: 1.6;
  background: var(--surface); color: var(--ink);
}
textarea:focus { outline: none; border-color: var(--navy); }
.counter { text-align: left; font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- buttons ---------- */
.btn {
  display: block; width: 100%; padding: 16px;
  border-radius: 16px; border: 1.5px solid transparent;
  font-family: inherit; font-size: 17px; font-weight: 600;
  cursor: pointer; text-align: center;
}
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:active { transform: scale(.99); }
.btn.secondary { background: transparent; border-color: #cfc9bb; color: var(--ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); font-weight: 500; font-size: 14px; }
.btn-row { display: grid; gap: 10px; margin-top: 22px; }

/* ---------- risk screens ---------- */
.screen.risk { padding: 0; }
.risk .top { padding: 26px 20px 22px; color: #fff; }
.risk.red .top { background: linear-gradient(160deg, #b02a22, #7d1c16); }
.risk.orange .top { background: linear-gradient(160deg, #b8541b, #8a3d10); }
.risk .stoptag {
  display: inline-block; background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.35);
  color: #fff; border-radius: 999px; padding: 5px 12px;
  font-size: 12.5px; font-weight: 600; margin-bottom: 12px;
}
.risk h1 { color: #fff; font-size: 30px; margin: 0 0 4px; }
.risk .sub { color: rgba(255,255,255,.9); font-size: 15px; margin: 0; }
.risk .body { padding: 20px; }
.risk .body p { font-size: 15.5px; line-height: 1.75; }
.risk .body a { color: var(--red); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.risk.orange .body a { color: var(--orange); }
.risk .body .btn.primary { background: var(--red); }
.risk.orange .body .btn.primary { background: var(--orange); }
.risk .note {
  background: #fdf3e7; border: 1px solid #f0dcc0; color: #7a5a2a;
  border-radius: 14px; padding: 12px 14px; font-size: 13px; margin-top: 4px;
}

/* ---------- result ---------- */
.result-head { padding: 18px 0 4px; }
.result-head .badge {
  display: inline-flex; align-items: center; gap: 7px;
  background: #e6efe9; color: var(--green);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 600;
}
.result-head .badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.result-sub { color: var(--muted); font-size: 15px; margin-top: 10px; }
.result-body { margin-top: 16px; }
.result-body p { font-size: 15px; line-height: 1.8; }
.result-body .strong { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; font-size: 15px; }

/* ---------- program ---------- */
.prog-head { padding: 16px 0 8px; }
.prog-head .count { color: var(--muted); font-size: 14px; }

.warn {
  background: #fdf3e7; border: 1px solid #efd9b6;
  border-right: 4px solid var(--gold);
  border-radius: 14px; padding: 14px 16px; margin: 14px 0;
  font-size: 14px; line-height: 1.75; color: #6d5122;
}
.warn b { display: block; margin-bottom: 4px; color: #8a5f16; font-size: 13px; }

.ex {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}
.ex .card-img { display: block; width: 100%; background: #0f1b34; }
.ex .card-img img { display: block; width: 100%; height: auto; }
.ex .body { padding: 15px 16px 17px; }
.ex .row { display: flex; align-items: flex-start; gap: 10px; }
.ex .num {
  width: 26px; height: 26px; flex: none; border-radius: 8px;
  background: #eef1f7; color: var(--navy);
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  margin-top: 2px;
}
.ex h3 { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.45; }
.ex .en {
  direction: ltr; text-align: right; font-size: 12px; color: #98a0af;
  font-weight: 500; margin: 1px 0 0;
}
.ex .chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 11px 0 10px; }
.chip {
  font-size: 12.5px; font-weight: 600; border-radius: 999px; padding: 4px 11px;
  background: #f1eee6; color: #6c6555;
}
.chip.dose { background: var(--navy); color: #f6e9cb; }
.ex .instr { font-size: 14.5px; line-height: 1.8; color: #33405a; margin: 0; }
.ex .noimg {
  padding: 22px 16px; background: #0f1b34; color: #cdd4e2;
  font-size: 13px; text-align: center;
}

/* ---------- therapist ---------- */
.th-head { background: var(--navy); color: #fff; border-radius: var(--radius); padding: 18px; margin: 14px 0 16px; }
.th-head .k { font-size: 12px; color: #a9b4c9; font-weight: 600; letter-spacing: .3px; }
.th-head h1 { color: #fff; font-size: 21px; margin: 4px 0 10px; }
.th-head .facts { display: flex; flex-wrap: wrap; gap: 8px; }
.th-head .facts span {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px; padding: 4px 11px; font-size: 12px;
}

.alertcard {
  border: 1.5px solid #eccfc9; background: #fdf4f2;
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.alertcard.orange { border-color: #f0d9c1; background: #fdf7ef; }
.alertcard.yellow { border-color: #ece1bf; background: #fdfaef; }
.alertcard .t { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.alertcard .lvl {
  display: inline-block; font-size: 12px; font-weight: 700; border-radius: 999px;
  padding: 3px 10px; background: var(--red); color: #fff; margin-bottom: 10px;
}
.alertcard.orange .lvl { background: var(--orange); }
.alertcard.yellow .lvl { background: var(--gold); color: #3c2c08; }
.alertcard dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; font-size: 13.5px; }
.alertcard dt { color: #7b6a63; font-weight: 600; white-space: nowrap; }
.alertcard dd { margin: 0; }

.block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.block h2 { font-size: 15px; margin: 0 0 10px; color: var(--navy); }
.block .quote {
  background: #f7f4ec; border-radius: 12px; padding: 12px 14px; font-size: 14.5px; line-height: 1.75;
}
.answers { display: grid; gap: 0; }
.answers .qa { padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.answers .qa:last-child { border-bottom: 0; }
.answers .qa .q { color: #4a5568; }
.answers .qa .a { font-weight: 600; margin-top: 2px; }
.answers .qa .a.flag-red { color: var(--red); }
.answers .qa .a.flag-orange { color: var(--orange); }
.answers .qa .a.flag-yellow { color: #9a7415; }
.answers .code { font-size: 11px; color: #9aa2b1; direction: ltr; display: inline-block; margin-inline-start: 6px; }

.th-list { display: grid; gap: 8px; }
.th-list .item { display: flex; gap: 10px; align-items: center; font-size: 14px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.th-list .item:last-child { border-bottom: 0; }
.th-list .code { direction: ltr; font-size: 11.5px; color: #9aa2b1; }

.demobar {
  margin-top: auto; padding: 18px 0 8px;
  font-size: 11.5px; color: #8b8477; text-align: center; line-height: 1.7;
}

.toast {
  position: fixed; bottom: 22px; right: 50%; transform: translateX(50%) translateY(20px);
  background: #1b2a4a; color: #fff; font-size: 13.5px; padding: 11px 18px;
  border-radius: 999px; opacity: 0; transition: all .25s ease; z-index: 60;
  max-width: 88vw; text-align: center; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(50%) translateY(0); }

.fade { animation: fade .28s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.pform{display:flex;flex-direction:column;gap:12px;margin:8px 0 16px}
.pform label,.pform .lbl{font-size:14px;font-weight:600;color:#0f1b34;display:flex;flex-direction:column;gap:6px}
.pform input{font:inherit;font-size:16px;padding:12px 14px;border:1px solid #d9dfeb;border-radius:12px;background:#fff;direction:rtl}
.sleeps{display:flex;gap:8px;flex-wrap:wrap}
.sleeps button{font:inherit;padding:10px 14px;border-radius:999px;border:1px solid #d9dfeb;background:#fff}
.sleeps button.on{background:#0f1b34;color:#fff;border-color:#0f1b34}
.advice{background:#fff;border:1px solid #e3e8f2;border-radius:16px;padding:14px 16px;margin:14px 0}
.advice h2{font-size:16px;margin:0 0 8px}
.advice ul{margin:0;padding:0 18px 0 0;line-height:1.8;font-size:15px}
.advice .draft{margin-top:10px;font-size:12px;color:#8a5a00;background:#fff4d6;border-radius:8px;padding:6px 10px;display:inline-block}

.chk{display:flex;gap:12px;align-items:flex-start;background:#fff;border:1px solid #d9dfeb;border-radius:14px;padding:14px;margin:10px 0;font-size:15px;line-height:1.6}
.chk input{width:22px;height:22px;flex:none;margin-top:2px}
.draft.top{display:inline-block;font-size:12px;color:#8a5a00;background:#fff4d6;border-radius:8px;padding:6px 10px;margin-bottom:6px}
.btn:disabled{opacity:.4}
.devjson{direction:ltr;text-align:left;font-size:11px;background:#f4f6fb;border-radius:10px;padding:10px;overflow:auto;max-height:220px;white-space:pre-wrap;margin:0}
