/* ─── SageFlow Design Tokens ─────────────────────── */
:root {
  --primary:      #7A9E8A;
  --primary-dark: #5d8571;
  --primary-pale: rgba(122,158,138,.12);
  --primary-glow: rgba(122,158,138,.28);
  --accent:       #C9A96E;
  --accent-pale:  rgba(201,169,110,.14);
  --bg:           #FAF7F6;
  --surface:      #ffffff;
  --surface-2:    #F2EFE9;
  --text:         #2C2C2C;
  --text-2:       #6B6B6B;
  --text-3:       #A8A8A8;
  --border:       #E5E1DC;
  --red:          #C0392B;
  --green:        #27AE60;

  --font-display: "Funnel Display", sans-serif;
  --font-body:    "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    "IBM Plex Mono", monospace;

  --r:     16px;
  --r-sm:  10px;
  --r-lg:  20px;
  --r-pill:100px;

  --shadow-sm: 0 2px 8px rgba(0,0,0,.06);
  --trans: .22s ease;
}

/* ─── Reset ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--font-body);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
img, svg { display: block; max-width: 100%; }
input, select, button { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ─── App shell ──────────────────────────────────── */
#app { min-height: 100vh; position: relative; }

/* Subtle background texture */
#app::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 70% 60% at 15% 10%, rgba(122,158,138,.07) 0%, transparent 100%),
    radial-gradient(ellipse 50% 50% at 85% 90%, rgba(201,169,110,.05) 0%, transparent 100%),
    var(--bg);
}
#app::after {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(rgba(122,158,138,.055) 1.5px, transparent 1.5px);
  background-size: 32px 32px;
}

/* ─── Screens ─────────────────────────────────────── */
.screen {
  display: none;
  position: relative; z-index: 1;
  min-height: 100vh;
  flex-direction: column;
}
.screen.active {
  display: flex;
  animation: screenIn .22s ease forwards;
}
@keyframes screenIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Page content wrapper ───────────────────────── */
.page {
  flex: 1;
  width: 100%; max-width: 680px;
  margin: 0 auto;
  padding: 0 20px 52px;
  display: flex; flex-direction: column;
}
@media (min-width: 768px)  { .page { max-width: 760px; padding: 0 40px 60px; } }
@media (min-width: 1100px) { .page { max-width: 820px; } }

/* ─── Top bar ────────────────────────────────────── */
.topbar {
  width: 100%; max-width: 680px; margin: 0 auto;
  padding: 20px 20px 0;
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}
@media (min-width: 768px)  { .topbar { max-width: 760px; padding: 28px 40px 0; } }
@media (min-width: 1100px) { .topbar { max-width: 820px; } }

.btn-back {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--surface); border: 1.5px solid var(--border);
  color: var(--text-2); font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background var(--trans), border-color var(--trans);
  box-shadow: var(--shadow-sm);
}
.btn-back:hover  { background: var(--surface-2); border-color: var(--primary); color: var(--primary); }
.btn-back:active { transform: scale(.94); }

.topbar-label {
  flex: 1; text-align: center;
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 600; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--text-3);
}
.topbar-space { width: 40px; }

/* ─── Progress dots ──────────────────────────────── */
.pdots {
  display: flex; justify-content: center; gap: 5px;
  padding: 14px 0 0;
  width: 100%; max-width: 680px; margin: 0 auto;
  flex-wrap: wrap;
}
@media (min-width: 768px)  { .pdots { max-width: 760px; } }
@media (min-width: 1100px) { .pdots { max-width: 820px; } }

.pdots span {
  display: block;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--border);
  transition: all .3s;
}
.pdots span.done { background: var(--primary); opacity: .5; }
.pdots span.now  { background: var(--primary); width: 18px; border-radius: 3px; }

/* ─── Category chip ──────────────────────────────── */
.q-cat {
  width: 100%; max-width: 680px; margin: 0 auto;
  padding: 14px 20px 0;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 600; letter-spacing: 1.8px;
  text-transform: uppercase; color: var(--primary);
  display: flex; align-items: center; gap: 7px;
}
@media (min-width: 768px)  { .q-cat { max-width: 760px; padding: 18px 40px 0; } }
@media (min-width: 1100px) { .q-cat { max-width: 820px; } }

/* ─── Question text ──────────────────────────────── */
.q-text {
  font-family: var(--font-display);
  font-size: clamp(22px, 5vw, 30px);
  font-weight: 700; line-height: 1.25;
  color: var(--text); letter-spacing: -.5px;
  margin-bottom: 20px; padding-top: 22px;
}

.spacer { flex: 1; min-height: 16px; }

