:root {
  --bg: #15110e; --surface: #221b16; --text: #f7efe8; --muted: #a8998c;
  --primary: #ff7a1a; --on-primary: #1c0f05; --accent: #ffd29a;
  --radius: 18px; --btn-radius: 999px;
  --font-head: 'Fraunces', Georgia, serif; --font-body: 'Outfit', system-ui, sans-serif;
  --line: color-mix(in srgb, var(--text) 12%, transparent);
  --soft: color-mix(in srgb, var(--text) 6%, transparent);
  --stage-bg: radial-gradient(120% 90% at 50% 35%, color-mix(in srgb, var(--surface) 80%, #fff 8%) 0%, var(--bg) 75%);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 15px; line-height: 1.4; overflow: hidden; }
[dir='rtl'] body, body[dir='rtl'] { font-family: var(--font-body), 'Cairo', 'Tajawal', sans-serif; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
svg { width: 1.15em; height: 1.15em; flex: none; }
[hidden] { display: none !important; }

.app { height: 100dvh; display: flex; flex-direction: column; }

/* ---------- cabecera ---------- */
.top { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: max(10px, env(safe-area-inset-top)) 16px 10px; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; text-align: start; min-width: 0; }
.brand strong { display: block; font-family: var(--font-head); font-size: 19px; font-weight: 600; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 62vw; }
.logo { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--surface); }
.top-actions { display: flex; gap: 8px; flex: none; }
.chip-btn { height: 36px; min-width: 44px; padding: 0 12px; border-radius: var(--btn-radius); background: var(--soft); border: 1px solid var(--line); font-weight: 600; font-size: 13px; }
.icon-btn { width: 36px; height: 36px; border-radius: var(--btn-radius); display: grid; place-items: center; background: var(--soft); border: 1px solid var(--line); }
.lang-pop { position: absolute; inset-inline-end: 16px; top: calc(100% - 4px); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 6px; box-shadow: 0 18px 40px rgb(0 0 0 / .35); display: grid; min-width: 150px; }
.lang-pop button { padding: 10px 12px; border-radius: 10px; text-align: start; display: flex; justify-content: space-between; gap: 12px; }
.lang-pop button:hover, .lang-pop button.on { background: var(--soft); }
.lang-pop button.on::after { content: '✓'; color: var(--primary); }

/* ---------- escenario 3D ---------- */
.layout { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.stage { position: relative; flex: 1 1 52%; min-height: 260px; margin: 0 12px; border-radius: calc(var(--radius) + 6px); overflow: hidden; background: var(--stage-bg); isolation: isolate; }
.stage.bg-color { background: var(--stage-color); }
.stage.bg-image { background: var(--stage-image) center/cover no-repeat, var(--bg); }
.stage.bg-image::before { content: ''; position: absolute; inset: 0; background: linear-gradient(to bottom, rgb(0 0 0 / .15), transparent 30%, transparent 65%, rgb(0 0 0 / .35)); z-index: 1; pointer-events: none; }
.stage.glow::after { content: ''; position: absolute; left: 10%; right: 10%; bottom: 14%; height: 26%; background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 22%, transparent), transparent); filter: blur(8px); z-index: -1; pointer-events: none; }
model-viewer { direction: ltr; width: 100%; height: 100%; --poster-color: transparent; background: transparent; outline: none; }
model-viewer::part(default-progress-bar) { display: none; }
.photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.progress { position: absolute; top: 0; left: 0; right: 0; height: 3px; z-index: 3; pointer-events: none; }
.progress span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .2s, opacity .4s; }
.loading-label { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; font-size: 13px; color: var(--muted); background: color-mix(in srgb, var(--bg) 70%, transparent); padding: 6px 12px; border-radius: 99px; pointer-events: none; }

.stage-top { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; z-index: 3; pointer-events: none; }
.stage-top > * { pointer-events: auto; }
.badge { background: var(--accent); color: #1a1208; font-size: 12px; font-weight: 700; padding: 6px 11px; border-radius: 99px; letter-spacing: .02em; }
.stage-tools { display: flex; gap: 8px; margin-inline-start: auto; }
.glass-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 40px; padding: 0 14px; border-radius: var(--btn-radius); background: color-mix(in srgb, var(--bg) 55%, transparent); border: 1px solid color-mix(in srgb, var(--text) 16%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); font-size: 13px; font-weight: 600; white-space: nowrap; }
.glass-btn.round { width: 40px; padding: 0; }
.glass-btn.on { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 45%, transparent); backdrop-filter: blur(10px); border: 1px solid color-mix(in srgb, var(--text) 12%, transparent); }
.nav.prev { inset-inline-start: 10px; } .nav.next { inset-inline-end: 10px; }
[dir='rtl'] .nav svg { transform: scaleX(-1); }
.stage-bar { position: absolute; left: 10px; right: 10px; bottom: 12px; z-index: 3; display: flex; justify-content: center; align-items: center; gap: 8px; }
.ar-btn { display: inline-flex; align-items: center; gap: 9px; height: 50px; padding: 0 22px; border-radius: var(--btn-radius); background: var(--primary); color: var(--on-primary); font-weight: 700; font-size: 15px; box-shadow: 0 10px 28px color-mix(in srgb, var(--primary) 45%, transparent); white-space: nowrap; }
.ar-btn svg { width: 1.35em; height: 1.35em; }
.ar-btn:active, .glass-btn:active { transform: scale(.97); }

