:root {
  --ink: #132a2d;
  --muted: #6f7f7f;
  --paper: #fbfaf5;
  --cream: #f4f0e6;
  --line: #dfe6df;
  --teal: #0f766e;
  --teal-dark: #095c57;
  --teal-soft: #dff4ef;
  --gold: #dfae47;
  --coral: #c6524e;
  --coral-soft: #fff0ee;
  --shadow: 0 18px 50px rgba(19, 42, 45, 0.10);
  font-family: "Tajawal", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--cream);
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--cream);
  background-image: linear-gradient(rgba(15,118,110,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(15,118,110,.035) 1px, transparent 1px);
  background-size: 32px 32px;
}
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid rgba(223,174,71,.8); outline-offset: 3px; }

.page-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand-seal {
  width: 48px; height: 48px; display: grid; place-items: center; border: 2px solid var(--teal); color: var(--teal);
  border-radius: 50%; font-weight: 900; transform: rotate(-8deg); position: relative;
}
.brand-seal::after { content: ""; position: absolute; inset: 4px; border: 1px dashed var(--gold); border-radius: inherit; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.06rem; letter-spacing: -.02em; }
.brand small { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.link-button { border: 0; background: transparent; color: var(--teal-dark); font-weight: 700; padding: 10px 4px; }
.link-button:hover { color: var(--coral); }

.main-content { width: min(980px, calc(100% - 40px)); margin: 0 auto; flex: 1; padding: 52px 0 70px; }
.hero { display: grid; grid-template-columns: 1.2fr .8fr; align-items: stretch; gap: 34px; margin-bottom: 32px; }
.hero-copy { padding: 28px 0 0; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; color: var(--teal); font-size: .83rem; font-weight: 800; letter-spacing: .05em; }
.eyebrow::before { content: ""; width: 30px; height: 2px; background: var(--gold); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2.2rem, 5.5vw, 4.8rem); line-height: 1.04; letter-spacing: -.06em; max-width: 680px; margin: 18px 0; }
h1 em { color: var(--teal); font-style: normal; }
.lede { color: var(--muted); max-width: 590px; font-size: 1.08rem; line-height: 1.9; margin-bottom: 28px; }
.hero-mark { min-height: 260px; border: 1px solid rgba(15,118,110,.15); background: rgba(251,250,245,.8); border-radius: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: center; padding: 30px; position: relative; overflow: hidden; }
.hero-mark::before { content: "∑"; position: absolute; left: -12px; top: -30px; font-size: 11rem; line-height: 1; color: rgba(15,118,110,.07); font-weight: 900; }
.hero-mark::after { content: ""; width: 140px; height: 140px; position: absolute; bottom: -70px; right: -30px; border-radius: 50%; border: 22px solid rgba(223,174,71,.25); }
.mark-label { color: var(--muted); font-size: .86rem; position: relative; z-index: 1; }
.mark-number { font-size: 5.2rem; line-height: .95; font-weight: 900; color: var(--teal); letter-spacing: -.08em; position: relative; z-index: 1; }
.mark-caption { font-weight: 800; font-size: 1.1rem; position: relative; z-index: 1; }

