@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,560;9..144,650&family=Noto+Naskh+Arabic:wght@500;600&family=Outfit:wght@400;500;600&display=swap");

:root {
  --bg: #16130f;
  --bg-2: #221e19;
  --bg-3: #2c261f;
  --ink: #f3eee6;
  --muted: #b3a89a;
  --line: rgba(243, 238, 230, 0.14);
  --accent: #e25b2a;
  --accent-ink: #1a120e;
  --paper: #c8c1b6;
  --good: #d5e2a4;
  --warn: #ffd7c4;
  --danger: #ffb4a8;
  --shadow: 0 24px 50px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
  font-family: Outfit, "Noto Naskh Arabic", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: radial-gradient(1200px 600px at 10% -10%, #3a2418 0%, transparent 55%), var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { max-width: 100%; }
h1, h2 { font-family: Fraunces, "Noto Naskh Arabic", Georgia, serif; font-weight: 560; letter-spacing: -0.03em; }
h1 { font-size: clamp(2.2rem, 4vw, 3.6rem); line-height: 1.05; margin: 0.2rem 0 0.8rem; }
h2 { font-size: 1.3rem; margin: 0.4rem 0; }
p { margin: 0.4rem 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.kicker {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.lede { font-size: 1.05rem; color: var(--ink); max-width: 38rem; }
.help { color: var(--muted); font-size: 0.92rem; }
.help.center { text-align: center; max-width: 36rem; margin: 12px auto 0; }
.tiny { color: var(--muted); font-size: 0.78rem; word-break: break-all; }
.price { color: var(--accent); font-family: Fraunces, Georgia, serif; font-size: 1.5rem; margin: 0; }

.btn, button.btn, a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 0.72rem 1.15rem;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  font-weight: 600;
}
.btn.ghost, a.btn.ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}
.btn.danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px rgba(255, 180, 168, 0.45); }
.btn:hover { filter: brightness(1.05); }

.top {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(22, 19, 15, 0.9);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.mark {
  width: 22px; height: 22px; border-radius: 6px;
  box-shadow: inset 0 0 0 2px var(--accent);
  position: relative;
}
.mark::after {
  content: "";
  position: absolute; inset: 6px;
  border-radius: 99px;
  background: var(--ink);
}
.brand-name { font-family: Fraunces, Georgia, serif; font-size: 1.25rem; }
.venue { color: var(--muted); font-size: 0.92rem; }
.nav { display: flex; gap: 8px; margin-left: 8px; }
.nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 999px; }
.nav a[aria-current="page"] { color: var(--ink); background: var(--bg-3); }
.out { margin-left: auto; }
.out button { background: transparent; border: 0; color: var(--muted); padding: 6px 8px; }

.banner, .warn {
  margin: 12px 18px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(226, 91, 42, 0.16);
  color: var(--warn);
}
.share .warn { margin: 8px 0; }

.studio {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: calc(100vh - 57px);
  min-height: 0;
}
.studio.has-piece { grid-template-columns: 280px minmax(0, 1fr) 330px; }
.rail, .controls, .stage-col { min-height: 0; overflow: auto; }
.rail, .controls { padding: 16px; border-right: 1px solid var(--line); }
.controls { border-right: 0; border-left: 1px solid var(--line); background: rgba(0, 0, 0, 0.15); }
.stage-col { padding: 16px 18px 28px; }

.create, .stack { display: grid; gap: 10px; }
.stack.wide { max-width: 640px; }
label { display: grid; gap: 6px; font-size: 0.86rem; color: var(--muted); }
input[type="text"], input[type="password"], input[type="url"], input[type="search"], input[type="number"], select, textarea {
  width: 100%;
  background: #100e0c;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
}
textarea { min-height: 84px; resize: vertical; }
.filter { margin-top: 16px; }
.pieces { list-style: none; padding: 8px 0 0; margin: 0; display: grid; gap: 6px; }
.piece {
  display: grid;
  gap: 2px;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 12px;
  background: transparent;
}
.piece.is-on, .piece:hover { background: var(--bg-3); }
.piece-title { color: var(--ink); }
.piece-meta { color: var(--muted); font-size: 0.8rem; }

.welcome { max-width: 40rem; padding: 6vh 4vw; }
.uses { padding-left: 1.1rem; color: var(--ink); }
.uses li { margin: 0.35rem 0; }

.identity {
  display: grid;
  grid-template-columns: 1.4fr 0.6fr 0.7fr;
  gap: 10px;
  margin-bottom: 14px;
}
.identity .span { grid-column: 1 / -1; }
.file-row { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.file-row p { margin: 0; color: var(--muted); }

.vitrine-frame {
  width: min(100%, calc(74vh * 9 / 16));
  margin: 0 auto;
  padding: 14px 14px 16px;
  background: linear-gradient(180deg, #3a332c, #241f1a);
  border-radius: 32px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.frame-cap {
  margin: 0 0 8px;
  text-align: center;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: #d9c7b4;
}
.viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 20px;
  overflow: hidden;
  background: var(--paper);
  touch-action: none;
}
.viewport canvas { width: 100%; height: 100%; display: block; }
.empty-model {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: #3c342c;
  pointer-events: none;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.4rem;
}
.empty-model[hidden] { display: none; }
.progress {
  position: absolute; left: 16px; right: 16px; bottom: 16px;
  height: 6px; border-radius: 99px; background: rgba(0,0,0,.25); overflow: hidden;
}
.progress span { display: block; height: 100%; width: 0; background: var(--accent); }
.vitrine-frame.dropping { outline: 2px solid var(--accent); }

.readout {
  position: sticky; top: 0; z-index: 2;
  padding: 10px 0 12px;
  background: linear-gradient(#1a1612, rgba(26, 22, 18, 0.92) 70%, transparent);
  font-family: Fraunces, Georgia, serif;
  font-size: 1.35rem;
}
.controls section { margin: 16px 0 20px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg-btn, .chips button {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
}
.seg-btn.is-on, .chips button:hover { background: var(--ink); color: var(--accent-ink); border-color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5.6rem;
  gap: 6px 8px;
  align-items: center;
  margin: 10px 0;
}
.field span { grid-column: 1 / -1; display: flex; justify-content: space-between; color: var(--muted); font-size: 0.86rem; }
.field output { color: var(--ink); }
.field input[type="number"] { width: 5.6rem; padding: 8px; }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 2px; background: rgba(243, 238, 230, 0.28);
  border-radius: 99px; padding: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--ink); border: 2px solid var(--accent); cursor: pointer;
}
.check { display: flex; grid-template-columns: none; align-items: center; gap: 8px; color: var(--ink); margin: 8px 0; }
.check input { width: auto; accent-color: var(--accent); }
.share { padding-bottom: 24px; }
.link-line {
  font-size: 0.82rem; word-break: break-all;
  padding: 10px; border-radius: 10px; background: #100e0c; border: 1px solid var(--line);
}
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.qr { width: min(220px, 100%); background: white; border-radius: 12px; padding: 8px; }
.save { color: var(--good); font-size: 0.85rem; }
.save.bad { color: var(--danger); }
.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--accent-ink);
  padding: 10px 14px; border-radius: 999px; z-index: 20;
}
.toast.bad { background: #3a1814; color: var(--danger); }

.gate, .sheet { max-width: 720px; margin: 0 auto; padding: 8vh 22px 48px; }
.sheet { max-width: 760px; }

.guest-wrap {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  min-height: 100vh;
  padding: 28px;
}
.guest-copy .kicker + .kicker { margin-top: 8px; }
.gestures { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 14px 0 0; list-style: none; }
.gestures li {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 0.88rem;
}
.launch { margin-top: 18px; min-height: 52px; font-size: 1.05rem; }
.stage-tools { width: min(100%, calc(74vh * 9 / 16)); margin: 12px auto 0; text-align: center; }
.ar-status, .phone-ar, .phone-ar-bar { display: none; }
html.ar-launching .ar-status {
  display: grid;
  position: fixed;
  inset: 0;
  z-index: 50;
  place-items: center;
  margin: 0;
  background: #16130f;
  color: #f3eee6;
  font-size: 1.25rem;
}
html.show-phone-ar .guest-wrap { display: none !important; }
html.show-phone-ar .phone-ar {
  display: block;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 40;
  background: #111;
}
html.show-phone-ar .phone-ar-bar {
  display: flex;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72), transparent);
  color: #f3eee6;
}
html.show-phone-ar .phone-ar-bar p { margin: 0; font-family: Fraunces, Georgia, serif; font-size: 1.2rem; }