/* ─── Choice buttons (gender etc.) ──────────────── */
.choice-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-bottom: 12px;
}
.choice-btn {
  padding: 26px 16px;
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--r-lg);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  cursor: pointer; transition: all var(--trans);
  box-shadow: var(--shadow-sm);
}
.choice-btn:hover  { border-color: var(--primary); background: var(--primary-pale); }
.choice-btn:active { transform: scale(.97); }
.choice-btn.sel    { border-color: var(--primary); background: var(--primary-pale); box-shadow: 0 0 0 2px var(--primary); }
.choice-icon  { font-size: 38px; line-height: 1; }
.choice-label {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700; color: var(--text);
}
.choice-btn.sel .choice-label { color: var(--primary); }

/* ─── Yes / No buttons ───────────────────────────── */
.yn-wrap { display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 520px) { .yn-wrap { flex-direction: row; } }

.btn-yn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 20px 20px; border-radius: var(--r);
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700; cursor: pointer;
  transition: transform var(--trans), background var(--trans), box-shadow var(--trans);
  border: none;
}
.btn-yn:active { transform: scale(.97); }
.btn-yn-yes {
  background: var(--primary); color: #fff;
  box-shadow: 0 4px 20px var(--primary-glow);
}
.btn-yn-yes:hover { background: var(--primary-dark); }
.btn-yn-no {
  background: var(--surface); color: var(--text-2);
  border: 1.5px solid var(--border);
}
.btn-yn-no:hover { border-color: var(--text-3); color: var(--text); }

/* ─── Stepper ────────────────────────────────────── */
.stepper-wrap { margin-bottom: 6px; }
.stepper {
  display: flex; align-items: center;
  border: 1.5px solid var(--border);
  border-radius: var(--r); overflow: hidden;
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.step-btn {
  width: 64px; height: 64px; border: none;
  background: var(--surface-2); color: var(--text);
  font-size: 26px; font-weight: 300;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background var(--trans), color var(--trans);
  flex-shrink: 0;
}
.step-btn:hover  { background: var(--primary-pale); color: var(--primary); }
.step-btn:active { background: var(--primary-pale); transform: scale(.95); }
.step-val {
  flex: 1; text-align: center;
  font-family: var(--font-display);
  font-size: 40px; font-weight: 700; color: var(--text);
  user-select: none;
}
.step-hint {
  text-align: center; font-size: 12px; color: var(--text-3); margin-top: 8px;
  font-family: var(--font-mono); letter-spacing: .5px;
}

/* ─── Amount input ───────────────────────────────── */
.amt-wrap {
  display: flex; align-items: stretch;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r); overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--trans), box-shadow var(--trans);
}
.amt-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-pale);
}
.amt-sym {
  padding: 0 18px;
  background: var(--primary-pale); border-right: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700; color: var(--primary);
  display: flex; align-items: center; min-width: 58px; justify-content: center;
  flex-shrink: 0;
}
.amt-input {
  flex: 1; border: none; outline: none;
  padding: 20px 18px;
  font-family: var(--font-display);
  font-size: 34px; font-weight: 700; color: var(--text);
  background: transparent;
  -moz-appearance: textfield;
}
.amt-input::-webkit-outer-spin-button,
.amt-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.amt-input::placeholder { color: var(--text-3); font-weight: 400; font-size: 26px; }

/* ─── Hint box ───────────────────────────────────── */
.hint-box {
  background: var(--primary-pale);
  border: 1px solid rgba(122,158,138,.18);
  border-radius: var(--r-sm); padding: 12px 15px;
  font-size: 14px; color: var(--text-2); line-height: 1.6;
  display: flex; gap: 10px; align-items: flex-start;
  margin-bottom: 16px;
}
.hint-icon { flex-shrink: 0; margin-top: 1px; }

/* ─── Primary action button ──────────────────────── */
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 19px 24px;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--r);
  font-family: var(--font-display);
  font-size: 19px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 20px var(--primary-glow);
  transition: background var(--trans), transform var(--trans), box-shadow var(--trans);
}
.btn-primary:hover  { background: var(--primary-dark); box-shadow: 0 6px 28px var(--primary-glow); }
.btn-primary:active { transform: scale(.97); box-shadow: none; }

/* Ghost button */
.btn-ghost {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 17px 24px;
  background: transparent; color: var(--text-2);
  border: 1.5px solid var(--border); border-radius: var(--r);
  font-family: var(--font-display);
  font-size: 17px; font-weight: 600; cursor: pointer;
  transition: all var(--trans);
}
.btn-ghost:hover  { border-color: var(--text-3); color: var(--text); }
.btn-ghost:active { transform: scale(.97); }

