:root {
  --cream: #f7efdc;
  --paper: #fffaf0;
  --sand: #efe2c2;
  --ink: #3a2a12;
  --ink-soft: #7a6440;
  --gold: #c99a2e;
  --gold-deep: #94700f;
  --gold-light: #ecd07c;
  --line: #e0cd9f;
  --terracotta: #b4532a;
  --mat: #2f2414;
  --field: #ffffff;
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%23c99a2e' stroke-opacity='.16' stroke-width='1'%3E%3Crect x='24' y='24' width='24' height='24'/%3E%3Crect x='24' y='24' width='24' height='24' transform='rotate(45 36 36)'/%3E%3Cpath d='M0 36h12M60 36h12M36 0v12M36 60v12'/%3E%3C/g%3E%3C/svg%3E");
  --star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='20' viewBox='0 0 48 20'%3E%3Cg fill='%23c99a2e'%3E%3Crect x='19' y='5' width='10' height='10'/%3E%3Crect x='19' y='5' width='10' height='10' transform='rotate(45 24 10)'/%3E%3C/g%3E%3Cpath d='M0 10h15M33 10h15' stroke='%23c99a2e' stroke-width='1'/%3E%3C/svg%3E");
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --cream: #1d160c;
    --paper: #281f12;
    --sand: #33281a;
    --ink: #f4e7c9;
    --ink-soft: #c4ae83;
    --gold: #e0b54a;
    --gold-deep: #b98c22;
    --line: #4b3b20;
    --terracotta: #e07a4f;
    --mat: #120d06;
    --field: #17110a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--pattern) var(--cream);
  font-family: "Tajawal", "Segoe UI", Tahoma, sans-serif;
  font-size: 17px;
  line-height: 1.7;
}
h1, h2, .btn, .num, .seal { font-family: "Reem Kufi", "Tajawal", sans-serif; }

/* ---------- Brand bar ---------- */

.brandbar {
  max-width: 1040px;
  margin: 0 auto;
  padding: 18px 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand b { display: block; font-family: "Reem Kufi", sans-serif; font-size: 1.15rem; line-height: 1.1; }
.brand small { display: block; font-size: .78rem; font-weight: 700; letter-spacing: .12em; color: var(--gold-deep); }
.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-family: "Reem Kufi", sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: #3a2a12;
  position: relative;
  isolation: isolate;
}
/* Gold diamond behind the letter, echoing the star pattern. */
.brand-mark::before {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: -1;
  border-radius: 5px;
  background: linear-gradient(135deg, var(--gold-light), var(--gold) 60%, var(--gold-deep));
  transform: rotate(45deg);
}
.fb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .88rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  border: 1.5px solid var(--gold);
  border-radius: 999px;
  padding: 4px 14px 4px 10px;
  transition: background .15s;
}
.fb:hover { background: color-mix(in srgb, var(--gold) 16%, transparent); }
.fb svg { width: 18px; height: 18px; fill: var(--gold-deep); }
footer a { color: var(--gold-deep); font-weight: 700; }

/* ---------- Hero ---------- */

