:root {
  --paper: #F7F2EA;
  --surface: #FFFDF9;
  --header: #574639;
  --header-2: #6B5747;
  --on-header: #F7F2EA;
  --on-header-2: #D3C3AE;
  --ink: #241E1A;
  --ink-2: #6B6057;
  --ink-3: #8C8278;
  --hairline: #F0E8DB;
  --border: #E8DECF;
  --chip-border: #E2D7C6;
  --accent: #8A5F33;
  --brass: #D9BE95;
  --brass-2: #EBD9BD;
  --tile-bg: #EFE6D8;   --tile-fg: #6E4F2C;
  --in-bg: #E6EDE8;     --in-fg: #2F5244;
  --low-bg: #F3E7D5;    --low-fg: #7A5329;
  --out-bg: #ECE6DC;    --out-fg: #554C44;

  --radius: 16px;
  --radius-sm: 10px;
  --gap: 18px;
  --tabbar-h: 64px;
  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --font-brand: 'Rubik', var(--font);
  color-scheme: light;
}
:root[lang="en"] { --font: 'IBM Plex Sans', 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.55 var(--font);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
#app {
  max-width: 560px; margin: 0 auto; outline: none;
  padding-bottom: calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom));
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }
.skip { position: absolute; inset-inline-start: -999px; }
.skip:focus { inset-inline-start: 8px; top: 8px; z-index: 20; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
[dir="rtl"] .ico.flip { transform: scaleX(-1); }   /* back points right in Arabic */

.money { unicode-bidi: isolate; white-space: nowrap; }
.money .cur { font-weight: 500; font-size: .78em; }

/* ---------- brand ---------- */
.lockup { display: inline-flex; align-items: center; gap: 10px; color: var(--on-header); }
.wordmark { font: 800 40px/1 var(--font-brand); letter-spacing: -.5px; }
.glass { width: 36px; height: 41px; color: var(--brass); margin-top: 2px; }
.glass .spark { stroke: var(--brass-2); fill: none; }

/* ---------- home hero ---------- */
.hero {
  background: var(--header); color: var(--on-header);
  padding: calc(18px + env(safe-area-inset-top)) var(--gap) 48px;
}
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 22px; }
.loc {
  display: inline-flex; align-items: center; gap: 7px; min-height: 44px; min-width: 0;
  background: none; border: 0; padding: 0; color: var(--on-header-2); font-size: 13px; cursor: pointer; text-align: start;
}
.loc .ico { width: 15px; height: 15px; }
.loc-value { color: #FFFFFF; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-toggle {
  flex: none; min-height: 34px; border: 1px solid rgba(247, 242, 234, .35); background: transparent; color: var(--on-header);
  border-radius: 999px; padding: 4px 13px; font: 600 13px/1.2 var(--font); cursor: pointer;
}
.lang-toggle:hover { background: rgba(247, 242, 234, .1); }
.lang-toggle[lang="en"] { font-family: 'IBM Plex Sans', sans-serif; }
.tagline { margin-top: 14px; color: #DCCDB8; font-size: 13.5px; font-weight: 300; }

.hero-search { padding: 0 var(--gap); margin-top: -26px; position: relative; z-index: 2; }

/* ---------- search field ---------- */
.search {
  display: flex; align-items: center; gap: 11px;
  background: var(--surface); border: 1px solid #E6DCCD; border-radius: 15px;
  height: 54px; padding: 0 14px; color: var(--accent);
  box-shadow: 0 8px 22px rgba(87, 70, 57, .15);
}
.search .ico { width: 18px; height: 18px; stroke-width: 2.3; }
.search input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
  color: var(--ink); font-size: 15px; padding: 0;
}
.search input::placeholder { color: var(--ink-2); opacity: 1; }
.search:focus-within { border-color: var(--accent); }
.search.compact { height: 46px; border-radius: 13px; box-shadow: none; border: 0; flex: 1; min-width: 0; }

