:root {
  --deep: #082824;
  --forest: #0b3b35;
  --mint: #b9ddc0;
  --lime: #dceba8;
  --gold: #e9c56a;
  --cream: #f7f0dc;
  --paper: #fffaf0;
  --ink: #17332e;
  --mono: "DM Mono", monospace;
  --soft: "Nunito", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--deep); color-scheme: dark; }
body { margin: 0; background: var(--deep); color: var(--cream); font: 600 1rem/1.5 var(--soft); }
button, a { font: inherit; }
a { color: inherit; }
main { min-height: 100dvh; overflow: hidden; }

.topbar {
  height: 78px;
  padding: 0 clamp(1rem, 4vw, 4rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(247, 240, 220, .14);
}
.brand { display: inline-flex; align-items: center; gap: .75rem; text-decoration: none; font: 500 .9rem var(--mono); letter-spacing: .14em; }
.brand small { display: block; margin-top: .1rem; color: var(--mint); font-size: .58rem; letter-spacing: .18em; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 9px; background: var(--gold); color: var(--deep); box-shadow: 3px 3px 0 var(--mint); font-weight: 800; }
.prototype-badge { padding: .45rem .65rem; border: 1px solid rgba(185, 221, 192, .38); border-radius: 99px; color: var(--mint); font: 500 .63rem var(--mono); letter-spacing: .12em; }

.viewer-shell { min-height: calc(100dvh - 78px); position: relative; display: grid; grid-template-columns: minmax(280px, 39%) 1fr; }
.viewer-copy { grid-column: 1; grid-row: 1; z-index: 2; padding: clamp(3rem, 8vh, 6.5rem) clamp(1.5rem, 4vw, 4.5rem) 2.5rem; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; }
.eyebrow { color: var(--gold); font: 500 .7rem var(--mono); letter-spacing: .16em; }
h1 { margin: 1.1rem 0; font-size: clamp(3.3rem, 7.8vw, 7.6rem); line-height: .8; letter-spacing: -.07em; }
h1 em { color: var(--mint); font-family: Georgia, serif; font-weight: 400; }
.instructions { color: rgba(247, 240, 220, .62); font-size: .9rem; }
.viewer-status { display: flex; align-items: center; gap: .65rem; color: var(--mint); font: 500 .68rem var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.status-light { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 5px rgba(233, 197, 106, .14); }
.viewer-status.ready .status-light { background: #8de69e; box-shadow: 0 0 0 5px rgba(141, 230, 158, .14); }

model-viewer { grid-column: 1 / -1; grid-row: 1; width: 100%; height: calc(100dvh - 78px); min-height: 620px; background: radial-gradient(circle at 68% 42%, #23685d 0, var(--forest) 35%, var(--deep) 72%); --progress-bar-color: var(--gold); --poster-color: transparent; }
.loading { width: 100%; height: 100%; display: grid; place-content: center; justify-items: center; gap: 1rem; color: var(--mint); font: 500 .75rem var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.loader { width: 44px; height: 44px; border: 2px solid rgba(185, 221, 192, .2); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ar-button { position: absolute; right: max(1.25rem, env(safe-area-inset-right)); bottom: max(1.5rem, env(safe-area-inset-bottom)); border: 0; border-radius: 12px; padding: .95rem 1.25rem; background: var(--gold); color: var(--deep); font-weight: 800; box-shadow: 0 8px 30px rgba(0, 0, 0, .28); cursor: pointer; }
.ar-button span { font-size: 1.25rem; margin-right: .4rem; }
.hotspot { display: none; }
.error-card { margin: auto; padding: 1rem 1.25rem; border-radius: 12px; background: var(--paper); color: var(--ink); }
.error-card span { display: block; margin-top: .25rem; font-size: .85rem; }

.handoff { padding: clamp(4rem, 10vw, 8rem) clamp(1.25rem, 8vw, 9rem); background: var(--cream); color: var(--ink); display: grid; grid-template-columns: 1fr minmax(260px, 390px); align-items: center; gap: clamp(3rem, 10vw, 9rem); }
.handoff h2 { margin: .8rem 0 1.3rem; font-size: clamp(2.7rem, 6vw, 5.5rem); line-height: .9; letter-spacing: -.055em; }
.handoff-copy > p:not(.eyebrow) { max-width: 560px; color: #50665f; font-size: 1.08rem; }
.copy-link { margin-top: 1.1rem; border: 0; border-radius: 9px; padding: .85rem 1.05rem; background: var(--forest); color: var(--cream); cursor: pointer; box-shadow: 3px 3px 0 var(--mint); }
.qr-card { background: var(--paper); padding: 1.35rem; border: 1px solid #d8cda9; border-radius: 18px; box-shadow: 10px 10px 0 #d8cda9; text-align: center; }
#qr-code { min-height: 232px; display: grid; place-items: center; padding: .65rem; background: #fff; border-radius: 10px; }
#qr-code img, #qr-code canvas { max-width: 100%; height: auto !important; }
.qr-card p { margin: 1rem 0 .25rem; font-weight: 800; }
.qr-card span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #728179; font: 400 .65rem var(--mono); }

footer { min-height: 100px; padding: 1.5rem clamp(1.25rem, 4vw, 4rem); display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: rgba(247, 240, 220, .65); font: 500 .65rem var(--mono); letter-spacing: .09em; }
footer a { color: var(--mint); }

@media (max-width: 760px) {
  .topbar { height: 66px; }
  .prototype-badge { display: none; }
  .viewer-shell { min-height: calc(100dvh - 66px); display: block; }
  model-viewer { height: calc(100dvh - 66px); min-height: 540px; }
  .viewer-copy { position: absolute; inset: 0; padding: 1.5rem 1.15rem max(5.5rem, env(safe-area-inset-bottom)); }
  h1 { font-size: clamp(3.5rem, 17vw, 5.4rem); }
  .instructions { display: none; }
  .ar-button { right: 1rem; bottom: max(1rem, env(safe-area-inset-bottom)); width: calc(100% - 2rem); min-height: 52px; }
  .viewer-status { margin-bottom: 4.5rem; }
  .handoff { grid-template-columns: 1fr; padding: 4.5rem 1.25rem 5rem; }
  .qr-card { display: none; }
  footer { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) { .loader { animation-duration: 1.8s; } }
