/* ENDOYAR design tokens – from the PRD's brand table */
:root {
  --primary: #a9c7cc;
  --primary-dark: #527f87;
  --secondary: #315c66;
  --accent: #d98c78;
  --accent-deep: #b5483a;
  --bg: #f7fafa;
  --surface: #ffffff;
  --text: #17282c;
  --text-2: #60777c;
  --border: #d5e1e3;
  --heat-0: #eaf3f4;
  --heat-1: #f3d9d0;
  --heat-2: #d98c78;
  --heat-3: #b5483a;
  --warn-bg: #fdf1ed;
  --radius: 16px;
  --font: 'Yekan Bakh', 'Yekan B', 'Vazirmatn', Tahoma, system-ui, sans-serif;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('assets/fonts/Vazirmatn-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--secondary); }
a.btn { text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--primary-dark); outline-offset: 2px; border-radius: 8px; }

#app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding: 0 16px 104px; }
#app.full { padding-bottom: 112px; }
main:focus, [tabindex='-1']:focus { outline: none; }
h1 { font-size: 1.35rem; margin: 0; line-height: 1.4; }
h2 { font-size: 1.1rem; margin: 0 0 8px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
p { margin: 0 0 8px; }
.muted { color: var(--text-2); font-size: 0.9rem; }
/* #60777c is 4.5:1 on the page background but only 4.2:1 on the tinted cards: use a slightly darker tone there */
.card.soft .muted, .note .muted, .testmode .muted, .banner .muted, .code-card .muted { color: #566d72; }
.small { font-size: 0.82rem; }
.num { font-feature-settings: 'tnum'; }

/* layout bits */
.topbar { display: flex; align-items: center; gap: 8px; padding: 18px 0 10px; }
.topbar .grow { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.card.soft { background: var(--heat-0); border-color: transparent; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }

/* buttons */
.btn {
  min-height: 48px; padding: 0 20px; border-radius: 14px; border: 1.5px solid var(--secondary);
  background: var(--surface); color: var(--secondary); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn.primary { background: var(--secondary); color: #fff; }
.btn.block { width: 100%; }
.btn.danger { border-color: var(--accent-deep); color: var(--accent-deep); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 0.9rem; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.iconbtn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); display: inline-grid; place-items: center; color: var(--secondary); }
.rtl-flip svg { transform: scaleX(-1); }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 6px 14px; border-radius: 22px; border: 1.5px solid var(--border); background: var(--surface);
  display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: center; text-align: right; line-height: 1.4;
}
.chip small { color: var(--text-2); font-size: 0.75rem; }
.chip.on { background: var(--secondary); border-color: var(--secondary); color: #fff; }
.chip.on small { color: #d5e8eb; }
.chip.removable { flex-direction: row; gap: 8px; align-items: center; background: var(--heat-0); }

/* 0-10 scale */
.scale10 { display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px; }
.sc { height: 44px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface); font-weight: 700; padding: 0; font-size: 0.85rem; }
.sc.h0 { background: var(--heat-0); }
.sc.h1 { background: var(--heat-1); }
.sc.h2 { background: #eab4a5; }
.sc.h3 { background: var(--accent); }
.sc.on { outline: 3px solid var(--secondary); outline-offset: 1px; border-color: var(--secondary); }
.scale-cap { display: flex; justify-content: space-between; color: var(--text-2); font-size: 0.78rem; margin-top: 4px; }
.scale-readout { font-weight: 700; color: var(--secondary); min-height: 1.7em; }

/* segmented control */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg button { min-height: 56px; border-radius: 16px; border: 1.5px solid var(--border); background: var(--surface); font-weight: 700; }
.seg button.on { background: var(--accent); border-color: var(--accent); color: var(--text); }
.seg button.on.neutral { background: var(--secondary); border-color: var(--secondary); color: #fff; }

/* fields */
.field { margin: 18px 0; }
.field > h3 { color: var(--secondary); }
input[type='text'], input[type='number'], input[type='search'], input[type='tel'], textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface);
}
textarea { min-height: 88px; resize: vertical; }
label.lbl { display: block; font-size: 0.88rem; color: var(--text-2); margin-bottom: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* notes */
.note { padding: 10px 14px; border-radius: 12px; background: var(--heat-0); font-size: 0.9rem; margin: 10px 0; }
.note.warn { background: var(--warn-bg); border: 1px solid var(--accent); }
.banner { background: var(--warn-bg); border: 1.5px solid var(--accent); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; }
.banner strong { color: var(--accent-deep); }
.sample-badge { display: inline-block; background: #fff3c4; color: #6b5200; border-radius: 8px; padding: 0 8px; font-size: 0.78rem; font-weight: 700; }

/* check-in shell */
.progress { display: flex; gap: 6px; margin: 4px 0 14px; }
.progress i { flex: 1; height: 6px; border-radius: 3px; background: var(--border); }
.progress i.done { background: var(--primary-dark); }
.progress i.cur { background: var(--accent); }
.footer-bar {
  position: fixed; inset-inline: 0; bottom: 0; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px);
  border-top: 1px solid var(--border); padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.footer-bar > div { max-width: 480px; margin: 0 auto; display: flex; gap: 10px; }
.footer-bar .btn { flex: 1; }
.footer-bar .btn.primary { flex: 2; }

/* bottom nav */
.nav { position: fixed; inset-inline: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.nav > div { max-width: 480px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; font-size: 0.78rem; color: var(--text-2); text-decoration: none; min-height: 56px; }
.nav a[aria-current='page'] { color: var(--secondary); font-weight: 700; }

/* home */
.hero-cta { background: var(--secondary); color: #fff; border-radius: 20px; padding: 18px; }
.hero-cta .btn { background: #fff; color: var(--secondary); border-color: #fff; margin-top: 10px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--text-2); }
.spark { display: flex; align-items: flex-end; gap: 6px; height: 64px; }
.spark button { flex: 1; border: 0; border-radius: 6px; background: var(--heat-0); min-height: 6px; padding: 0; }
.spark button.h1 { background: var(--heat-1); } .spark button.h2 { background: #eab4a5; } .spark button.h3 { background: var(--accent); }
.spark-lbl { display: flex; gap: 6px; margin-top: 2px; }
.spark-lbl span { flex: 1; text-align: center; font-size: 0.7rem; color: var(--text-2); }

/* calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 0 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 0.8rem; color: var(--text-2); padding: 4px 0; }
.day {
  position: relative; aspect-ratio: 1 / 1.05; border-radius: 12px; border: 1.5px solid transparent; background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0; font-weight: 600; font-size: 0.95rem;
}
.day.h0 { background: var(--heat-0); } .day.h1 { background: var(--heat-1); } .day.h2 { background: #eab4a5; }
.day.h3 { background: var(--heat-3); color: #fff; }
.day.today { border-color: var(--secondary); }
.day.future { color: var(--text-2); background: transparent; }
.day.pred { border: 1.5px dashed var(--accent); background: transparent; }
.day .drop { position: absolute; top: 4px; inset-inline-start: 5px; width: 8px; height: 8px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--accent-deep); }
.day.h3 .drop { background: #fff; }
.day .spot { position: absolute; bottom: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent-deep); opacity: 0.6; }
.day.empty { visibility: hidden; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; font-size: 0.8rem; color: var(--text-2); margin: 12px 0; align-items: center; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-inline-end: 4px; }

dialog.sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 480px; border-radius: 22px 22px 0 0; background: var(--surface); color: var(--text); }
dialog.sheet::backdrop { background: rgba(23, 40, 44, 0.45); }
dialog.sheet .inner { padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }

/* report */
.bars { display: flex; align-items: flex-end; gap: 2px; height: 90px; }
.bars b { flex: 1; min-width: 2px; border-radius: 2px 2px 0 0; background: var(--border); }
.bars b.h0 { background: var(--primary); } .bars b.h1 { background: var(--heat-1); } .bars b.h2 { background: #eab4a5; } .bars b.h3 { background: var(--accent-deep); }
.pattern { border-inline-start: 4px solid var(--primary-dark); padding: 6px 12px; margin: 10px 0; background: var(--bg); border-radius: 8px; }
.pill { display: inline-block; background: var(--heat-0); border-radius: 10px; padding: 0 8px; font-size: 0.78rem; }
.range { display: inline-flex; border: 1.5px solid var(--border); border-radius: 12px; overflow: hidden; }
.range button { border: 0; background: var(--surface); padding: 8px 14px; min-height: 40px; }
.range button.on { background: var(--secondary); color: #fff; }
.disclaimer { font-size: 0.8rem; color: var(--text-2); border-top: 1px solid var(--border); margin-top: 24px; padding-top: 12px; }

/* toast */
#toast { position: fixed; inset-inline: 16px; bottom: 90px; margin: 0 auto; max-width: 420px; background: var(--text); color: #fff; padding: 12px 16px; border-radius: 14px; opacity: 0; transform: translateY(8px); transition: 0.2s; pointer-events: none; z-index: 20; text-align: center; }
#toast.show { opacity: 1; transform: none; }

@media print {
  body { background: #fff; }
  .nav, .footer-bar, .no-print, #toast { display: none !important; }
  #app { max-width: none; padding: 0; }
  .card { break-inside: avoid; border-color: #999; }
  .bars b { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ── login / account ─────────────────────────────────────────────────────── */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: isolate; }
input.ltr { text-align: right; }
.linkbtn { min-height: 44px; padding: 0 10px; background: none; border: 0; color: var(--secondary); font-weight: 700; text-decoration: underline; }
.linkbtn[disabled] { opacity: 0.5; text-decoration: none; cursor: default; }
input.otp { text-align: center; font-size: 1.6rem; letter-spacing: 0.35em; padding-inline-start: calc(14px + 0.35em); min-height: 56px; }
.testmode { border: 2px dashed var(--accent-deep); background: var(--warn-bg); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; }
.testmode strong { margin-inline-end: 8px; }
.testmode .pill { background: #fff3c4; color: #6b5200; font-weight: 700; }
.code-card { border: 2px dashed var(--primary-dark); border-radius: var(--radius); padding: 10px 14px; margin: 12px 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.code-card .code { font-size: 1.6rem; font-weight: 700; letter-spacing: 0.3em; }
dialog.confirm .inner { max-width: 480px; margin: 0 auto; }
dialog.confirm .btn { margin-top: 0; }
.err-page { padding-top: 48px; text-align: center; }