.card { background: rgba(251,250,245,.94); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.setup-card { padding: 28px; border-right: 5px solid var(--teal); }
.setup-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 22px; }
.setup-head h2 { font-size: 1.45rem; margin-bottom: 7px; }
.setup-head p { color: var(--muted); margin-bottom: 0; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.stat { border: 1px solid var(--line); border-radius: 12px; padding: 10px 13px; min-width: 82px; text-align: center; background: white; }
.stat strong, .stat span { display: block; }
.stat strong { font-size: 1.2rem; color: var(--teal); }
.stat span { color: var(--muted); font-size: .72rem; margin-top: 2px; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: end; }
.field label { font-size: .84rem; font-weight: 800; display: block; margin-bottom: 8px; }
.select, .number-input { width: 100%; border: 1px solid var(--line); background: white; color: var(--ink); border-radius: 12px; padding: 13px 14px; min-height: 48px; }
.button { border: 0; border-radius: 12px; min-height: 50px; padding: 12px 20px; font-weight: 800; transition: transform .2s ease, box-shadow .2s ease, background .2s ease; }
.button:hover { transform: translateY(-2px); }
.button-primary { color: white; background: var(--teal); box-shadow: 0 10px 22px rgba(15,118,110,.2); }
.button-primary:hover { background: var(--teal-dark); box-shadow: 0 13px 25px rgba(15,118,110,.26); }
.button-secondary { background: var(--teal-soft); color: var(--teal-dark); }
.button-ghost { color: var(--teal-dark); background: transparent; border: 1px solid var(--line); }
.small-note { color: var(--muted); font-size: .78rem; margin: 14px 0 0; }

.quiz-shell { max-width: 820px; margin: 0 auto; }
.quiz-top { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 12px; }
.quiz-label { color: var(--muted); font-size: .9rem; font-weight: 700; }
.quiz-count { font-weight: 800; color: var(--teal); }
.progress-track { height: 8px; background: #dfe9e5; border-radius: 999px; overflow: hidden; margin-bottom: 22px; }
.progress-value { height: 100%; background: linear-gradient(90deg, var(--teal), #31a899); border-radius: inherit; transition: width .35s ease; }
.question-card { padding: clamp(24px, 5vw, 44px); border-top: 4px solid var(--teal); }
.section-tag { color: var(--teal); font-weight: 800; font-size: .82rem; margin-bottom: 18px; }
.question-text { font-size: clamp(1.4rem, 3vw, 2rem); line-height: 1.65; margin-bottom: 28px; letter-spacing: -.02em; }
.options { display: grid; gap: 12px; }
.option { display: flex; align-items: flex-start; gap: 13px; width: 100%; text-align: right; border: 1px solid var(--line); border-radius: 14px; background: white; padding: 15px 17px; color: var(--ink); transition: border .2s ease, background .2s ease, transform .2s ease; }
.option:hover { border-color: rgba(15,118,110,.5); transform: translateX(-2px); }
.option.selected { background: var(--teal-soft); border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
.option-key { flex: 0 0 31px; height: 31px; border-radius: 50%; border: 1px solid #cfdad5; display: grid; place-items: center; color: var(--muted); font-weight: 800; font-size: .86rem; }
.option.selected .option-key { color: white; background: var(--teal); border-color: var(--teal); }
.option-copy { line-height: 1.75; padding-top: 1px; }
.quiz-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }
.quiz-actions .action-group { display: flex; gap: 10px; }
.unanswered-note { color: var(--coral); font-size: .82rem; font-weight: 700; margin: 0; }

.result-header { padding: 30px; display: grid; grid-template-columns: 200px 1fr; gap: 30px; align-items: center; margin-bottom: 24px; border-bottom: 4px solid var(--teal); }
.score-ring { width: 176px; height: 176px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--teal) var(--score), #dfe9e5 0); position: relative; margin: auto; }
.score-ring::before { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--paper); }
.score-ring-content { position: relative; text-align: center; }
.score-ring strong { display: block; color: var(--teal); font-size: 3rem; line-height: 1; letter-spacing: -.08em; }
.score-ring span { display: block; color: var(--muted); font-size: .78rem; margin-top: 5px; }
.result-header h1 { font-size: clamp(2rem, 4vw, 3.6rem); margin: 8px 0 12px; }
.result-header p { color: var(--muted); line-height: 1.8; margin-bottom: 0; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.summary-box { padding: 17px; border: 1px solid var(--line); border-radius: 16px; background: rgba(251,250,245,.9); }
.summary-box strong { display: block; font-size: 1.55rem; }
.summary-box span { color: var(--muted); font-size: .83rem; }
.summary-box.good strong { color: var(--teal); }
.summary-box.bad strong { color: var(--coral); }
.review-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin: 26px 0 12px; }
.review-head h2 { margin: 0; font-size: 1.5rem; }
.review-head p { color: var(--muted); margin: 5px 0 0; font-size: .9rem; }
.filter-tabs { display: flex; gap: 7px; flex-wrap: wrap; }
.filter-tab { border: 1px solid var(--line); border-radius: 999px; background: white; color: var(--muted); padding: 8px 13px; font-size: .78rem; font-weight: 700; }
.filter-tab.active { color: white; border-color: var(--teal); background: var(--teal); }
.review-list { display: grid; gap: 14px; }
.review-item { padding: 22px; border-right: 4px solid var(--line); }
.review-item.correct { border-right-color: var(--teal); }
.review-item.incorrect { border-right-color: var(--coral); }
.review-item h3 { font-size: 1.08rem; line-height: 1.65; margin: 0 0 15px; }
.review-status { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 800; margin-bottom: 12px; }
.review-status.correct { color: var(--teal); }
.review-status.incorrect { color: var(--coral); }
.answer-line { padding: 10px 12px; border-radius: 10px; background: var(--coral-soft); margin-bottom: 8px; line-height: 1.65; font-size: .9rem; }
.answer-line.correct-line { background: var(--teal-soft); }
.answer-line strong { margin-left: 4px; }
.explanation { color: #526363; line-height: 1.85; font-size: .9rem; border-top: 1px dashed var(--line); margin-top: 14px; padding-top: 14px; }
.explanation strong { color: var(--ink); }
.empty-state { text-align: center; color: var(--muted); padding: 34px; }
.footer { width: min(1160px, calc(100% - 40px)); padding: 22px 0 28px; margin: auto; display: flex; justify-content: center; gap: 10px; color: #87928f; font-size: .78rem; }
.footer-dot { color: var(--gold); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: white; border-radius: 10px; padding: 12px 17px; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 5; font-size: .88rem; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.share-modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: rgba(19,42,45,.45); backdrop-filter: blur(5px); }
.share-modal[hidden] { display: none; }
.share-dialog { width: min(580px, 100%); padding: 30px; position: relative; border-top: 4px solid var(--teal); }
.share-dialog h2 { margin: 10px 0 8px; font-size: 1.65rem; }
.share-dialog > p { color: var(--muted); line-height: 1.8; margin-bottom: 18px; }
.share-close { position: absolute; top: 14px; left: 16px; border: 0; background: transparent; color: var(--muted); font-size: 1.8rem; line-height: 1; }
.share-field { display: flex; gap: 8px; align-items: stretch; }
.share-field input { min-width: 0; flex: 1; border: 1px solid var(--line); border-radius: 12px; background: white; color: var(--ink); padding: 12px; direction: ltr; text-align: left; font-size: .85rem; }

@media (max-width: 760px) {
  .topbar, .main-content { width: min(100% - 28px, 620px); }
  .topbar { padding-top: 16px; }
  .link-button { font-size: .8rem; }
  .hero { grid-template-columns: 1fr; gap: 16px; }
  .hero-copy { padding-top: 18px; }
  h1 { font-size: clamp(2.25rem, 12vw, 4rem); }
  .hero-mark { min-height: 150px; flex-direction: row; align-items: center; gap: 20px; }
  .mark-number { font-size: 3.8rem; }
  .setup-head, .quiz-top, .review-head { display: block; }
  .stats { justify-content: flex-start; margin-top: 18px; }
  .controls { grid-template-columns: 1fr; }
  .question-card { padding: 24px 18px; }
  .quiz-actions { align-items: stretch; flex-direction: column; }
  .quiz-actions .action-group { width: 100%; }
  .quiz-actions .button { flex: 1; }
  .unanswered-note { order: 3; }
  .result-header { grid-template-columns: 1fr; text-align: center; padding: 24px 18px; }
  .result-actions { justify-content: center; }
  .summary-grid { gap: 8px; }
  .summary-box { padding: 13px 9px; text-align: center; }
  .summary-box strong { font-size: 1.3rem; }
  .summary-box span { font-size: .72rem; }
  .filter-tabs { margin-top: 14px; }
  .footer { width: min(100% - 28px, 620px); flex-wrap: wrap; }
  .share-dialog { padding: 26px 18px; }
  .share-field { flex-direction: column; }
  .share-field .button { width: 100%; }
}