/* Outline button */
.btn-outline {
  flex: 1; padding: 17px;
  background: transparent; color: var(--text-2);
  border: 1.5px solid var(--border); border-radius: var(--r);
  font-family: var(--font-display);
  font-size: 16px; font-weight: 600; cursor: pointer;
  transition: all var(--trans);
}
.btn-outline:hover  { border-color: var(--text-3); color: var(--text); }
.btn-outline:active { transform: scale(.97); }

/* ─── Currency grid ──────────────────────────────── */
.curr-heading {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 700; color: var(--text);
  margin-bottom: 6px; padding-top: 22px; letter-spacing: -.5px;
}
.curr-sub { font-size: 15px; color: var(--text-2); margin-bottom: 22px; line-height: 1.5; }
.curr-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
@media (min-width: 480px) { .curr-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 760px) { .curr-grid { grid-template-columns: repeat(5, 1fr); } }

.curr-btn {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-sm); padding: 12px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; transition: all var(--trans);
  user-select: none; box-shadow: var(--shadow-sm);
}
.curr-btn:hover { border-color: var(--primary); background: var(--primary-pale); }
.curr-btn.sel   { border-color: var(--primary); background: var(--primary-pale); box-shadow: 0 0 0 2px var(--primary); }
.curr-flag    { font-size: 22px; line-height: 1; }
.curr-name    { font-size: 11px; font-weight: 700; color: var(--text-2); letter-spacing: .3px; }
.curr-country { font-size: 9px; font-weight: 500; color: var(--text-3); }

/* ─── WELCOME screen ─────────────────────────────── */
#s-welcome {
  align-items: center; justify-content: center;
  min-height: 100vh; padding: 40px 24px 48px;
  text-align: center;
}
.wlc-inner {
  display: flex; flex-direction: column;
  align-items: center;
  max-width: 520px; width: 100%;
}
.wlc-symbol {
  width: 80px; height: 80px; border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 28px;
  box-shadow: 0 8px 32px var(--primary-glow);
}
.wlc-symbol svg { width: 40px; height: 40px; color: #fff; }
.wlc-arabic {
  font-size: 52px; font-weight: 400; line-height: 1;
  font-family: 'Amiri', 'Traditional Arabic', serif;
  color: var(--accent); letter-spacing: 4px; margin-bottom: 8px;
}
.wlc-title {
  font-family: var(--font-display);
  font-size: 34px; font-weight: 700; letter-spacing: -.6px;
  color: var(--text); margin-bottom: 10px;
}
.wlc-desc {
  font-size: 16px; color: var(--text-2); line-height: 1.65;
  max-width: 320px; margin-bottom: 24px;
}
.wlc-pills {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; margin-bottom: 32px;
}
.wlc-pill {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 5px 12px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px; color: var(--primary);
}
.wlc-btn-wrap { width: 100%; max-width: 360px; }
.wlc-verse {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 14px 18px; max-width: 360px; width: 100%;
  font-size: 14px; font-style: italic; line-height: 1.8;
  color: var(--text-2); text-align: left; margin: 28px 0 0;
}
.wlc-verse cite {
  display: block; margin-top: 6px; font-style: normal;
  font-size: 12px; color: var(--primary); font-weight: 600;
}
.nimazi-link {
  display: inline-block; margin-top: 20px;
  font-size: 13px; font-weight: 500; color: var(--text-3);
  transition: color var(--trans);
}
.nimazi-link:hover { color: var(--text-2); }

/* ─── REVIEW screen ──────────────────────────────── */
.review-hd {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 700; color: var(--text);
  padding-top: 24px; margin-bottom: 4px; letter-spacing: -.5px;
}
.review-sub { font-size: 15px; color: var(--text-2); margin-bottom: 22px; }

.r-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.r-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer; transition: background var(--trans), border-color var(--trans);
  user-select: none; box-shadow: var(--shadow-sm);
}
.r-item:hover  { background: var(--primary-pale); border-color: var(--primary); }
.r-item:active { transform: scale(.99); }
.r-icon {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary-pale); display: flex; align-items: center;
  justify-content: center; font-size: 18px;
}
.r-icon.dim { background: var(--surface-2); filter: grayscale(.5); opacity: .6; }
.r-content  { flex: 1; min-width: 0; }
.r-label {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 600; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 2px;
}
.r-value     { font-size: 16px; font-weight: 600; color: var(--text); }
.r-value.dim { font-size: 15px; color: var(--text-3); font-weight: 400; }
.r-edit {
  font-family: var(--font-mono); font-size: 11px;
  font-weight: 600; color: var(--primary); flex-shrink: 0; letter-spacing: .5px;
}

