@font-face {
  font-family: "Cairo";
  src: url("assets/cairo-regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Cairo";
  src: url("assets/cairo-semibold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Cairo";
  src: url("assets/cairo-bold.ttf") format("truetype");
  font-weight: 700 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #292723;
  --muted: #716b63;
  --forest: #332d2b;
  --green: #946a38;
  --mint: #eee3d4;
  --mint-pale: #f7f3ed;
  --sand: #f6f1e8;
  --amber: #b36b18;
  --amber-pale: #fff4df;
  --line: #e6dfd5;
  --panel: #ffffff;
  --canvas: #faf9f6;
  --shadow: 0 18px 50px rgba(22, 53, 48, .09);
  --radius-lg: 22px;
  --radius-md: 15px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Cairo", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.is-hidden { display: none !important; }
.skip-link { position: fixed; top: 8px; right: 8px; z-index: 100; padding: 8px 14px; background: #fff; color: var(--forest); transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }

.topbar {
  height: 76px;
  padding: 0 clamp(20px, 5vw, 74px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: rgba(255, 255, 255, .93);
  border-bottom: 1px solid rgba(23, 63, 58, .09);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--forest); text-decoration: none; }
.brand-mark { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 12px; color: #fff; background: var(--forest); }
.brand-mark svg { width: 25px; height: 25px; }
.brand span:last-child { display: grid; line-height: 1.35; }
.brand strong { font-size: 14px; font-weight: 800; }
.brand small { font-size: 10px; color: var(--muted); }
.top-actions { display: flex; gap: 8px; }
.ghost-button, .icon-button, .text-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--forest);
  border-radius: 10px;
  cursor: pointer;
  transition: .18s ease;
}
.ghost-button { min-height: 40px; padding: 7px 13px; display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-size: 12px; }
.ghost-button svg, .icon-button svg { width: 18px; height: 18px; }
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; }
.ghost-button:hover, .icon-button:hover { background: var(--mint-pale); border-color: #d0c8bb; transform: translateY(-1px); }

.hero {
  padding: 58px clamp(20px, 6vw, 88px) 52px;
  color: #fff;
  background:
    linear-gradient(100deg, rgba(10, 47, 43, .98), rgba(20, 76, 67, .95)),
    radial-gradient(circle at 15% 20%, #72644e 0, transparent 34%);
  position: relative;
  overflow: hidden;
}
.hero::before, .hero::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.08); border-radius: 50%; pointer-events: none; }
.hero::before { width: 390px; height: 390px; left: -130px; top: -220px; }
.hero::after { width: 510px; height: 510px; left: 4%; bottom: -470px; }
.eyebrow-row { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; position: relative; z-index: 1; }
.eyebrow, .status-pill, .review-pill { border-radius: 999px; font-size: 10px; font-weight: 700; padding: 5px 10px; }
.eyebrow { color: #dad3c9; background: rgba(180, 237, 220, .12); border: 1px solid rgba(180, 237, 220, .22); letter-spacing: .03em; }
.status-pill, .review-pill { color: #e6e2db; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; }
.status-pill i { width: 6px; height: 6px; border-radius: 50%; background: #b6a894; box-shadow: 0 0 0 4px rgba(102,228,168,.13); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(290px, .55fr); gap: clamp(40px, 8vw, 110px); align-items: end; max-width: 1440px; margin: 26px auto 0; position: relative; z-index: 1; }
.hero h1 { margin: 0; font-size: clamp(31px, 4.1vw, 55px); line-height: 1.35; letter-spacing: -.035em; max-width: 900px; }
.hero h1 em { color: #dad3c9; font-style: normal; }
.hero p { max-width: 760px; margin: 17px 0 0; color: rgba(235, 246, 243, .75); font-size: clamp(13px, 1.25vw, 16px); }
.priority-card { display: flex; gap: 15px; padding: 18px; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.07); border-radius: 15px; backdrop-filter: blur(8px); }
.priority-number { color: #c0b4a3; font-size: 11px; border-left: 1px solid rgba(255,255,255,.15); padding-left: 14px; }
.priority-card strong { font-size: 13px; }
.priority-card p { margin: 6px 0 0; font-size: 11px; line-height: 1.7; }

.explorer { max-width: 1510px; margin: -1px auto 0; padding: 34px clamp(18px, 4vw, 60px) 64px; display: grid; grid-template-columns: minmax(340px, .73fr) minmax(540px, 1.27fr); gap: 24px; align-items: start; }
.input-panel, .results-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.input-panel { padding: 25px; position: sticky; top: 96px; }
.results-panel { padding: 25px; min-height: 730px; }
.panel-heading, .result-header, .layer-heading, .section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.step-label, .micro-label { display: block; color: var(--green); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.panel-heading h2, .result-header h2, .section-heading h2 { margin: 3px 0 0; font-size: 22px; line-height: 1.35; }
.text-button { border: 0; color: var(--green); padding: 5px; font-size: 11px; font-weight: 700; }
.text-button:hover { color: var(--ink); }
fieldset { border: 0; padding: 0; margin: 22px 0 0; }
legend { width: 100%; font-size: 11px; font-weight: 800; margin-bottom: 8px; }
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.type-option { cursor: pointer; position: relative; }
.type-option input { position: absolute; opacity: 0; pointer-events: none; }
.type-option > span { min-height: 86px; padding: 12px 11px; display: grid; grid-template-columns: 27px 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 8px; border: 1px solid var(--line); border-radius: 12px; transition: .18s ease; }
.type-option svg { width: 26px; height: 26px; grid-row: 1/3; color: #918778; }
.type-option b { font-size: 11px; line-height: 1.4; }
.type-option small { color: var(--muted); font-size: 9px; }
.type-option input:checked + span { color: var(--forest); background: var(--mint-pale); border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.type-option input:checked + span svg { color: var(--green); }
.type-option input:focus-visible + span { outline: 3px solid rgba(30,103,92,.2); outline-offset: 2px; }

.field-grid { display: grid; gap: 10px; margin-top: 16px; }
.field-grid.two { grid-template-columns: 1fr 1fr; }
.field-grid.three { grid-template-columns: repeat(3, 1fr); }
.field-grid .full { grid-column: 1 / -1; }
.field { display: grid; gap: 5px; }
.field > span { color: #5b5244; font-size: 10px; font-weight: 700; }
.field > span b { color: var(--muted); font-weight: 500; }
.field > span small { color: #918b83; font-size: 8px; margin-right: 4px; }
.field input { width: 100%; min-width: 0; height: 42px; padding: 0 12px; color: var(--ink); background: #fcfcfb; border: 1px solid var(--line); border-radius: 10px; outline: 0; font-size: 13px; direction: rtl; transition: .15s ease; }
.field input::placeholder { color: #b4b0a9; font-size: 10px; }
.field input:focus { background: #fff; border-color: var(--green); box-shadow: 0 0 0 3px rgba(30,103,92,.09); }
.switch-row, .switch-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer; }
.switch-row { margin-top: 13px; }
.switch-row span, .switch-card span { display: grid; line-height: 1.5; }
.switch-row b, .switch-card b { font-size: 10px; }
.switch-row small, .switch-card small { color: var(--muted); font-size: 9px; }
.switch-row input, .switch-card input { position: absolute; opacity: 0; }
.switch-row i, .switch-card i { width: 35px; height: 20px; flex: 0 0 auto; border-radius: 999px; background: #dddad6; position: relative; transition: .2s ease; }
.switch-row i::after, .switch-card i::after { content: ""; width: 14px; height: 14px; position: absolute; top: 3px; right: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: .2s ease; }
.switch-row input:checked + i, .switch-card input:checked + i { background: var(--green); }
.switch-row input:checked + i::after, .switch-card input:checked + i::after { transform: translateX(-15px); }
.switch-row input:focus-visible + i, .switch-card input:focus-visible + i { outline: 3px solid rgba(30,103,92,.22); }
.switch-card { padding: 12px; border: 1px solid var(--line); border-radius: 11px; }

.riyadh-layer { margin-top: 20px; padding: 16px; background: linear-gradient(145deg, #f6f4f1, #fdfcfb); border: 1px solid #dfd9d0; border-radius: 15px; }
.layer-heading { align-items: center; }
.layer-icon { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; color: var(--green); background: #e7e3dc; border-radius: 10px; }
.layer-icon svg { width: 19px; height: 19px; }
.layer-heading > div { margin-left: auto; }
.layer-heading h3 { margin: 0; font-size: 14px; }
.map-link { color: var(--green); font-size: 9px; font-weight: 800; text-decoration: none; }
.map-link:hover { text-decoration: underline; }
.layer-note { margin: 11px 0 0; color: #756d61; font-size: 9px; line-height: 1.75; }
.compact-fields { margin-top: 12px; }
.special-switch { padding-top: 12px; border-top: 1px solid #e5e1da; }
.override-panel { margin-top: 12px; padding-top: 11px; border-top: 1px solid #e5e1da; }
.override-panel > p { margin: 0; color: #7d766b; font-size: 9px; }
.override-panel .field-grid { margin-top: 10px; }
.override-panel > .field { margin-top: 10px; }

.result-state { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border-radius: 999px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.result-state i { width: 7px; height: 7px; border-radius: 50%; }
.result-state.preliminary { color: #8b5815; background: var(--amber-pale); }
.result-state.preliminary i { background: #d18a2e; }
.result-state.parcel { color: #443b2e; background: var(--mint); }
.result-state.parcel i { background: #6e604b; }
.decision-banner { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 12px; margin-top: 20px; padding: 14px 16px; border-radius: 13px; }
.decision-banner.preliminary { background: var(--amber-pale); border: 1px solid #f0d9ae; color: #73501e; }
.decision-banner.parcel { background: var(--mint-pale); border: 1px solid #ddd7cd; color: #473e31; }
.decision-banner svg { width: 23px; height: 23px; }
.decision-banner strong { font-size: 11px; }
.decision-banner p { margin: 2px 0 0; font-size: 9px; opacity: .8; }
.decision-banner a { font-size: 9px; font-weight: 800; text-decoration: none; white-space: nowrap; }
.decision-banner a:hover { text-decoration: underline; }
.result-tabs { margin-top: 22px; display: flex; gap: 4px; padding: 4px; background: #f5f4f2; border-radius: 11px; }
.result-tabs button { flex: 1; min-height: 37px; border: 0; border-radius: 8px; color: #7c766c; background: transparent; font-size: 10px; font-weight: 800; cursor: pointer; }
.result-tabs button.active { color: var(--forest); background: #fff; box-shadow: 0 2px 8px rgba(25,58,52,.08); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: panel-in .2s ease both; }
@keyframes panel-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.metric-card { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #fff; position: relative; overflow: hidden; }
.metric-card.primary { background: linear-gradient(150deg, #f5f3f1, #fff); border-color: #dad3c8; }
.metric-card.primary::after { content: ""; width: 56px; height: 56px; position: absolute; left: -24px; top: -25px; border-radius: 50%; border: 11px solid rgba(30,103,92,.07); }
.metric-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; color: #6e6659; font-size: 10px; font-weight: 700; }
.source-badge { padding: 2px 6px; color: #756958; background: #f2f0ee; border-radius: 999px; font-size: 7px; font-weight: 800; white-space: nowrap; }
.source-badge.riyadh { color: #fff; background: var(--green); }
.metric-card > strong { display: block; margin-top: 15px; color: var(--forest); font-size: clamp(25px, 3vw, 35px); line-height: 1.15; letter-spacing: -.03em; }
.metric-card > strong small { color: #908575; font-size: 10px; letter-spacing: 0; }
.metric-card p { margin: 8px 0 0; color: #857f77; font-size: 9px; line-height: 1.6; }
.metric-card p b { color: var(--green); }
.annex-base-control { margin-top: 10px; min-height: 59px; padding: 10px 14px; display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; border: 1px dashed #d8d3cc; border-radius: 12px; background: #fcfcfb; }
.annex-base-control > div { display: grid; }
.annex-base-control strong { font-size: 10px; }
.annex-base-control label { display: flex; align-items: center; direction: ltr; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.annex-base-control input { width: 90px; height: 34px; border: 0; outline: 0; padding: 0 8px; direction: rtl; text-align: right; color: var(--ink); font-weight: 700; }
.annex-base-control label span { padding: 0 8px; color: var(--muted); font-size: 9px; }
.annex-base-control button { border: 0; background: transparent; color: var(--green); font-size: 9px; font-weight: 800; cursor: pointer; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 15px; }
.detail-card { padding: 15px; border: 1px solid var(--line); border-radius: 13px; }
.detail-card header { display: flex; align-items: center; gap: 9px; }
.detail-card h3 { margin: 0; font-size: 11px; }
.number-icon { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; color: var(--green); background: var(--mint-pale); font-size: 8px; font-weight: 800; }
.detail-card p { margin: 9px 0 0; color: #767066; font-size: 9px; line-height: 1.8; }
.villa-setback-diagram {
  width: min(100%, 310px);
  min-height: 190px;
  margin: 18px auto 0;
  padding: 34px 58px;
  display: grid;
  place-items: center;
  position: relative;
  color: var(--forest);
  background: #faf9f8;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.building-shape {
  width: 112px;
  height: 88px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--green);
  border-bottom: 6px solid var(--forest);
  border-right: 6px solid var(--forest);
  border-radius: 4px 0 4px 0;
  font-size: 14px;
  font-weight: 800;
}
.edge { position: absolute; color: #71695d; font-size: 12px; font-weight: 700; }
.edge-top { top: 8px; right: 50%; transform: translateX(50%); }
.edge-bottom { bottom: 8px; right: 50%; transform: translateX(50%); color: #9a5e17; }
.edge-right { right: 8px; top: 50%; transform: translateY(-50%) rotate(90deg); color: #9a5e17; }
.edge-left { left: 8px; top: 50%; transform: translateY(-50%) rotate(-90deg); }
.diagram-note { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; text-align: center; }
.override-note { margin-top: 9px; padding: 8px; color: #463d30; background: var(--mint-pale); border-radius: 8px; font-size: 8px; font-weight: 700; }
.formula-strip { margin-top: 15px; padding: 12px 14px; display: flex; align-items: center; gap: 18px; background: #f7f6f5; border-radius: 11px; }
.formula-strip > span { color: #756f65; font-size: 8px; font-weight: 800; white-space: nowrap; }
.formula-strip ol { flex: 1; margin: 0; padding: 0; list-style: none; display: flex; align-items: center; }
.formula-strip li { flex: 1; color: #89837a; font-size: 8px; text-align: center; position: relative; }
.formula-strip li:not(:last-child)::after { content: "←"; position: absolute; left: -3px; color: #aba69e; }
.formula-strip li.active { color: var(--green); font-weight: 800; }
.parking-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px; margin-top: 14px; padding: 18px; color: #fff; background: var(--forest); border-radius: 15px; }
.parking-visual { width: 86px; display: flex; align-items: center; gap: 8px; color: #d4ccc1; }
.parking-visual span { width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.35); border-radius: 5px; font-size: 12px; font-weight: 800; }
.parking-visual svg { width: 50px; }
.parking-card h3 { margin: 2px 0 0; font-size: 24px; line-height: 1.3; }
.parking-card p { margin: 2px 0 0; color: #cbc4b9; font-size: 8px; }
.parking-rule { max-width: 190px; padding-right: 15px; border-right: 1px solid rgba(255,255,255,.15); display: grid; }
.parking-rule span { color: #aea494; font-size: 7px; }
.parking-rule strong { margin-top: 3px; font-size: 8px; line-height: 1.7; }
.requirements-list { display: grid; gap: 9px; margin-top: 17px; }
.requirements-list article { display: flex; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; }
.check-icon { width: 25px; height: 25px; flex: 0 0 auto; display: grid; place-items: center; color: var(--green); background: var(--mint-pale); border-radius: 50%; font-size: 10px; font-weight: 800; }
.requirements-list h3 { margin: 0; font-size: 11px; }
.requirements-list p { margin: 3px 0 0; color: #797268; font-size: 9px; }
.service-warning { margin-top: 12px; padding: 13px 15px; color: #79551e; background: var(--amber-pale); border: 1px solid #eed8af; border-radius: 12px; font-size: 9px; }
.source-line { margin-top: 17px; padding-top: 13px; display: flex; justify-content: space-between; gap: 14px; color: #8a847c; border-top: 1px solid var(--line); font-size: 8px; }
.source-line a { color: var(--green); font-weight: 800; text-decoration: none; }

.sources { padding: 65px clamp(20px, 6vw, 88px); background: #fff; border-top: 1px solid var(--line); }
.section-heading { max-width: 1380px; margin: 0 auto; }
.section-heading p { max-width: 470px; margin: 0; color: var(--muted); font-size: 11px; }
.source-grid { max-width: 1380px; margin: 25px auto 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; }
.source-card { min-height: 155px; padding: 17px; display: grid; grid-template-columns: auto 1fr auto; gap: 11px; align-items: start; color: var(--ink); border: 1px solid var(--line); border-radius: 15px; text-decoration: none; transition: .18s ease; }
.source-card:hover { border-color: #c1b5a4; box-shadow: 0 12px 30px rgba(27,67,59,.08); transform: translateY(-2px); }
.source-card.featured { background: var(--forest); color: #fff; border-color: var(--forest); }
.source-index { color: #8e816e; font-size: 9px; font-weight: 800; }
.source-card small { color: #908677; font-size: 8px; }
.source-card.featured small, .source-card.featured .source-index { color: #c5baa9; }
.source-card h3 { margin: 6px 0 0; font-size: 12px; line-height: 1.6; }
.source-card p { margin: 8px 0 0; color: #807a70; font-size: 8px; line-height: 1.7; }
.source-card.featured p { color: #d1c9bc; }
.source-card > b { color: #90826e; }
.source-card.featured > b { color: #d0c8bb; }
.caveat-grid { max-width: 1380px; margin: 15px auto 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; }
.caveat-grid article { padding: 17px; background: #f8f7f6; border-radius: 13px; }
.caveat-grid strong { font-size: 10px; }
.caveat-grid p { margin: 6px 0 0; color: #7c766d; font-size: 8px; line-height: 1.75; }
footer { padding: 20px clamp(20px, 6vw, 88px); display: flex; justify-content: space-between; color: #89837b; background: #f2f0ee; font-size: 8px; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 24px; padding: 10px 18px; color: #fff; background: var(--forest); border-radius: 999px; font-size: 10px; font-weight: 700; box-shadow: var(--shadow); transform: translate(-50%, 25px); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 1050px) {
  .hero-grid { grid-template-columns: 1fr; gap: 28px; }
  .priority-card { max-width: 520px; }
  .explorer { grid-template-columns: 1fr; }
  .input-panel { position: static; }
  .source-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
  .topbar { height: 66px; padding: 0 14px; }
  .brand small, .ghost-button { display: none; }
  .hero { padding: 38px 18px 44px; }
  .hero h1 br { display: none; }
  .eyebrow-row { gap: 4px; }
  .review-pill { display: none; }
  .priority-card { padding: 14px; }
  .explorer { padding: 16px 10px 40px; gap: 13px; }
  .input-panel, .results-panel { padding: 16px; border-radius: 17px; }
  .field-grid.three { grid-template-columns: 1fr 1fr; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; align-items: end; }
  .metric-card .metric-top { grid-column: 1 / -1; }
  .metric-card > strong { margin-top: 10px; }
  .metric-card p { text-align: left; }
  .annex-base-control { grid-template-columns: 1fr auto; }
  .annex-base-control button { grid-column: 1 / -1; text-align: right; }
  .detail-grid { grid-template-columns: 1fr; }
  .formula-strip { display: block; overflow-x: auto; }
  .formula-strip ol { min-width: 430px; margin-top: 8px; }
  .parking-card { grid-template-columns: auto 1fr; }
  .parking-rule { grid-column: 1 / -1; max-width: none; padding: 10px 0 0; border-right: 0; border-top: 1px solid rgba(255,255,255,.15); }
  .source-line { display: grid; }
  .source-grid, .caveat-grid { grid-template-columns: 1fr; }
  .section-heading { display: grid; }
  .section-heading p { margin-top: 8px; }
  footer { display: grid; text-align: center; justify-content: center; }
}

@media (max-width: 430px) {
  .brand strong { font-size: 12px; }
  .type-grid, .field-grid.two, .field-grid.three { grid-template-columns: 1fr; }
  .type-option > span { min-height: 67px; }
  .decision-banner { grid-template-columns: 24px 1fr; }
  .decision-banner a { grid-column: 2; }
  .result-tabs { overflow-x: auto; }
  .result-tabs button { min-width: 110px; }
  .panel-heading h2, .result-header h2 { font-size: 18px; }
}

@media print {
  body { background: #fff; }
  .topbar, .hero, .input-panel, .result-tabs, .source-line, .sources, footer, .toast { display: none !important; }
  .explorer { display: block; padding: 0; }
  .results-panel { box-shadow: none; border: 0; padding: 0; }
  .tab-panel { display: block !important; break-inside: avoid; }
  .tab-panel + .tab-panel { margin-top: 20px; }
  .decision-banner, .metric-card, .detail-card, .parking-card, .requirements-list article { break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* مقاسات قراءة عملية للاستخدام الهندسي */
.brand strong { font-size: 16px; }
.brand small, .eyebrow, .status-pill, .review-pill, .source-line, footer { font-size: 12px; }
.ghost-button, .text-button, .map-link { font-size: 13px; }
.hero p { font-size: clamp(15px, 1.25vw, 17px); }
.priority-card strong { font-size: 15px; }
.priority-card p, .layer-note, .override-panel > p, .section-heading p { font-size: 13px; }
.step-label, .micro-label, .formula-strip > span { font-size: 12px; }
legend, .type-option b, .switch-row b, .switch-card b { font-size: 14px; }
.type-option small, .switch-row small, .switch-card small, .field > span small { font-size: 12px; }
.field > span, .metric-top, .annex-base-control strong { font-size: 14px; }
.field input { font-size: 16px; }
.field input::placeholder { font-size: 13px; }
.result-state, .decision-banner p, .decision-banner a, .metric-card p, .annex-base-control label span, .annex-base-control button { font-size: 13px; }
.decision-banner strong, .detail-card h3, .requirements-list h3 { font-size: 15px; }
.result-tabs button, .detail-card p, .requirements-list p, .service-warning { font-size: 14px; }
.source-badge, .number-icon, .parking-card p, .parking-rule strong, .parking-rule span, .source-index, .source-card small { font-size: 11px; }
.formula-strip li, .source-card p, .caveat-grid p { font-size: 13px; }
.source-card h3 { font-size: 16px; }
.caveat-grid strong { font-size: 14px; }

/* The supplied villa summary is the active ruleset. */
.hero-source { display: inline-block; margin-top: 10px; color: #e7e2db; font-size: 13px; }
.priority-number { font-size: 22px; }
.input-panel { position: static; }
.type-option > span { grid-template-columns: 1fr; gap: 4px; min-height: 78px; }
.field small, .field-help { font-size: 12px; color: var(--muted); line-height: 1.8; }
.field-help { margin: 10px 0; }
.field select { width: 100%; min-width: 0; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; background: #fcfcfb; color: var(--ink); font: inherit; font-size: 14px; }
.field select:focus-visible { outline: 3px solid #d6cfc4; }
.field input[aria-invalid="true"] { border-color: #af4933; }
.metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
.metric-top { flex-wrap: wrap; }
.metric-top .source-badge { font-size: 10px; }
.metric-card p a { text-decoration-color: #c8c0b4; text-underline-offset: 3px; }
.calculation-note { padding: 10px 13px; margin: 10px 0 0; background: #f6f4f1; border-radius: 10px; font-size: 13px; }
.inline-note { color: #8b5815 !important; }
.annex-base-control { grid-template-columns: minmax(0,1fr) auto; }
.annex-base-control button { grid-column: 1/-1; text-align: right; }
.checks-section { margin-top: 23px; padding-top: 16px; border-top: 1px solid var(--line); }
.checks-section h3 { font-size: 16px; margin: 0; }
.check-row { display: flex; gap: 9px; align-items: baseline; padding: 9px 12px; margin-top: 7px; border-radius: 9px; font-size: 13px; background: #f5f3f0; }
.check-row.review { background: #fff4df; color: #78511f; }
.check-row.fail { background: #fff0eb; color: #963c27; }
.check-row .check-label { flex: 0 0 auto; font-weight: 700; }
#warningsList { padding-right: 20px; font-size: 13px; color: #73501e; }
#warningsList li { margin-top: 8px; }
#inputErrors ul { margin: 5px 0; padding-right: 20px; }
.result-header { flex-wrap: wrap; }
.villa-setback-diagram { margin-top: 28px; width: min(100%,310px); padding: 42px 58px; }
.edge { font-size: 11px; white-space: nowrap; }
.rulebook-tools { max-width: 1380px; margin: 30px auto 20px; display: grid; grid-template-columns: 2fr 1fr auto; gap: 14px; align-items: end; }
#ruleCount { font-size: 13px; color: var(--muted); padding-bottom: 10px; }
.rulebook { max-width: 1380px; margin: auto; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.rule-card { border: 1px solid var(--line); border-radius: 13px; padding: 17px; scroll-margin-top: 95px; }
.rule-card:target { outline: 3px solid #ae9f88; background: #f9f8f6; }
.rule-card header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.rule-card h3 { font-size: 15px; margin: 7px 0; }
.rule-card p { font-size: 14px; color: #6b6357; line-height: 1.9; margin: 0; }
.rule-card header a, .rule-category { font-size: 12px; color: #776c5c; }
.rule-status { display: inline-block; margin-top: 9px; padding: 2px 8px; border-radius: 5px; font-size: 11px; background: #fff1d5; color: #78511f; }
.source-grid .source-card { min-width: 0; }
.source-grid .source-card p { overflow-wrap: anywhere; }
#noRules { text-align: center; }
button:disabled { opacity: .55; cursor: not-allowed; }
@media (max-width:680px) {
  .rulebook { grid-template-columns: 1fr; }
  .rulebook-tools { grid-template-columns: 1fr; }
  .result-state { white-space: normal; }
  .metric-card { display: block; }
  .metric-card p { text-align: right; }
  .setbacks-grid { grid-template-columns: 1fr; }
}
@media (max-width:430px) {
  .metric-grid { grid-template-columns: 1fr; }
  .decision-banner { grid-template-columns: 24px minmax(0,1fr); }
  .check-row { display: block; }
  .check-row .check-label { display: block; }
}
@media print {
  .results-panel { font-size: 12px; }
  .checks-section, .calculation-note { break-inside: avoid; }
  .field-help { display: block; }
  .annex-base-control button { display: none; }
  .source-line { display: block !important; }
  .source-line a { display: none; }
  .metric-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
}

@media (max-width:680px) {
  .topbar .ghost-button { display: flex; font-size: 12px; padding: 6px 9px; }
  .top-actions { flex-shrink: 0; }
  .brand strong { font-size: 14px; }
}
@media (max-width:430px) {
  .brand-mark { display: none; }
  .brand strong { font-size: 12px; }
}
.input-panel, .results-panel { min-width: 0; }
.hero h1 em { display: block; }
.hero h1 br { display: none; }
@media (max-width:1050px) { .explorer { grid-template-columns: minmax(0,1fr); } }

/* Keep the visit focused on project inputs and results. */
.hero { padding-top: 30px; padding-bottom: 34px; }
.hero-grid { margin-top: 18px; }
.hero h1 { font-size: clamp(28px, 3.4vw, 46px); }
.decision-banner { grid-template-columns: 26px minmax(0,1fr); }
.extra-settings { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 15px; }
.extra-settings > summary { color: var(--green); font-size: 14px; font-weight: 700; cursor: pointer; }
.extra-settings .riyadh-layer { margin-top: 12px; }
@media (max-width:680px) { .hero { padding: 28px 18px; } }

/* Company profile: warm white, charcoal and architectural gold. */
:root { --ink:#292723; --forest:#332d2b; --green:#946a38; --muted:#716b63; --mint:#eee3d4; --mint-pale:#f6f2eb; --line:#e5dfd6; --canvas:#faf9f6; --shadow:0 12px 36px rgba(51,45,43,.045); }
.topbar { border-bottom-color:var(--line); }
.company-mark { width:49px; height:49px; object-fit:contain; }
.hero { background:#f4f1eb; color:var(--ink); border-bottom:1px solid var(--line); }
.hero::before,.hero::after { border-color:#ded2bf; border-radius:0; transform:rotate(45deg); }
.hero h1 { font-weight:700; letter-spacing:-.025em; }
.hero h1 em { color:#a57844; }
.hero p { color:#716b63; }
.eyebrow { color:#936936; background:#ece2d3; border-color:#dfcdb4; }
.status-pill,.review-pill { color:#6c6255; }
.status-pill i { background:#b18b56; box-shadow:0 0 0 4px #e8ddce; }
.priority-card { background:#ffffff80; border-color:#e1d8ca; align-items:center; }
.hero-mark { width:74px; height:74px; }
.result-state.parcel { color:#73512c; background:#efe5d6; }
.decision-banner.parcel { border-color:#e3d6c4; color:#57452f; }
.metric-card.primary { background:linear-gradient(150deg,#f5eee3,#fff); border-color:#dfcfb6; }
.parking-card .micro-label { color:#d4b78f; }
input[type=number] { direction:ltr; text-align:right; font-variant-numeric:tabular-nums; }
.plan-jump { display:inline-block; color:#946a38; font-weight:700; margin:8px 0; }
.plan-workspace { max-width:1390px; margin:0 auto 64px; padding:36px; background:#fff; border:1px solid var(--line); border-radius:22px; scroll-margin-top:90px; }
.plan-heading { display:flex; justify-content:space-between; align-items:center; gap:20px; }
.plan-heading h2 { font-size:36px; margin:3px 0; }
.plan-heading p { color:var(--muted); margin:0; }
.plan-controls { display:grid; grid-template-columns:1fr 1.3fr 1.5fr auto; gap:16px; align-items:end; padding:24px 0; margin-top:15px; border-top:1px solid var(--line); }
.plan-controls .ghost-button { min-height:44px; }
.plan-intro { color:var(--muted); font-size:14px; background:#f6f2eb; padding:12px 16px; border-radius:10px; }
.plan-layout { display:grid; grid-template-columns:minmax(0,1fr) 280px; gap:26px; align-items:start; }
.plan-sheet { background:#fff; border:1px solid var(--line); border-radius:14px; min-width:0; padding:12px; overflow:auto; }
#floorPlan { min-height:260px; }
#floorPlan>svg { display:block; width:100%; height:auto; min-width:520px; fill:initial; stroke:initial; stroke-width:initial; stroke-linecap:initial; stroke-linejoin:initial; }
.plan-details { background:#f9f7f2; border-radius:14px; padding:20px; }
.plan-details h3 { font-size:17px; border-top:1px solid var(--line); padding-top:18px; }
#planStats>strong { font-size:36px; color:#946a38; display:block; }
#planStats small { font-size:14px; }
#planStats p { font-size:12px; color:var(--muted); }
#planStats dl { margin:10px 0; font-size:12px; }
#planStats dl>div { display:flex; justify-content:space-between; gap:10px; padding:7px 0; border-top:1px solid var(--line); }
#planStats dd { margin:0; white-space:nowrap; }
.room-row { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:6px; margin-top:10px; }
.room-row input { width:100%; min-width:0; border:1px solid #e2d8ca; border-radius:6px; background:#fff; padding:5px 8px; font-size:12px; }
.room-row span { font-size:11px; color:var(--muted); direction:ltr; white-space:nowrap; }
.plan-footnote { color:var(--muted); font-size:12px; margin:22px 0 0; }
#roomSplit { accent-color:#a57844; padding:0; }
@media(max-width:1050px){.plan-workspace{margin:0 18px 40px;padding:24px}.plan-layout{grid-template-columns:minmax(0,1fr) 240px}.plan-controls{grid-template-columns:1fr 1fr}}
@media(max-width:680px){.company-mark{width:38px;height:38px}.brand strong{font-size:13px}.brand small{display:block;font-size:9px}.plan-workspace{margin:0 10px 30px;padding:16px}.plan-heading{display:block}.plan-heading h2{font-size:28px}.plan-heading>a{margin-top:12px}.plan-controls{grid-template-columns:1fr;gap:12px}.plan-layout{grid-template-columns:minmax(0,1fr)}.plan-sheet{padding:0}.plan-details{padding:16px}.hero-mark{width:55px;height:55px}}
@media print{.plan-workspace{break-before:page;border:0;padding:0;margin:0}.plan-controls,.plan-heading>a,.plan-details .field,.plan-footnote{display:none}.plan-layout{grid-template-columns:minmax(0,1fr) 210px}.plan-sheet{overflow:visible}#floorPlan>svg{min-width:0}.room-row input{border:0}.plan-workspace *{-webkit-print-color-adjust:exact;print-color-adjust:exact}}
/* Top-align fields so helper text cannot shift the neighbouring input. */
.field { align-content:start; }
.field-grid { align-items:start; }
.plan-actions { display:flex; gap:8px; flex-wrap:wrap; }
.plan-actions .ghost-button { justify-content:center; }
#floorPlan>svg { min-width:0; }
.plan-sheet.zoomed #floorPlan>svg { min-width:950px; }
@media(max-width:680px){.plan-actions .ghost-button{flex:1}.plan-sheet.zoomed #floorPlan>svg{min-width:700px}}
@media print{.plan-sheet.zoomed #floorPlan>svg{min-width:0}}
@media(max-width:680px){.plan-actions .ghost-button,.plan-heading>.ghost-button{display:inline-flex}}
/* Parcel dimensions and massing plans. */
.derived-area { display:grid; grid-template-columns:1fr auto; align-items:center; gap:4px 14px; padding:13px 15px; background:#f5f0e7; border:1px solid #e5d8c4; border-radius:12px; }
.derived-area>span { font-size:13px; font-weight:700; }.derived-area strong { color:#946a38; font-size:24px; }.derived-area strong small{font-size:12px}.derived-area>small{grid-column:1/-1;color:var(--muted);font-size:11px}
.total-building-card { display:grid; grid-template-columns:auto minmax(0,1fr); gap:22px; align-items:center; padding:20px; background:#332d2b; color:#fff; border-radius:16px; margin-top:16px; }
.total-building-card>div>span { display:block; font-size:14px; color:#e0c7a4; }.total-building-card strong { display:block;font-size:37px;line-height:1.4 }.total-building-card strong small{font-size:14px;font-weight:400}.total-building-card p{font-size:12px;line-height:1.9;color:#ddd4c8;margin:0}
.plan-controls { grid-template-columns:1fr 1.3fr auto; }.plan-layout{grid-template-columns:minmax(0,1fr) 300px}
.floor-overview{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin:20px 0}.floor-overview button{font:inherit;cursor:pointer;text-align:right;border:1px solid var(--line);background:#fff;border-radius:12px;padding:14px 18px;color:var(--ink)}.floor-overview button.selected{background:#f4eee4;border-color:#ae8b5c}.floor-overview span{font-size:13px;display:block}.floor-overview strong{display:block;font-size:26px;color:#946a38}.floor-overview small{font-size:12px;font-weight:400}
.plan-legend{display:flex;flex-wrap:wrap;justify-content:center;gap:12px 18px;padding:14px 8px;border-top:1px solid var(--line);font-size:11px;color:var(--muted)}.plan-legend span{display:flex;align-items:center;gap:7px}.plan-legend i{display:inline-block;width:20px;height:12px}.mass-key{background:#e9ddca;border:1px solid #6f5535}.ghost-key{border:1px dashed #9f9b93}.envelope-key{border:1px dashed #c4ac89}.projection-key{background:#c3975c}
@media(max-width:1050px){.plan-controls{grid-template-columns:1fr 1fr}.plan-actions{grid-column:1/-1}.plan-layout{grid-template-columns:minmax(0,1fr) 250px}}
@media(max-width:680px){.plan-controls,.plan-layout{grid-template-columns:minmax(0,1fr)}.total-building-card{grid-template-columns:1fr;gap:10px}.floor-overview{gap:6px}.floor-overview button{padding:10px 8px}.floor-overview span{font-size:11px}.floor-overview strong{font-size:21px}}
@media print{.floor-overview{display:none}.total-building-card{break-inside:avoid;-webkit-print-color-adjust:exact;print-color-adjust:exact}.plan-layout{grid-template-columns:minmax(0,1fr) 220px}}