/* ---------- top bar (inner pages) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--header); color: var(--on-header);
  padding: calc(14px + env(safe-area-inset-top)) 16px 16px;
  display: flex; align-items: center; gap: 8px;
}
.topbar h1 { font-size: 15.5px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back {
  flex: none; width: 44px; height: 44px; margin-inline-start: -8px;
  border: 0; background: none; color: #E7DCCB; cursor: pointer;
  display: grid; place-items: center;
}

/* ---------- sections ---------- */
.section { padding: 22px var(--gap) 0; }
.section > h2, .section-head h2 { font-size: 12.5px; font-weight: 600; color: var(--ink-2); letter-spacing: .3px; margin-bottom: 12px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; }
.section-head a { font-size: 13px; font-weight: 500; color: var(--accent); }
.hero-search + .section { padding-top: 28px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-link {
  display: inline-flex; align-items: center; min-height: 38px; padding: 0 15px;
  border-radius: 19px; background: var(--surface); border: 1px solid var(--chip-border);
  font-size: 13.5px; color: var(--ink);
}
.chip-link:active { background: var(--tile-bg); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.group { overflow: hidden; }
.group > * + * { border-top: 1px solid var(--hairline); }
.list { display: grid; gap: 12px; }
.note {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  padding: 12px 14px; font-size: 13.5px; color: var(--ink-2);
}
.btn {
  flex: none; border: 1px solid #D8C9B2; background: var(--surface); color: #6B4A26;
  min-height: 40px; padding: 0 16px; border-radius: 12px; font-weight: 600; font-size: 13.5px; cursor: pointer;
}
.btn.primary { background: var(--header); border-color: var(--header); color: var(--on-header); }
.btn.block { display: block; width: 100%; min-height: 48px; }
.fineprint { display: flex; gap: 7px; align-items: flex-start; margin-top: 14px; font-size: 11.5px; color: var(--ink-2); line-height: 1.5; }
.fineprint .ico { width: 13px; height: 13px; margin-top: 2px; color: var(--ink-3); }

/* ---------- tiles ---------- */
.tile {
  flex: none; width: 42px; height: 42px; border-radius: 11px;
  background: var(--tile-bg); color: var(--tile-fg);
  display: grid; place-items: center; font-size: 15px; font-weight: 700;
}
.tile.sm { width: 38px; height: 38px; border-radius: 10px; font-size: 14px; }
.tile.lg { width: 80px; height: 80px; font-size: 30px; border-radius: 14px; }
.tile.muted { background: var(--out-bg); color: var(--ink-2); }
.tile.on-dark { width: 54px; height: 54px; border-radius: 14px; background: var(--header-2); color: #F0E3CF; font-size: 20px; }
.tile.photo { background: #fff; border: 1px solid var(--hairline); overflow: hidden; padding: 4px; }
.tile.photo img { width: 100%; height: 100%; object-fit: contain; }

/* ---------- availability ---------- */
.band, .badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  border-radius: 6px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.band.in_stock, .badge.in_stock { background: var(--in-bg); color: var(--in-fg); }
.band.low { background: var(--low-bg); color: var(--low-fg); }
.band.out, .badge.out { background: var(--out-bg); color: var(--out-fg); }
.badge { flex: none; height: 24px; padding: 0 9px; font-size: 11.5px; }

.stamp { color: var(--ink-2); }
.stale {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; color: var(--low-fg);
  border: 1px dashed var(--low-fg); border-radius: 999px; padding: 0 7px; white-space: nowrap;
}

/* ---------- shop rows ---------- */
.store-row { display: flex; align-items: center; gap: 13px; padding: 13px 14px; }
.store-row .body { flex: 1; min-width: 0; }
.store-row .name { font-size: 14.5px; font-weight: 600; }
.meta { font-size: 12px; color: var(--ink-2); }
.meta, .result h3, .pd-hero h2 { overflow-wrap: anywhere; }

/* ---------- result card ---------- */
.result { padding: 0; overflow: hidden; }
.result-head { display: flex; gap: 14px; align-items: center; padding: 14px; }
.result-head .body { flex: 1; min-width: 0; }
.result h3 { font-size: 15px; font-weight: 600; line-height: 1.35; }
.result .tile { width: 56px; height: 56px; border-radius: 12px; font-size: 22px; }
.from { flex: none; text-align: end; font-size: 11.5px; color: var(--ink-2); line-height: 1.3; }
.from b { display: block; font-size: 16px; color: var(--ink); font-weight: 700; margin-top: 2px; }
.result-offers { display: block; padding: 0 14px 6px; }
.avail-line { font-size: 13px; color: var(--ink); padding-bottom: 6px; }
.mini { list-style: none; margin: 0; padding: 0; }
.mini li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--hairline); }
.mini .who { flex: 1; min-width: 0; display: grid; }
.mini .store { font-size: 14px; font-weight: 600; }
.mini .stamp-line { font-size: 11.5px; color: var(--ink-2); }
.mini .end, .offer .end, .item .end { flex: none; display: grid; justify-items: end; gap: 4px; text-align: end; }
.mini .price, .offer .price { font-size: 14.5px; font-weight: 700; }
.mini li.is-out .store, .mini li.is-out .price { color: var(--ink-3); }

.sizes { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.section .sizes { padding-inline: 0; }
.size {
  border: 1px solid var(--chip-border); background: var(--surface); color: var(--ink);
  border-radius: 17px; min-height: 34px; padding: 0 13px; font: 500 12.5px/1.4 var(--font); cursor: pointer;
}
.size.on { background: var(--header); border-color: var(--header); color: var(--on-header); font-weight: 600; }
.size-prices { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; font-size: 12px; color: var(--ink-2); }
.size-prices .is-out { text-decoration: line-through; opacity: .7; }

/* ---------- product page ---------- */
.pd-hero { display: flex; gap: 16px; align-items: center; padding: 18px; }
.pd-hero .body { flex: 1; min-width: 0; }
.pd-hero h2 { font-size: 16.5px; font-weight: 600; line-height: 1.35; }
.pd-hero .meta { font-size: 13px; margin-top: 5px; }
.credit { font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.summary { display: flex; overflow: hidden; }
.summary .cell { flex: 1; padding: 15px 16px; min-width: 0; }
.summary .cell + .cell { border-inline-start: 1px solid var(--hairline); }
.summary .label { font-size: 11.5px; font-weight: 500; color: var(--ink-2); }
.summary .big { font-size: 19px; font-weight: 700; margin: 6px 0 3px; }
.summary .big.good { color: var(--in-fg); }
.offer { display: flex; align-items: center; gap: 12px; padding: 13px 14px; }
.offer .body { flex: 1; min-width: 0; }
.offer .name { font-size: 14.5px; font-weight: 600; }
.offer .meta { font-size: 11.5px; margin-top: 2px; }
.offer.is-out .name, .offer.is-out .price { color: var(--ink-3); }
.cheapest { font-size: 10.5px; font-weight: 700; color: var(--in-fg); background: var(--in-bg); padding: 1px 7px; border-radius: 6px; vertical-align: 1px; }

/* ---------- shop page ---------- */
.st-hero {
  background: var(--header); color: var(--on-header);
  padding: calc(12px + env(safe-area-inset-top)) var(--gap) 44px;
}
.st-hero .back { margin-bottom: 8px; margin-inline-start: -12px; }
.st-id { display: flex; align-items: center; gap: 14px; }
.st-id .body { flex: 1; min-width: 0; }
.st-id h1 { font-size: 22px; font-weight: 700; line-height: 1.25; }
.st-id .meta { color: var(--on-header-2); font-size: 12.5px; margin-top: 4px; }
.feed-pill {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 16px;
  min-height: 28px; padding: 0 11px; border-radius: 8px; background: var(--header-2);
  font-size: 11.5px; font-weight: 500; color: #EADFCD;
}
.feed-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: #9DC4AF; }
.feed-pill.is-stale .dot { background: #E0B98A; }
.st-hero + .hero-search { margin-top: -24px; }
.st-hero + .hero-search .search { height: 50px; border-radius: 14px; }
.banner {
  margin: 16px var(--gap) 0; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--low-bg); color: var(--low-fg); font-size: 13px; border: 1px dashed var(--low-fg);
}
.counts { display: flex; flex-wrap: wrap; gap: 8px; }
.cat { font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding: 16px 2px 10px; }
.items { overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; }
.item + .item { border-top: 1px solid var(--hairline); }
.item .tile { width: 44px; height: 44px; font-size: 16px; }
.item .body { flex: 1; min-width: 0; }
.item .name { font-size: 14px; font-weight: 600; line-height: 1.4; }
.item .price { font-size: 14.5px; font-weight: 700; }
.item .end small { font-weight: 500; color: var(--ink-2); font-size: 11px; }

/* ---------- bottom tabs ---------- */
.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 0 1 140px; min-height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--ink-2); font-size: 11px; font-weight: 500;
}
.tabbar a[aria-current="page"] { color: #7A5329; font-weight: 600; }

/* ---------- states ---------- */
.empty { padding: 40px var(--gap); text-align: center; color: var(--ink-2); }
.empty strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 6px; }
.skeleton { height: 92px; border-radius: var(--radius); background: linear-gradient(90deg, var(--hairline), var(--surface), var(--hairline)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
.mt { margin-top: 14px; }