.hero {
  max-width: 1040px;
  margin: 0 auto;
  padding: 30px 20px 28px;
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 32px;
  align-items: center;
}
.kicker {
  display: inline-block;
  font-weight: 700;
  font-size: .9rem;
  color: var(--gold-deep);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 2px;
  letter-spacing: .02em;
}
.hero h1 {
  margin: 14px 0 12px;
  font-size: clamp(2.3rem, 6vw, 3.6rem);
  line-height: 1.15;
  font-weight: 700;
}
.hero h1 span {
  display: block;
  background: linear-gradient(100deg, var(--gold-deep), var(--gold) 45%, var(--gold-light) 60%, var(--gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lead { margin: 0 0 14px; color: var(--ink-soft); font-size: 1.1rem; max-width: 34em; }
.uses { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.uses li {
  font-size: .88rem;
  font-weight: 700;
  padding: 3px 12px;
  color: var(--gold-deep);
  background: var(--paper);
  border: 1px dashed var(--gold);
  border-radius: 4px;
}
.promise {
  margin: 0;
  padding: 10px 14px;
  border-inline-start: 4px solid var(--gold);
  background: color-mix(in srgb, var(--gold) 10%, transparent);
  max-width: 34em;
}

.hero-art { position: relative; height: 300px; }
.print {
  position: absolute;
  width: 140px;
  height: 180px;
  background: #fff;
  padding: 9px 9px 30px;
  box-shadow: 0 12px 24px rgba(58, 42, 18, .18), 0 2px 4px rgba(58, 42, 18, .12);
}
.print::before { content: ""; display: block; height: 100%; background: #e8eef0; }
.print i, .print b { position: absolute; left: 50%; transform: translateX(-50%); background: #3a2a12; }
.print i { top: 34px; width: 48px; height: 56px; border-radius: 50% 50% 46% 46%; }
.print b { top: 92px; width: 100px; height: 49px; border-radius: 50px 50px 0 0; }
.print::after {
  content: "";
  position: absolute;
  left: 22px; right: 22px; bottom: 12px;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
}
.p1 { top: 40px; right: 0; transform: rotate(7deg); }
.p1::before { background: #f3e3c3; }
.p1 i, .p1 b { background: #8a5a2b; }
.p2 { top: 10px; right: 120px; transform: rotate(-5deg); z-index: 1; }
.p2 i, .p2 b { background: #1f1a14; }
.p3 { top: 90px; right: 230px; transform: rotate(3deg); }
.p3::before { background: #e6e1ea; }
.p3 i, .p3 b { background: #f4f1ea; box-shadow: inset 0 0 0 2px #d9d2c4; }
.seal {
  position: absolute;
  bottom: 6px;
  right: 70px;
  z-index: 2;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: grid;
  place-content: center;
  text-align: center;
  color: #3a2a12;
  background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold) 55%, var(--gold-deep));
  box-shadow: 0 0 0 5px var(--cream), 0 0 0 6px var(--gold), 0 10px 22px rgba(58, 42, 18, .25);
  transform: rotate(-14deg);
}
.seal strong { font-size: 2.2rem; line-height: 1; }
.seal small { font-family: "Tajawal", sans-serif; font-weight: 700; font-size: .78rem; line-height: 1.25; }

.ornament { height: 20px; max-width: 1040px; margin: 0 auto; background: var(--star) center / auto 20px repeat-x; opacity: .85; }
.ornament.small { max-width: 240px; }

/* ---------- Steps ---------- */

main { max-width: 1040px; margin: 0 auto; padding: 8px 20px 24px; }
.step {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px 24px;
  padding: 34px 0;
  border-bottom: 1px dashed var(--line);
}
.step[hidden] { display: none; }
.num {
  font-size: 4.6rem;
  line-height: .9;
  font-weight: 700;
  text-align: center;
  color: transparent;
  -webkit-text-stroke: 2px var(--gold);
}
.step h2 { margin: 6px 0 16px; font-size: 1.7rem; font-weight: 700; }

.drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 34px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--paper);
  border: 2px dashed var(--gold);
  transition: background .2s, transform .2s;
}
.drop:hover, .drop.over { background: color-mix(in srgb, var(--gold) 12%, var(--paper)); }
.drop.over { transform: scale(1.01); }
.drop strong { font-family: "Reem Kufi", sans-serif; font-size: 1.35rem; color: var(--gold-deep); }
.drop span { color: var(--ink-soft); }
.drop em { margin-top: 8px; font-style: normal; font-size: .8rem; color: var(--ink-soft); letter-spacing: .04em; }
.scissors {
  position: absolute;
  top: -17px;
  right: 24px;
  font-size: 1.6rem;
  color: var(--gold-deep) !important;
  background: var(--cream);
  padding: 0 6px;
  line-height: 1.2;
  transition: right 1.2s ease-in-out;
}
.drop:hover .scissors { right: calc(100% - 64px); }
.camera { margin-top: 14px; }

/* Settings: each choice is a framed panel, like a box on a printed form, with its title on the frame. */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 18px; }
.panel {
  margin: 0;
  min-width: 0;
  padding: 14px 18px 18px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 12px;
}
.panel.wide { grid-column: 1 / -1; }
.panel legend {
  padding: 0 10px;
  font-family: "Reem Kufi", sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--gold-deep);
}
.panel-note { margin: 12px 0 0; color: var(--ink-soft); font-size: .92rem; }
.panel-note[hidden] { display: none; }

/* Picture-type tiles: pick one, the chosen tile gets a gold frame and a check mark. */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tile {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 14px;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  background: var(--cream);
  border: 2px solid var(--line);
  border-radius: 10px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.tile input { position: absolute; opacity: 0; }
.tile strong { font-size: 1.08rem; }
.tile small { grid-column: 2; color: var(--ink-soft); font-size: .9rem; }
.tile-icon {
  grid-row: span 2;
  width: 58px;
  height: 46px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 5px;
  background: #fff;
  border: 1px solid #e3d6b6;
  box-shadow: 0 2px 5px rgba(58, 42, 18, .12);
  transform: rotate(-3deg);
}
.tile-icon.one { width: 40px; height: 50px; grid-template-columns: 1fr; margin-inline: 9px; transform: rotate(3deg); }
.tile-icon i { background: #b39a6b; border-radius: 2px; }
.tile:hover { border-color: var(--gold); }
.tile:has(input:checked) {
  border-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 14%, var(--paper));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 22%, transparent);
}
.tile:has(input:checked)::after {
  content: "✓";
  position: absolute;
  top: -11px;
  left: -11px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 700;
  color: #3a2a12;
  background: var(--gold);
  box-shadow: 0 0 0 3px var(--paper);
}
.tile:has(input:focus-visible) { outline: 2px solid var(--gold-deep); outline-offset: 3px; }

/* Number boxes: big, centred digits with the unit underneath. */
.stepper { display: flex; align-items: stretch; gap: 10px; }
.step-btn {
  flex: none;
  width: 54px;
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  color: var(--gold-deep);
  background: var(--cream);
  border: 1.5px solid var(--gold);
  border-radius: 10px;
}
.step-btn:hover { background: color-mix(in srgb, var(--gold) 18%, var(--cream)); }
.step-btn:active { transform: scale(.95); }
.number {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 10px 8px;
  background: var(--field);
  border: 2px solid var(--gold);
  border-radius: 10px;
  cursor: text;
}
.number:focus-within { box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 28%, transparent); }
.number input {
  width: 100%;
  padding: 0;
  text-align: center;
  font-family: "Reem Kufi", sans-serif;
  font-size: 2.3rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}
.number input::-webkit-inner-spin-button, .number input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.number span { font-size: .82rem; font-weight: 700; color: var(--ink-soft); }
.number.small input { font-size: 1.7rem; }

.chips { display: flex; gap: 8px; margin-top: 14px; }
.chip {
  flex: 1;
  padding: 5px 0;
  cursor: pointer;
  font-family: "Reem Kufi", sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: 999px;
}
.chip:hover { border-color: var(--gold); }
.chip.on { color: var(--paper); background: var(--ink); border-color: var(--ink); }

/* Two-way switch for the size choice. */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--sand); border-radius: 10px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented span {
  display: block;
  padding: 10px 6px;
  text-align: center;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink-soft);
  border-radius: 7px;
  transition: background .15s, color .15s;
}
.segmented input:checked + span { color: var(--ink); background: var(--paper); box-shadow: 0 1px 3px rgba(0, 0, 0, .15), inset 0 -3px 0 var(--gold); }
.segmented input:focus-visible + span { outline: 2px solid var(--gold-deep); }
.custom-size { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.custom-size[hidden] { display: none; }
.times { font-size: 1.6rem; color: var(--gold-deep); }

.toggle-row { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; cursor: pointer; }
.toggle-row strong { display: block; font-size: 1.05rem; }
.toggle-row small { color: var(--ink-soft); font-size: .9rem; }
.toggle { position: relative; display: inline-flex; flex: none; }
.toggle input { position: absolute; opacity: 0; }
.toggle span {
  position: relative;
  width: 46px; height: 26px;
  flex: none;
  border-radius: 13px;
  background: var(--sand);
  border: 1px solid var(--line);
  transition: background .2s;
}
.toggle span::after {
  content: "";
  position: absolute;
  top: 3px; right: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: right .2s;
}
.toggle input:checked + span { background: var(--gold); border-color: var(--gold-deep); }
.toggle input:checked + span::after { right: 23px; }
.toggle input:focus-visible + span { outline: 2px solid var(--gold-deep); outline-offset: 2px; }

/* ---------- Buttons ---------- */

.btn {
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 20px;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  transition: background .15s, transform .1s;
}
.btn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary {
  font-size: 1.2rem;
  padding: 12px 34px;
  color: #3a2a12;
  border: 1px solid var(--gold-deep);
  border-radius: 6px;
  background: linear-gradient(180deg, #f6dc8c, #d8aa3c 55%, #bf8f22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 4px 0 #7d5d0c, 0 8px 16px rgba(58, 42, 18, .2);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.primary:active:not(:disabled) { transform: translateY(3px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 1px 0 #7d5d0c; }
.btn.danger { color: var(--terracotta); border-color: var(--terracotta); }
.btn.small { font-size: .82rem; padding: 4px 12px; border-width: 1px; }
.actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 22px; align-items: center; }

/* ---------- Sheet editor ---------- */

.tips { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 22px; color: var(--ink-soft); font-size: .95rem; }
.tips li::before { content: "◆"; color: var(--gold); margin-inline-end: 6px; font-size: .7rem; vertical-align: middle; }
.tips b { color: var(--ink); }
.sheet { margin-bottom: 22px; }
.sheet-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 10px; }
.sheet-head .title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.sheet-head .count {
  font-family: "Reem Kufi", sans-serif;
  font-weight: 700;
  font-size: .9rem;
  padding: 1px 12px;
  color: var(--gold-deep);
  border: 1.5px solid var(--gold);
  border-radius: 4px;
  transform: rotate(-3deg);
}
.sheet-head .tools { display: flex; flex-wrap: wrap; gap: 6px; margin-inline-start: auto; }
/* The sheet sits on a dark "light table" so the paper stands out. */
.canvas-wrap {
  display: flex;
  justify-content: center;
  padding: 14px;
  background: var(--mat);
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(201, 154, 46, .35), inset 0 0 40px rgba(0, 0, 0, .5);
}
.canvas-wrap canvas { touch-action: none; cursor: crosshair; max-width: 100%; box-shadow: 0 6px 18px rgba(0, 0, 0, .5); }

/* ---------- Results ---------- */

.status { font-family: "Reem Kufi", sans-serif; font-weight: 700; font-size: 1.15rem; color: var(--gold-deep); margin: 0 0 6px; }
.note { margin: 0 0 18px; color: var(--ink-soft); }
.stale {
  display: inline-block;
  margin: 0 0 14px;
  padding: 8px 16px;
  color: #5a3d06;
  background: #f6e3a4;
  box-shadow: 0 2px 6px rgba(58, 42, 18, .15);
  transform: rotate(-1deg);
}
.stale[hidden] { display: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 26px 20px; padding: 6px 4px; }
.grid.dim { opacity: .45; }
/* Each result looks like a printed passport photo with the name handwritten underneath. */
.result {
  background: #fff;
  padding: 8px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 8px 18px rgba(58, 42, 18, .16), 0 1px 3px rgba(58, 42, 18, .2);
  transform: rotate(var(--tilt, 0deg));
  transition: transform .2s, box-shadow .2s;
}
.result:nth-child(4n+1) { --tilt: -1.6deg; }
.result:nth-child(4n+2) { --tilt: 1.2deg; }
.result:nth-child(4n+3) { --tilt: -.6deg; }
.result:nth-child(4n) { --tilt: 1.8deg; }
.result:hover, .result:focus-within { transform: rotate(0) translateY(-4px); box-shadow: 0 14px 26px rgba(58, 42, 18, .22); }
.result img { width: 100%; aspect-ratio: 3 / 4; object-fit: contain; background: #f4efe4; }
.result input {
  font-family: "Aref Ruqaa", serif;
  font-size: 1.15rem;
  text-align: center;
  color: #2a1e0c;
  background: transparent;
  border: 0;
  border-bottom: 1.5px dashed #c9b27a;
  padding: 2px 0 0;
  width: 100%;
  outline: none;
}
.result input::placeholder { color: #b5a37c; }
.result input:focus { border-bottom-color: var(--gold-deep); }
.result .meta { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; color: #8a7652; }
.result a { color: #94700f; font-weight: 700; text-decoration: none; }
.result a:hover { text-decoration: underline; }

footer { text-align: center; color: var(--ink-soft); font-size: .9rem; padding: 26px 20px 40px; }
footer p { margin: 10px 0 0; }
footer .copyright { margin-top: 14px; font-size: .85rem; letter-spacing: .02em; }
footer .copyright b { font-family: "Reem Kufi", sans-serif; color: var(--gold-deep); font-size: 1rem; }

/* ---------- Small screens ---------- */

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; padding-top: 28px; gap: 8px; }
  .hero-art { height: 220px; max-width: 360px; margin: 0 auto; width: 100%; transform: scale(.78); transform-origin: top center; }
  .p1 { right: 0; } .p2 { right: 100px; } .p3 { right: 200px; }
  .seal { right: 40px; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .hero, main { padding-left: 16px; padding-right: 16px; }
  .step { grid-template-columns: 1fr; padding: 26px 0; position: relative; }
  .num { position: absolute; top: 14px; left: 0; font-size: 3.6rem; opacity: .7; }
  .step h2 { margin-top: 0; }
  .canvas-wrap { padding: 8px; }
  .actions .btn { flex: 1; }
  .form, .tiles { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 20px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