/* ---------- panel inferior ---------- */
.panel { flex: 0 1 auto; max-height: 48%; overflow-y: auto; padding: 14px 16px max(14px, env(safe-area-inset-bottom)); scrollbar-width: none; }
.panel::-webkit-scrollbar { display: none; }
.dish-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.dish-title { min-width: 0; }
.dish-head h1 { font-family: var(--font-head); font-weight: 600; font-size: clamp(22px, 6vw, 30px); line-height: 1.1; margin: 0 0 5px; }
.dish-head p { margin: 0; color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dish-price { font-family: var(--font-head); font-size: 22px; font-weight: 700; color: var(--primary); white-space: nowrap; padding-top: 2px; }
.mini-allergens { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; min-height: 0; }
.mini-allergens span { font-size: 12px; padding: 3px 8px; border-radius: 99px; background: var(--soft); color: var(--muted); }

.cats { display: flex; gap: 8px; overflow-x: auto; margin: 14px -16px 10px; padding: 0 16px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cats button { flex: none; height: 36px; padding: 0 14px; border-radius: var(--btn-radius); background: var(--soft); border: 1px solid var(--line); font-size: 13.5px; font-weight: 600; color: var(--muted); }
.cats button.on { background: var(--text); color: var(--bg); border-color: transparent; }

.dishes { display: flex; gap: 10px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 4px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.dishes::-webkit-scrollbar { display: none; }
.card { flex: none; scroll-snap-align: start; width: 128px; text-align: start; border-radius: var(--radius); background: var(--surface); border: 1.5px solid transparent; padding: 8px 8px 10px; transition: border-color .2s, transform .2s; }
.card.on { border-color: var(--primary); }
.card .thumb { aspect-ratio: 1; border-radius: calc(var(--radius) - 6px); background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--text) 9%, transparent), transparent 70%); display: grid; place-items: center; overflow: hidden; }
.card .thumb img { width: 112%; height: 112%; object-fit: contain; }
.card .thumb img.cover { width: 100%; height: 100%; object-fit: cover; }
.card b { display: block; font-size: 13px; font-weight: 600; margin-top: 7px; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.4em; }
.card small { color: var(--primary); font-weight: 700; font-size: 13px; }
.card .is3d { font-size: 10px; font-weight: 700; color: var(--muted); float: inline-end; margin-top: 2px; }

/* estilo círculos */
.style-circles .card { background: none; width: 92px; padding: 0; text-align: center; border: 0; }
.style-circles .card .thumb { border-radius: 50%; background: var(--surface); border: 2px solid transparent; }
.style-circles .card.on .thumb { border-color: var(--primary); }
.style-circles .card .is3d { display: none; }
.style-circles .card b { min-height: 0; }
/* estilo minimal (solo texto) */
.style-minimal .card { width: auto; padding: 10px 14px; display: flex; gap: 10px; align-items: center; }
.style-minimal .card .thumb { width: 44px; flex: none; }
.style-minimal .card b { margin: 0; min-height: 0; white-space: nowrap; }
.style-minimal .card .is3d { display: none; }

