:root {
  --navy: #1F2157;
  --navy-soft: #3a3d78;
  --beige: #DFD6CD;
  --beige-light: #EEE8E2;
  --bg: #DFDDDB;
  --card: #FBF9F7;
  --text: #1F2157;
  --muted: #5b5d82;
  --error: #9b2c2c;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(31, 33, 87, 0.08);
  --font: 'Rubik', 'Arial Hebrew', Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: center;
  padding: 14px 16px 6px;
}
body[data-screen="welcome"] .topbar { display: none; }
.wordmark { height: 20px; width: auto; opacity: .9; }

main {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 16px 32px;
}

.screen { display: none; }
.screen.is-active { display: block; animation: fadeIn .35s ease both; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .screen.is-active, .question.swap { animation: none; }
}

h1, h2, h3 { font-weight: 700; line-height: 1.3; margin: 0; }

/* פתיחה */
[data-screen="welcome"] { text-align: center; padding-top: 8px; }
.hero-logo { width: 150px; height: auto; margin: 4px auto 18px; display: block; }
h1 { font-size: 28px; margin-bottom: 18px; }
.lead p { margin: 0 0 10px; }
.lead-strong { font-weight: 500; margin-top: 16px !important; }
.fine { font-size: 14px; color: var(--muted); margin: 14px 0 0; }

/* כפתורים */
.btn {
  font-family: inherit;
  font-size: 18px;
  font-weight: 500;
  border-radius: 999px;
  border: 0;
  min-height: 54px;
  padding: 12px 26px;
  width: 100%;
  cursor: pointer;
  transition: transform .12s ease, background-color .2s ease, box-shadow .2s ease;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  line-height: 1.3;
}
.btn:active { transform: scale(.98); }
.btn:focus-visible, .option:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--navy-soft);
  outline-offset: 2px;
}
.btn-primary { background: var(--navy); color: #fff; box-shadow: 0 6px 18px rgba(31, 33, 87, .22); margin-top: 22px; }
.btn-primary:hover { background: var(--navy-soft); }
.btn-secondary { background: var(--beige); color: var(--navy); }
.btn-secondary:hover { background: #d4c9be; }
.btn-ghost { background: transparent; color: var(--navy); min-height: 48px; font-size: 16px; text-decoration: underline; text-underline-offset: 4px; }
.btn-ghost:disabled { visibility: hidden; }
.btn-small { min-height: 46px; font-size: 16px; padding: 10px 18px; }

.nav-row { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }

/* פרטים */
.screen-title { font-size: 24px; margin: 8px 0 18px; text-align: center; }
.field { border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
.field > label, legend { display: block; font-size: 19px; font-weight: 500; margin-bottom: 4px; padding: 0; }
.hint { font-size: 15px; color: var(--muted); margin: 0 0 10px; }
.sub-label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }

input[type="text"], select, textarea {
  font-family: inherit;
  font-size: 18px; /* 16px ומעלה כדי ש-iOS לא יעשה זום */
  color: var(--text);
  background: #fff;
  border: 1.5px solid #c9c3bc;
  border-radius: 14px;
  width: 100%;
  min-height: 54px;
  padding: 12px 14px;
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--navy) 50%), linear-gradient(135deg, var(--navy) 50%, transparent 50%);
  background-position: 18px 50%, 12px 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-left: 30px;
}
#byear { direction: ltr; text-align: center; }
#byear::placeholder { direction: rtl; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--error); }

.date-row { display: grid; grid-template-columns: 1fr 1.6fr 1.3fr; gap: 8px; }
.error { color: var(--error); font-size: 15px; margin: 8px 0 0; font-weight: 500; }

.info-cards { display: grid; gap: 10px; margin: 6px 0 16px; }
.info-card { background: var(--beige-light); border-radius: var(--radius); padding: 14px 16px; }
.info-card h3 { font-size: 17px; margin-bottom: 4px; }
.info-card p { margin: 0; font-size: 15px; }
.privacy { font-size: 14px; color: var(--muted); margin: 0; }