.summary-card {
  background: var(--primary-pale); border: 1px solid rgba(122,158,138,.22);
  border-radius: var(--r-sm); padding: 16px; margin-bottom: 8px;
}
.sum-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 15px; color: var(--text-2); padding: 7px 0;
  border-bottom: 1px solid rgba(122,158,138,.15);
}
.sum-row:last-child {
  border-bottom: none; font-size: 17px; font-weight: 700;
  color: var(--text); padding-top: 11px; margin-top: 4px;
}
.val-green { color: var(--green); font-weight: 700; }
.val-red   { color: var(--red);   font-weight: 700; }

/* ─── RESULT screen ──────────────────────────────── */
.result-hero {
  text-align: center; padding: 36px 0 28px;
  border-bottom: 1px solid var(--border); margin-bottom: 22px;
}
.result-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.8px;
  color: var(--primary); margin-bottom: 10px;
}
.result-amount {
  font-family: var(--font-display);
  font-size: clamp(48px, 12vw, 72px);
  font-weight: 700; line-height: 1;
  letter-spacing: -2px; color: var(--primary); margin-bottom: 6px;
}
.result-sym  { font-size: clamp(28px, 6vw, 40px); vertical-align: .1em; letter-spacing: -1px; }
.result-sub  { font-size: 14px; color: var(--text-2); }

/* Distribution card */
.dist-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 18px;
  box-shadow: var(--shadow-sm); margin-bottom: 14px;
}
.dist-card-title {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 600; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 14px;
}
.dist-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.dist-row:last-child { border-bottom: none; padding-bottom: 0; }
.dist-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary-pale);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 17px;
}
.dist-info { flex: 1; min-width: 0; }
.dist-heir { font-size: 15px; font-weight: 600; color: var(--text); }
.dist-exp  { font-size: 12px; color: var(--text-2); line-height: 1.45; margin-top: 2px; }
.dist-right { text-align: right; flex-shrink: 0; }
.dist-fraction { font-family: var(--font-mono); font-size: 13px; color: var(--primary); font-weight: 600; }
.dist-amount   { font-family: var(--font-display); font-size: 15px; font-weight: 700; color: var(--text); margin-top: 2px; }
.dist-pct      { font-size: 10px; color: var(--text-3); }

/* Flag / note boxes */
.flag-box {
  background: var(--accent-pale); border: 1px solid rgba(201,169,110,.28);
  border-radius: var(--r); padding: 15px 18px;
  font-size: 14px; color: var(--text-2); line-height: 1.65;
  display: flex; gap: 12px; margin-bottom: 14px;
}
.flag-box strong { color: var(--text); display: block; margin-bottom: 3px; }

.info-flag {
  background: var(--primary-pale); border: 1px solid rgba(122,158,138,.22);
  border-radius: var(--r); padding: 15px 18px;
  font-size: 14px; color: var(--text-2); line-height: 1.65;
  display: flex; gap: 12px; margin-bottom: 14px;
}

.disclaimer-box {
  background: var(--accent-pale); border: 1px solid rgba(201,169,110,.22);
  border-radius: var(--r); padding: 14px 18px;
  font-size: 13px; color: var(--text-2); line-height: 1.7;
  margin-bottom: 16px;
}
.disclaimer-box strong { color: var(--text); }

/* Checklist card */
.cl-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
.cl-header {
  padding: 16px 18px 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.cl-title {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 600; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text-3);
}
.cl-prog { font-family: var(--font-mono); font-size: 11px; color: var(--primary); font-weight: 600; }
.cl-track {
  height: 3px; background: var(--border); margin: 0 18px 12px;
  border-radius: var(--r-pill); overflow: hidden;
}
.cl-fill {
  height: 100%; background: var(--primary);
  border-radius: var(--r-pill); transition: width .4s ease;
}
.cl-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 18px; border-top: 1px solid var(--border);
  cursor: pointer; user-select: none; transition: background var(--trans);
}
.cl-item:hover { background: var(--primary-pale); }
.cl-box {
  width: 20px; height: 20px; border-radius: 5px;
  border: 2px solid var(--border); background: var(--surface-2);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  transition: all var(--trans); margin-top: 1px;
}
.cl-item.done .cl-box { background: var(--primary); border-color: var(--primary); }
.cl-item.done .cl-box::after {
  content: ''; display: block; width: 5px; height: 8px;
  border-right: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(45deg) translate(-1px,-1px);
}
.cl-item.done .cl-text { color: var(--text-3); text-decoration: line-through; }
.cl-text { font-size: 14px; color: var(--text); line-height: 1.45; flex: 1; }
.cl-sub  { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* Result footer */
.result-footer { display: flex; gap: 10px; margin-top: 4px; }

/* Print */
@media print {
  #s-result { display: flex !important; }
  #s-welcome, #s-question, #s-review { display: none !important; }
  .result-footer, .topbar { display: none !important; }
  body { background: #fff; }
  #app::before, #app::after { display: none; }
}