/* ---------- hojas ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgb(0 0 0 / .5); animation: fade .2s; }
.sheet { position: relative; width: min(560px, 100%); max-height: 86dvh; overflow-y: auto; background: var(--surface); border-radius: 24px 24px 0 0; padding: 26px 20px max(22px, env(safe-area-inset-bottom)); animation: up .28s cubic-bezier(.2, .9, .3, 1); }
.sheet-x { position: absolute; top: 14px; inset-inline-end: 14px; }
.sheet h2 { font-family: var(--font-head); font-weight: 600; font-size: 24px; margin: 0 40px 6px 0; line-height: 1.15; }
[dir='rtl'] .sheet h2 { margin: 0 0 6px 40px; }
.sheet h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 0 8px; font-weight: 600; }
.sheet p { margin: 0; color: color-mix(in srgb, var(--text) 85%, transparent); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span { padding: 7px 11px; border-radius: 99px; background: var(--soft); border: 1px solid var(--line); font-size: 13.5px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.facts div { background: var(--soft); border-radius: 14px; padding: 10px; text-align: center; }
.facts b { display: block; font-size: 17px; font-family: var(--font-head); }
.facts small { color: var(--muted); font-size: 11.5px; }
.wa-btn { margin-top: 20px; width: 100%; height: 50px; border-radius: var(--btn-radius); background: #25d366; color: #052e14; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 9px; }
.howto { display: grid; gap: 10px; margin-top: 14px; }
.howto div { display: flex; gap: 14px; align-items: center; background: var(--soft); border-radius: 16px; padding: 12px 14px; }
.howto i { font-style: normal; width: 44px; height: 44px; border-radius: 12px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 800; font-size: 18px; flex: none; }
.howto b { display: block; } .howto small { color: var(--muted); }
.primary-btn { margin-top: 18px; width: 100%; height: 50px; border-radius: var(--btn-radius); background: var(--primary); color: var(--on-primary); font-weight: 700; }
.info-list { display: grid; gap: 4px; margin-top: 10px; }
.info-list a, .info-list div { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 12px; color: inherit; text-decoration: none; background: var(--soft); }
.info-list small { display: block; color: var(--muted); font-size: 12px; }
.qr { width: 220px; height: 220px; margin: 16px auto 4px; background: #fff; border-radius: 16px; padding: 12px; }
.qr img { width: 100%; height: 100%; }
.center { text-align: center; }

.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 99; transition: opacity .4s; }
.boot.off { opacity: 0; pointer-events: none; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- escritorio / tablet horizontal ---------- */
@media (min-width: 900px) {
  .layout { flex-direction: row; padding: 0 16px 16px; gap: 20px; }
  .stage { margin: 0; flex: 1 1 62%; }
  .panel { flex: 0 0 min(420px, 36%); max-height: none; padding: 6px 0 0; }
  .dish-head h1 { font-size: 34px; }
  .cats { margin: 18px 0 12px; padding: 0; flex-wrap: wrap; }
  .dishes { flex-wrap: wrap; margin: 0; padding: 0 0 8px; overflow: visible; }
  .card { width: calc(33.33% - 7px); }
  .style-circles .card { width: calc(25% - 8px); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- móvil estrecho ---------- */
@media (max-width: 520px) {
  .stage-bar { gap: 6px; left: 8px; right: 8px; }
  #resetBtn { width: 44px; padding: 0; }
  #resetBtn span { display: none; }
  #ingBtn { padding: 0 12px; }
  .ar-btn { height: 48px; padding: 0 18px; font-size: 14.5px; }
  .mini-allergens span b { display: none; }
  .mini-allergens span { padding: 3px 7px; font-size: 14px; }
  .card { width: 112px; }
  .dish-head p { font-size: 13.5px; }
}
@media (max-width: 360px) { #ingBtn span { display: none; } #ingBtn { width: 44px; padding: 0; } }
.cats, .dishes { position: relative; }