body.paper { background: #e7e1d8; color: #1c1915; color-scheme: light; }
.card-sheet {
  width: min(440px, calc(100% - 32px));
  margin: 32px auto;
  background: white;
  color: #1c1915;
  padding: 28px 24px 32px;
  text-align: center;
  border-radius: 18px;
}
.card-sheet h1 { font-size: 2.2rem; }
.card-sheet img { width: min(320px, 100%); margin: 12px auto; }
.no-print { margin-top: 16px; }

body.ar-body { margin: 0; height: 100%; background: #000; overflow: hidden; }
body.ar-body a-scene { position: fixed; inset: 0; }
body.ar-body canvas { touch-action: none; }
#booting {
  position: fixed; inset: 0; margin: 0;
  display: grid; place-items: center;
  background: #000; color: #f3eee6;
  z-index: 1;
}
.hud { position: fixed; inset: 0; z-index: 8; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; }
.hud-top, .hud-bottom {
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0,0,0,.45), transparent);
}
.hud-top { padding-top: calc(12px + env(safe-area-inset-top)); background: linear-gradient(to bottom, rgba(0,0,0,.45), transparent); }
.hud-brand, .hud-title, #gestureHint { margin: 0; text-shadow: 0 1px 8px rgba(0,0,0,.6); }
.hud-brand { font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: #f3eee6; }
.hud-title { font-family: Fraunces, Georgia, serif; font-size: 1.35rem; }
#gestureHint { color: #f3eee6; font-size: 0.92rem; margin-top: 8px; }
.hud button {
  pointer-events: auto;
  background: rgba(22, 19, 15, 0.72);
  color: #f3eee6;
  border: 1px solid rgba(243, 238, 230, 0.3);
  border-radius: 999px;
  padding: 8px 12px;
}
.ar-fail {
  position: fixed; inset: 0; z-index: 12;
  display: grid; place-items: center; align-content: center; gap: 14px;
  padding: 24px; text-align: center; background: rgba(12, 10, 8, 0.88); color: #f3eee6;
}
.ar-fail[hidden] { display: none; }

@media (max-width: 1100px) {
  .studio, .studio.has-piece { grid-template-columns: 1fr; height: auto; }
  .rail, .controls { border: 0; }
  .identity { grid-template-columns: 1fr; }
  .guest-wrap { grid-template-columns: 1fr; }
  .vitrine-frame, .stage-tools { width: min(100%, 460px); }
}
@media (max-width: 720px) {
  .top { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; }
  .out { margin-left: 0; }
}
@media print {
  body.paper { background: white; }
  .no-print { display: none !important; }
  .card-sheet { margin: 0; width: 100%; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