/* שאלון */
.progress { height: 8px; background: var(--beige); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress-bar { height: 100%; width: 0; background: var(--navy); border-radius: 99px; transition: width .35s ease; }
.progress-label { font-size: 14px; color: var(--muted); margin: 8px 0 14px; }
.q-text { font-size: 22px; margin-bottom: 6px; }
.question.swap { animation: fadeIn .3s ease both; }
.options { display: grid; gap: 10px; margin-top: 14px; }
.option {
  font-family: inherit;
  font-size: 17px;
  text-align: right;
  color: var(--text);
  background: var(--card);
  border: 1.5px solid transparent;
  border-radius: 16px;
  padding: 14px 16px;
  min-height: 58px;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .15s ease, background-color .15s ease;
}
.option .dot {
  flex: 0 0 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #b9b2ab;
  background: #fff;
}
.option[aria-checked="true"] { border-color: var(--navy); background: #fff; }
.option[aria-checked="true"] .dot { border-color: var(--navy); background: radial-gradient(circle, var(--navy) 45%, #fff 50%); }

/* תוצאה */
.result { display: grid; gap: 16px; }
.r-hero { text-align: center; padding: 6px 4px 4px; }
.r-hero h1 { font-size: 26px; margin-bottom: 10px; }
.r-hero p { margin: 0; color: var(--muted); }
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 18px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 21px; margin-bottom: 10px; }
.card p { margin: 0 0 10px; }
.card p:last-child { margin-bottom: 0; }
.eyebrow { font-size: 13px; font-weight: 500; letter-spacing: .02em; color: var(--muted); margin: 0 0 4px; }
.num-row { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.num {
  flex: 0 0 64px; height: 64px; border-radius: 50%;
  background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 700;
}
.calc { font-size: 14px; color: var(--muted); margin: 0 !important; }
.calc .math { display: block; direction: ltr; text-align: right; unicode-bidi: isolate; white-space: nowrap; font-weight: 500; color: var(--navy); margin-top: 2px; }
.letters { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.letter { background: var(--beige-light); border-radius: 10px; padding: 4px 9px; font-size: 15px; }
.letter b { font-weight: 700; margin-inline-start: 4px; }
.pattern-block { border-inline-start: 4px solid var(--beige); padding-inline-start: 12px; margin: 12px 0; }
.pattern-block h3 { font-size: 18px; margin-bottom: 4px; }
.tool { background: var(--navy); color: #fff; }
.tool .eyebrow { color: #c9cbe8; }
.tool h2 { color: #fff; }
.tool h3 { font-size: 17px; color: #fff; margin: 12px 0 4px; }
.reflect label { display: block; font-weight: 500; margin: 14px 0 6px; }
.reflect label:first-of-type { margin-top: 0; }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.save-row { display: grid; gap: 8px; margin-top: 14px; }
.save-options { display: grid; gap: 8px; }
.save-options[hidden] { display: none; }
.invite p { margin: 0 0 10px; }
.signature { font-weight: 500; margin-top: 14px !important; }
.cta { display: grid; gap: 10px; }
.cta .btn-primary { margin-top: 4px; }
.restart { text-align: center; }

.site-footer {
  max-width: 560px; margin: 0 auto; padding: 18px 16px 28px;
  font-size: 13px; color: var(--muted); text-align: center;
}
.site-footer p { margin: 0 0 6px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: 15px; box-shadow: var(--shadow); z-index: 10; max-width: calc(100% - 32px); text-align: center;
}
.noscript { text-align: center; padding: 20px; }

@media (min-width: 600px) {
  h1 { font-size: 32px; }
  .card { padding: 26px 26px; }
}

/* הדפסה / שמירה כ-PDF */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; font-size: 12pt; }
  .topbar, .site-footer, .toast, .no-print, .screen:not([data-screen="result"]) { display: none !important; }
  [data-screen="result"] { display: block !important; animation: none !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  .card h2, .card h3, .num-row { break-after: avoid; }
  .tool, .pattern-block { break-inside: avoid; }
  .tool { background: #fff; color: var(--navy); border: 2px solid var(--navy); }
  .tool h2, .tool h3 { color: var(--navy); }
  .tool .eyebrow { color: var(--muted); }
  .num { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  textarea { border: 1px solid #ccc; min-height: auto; }
  .print-answer { white-space: pre-wrap; border: 1px solid #ccc; border-radius: 10px; padding: 8px 10px; }
}
.print-answer { display: none; }
@media print {
  .print-answer { display: block; }
  .reflect textarea { display: none; }
}

.hint-after { margin-top: 10px; }
.offscreen-copy { position: fixed; top: 0; left: 0; opacity: 0; width: 1px; height: 1px; }
.save-options .btn { background: #fff; border: 1.5px solid var(--beige); }
