/* بطاقتي الطبية — styles
   Paper, ink, and one signal colour. Type: IBM Plex Sans Arabic + IBM Plex Mono. */

/* ───────── fonts ───────── */
@font-face { font-family: "Plex"; font-weight: 400; font-display: swap; src: url("fonts/plex-arabic-400.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200F, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Plex"; font-weight: 500; font-display: swap; src: url("fonts/plex-arabic-500.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200F, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Plex"; font-weight: 600; font-display: swap; src: url("fonts/plex-arabic-600.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200F, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Plex"; font-weight: 700; font-display: swap; src: url("fonts/plex-arabic-700.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200F, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Plex"; font-weight: 400; font-display: swap; src: url("fonts/plex-latin-400.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: "Plex"; font-weight: 500; font-display: swap; src: url("fonts/plex-latin-500.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: "Plex"; font-weight: 600; font-display: swap; src: url("fonts/plex-latin-600.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: "Plex"; font-weight: 700; font-display: swap; src: url("fonts/plex-latin-700.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: "Plex Mono"; font-weight: 500; font-display: swap; src: url("fonts/plex-mono-500.woff2") format("woff2"); unicode-range: U+0020-007E, U+00A0-00FF, U+2212; }
@font-face { font-family: "Plex Mono"; font-weight: 600; font-display: swap; src: url("fonts/plex-mono-600.woff2") format("woff2"); unicode-range: U+0020-007E, U+00A0-00FF, U+2212; }

/* ───────── tokens ───────── */
:root {
  --paper: #F3F1EA;
  --paper-2: #E9E6DB;
  --surface: #FFFFFF;
  --ink: #161D1A;
  --ink-2: #454F4A;
  --ink-3: #78827C;
  --line: #D8D4C7;
  --line-2: #E5E2D8;
  --red: #D13A1E;
  --red-ink: #A82A12;
  --green: #0C5F4C;
  --green-bright: #2BB592;
  --amber: #C27A08;

  --sans: "Plex", system-ui, "Segoe UI", Tahoma, sans-serif;
  --mono: "Plex Mono", "Plex", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(.2, .75, .2, 1);
  --r: 12px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.7 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
h1, h2, p, ol, ul { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--ink); color: var(--paper); }

.mono { font-family: var(--mono); font-weight: 500; letter-spacing: .1em; }
.ltr { direction: ltr; text-align: right; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ───────── header ───────── */
.top {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: 68px;
  padding-inline: clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.3) blur(12px);
  backdrop-filter: saturate(1.3) blur(12px);
  border-bottom: 1px solid var(--line-2);
}
.brand { justify-self: start; display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.0625rem; }
.mark { width: 28px; height: 28px; }
.mark rect { fill: var(--red); }
.mark path { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.tabs { position: relative; display: flex; padding: 4px; background: var(--paper-2); border-radius: 999px; }
.tabs a { position: relative; z-index: 1; padding: 7px 20px; border-radius: 999px; font-weight: 500; font-size: .9375rem; color: var(--ink-2); transition: color .25s; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--ink); }
.tabs-pill {
  position: absolute; top: 4px; bottom: 4px; left: 0; width: 0;
  background: var(--surface); border-radius: 999px;
  box-shadow: 0 1px 2px rgba(22, 29, 26, .14);
  transition: transform .38s var(--ease), width .38s var(--ease);
}
.tabs-pill.still { transition: none; }

.chip { justify-self: end; display: inline-flex; align-items: center; gap: 8px; padding: 6px 13px; border: 1px solid var(--line); border-radius: 999px; font-size: .8125rem; color: var(--ink-2); transition: background .2s; }
.chip:hover { background: var(--surface); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.chip[data-state="on"] .dot { background: var(--green-bright); }
.chip[data-state="pending"] .dot { background: var(--amber); animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* ───────── page frame ───────── */
main { width: 100%; max-width: 1200px; margin-inline: auto; padding: clamp(28px, 5vw, 68px) clamp(16px, 4vw, 40px) 72px; flex: 1; }
.view { animation: view-in .45s var(--ease) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(12px); } }

.eyebrow { display: flex; align-items: center; gap: 12px; font-size: .875rem; font-weight: 500; color: var(--ink-3); margin-bottom: 18px; }
.eyebrow .mono { color: var(--red); font-size: .75rem; letter-spacing: .16em; }
.eyebrow .mono::after { content: ""; display: inline-block; width: 28px; height: 1px; background: var(--line); vertical-align: middle; margin-inline-start: 12px; }
h1 { font-size: clamp(2.2rem, 1.3rem + 3.6vw, 3.75rem); font-weight: 700; line-height: 1.24; text-wrap: balance; }
.lede { margin-top: 20px; max-width: 34rem; font-size: 1.125rem; line-height: 1.85; color: var(--ink-2); text-wrap: pretty; }
.hero-wide { margin-bottom: clamp(28px, 4vw, 44px); }

.foot { display: flex; justify-content: space-between; gap: 16px; padding: 20px clamp(16px, 4vw, 40px); border-top: 1px solid var(--line-2); font-size: .8125rem; color: var(--ink-3); }
.foot .mono { letter-spacing: .08em; }
.fine { font-size: .8125rem; line-height: 1.7; color: var(--ink-3); }

/* ───────── buttons & fields ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: var(--r);
  font-weight: 600; font-size: .9375rem; white-space: nowrap;
  transition: transform .12s, background .2s, border-color .2s, color .2s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: #000; }
.btn-ghost { border: 1px solid var(--line); background: transparent; }
.btn-ghost:hover { background: var(--surface); border-color: var(--ink-3); }
.btn-danger { border: 1px solid var(--line); color: var(--red-ink); }
.btn-danger:hover { background: var(--surface); border-color: var(--red); }
.btn-danger-solid { background: var(--red); color: #fff; }
.btn-danger-solid:hover { background: var(--red-ink); }
.btn-small { min-height: 38px; padding: 0 14px 0 12px; border: 1px solid var(--ink); border-radius: 999px; font-size: .875rem; gap: 4px; }
.btn-small:hover { background: var(--ink); color: var(--paper); }
.btn-small .ic { width: 16px; height: 16px; stroke-width: 2.2; }
.link { display: inline-flex; align-items: center; gap: 4px; font-size: .875rem; font-weight: 500; color: var(--ink-2); padding: 6px 0; justify-self: start; }
.link:hover { color: var(--ink); }
.link .ic { width: 16px; height: 16px; }

.field { display: grid; gap: 7px; }
.field label, .label { font-size: .875rem; font-weight: 500; color: var(--ink-2); }
.opt { font-weight: 400; color: var(--ink-3); margin-inline-start: 6px; }
.input {
  width: 100%; min-height: 50px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none; appearance: none;
}
textarea.input { padding-block: 12px; min-height: 84px; resize: vertical; line-height: 1.7; }
.input::placeholder { color: #A9AFA9; }
.input:hover { border-color: var(--ink-3); }
.input:focus { outline: 0; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(22, 29, 26, .1); }
input[type="date"].input, input[type="time"].input { font-family: var(--mono); font-size: .9375rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.err { font-size: .875rem; color: var(--red-ink); }

/* ───────── card view ───────── */
.card-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 468px);
  grid-template-areas: "hero card" "form card";
  column-gap: clamp(40px, 6vw, 88px);
  align-items: start;
}
.card-layout > .hero { grid-area: hero; }
.card-col { grid-area: card; position: sticky; top: 100px; }
.profile { grid-area: form; }

.sec { display: grid; gap: 18px; margin-top: 40px; padding-top: 28px; border-top: 1px solid var(--line); }
.sec h2 { display: flex; align-items: baseline; gap: 14px; font-size: 1.25rem; font-weight: 600; margin-bottom: 2px; }
.num { color: var(--red); font-size: .75rem; letter-spacing: .14em; flex: none; }

.blood { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pick { position: relative; cursor: pointer; }
.pick input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.pick span {
  display: grid; place-items: center; height: 50px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  font: 500 1.0625rem var(--mono); direction: ltr;
  transition: background .18s, color .18s, border-color .18s, transform .12s;
}
.pick:hover span { border-color: var(--ink-3); }
.pick:active span { transform: scale(.96); }
.pick input:checked + span { background: var(--red); border-color: var(--red); color: #fff; }
.pick input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.pick-wide { grid-column: 1 / -1; }
.pick-wide span { height: 42px; font: 500 .875rem var(--sans); direction: rtl; background: transparent; }
.pick-wide input:checked + span { background: var(--ink); border-color: var(--ink); }

.switch { display: flex; align-items: center; gap: 12px; font-size: .9375rem; cursor: pointer; width: fit-content; position: relative; }
.switch input { position: absolute; opacity: 0; }
.switch-ui { width: 42px; height: 24px; border-radius: 999px; background: var(--line); position: relative; flex: none; transition: background .2s; }
.switch-ui::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .25s var(--ease); }
.switch input:checked + .switch-ui { background: var(--green); }
.switch input:checked + .switch-ui::after { transform: translateX(-18px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--ink); outline-offset: 2px; }

.saved { display: flex; align-items: flex-start; gap: 8px; margin-top: 32px; font-size: .875rem; color: var(--ink-3); }
.saved .ic { width: 18px; height: 18px; margin-top: 3px; color: var(--green); }
.saved.pulse .ic { animation: pop .5s var(--ease); }
@keyframes pop { 40% { transform: scale(1.5); } }

/* stage */
.stage {
  position: relative; padding: 44px 30px 14px; border-radius: 28px;
  border: 1px solid var(--line);
  background-color: var(--paper-2);
  background-image: radial-gradient(rgba(22, 29, 26, .16) 1px, transparent 1.3px);
  background-size: 16px 16px;
}
.flip { container-type: inline-size; perspective: 1400px; cursor: pointer; outline: 0; -webkit-tap-highlight-color: transparent; }
.flip-inner {
  position: relative; aspect-ratio: 85.6 / 54;
  transform-style: preserve-3d;
  transform: rotateX(var(--rx, 0deg)) rotateY(calc(var(--ry, 0deg) + var(--turn, 0deg)));
  transition: transform .7s var(--ease);
}
.flip[aria-pressed="true"] .flip-inner { --turn: 180deg; }
.flip.tilting .flip-inner { transition: transform .12s linear; }
.flip:focus-visible .flip-inner { outline: 2px solid var(--ink); outline-offset: 6px; border-radius: 4.2cqi; }
.face {
  position: absolute; inset: 0; border-radius: 4.2cqi;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
  box-shadow: 0 1px 1px rgba(22, 29, 26, .1), 0 12px 22px -10px rgba(22, 29, 26, .28), 0 36px 56px -28px rgba(22, 29, 26, .42);
}
.face-back { transform: rotateY(180deg); }
.face::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 0%), rgba(255, 255, 255, .5), transparent 58%);
  opacity: 0; transition: opacity .3s;
}
.flip.tilting .face::after { opacity: 1; }

.flip-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 22px; padding: 8px; font-size: .8125rem; font-weight: 500; color: var(--ink-2); border-radius: 10px; }
.flip-btn:hover { color: var(--ink); }
.flip-btn .ic { width: 16px; height: 16px; transition: transform .6s var(--ease); }
.flip-btn:hover .ic { transform: rotate(-180deg); }
.stage-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.card-col .fine { margin-top: 14px; }
.card-col .fine.warn { color: var(--red-ink); }

/* ───────── the card itself (sized in cqi so it scales from screen to print) ───────── */
.cq { container-type: inline-size; }
.mc {
  height: 100%; display: flex; flex-direction: column; overflow: hidden;
  background: #fff; color: #161D1A; border-radius: 4.2cqi;
  font: 500 3.3cqi/1.3 var(--sans);
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.mc i { font-style: normal; }
.mc-band { flex: none; height: 10.5cqi; padding-inline: 4.6cqi; background: var(--red); color: #fff; display: flex; align-items: center; justify-content: space-between; }
.mc-band b { font-size: 3.5cqi; font-weight: 600; }
.mc-band i { font: 500 2.2cqi var(--mono); letter-spacing: .18em; }
.mc-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3.4cqi; padding: 3.1cqi 4.6cqi 0; overflow: hidden; }
.mc-fields { display: flex; flex-direction: column; gap: 1.6cqi; min-width: 0; }
.mc-l { display: flex; align-items: baseline; gap: 1.3cqi; font-size: 2.2cqi; font-weight: 400; color: #78827C; white-space: nowrap; line-height: 1.35; }
.mc-l i { font: 500 1.65cqi var(--mono); letter-spacing: .12em; }
.mc-v { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.mc-v.one { -webkit-line-clamp: 1; line-clamp: 1; }
.mc-v.three { -webkit-line-clamp: 3; line-clamp: 3; }
.mc-v.blank { color: #C2C6C0; font-weight: 400; }
.mc-name { font-size: 4.8cqi; font-weight: 700; line-height: 1.35; }
.mc-side { display: flex; flex-direction: column; gap: 2.2cqi; width: 19cqi; }
.mc-blood { border: .4cqi solid var(--red); border-radius: 2.6cqi; text-align: center; padding: 1.9cqi 0 1.5cqi; }
.mc-blood b { display: block; font: 600 8.6cqi/1 var(--mono); color: var(--red); direction: ltr; letter-spacing: -.02em; }
.mc-blood b.blank { color: #D9DCD6; }
.mc-blood span { display: block; margin-top: 1cqi; font-size: 1.9cqi; font-weight: 400; color: #78827C; }
.mc-dob { text-align: center; }
.mc-dob .mc-l { justify-content: center; }
.mc-dob b { font: 500 2.6cqi var(--mono); direction: ltr; display: block; }
.mc-foot { flex: none; margin-inline: 4.6cqi; padding: 1.8cqi 0 2.6cqi; border-top: .25cqi solid #E5E2D8; display: flex; align-items: flex-end; justify-content: space-between; gap: 3cqi; }
.mc-foot > div { min-width: 0; }
.mc-contact { font-size: 3.3cqi; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-phone { flex: none; font: 600 3.5cqi var(--mono); direction: ltr; letter-spacing: .02em; }

.mc-back { flex-direction: row; align-items: stretch; gap: 4.4cqi; padding: 4.6cqi 4.6cqi 4.2cqi 6.2cqi; position: relative; }
.mc-back::before { content: ""; position: absolute; inset-block: 0; inset-inline-end: 0; width: 1.8cqi; background: var(--red); }
.mc-qr { flex: none; width: 43cqi; align-self: center; aspect-ratio: 1; display: grid; place-items: center; }
.mc-qr svg { width: 100%; height: 100%; display: block; shape-rendering: crispEdges; }
.mc-qr-empty { width: 100%; height: 100%; border: .4cqi dashed #D8D4C7; border-radius: 2.6cqi; display: grid; place-items: center; text-align: center; padding: 4cqi; font-size: 2.5cqi; font-weight: 400; color: #78827C; line-height: 1.6; }
.mc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2.1cqi; }
.mc-scan { font-size: 3.2cqi; font-weight: 600; line-height: 1.4; }
.mc-scan i { display: block; margin-top: .7cqi; font: 500 1.9cqi var(--mono); letter-spacing: .06em; color: #78827C; }
.mc-site { margin-top: auto; font: 500 2.2cqi var(--mono); letter-spacing: .1em; color: var(--red); direction: ltr; text-align: right; }

/* ───────── reminders: mailbox ───────── */
.mailbox {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--ink); color: var(--paper);
  border-radius: 28px; padding: clamp(24px, 3.4vw, 36px);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px 22px; align-items: center;
}
.mailbox::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image: radial-gradient(rgba(243, 241, 234, .2) 1px, transparent 1.3px); background-size: 16px 16px;
  -webkit-mask-image: linear-gradient(to left, transparent 30%, #000 100%); mask-image: linear-gradient(to left, transparent 30%, #000 100%);
}
.mb-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: rgba(243, 241, 234, .08); border: 1px solid rgba(243, 241, 234, .16); position: relative; }
.mb-icon .ic { width: 26px; height: 26px; stroke-width: 2; }
.mailbox[data-state="on"] .mb-icon { background: var(--green-bright); border-color: var(--green-bright); color: var(--ink); }
.mailbox[data-state="on"] .mb-icon path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: draw .55s .15s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.mailbox[data-state="pending"] .mb-icon::before, .mailbox[data-state="pending"] .mb-icon::after {
  content: ""; position: absolute; inset: -1px; border-radius: 50%; border: 1px solid var(--amber); animation: ring 2s ease-out infinite;
}
.mailbox[data-state="pending"] .mb-icon::after { animation-delay: 1s; }
@keyframes ring { from { transform: scale(1); opacity: .9; } to { transform: scale(1.7); opacity: 0; } }
.mb-core { width: 10px; height: 10px; border-radius: 50%; background: var(--amber); }
.mb-text { min-width: 0; }
.mb-k { display: block; font: 500 .6875rem var(--mono); letter-spacing: .18em; color: #8E9A93; margin-bottom: 6px; }
.mailbox h2 { font-size: clamp(1.25rem, 1rem + 1vw, 1.625rem); font-weight: 600; line-height: 1.4; }
.mailbox p { color: #B4BEB8; font-size: .9375rem; margin-top: 4px; }
.mailbox bdi { color: var(--paper); font-weight: 500; }
.mb-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.mailbox .btn { min-height: 44px; padding: 0 16px; font-size: .875rem; }
.mb-btn { background: var(--paper); color: var(--ink); }
.mb-btn:hover { background: #fff; }
.mb-ghost { border: 1px solid rgba(243, 241, 234, .24); color: var(--paper); }
.mb-ghost:hover { background: rgba(243, 241, 234, .08); }
.mb-form { grid-column: 1 / -1; display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.mb-form .input { flex: 1 1 260px; min-height: 52px; background: rgba(243, 241, 234, .07); border-color: rgba(243, 241, 234, .22); color: #fff; font-family: var(--mono); font-size: .9375rem; }
.mb-form .input::placeholder { color: #7F8B84; }
.mb-form .input:hover { border-color: rgba(243, 241, 234, .45); }
.mb-form .input:focus { border-color: var(--paper); box-shadow: 0 0 0 3px rgba(243, 241, 234, .16); }
.mb-form .btn { min-height: 52px; padding: 0 22px; font-size: .9375rem; }
.mb-err { grid-column: 1 / -1; color: #FFB4A3 !important; font-size: .875rem !important; }
.mailbox :focus-visible { outline-color: var(--paper); }
.mailbox[data-state="none"] { grid-template-columns: minmax(0, 1fr); }

/* ───────── reminders: day rail ───────── */
.day { margin-top: 20px; padding: 22px clamp(18px, 3vw, 30px) 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 28px; }
.day-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 20px; }
.day-title { font-weight: 600; font-size: 1.0625rem; }
.day-date { color: var(--ink-3); font-size: .875rem; margin-inline-start: 10px; }
.day-next { font-size: .9375rem; color: var(--ink-2); }
.day-next b { color: var(--ink); font-weight: 600; }
.rail { position: relative; height: 78px; margin: 18px 8px 0; }
.rail-line { position: absolute; inset-inline: 0; top: 34px; height: 2px; border-radius: 2px; background: var(--line); }
.rail-done { position: absolute; inset-inline-start: 0; top: 34px; height: 2px; border-radius: 2px; background: var(--ink); }
.rail-tick { position: absolute; top: 29px; width: 1px; height: 12px; background: var(--line); }
.rail-tick.major { height: 16px; top: 27px; background: #BDB9AC; }
.rail-tick span { position: absolute; top: 24px; right: 0; transform: translateX(50%); font: 500 .6875rem var(--mono); color: var(--ink-3); white-space: nowrap; direction: rtl; }
.rail-now { position: absolute; top: 14px; width: 2px; height: 41px; margin-inline-start: -1px; background: var(--red); border-radius: 2px; z-index: 2; }
.rail-now::before { content: "الآن"; position: absolute; top: -20px; right: 50%; transform: translateX(50%); font-size: .6875rem; font-weight: 600; color: var(--red); white-space: nowrap; }
.rail-dot {
  position: absolute; top: 35px; width: 16px; height: 16px; margin-inline-start: -8px; margin-top: -8px;
  border-radius: 50%; background: var(--green); border: 3px solid var(--surface); box-shadow: 0 0 0 1.5px var(--green);
  z-index: 3; cursor: default; transition: transform .2s var(--ease);
  animation: dot-in .4s var(--ease) both;
}
@keyframes dot-in { from { transform: scale(0); } }
.rail-dot.past { background: var(--surface); box-shadow: 0 0 0 1.5px var(--ink-3); }
.rail-dot.appt { border-radius: 3px; transform: rotate(45deg); background: var(--ink); box-shadow: 0 0 0 1.5px var(--ink); animation: none; }
.rail-dot:hover, .rail-dot:focus-visible { transform: scale(1.25); outline: 0; }
.rail-dot.appt:hover, .rail-dot.appt:focus-visible { transform: rotate(45deg) scale(1.25); }
.rail-tip {
  position: absolute; bottom: calc(100% - 12px); z-index: 5; pointer-events: none;
  background: var(--ink); color: var(--paper); font-size: .75rem; font-weight: 500; line-height: 1.5;
  padding: 5px 10px; border-radius: 8px; white-space: nowrap; transform: translateX(50%) translateY(4px); opacity: 0; transition: opacity .15s, transform .15s;
}
.rail-tip.show { opacity: 1; transform: translateX(50%); }

/* ───────── reminders: lists ───────── */
.lists { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(28px, 4vw, 56px); margin-top: 44px; align-items: start; }
.list { border-top: 2px solid var(--ink); padding-top: 16px; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.list-head h2 { font-size: 1.375rem; font-weight: 700; }
.list-fine { margin-top: 14px; }

.adder { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .34s var(--ease); }
.adder[data-open="true"] { grid-template-rows: 1fr; }
.adder > div { overflow: hidden; min-height: 0; }
.adder-in { display: grid; gap: 14px; margin-top: 16px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.adder-actions { display: flex; gap: 8px; }
.time-list { display: flex; flex-wrap: wrap; gap: 8px; }
.time-item { display: flex; align-items: center; gap: 2px; }
.time-item .input { width: 136px; }
.icon-btn { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 10px; color: var(--ink-3); transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.icon-btn.danger:hover { color: var(--red-ink); }
.icon-btn .ic { width: 18px; height: 18px; }

.rows { list-style: none; padding: 0; margin-top: 8px; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 6px 12px; padding: 16px 0; border-bottom: 1px solid var(--line); animation: row-in .4s var(--ease) both; }
@keyframes row-in { from { opacity: 0; transform: translateY(-6px); } }
.row.appt { grid-template-columns: auto minmax(0, 1fr) auto auto; }
.row.done { opacity: .5; }
.row-title { font-weight: 600; font-size: 1.0625rem; line-height: 1.5; overflow-wrap: anywhere; }
.row-note { font-size: .875rem; color: var(--ink-3); overflow-wrap: anywhere; }
.times { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 190px; }
.time { font: 500 .8125rem var(--mono); padding: 4px 9px; border-radius: 8px; background: var(--paper-2); white-space: nowrap; }
.row-actions { display: flex; }
.datebox { width: 54px; text-align: center; padding: 7px 0 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin-inline-end: 4px; }
.datebox b { display: block; font: 600 1.25rem/1.1 var(--mono); }
.datebox span { display: block; font-size: .6875rem; color: var(--ink-3); margin-top: 2px; }
.badge { font-size: .75rem; font-weight: 500; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.badge.soon { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.empty { padding: 26px 0; border-bottom: 1px solid var(--line); color: var(--ink-3); font-size: .9375rem; }

/* ───────── privacy ───────── */
.facts { list-style: none; padding: 0; border-top: 2px solid var(--ink); max-width: 860px; }
.facts li { display: grid; grid-template-columns: 64px minmax(0, 1fr); padding: 28px 0; border-bottom: 1px solid var(--line); }
.facts .num { padding-top: 8px; }
.facts h2 { font-size: 1.375rem; font-weight: 700; margin-bottom: 8px; }
.facts p { color: var(--ink-2); max-width: 40rem; line-height: 1.9; }
.tools { margin-top: 44px; }
.tools h2 { font-size: 1.125rem; font-weight: 600; margin-bottom: 14px; }
.tools-row { display: flex; flex-wrap: wrap; gap: 10px; }
.disclaimer { margin-top: 44px; max-width: 46rem; font-size: .875rem; line-height: 1.9; color: var(--ink-3); }

/* ───────── toast & dialog ───────── */
.toast {
  position: fixed; bottom: 28px; left: 50%; z-index: 60;
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 12px;
  background: var(--ink); color: var(--paper); font-size: .9375rem; font-weight: 500;
  box-shadow: 0 16px 40px -12px rgba(22, 29, 26, .5);
  transform: translate(-50%, 24px); opacity: 0; pointer-events: none;
  transition: transform .35s var(--ease), opacity .25s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

dialog { border: 0; padding: 28px; width: min(440px, calc(100vw - 32px)); border-radius: 24px; background: var(--surface); color: var(--ink); box-shadow: 0 40px 90px -30px rgba(22, 29, 26, .6); }
dialog[open] { animation: view-in .3s var(--ease); }
dialog::backdrop { background: rgba(22, 29, 26, .5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 8px; }
dialog p { color: var(--ink-2); }
.dialog-actions { display: flex; gap: 10px; margin-top: 24px; }

/* ───────── standalone pages (confirm, unsubscribe, 404) ───────── */
.solo { flex: 1; display: grid; place-items: center; padding: 32px 16px; }
.solo-card { width: min(480px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: clamp(28px, 6vw, 44px); text-align: center; animation: view-in .5s var(--ease) both; }
.solo-card .brand { margin-bottom: 30px; }
.solo-icon { width: 64px; height: 64px; margin: 0 auto 20px; border-radius: 50%; display: grid; place-items: center; background: var(--paper-2); color: var(--ink); }
.solo-icon .ic { width: 30px; height: 30px; stroke-width: 2; }
.solo-icon.ok { background: var(--green); color: #fff; }
.solo-icon.ok path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: draw .55s .2s var(--ease) forwards; }
.solo-icon.bad { background: #FBE6E0; color: var(--red-ink); }
.solo-card h1 { font-size: 1.75rem; line-height: 1.4; }
.solo-card p { margin-top: 10px; color: var(--ink-2); }
.solo-card bdi { color: var(--ink); font-weight: 600; }
.solo-actions { display: grid; gap: 10px; margin-top: 26px; }
.solo-card .fine { margin-top: 20px; }

/* ───────── responsive ───────── */
@media (max-width: 980px) {
  .card-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "hero" "card" "form"; }
  .card-col { position: static; margin-top: 32px; max-width: 520px; width: 100%; justify-self: center; }
  .lists { grid-template-columns: minmax(0, 1fr); }
  .mailbox { grid-template-columns: auto minmax(0, 1fr); }
  .mb-actions { grid-column: 1 / -1; justify-content: flex-start; margin-top: 10px; }
}
@media (max-width: 760px) {
  .top { grid-template-columns: 1fr auto; height: 60px; background: var(--paper); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .tabs {
    position: fixed; z-index: 40; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%);
    background: var(--ink); padding: 5px; box-shadow: 0 14px 34px -10px rgba(22, 29, 26, .6);
  }
  .tabs a { color: #B4BEB8; padding: 10px 20px; }
  .tabs a[aria-current="page"] { color: var(--ink); }
  .tabs-pill { top: 5px; bottom: 5px; background: var(--paper); }
  main { padding-bottom: 40px; }
  .foot { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(86px + env(safe-area-inset-bottom)); }
  .stage { padding: 30px 18px 10px; border-radius: 22px; }
  .mailbox, .day { border-radius: 22px; }
  .rail { margin-inline: 4px; }
  .facts li { grid-template-columns: 44px minmax(0, 1fr); }
  .row { grid-template-columns: minmax(0, 1fr) auto; }
  .row .times { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; max-width: none; }
  .row.appt { grid-template-columns: auto minmax(0, 1fr) auto; }
  .row.appt .badge { grid-column: 2; grid-row: 2; justify-self: start; }
  .row.appt .row-actions { grid-row: 1; grid-column: 3; }
}
@media (max-width: 420px) {
  .chip span { display: none; }
  .chip { padding: 8px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .stage-actions { grid-template-columns: minmax(0, 1fr); }
  .tabs a { padding: 10px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ───────── print: just the card, at wallet size ───────── */
#print-sheet { display: none; }
@media print {
  @page { size: A4 portrait; margin: 16mm; }
  body { background: #fff; display: block; }
  body > *:not(#print-sheet) { display: none !important; }
  #print-sheet { display: block; color: #000; }
  .ps-title { font-size: 13pt; font-weight: 700; }
  .ps-help { font-size: 9.5pt; color: #444; margin-top: 2mm; }
  .ps-cards { display: flex; margin-top: 12mm; width: 171.2mm; }
  .ps-card { width: 85.6mm; height: 54mm; flex: none; outline: .25mm dashed #888; outline-offset: 0; }
  .ps-card .mc { border-radius: 0; }
  .ps-fold { font-size: 8pt; color: #666; width: 171.2mm; text-align: center; margin-top: 3mm; letter-spacing: .02em; }
}

/* ───────── small additions ───────── */
.mc-contact.blank, .mc-name.blank { color: #C2C6C0; font-weight: 400; }
.btn[aria-disabled="true"] { opacity: .5; }

/* ───────── emergency page (what a scan opens) ───────── */
.em-band { background: var(--red); color: #fff; padding: 14px clamp(16px, 5vw, 32px); display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.em-band b { font-size: 1.0625rem; font-weight: 700; }
.em-band i { font: 500 .6875rem var(--mono); letter-spacing: .16em; font-style: normal; }
.em { width: 100%; max-width: 640px; margin-inline: auto; padding: clamp(24px, 6vw, 44px) clamp(16px, 5vw, 32px) 40px; flex: 1; animation: view-in .45s var(--ease) both; }
.em i { font-style: normal; }
.em-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: start; }
.em-name { font-size: clamp(1.75rem, 1.2rem + 3vw, 2.5rem); font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.em-sub { margin-top: 6px; color: var(--ink-2); }
.em-blood { border: 2px solid var(--red); border-radius: 18px; padding: 12px 18px 10px; text-align: center; background: var(--surface); }
.em-blood b { display: block; font: 600 2.75rem/1 var(--mono); color: var(--red); direction: ltr; }
.em-blood span { display: block; margin-top: 6px; font-size: .75rem; color: var(--ink-3); }
.em-list { margin-top: 28px; border-top: 2px solid var(--ink); }
.em-item { padding: 18px 0; border-bottom: 1px solid var(--line); }
.em-item h2 { display: flex; align-items: baseline; gap: 10px; font-size: .875rem; font-weight: 500; color: var(--ink-3); margin-bottom: 4px; }
.em-item h2 i { font: 500 .6875rem var(--mono); letter-spacing: .14em; }
.em-item p { font-size: 1.25rem; font-weight: 600; line-height: 1.6; overflow-wrap: anywhere; }
.em-item.alert p { color: var(--red-ink); }
.em-call { margin-top: 28px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 16px; padding: 18px 22px; border-radius: 20px; background: var(--ink); color: var(--paper); transition: transform .12s; }
.em-call:active { transform: scale(.98); }
.em-call small { grid-column: 1; font-size: .8125rem; color: #B4BEB8; }
.em-call strong { grid-column: 1; font-size: 1.25rem; font-weight: 600; overflow-wrap: anywhere; }
.em-call bdi { grid-column: 2; grid-row: 1 / span 2; font: 600 1.25rem var(--mono); direction: ltr; white-space: nowrap; }
.em-foot { margin-top: 28px; font-size: .8125rem; line-height: 1.8; color: var(--ink-3); }
.em-foot a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 420px) { .em-call { grid-template-columns: minmax(0, 1fr); } .em-call bdi { grid-column: 1; grid-row: auto; margin-top: 6px; } }
