:root {
  color-scheme: dark;
  --bg: #080b12;
  --panel: rgba(13, 17, 27, .78);
  --panel-strong: rgba(12, 16, 25, .94);
  --line: rgba(255, 255, 255, .11);
  --line-strong: rgba(255, 255, 255, .2);
  --text: #f5f7fb;
  --muted: #a5adbb;
  --accent: #b9ff35;
  --accent-2: #83e62b;
  --danger: #ff6472;
  --radius: 1.25rem;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); }
body { color: var(--text); font-size: 1rem; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.app, .viewport, .camera-feed { position: fixed; inset: 0; width: 100%; height: 100%; }
.app { isolation: isolate; background: radial-gradient(circle at 70% 20%, #25331a 0, #0d1119 34%, #06080d 72%); }
.viewport { z-index: 1; }
.viewport canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.camera-feed { z-index: 0; object-fit: cover; background: #070a10; }

.welcome { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; overflow: hidden; background: radial-gradient(circle at 68% 28%, rgba(185, 255, 53, .13), transparent 27%), linear-gradient(145deg, #111724 0%, #080b12 57%, #10150b 100%); transition: opacity .45s ease, visibility .45s; }
.welcome::after { content: ""; position: absolute; inset: 0; opacity: .18; background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px); background-size: 52px 52px; mask-image: linear-gradient(to bottom, #000, transparent 90%); }
.welcome.is-leaving { opacity: 0; visibility: hidden; pointer-events: none; }
.welcome__glow { position: absolute; width: min(72vw, 50rem); aspect-ratio: 1; border: 1px solid rgba(185,255,53,.1); border-radius: 50%; box-shadow: 0 0 0 6rem rgba(185,255,53,.018), 0 0 0 12rem rgba(185,255,53,.012); transform: translate(38%, -32%); }
.welcome__content { position: relative; z-index: 1; width: min(90vw, 42rem); padding: 2rem; text-align: center; }
.eyebrow { margin: 0 0 .7rem; color: var(--accent); font-size: .74rem; font-weight: 800; letter-spacing: .18em; }
.welcome h1 { margin: .6rem 0 1.1rem; font-size: clamp(2.7rem, 9vw, 5.6rem); line-height: .94; letter-spacing: -.065em; }
.welcome h1 em { color: var(--accent); font-style: normal; font-weight: 500; }
.welcome__lead { max-width: 34rem; margin: 0 auto; color: var(--muted); font-size: clamp(1rem, 2.4vw, 1.2rem); line-height: 1.55; }
.welcome__stats { display: flex; justify-content: center; gap: clamp(1.5rem, 7vw, 4rem); margin: 2.1rem 0; }
.welcome__stats div { display: flex; flex-direction: column; gap: .25rem; }
.welcome__stats strong { font-size: 1.35rem; }
.welcome__stats span { color: var(--muted); font-size: .76rem; }
.welcome__security { color: #7f8999; font-size: .78rem; }
.welcome__security span { margin-right: .35rem; color: var(--accent); }

.brand-mark { position: relative; width: 2.35rem; height: 2.35rem; flex: 0 0 auto; border: 1px solid rgba(185,255,53,.55); border-radius: 50%; background: radial-gradient(circle, rgba(185,255,53,.22), transparent 64%); }
.brand-mark::before, .brand-mark::after, .brand-mark span { content: ""; position: absolute; inset: 50% auto auto 50%; border: 1px solid var(--accent); transform: translate(-50%, -50%) rotate(45deg); }
.brand-mark::before { width: 1rem; height: 1rem; }
.brand-mark::after { width: .4rem; height: .4rem; background: var(--accent); }
.brand-mark span { width: 1.55rem; height: 1.55rem; border-color: rgba(185,255,53,.25); }
.brand-mark--large { width: 4rem; height: 4rem; margin: 0 auto 1.4rem; }
.brand-mark--large span { width: 2.7rem; height: 2.7rem; }
.brand-mark--large::before { width: 1.8rem; height: 1.8rem; }
.brand-mark--large::after { width: .7rem; height: .7rem; }

.button { min-height: 3rem; border: 1px solid var(--line); border-radius: .9rem; background: rgba(12,16,24,.86); font-weight: 750; cursor: pointer; transition: transform .18s ease, border-color .18s, background .18s; }
.button:active, .icon-button:active, .tool-button:active { transform: scale(.96); }
.button--primary { border-color: var(--accent); background: var(--accent); color: #10150b; box-shadow: 0 10px 35px rgba(185,255,53,.18); }
.button--start { display: inline-flex; align-items: center; justify-content: center; gap: .75rem; min-width: min(100%, 19rem); padding: .2rem 1.5rem; }
.button__icon { font-size: 1.4rem; }

.ui { position: fixed; inset: 0; z-index: 10; pointer-events: none; opacity: 1; transition: opacity .32s ease; }
.ui.is-hidden { opacity: 0; }
.ui.is-hidden * { pointer-events: none !important; }
.glass-panel { border: 1px solid var(--line); background: var(--panel); box-shadow: 0 18px 60px rgba(0,0,0,.22); backdrop-filter: blur(22px) saturate(120%); -webkit-backdrop-filter: blur(22px) saturate(120%); }
.topbar { position: absolute; top: calc(var(--safe-top) + .85rem); left: 50%; display: flex; align-items: center; justify-content: space-between; width: min(calc(100% - 1.5rem), 74rem); height: 4rem; padding: .6rem .7rem .6rem .8rem; border-radius: 1.15rem; transform: translateX(-50%); pointer-events: auto; }
.topbar__brand { display: flex; align-items: center; gap: .65rem; }
.topbar__brand div:last-child { display: flex; flex-direction: column; }
.topbar__brand strong { font-size: .95rem; letter-spacing: -.02em; }
.topbar__brand span { color: var(--muted); font-size: .68rem; }
.topbar__actions { display: flex; gap: .45rem; }
.icon-button { display: grid; place-items: center; width: 2.7rem; height: 2.7rem; padding: 0; border: 1px solid var(--line); border-radius: .8rem; background: rgba(255,255,255,.055); cursor: pointer; transition: transform .18s, background .18s, border-color .18s; }
.icon-button:hover { border-color: var(--line-strong); background: rgba(255,255,255,.09); }
.icon-button--danger { color: var(--danger); font-size: 1.55rem; }
.pause-icon { width: .85rem; height: 1rem; border-left: .25rem solid currentColor; border-right: .25rem solid currentColor; }
.icon-button[data-paused="true"] .pause-icon { width: 0; height: 0; border: 0; border-top: .55rem solid transparent; border-bottom: .55rem solid transparent; border-left: .85rem solid currentColor; }
.tracking-status { display: flex; align-items: center; gap: .5rem; padding: .5rem .8rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .76rem; }
.tracking-status i { width: .5rem; height: .5rem; border-radius: 50%; background: #f1b74d; box-shadow: 0 0 0 4px rgba(241,183,77,.1); }
.tracking-status[data-status="tracking"] i { background: var(--accent); box-shadow: 0 0 0 4px rgba(185,255,53,.12), 0 0 12px rgba(185,255,53,.65); }
.tracking-status[data-status="paused"] i { background: #f1b74d; }
.tracking-status[data-status="error"] i { background: var(--danger); }

.catalog { position: absolute; top: calc(var(--safe-top) + 5.6rem); bottom: calc(var(--safe-bottom) + 1rem); left: max(.75rem, calc((100vw - 74rem) / 2)); display: flex; flex-direction: column; width: min(22.5rem, calc(100vw - 1.5rem)); padding: 1.1rem; border-radius: var(--radius); pointer-events: auto; transition: transform .35s cubic-bezier(.2,.9,.25,1), opacity .25s; }
.catalog.is-closed { transform: translateX(calc(-100% - 2rem)); opacity: 0; pointer-events: none; }
.catalog__header { display: flex; align-items: flex-start; justify-content: space-between; }
.catalog__header h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.035em; }
.catalog__close { width: 2.3rem; height: 2.3rem; font-size: 1.35rem; }
.search-wrap { display: flex; align-items: center; gap: .5rem; margin: 1rem 0 .75rem; padding: 0 .8rem; border: 1px solid var(--line); border-radius: .8rem; background: rgba(0,0,0,.18); }
.search-wrap span { color: var(--muted); font-size: 1.25rem; }
.search-wrap input { width: 100%; height: 2.75rem; border: 0; outline: 0; color: var(--text); background: transparent; }
.search-wrap input::placeholder { color: #737c8c; }
.category-tabs { display: flex; gap: .35rem; overflow-x: auto; padding-bottom: .75rem; scrollbar-width: none; }
.category-tabs::-webkit-scrollbar { display: none; }
.category-tabs button { display: inline-flex; align-items: center; gap: .35rem; min-height: 2.35rem; padding: 0 .7rem; border: 1px solid transparent; border-radius: .7rem; background: rgba(255,255,255,.04); color: var(--muted); white-space: nowrap; cursor: pointer; font-size: .78rem; }
.category-tabs button[aria-selected="true"] { border-color: rgba(185,255,53,.35); background: rgba(185,255,53,.12); color: var(--accent); }
.category-tabs span { opacity: .65; font-size: .66rem; }
.model-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .55rem; overflow: auto; padding: .1rem .15rem .3rem 0; scrollbar-color: rgba(255,255,255,.2) transparent; }
.model-card { position: relative; min-height: 8.1rem; padding: .65rem; overflow: hidden; border: 1px solid var(--line); border-radius: .9rem; background: linear-gradient(155deg, rgba(255,255,255,.075), rgba(255,255,255,.025)); text-align: left; cursor: pointer; }
.model-card::after { content: ""; position: absolute; right: -.8rem; top: -.8rem; width: 4.2rem; height: 4.2rem; border-radius: 50%; background: var(--card-color, rgba(185,255,53,.14)); filter: blur(15px); opacity: .5; }
.model-card:hover, .model-card[aria-pressed="true"] { border-color: rgba(185,255,53,.5); background: rgba(185,255,53,.09); }
.model-card__visual { display: grid; place-items: center; height: 4.5rem; color: var(--card-accent, var(--accent)); font-size: 2.4rem; }
.model-card__visual span { filter: drop-shadow(0 7px 13px rgba(0,0,0,.35)); transform: rotate(-5deg); }
.model-card__name { display: block; overflow: hidden; font-size: .83rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.model-card__type { color: var(--muted); font-size: .65rem; }
.empty-models { color: var(--muted); text-align: center; }
.catalog-open { position: absolute; bottom: calc(var(--safe-bottom) + 1rem); left: max(.75rem, calc((100vw - 74rem) / 2)); display: flex; align-items: center; gap: .55rem; padding: 0 1rem; pointer-events: auto; }
.catalog-open b { display: grid; place-items: center; min-width: 1.35rem; height: 1.35rem; border-radius: 50%; background: var(--accent); color: #11160b; font-size: .7rem; }

.placement-guide { position: absolute; left: 50%; top: 50%; display: flex; flex-direction: column; align-items: center; width: min(19rem, 78vw); text-align: center; transform: translate(-50%, -46%); pointer-events: none; transition: opacity .2s; }
.placement-guide p { margin: 1rem 0 .2rem; font-size: .9rem; font-weight: 800; text-shadow: 0 2px 8px #000; }
.placement-guide span { color: #d2d7df; font-size: .75rem; text-shadow: 0 2px 8px #000; }
.scan-corners { position: relative; width: 5.2rem; height: 5.2rem; animation: breathe 1.8s ease-in-out infinite; }
.scan-corners i { position: absolute; width: 1.3rem; height: 1.3rem; border-color: var(--accent); border-style: solid; filter: drop-shadow(0 0 5px rgba(185,255,53,.45)); }
.scan-corners i:nth-child(1) { top:0; left:0; border-width:2px 0 0 2px; }
.scan-corners i:nth-child(2) { top:0; right:0; border-width:2px 2px 0 0; }
.scan-corners i:nth-child(3) { bottom:0; left:0; border-width:0 0 2px 2px; }
.scan-corners i:nth-child(4) { right:0; bottom:0; border-width:0 2px 2px 0; }
@keyframes breathe { 50% { transform: scale(1.08); opacity: .72; } }

.object-controls { position: absolute; left: 50%; bottom: calc(var(--safe-bottom) + 1rem); display: flex; align-items: center; gap: 1rem; width: min(calc(100% - 2rem), 43rem); padding: .65rem .75rem; border-radius: 1rem; transform: translateX(-50%); pointer-events: auto; }
.object-controls__identity { display: flex; align-items: center; min-width: 9rem; gap: .6rem; padding-right: .8rem; border-right: 1px solid var(--line); }
.object-controls__identity > div:last-child { display: flex; flex-direction: column; min-width: 0; }
.object-controls__identity span { color: var(--muted); font-size: .65rem; }
.object-controls__identity strong { overflow: hidden; max-width: 8rem; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.selected-icon { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: .7rem; background: rgba(185,255,53,.12); color: var(--accent); font-size: 1.3rem; }
.object-controls__tools { display: flex; align-items: center; justify-content: space-between; gap: .3rem; flex: 1; }
.tool-button { display: flex; flex-direction: column; align-items: center; gap: .2rem; min-width: 4.2rem; padding: .35rem .4rem; border: 0; border-radius: .65rem; background: transparent; color: var(--muted); cursor: pointer; font-size: .62rem; }
.tool-button span { color: var(--text); font-size: 1.15rem; }
.tool-button:hover, .tool-button.is-active { background: rgba(185,255,53,.1); color: var(--accent); }
.tool-button--danger:hover, .tool-button--danger span { color: var(--danger); }
.scale-control { display: flex; flex-direction: column; gap: .3rem; min-width: 7rem; color: var(--muted); font-size: .62rem; }
.scale-control input { width: 100%; accent-color: var(--accent); }

.loading, .toast { position: absolute; left: 50%; pointer-events: none; transform: translateX(-50%); }
.loading { top: 7rem; display: flex; align-items: center; gap: .7rem; padding: .7rem 1rem; border: 1px solid var(--line); border-radius: 999px; background: var(--panel-strong); font-size: .78rem; }
.loading i { width: .8rem; height: .8rem; border: 2px solid rgba(255,255,255,.2); border-top-color: var(--accent); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { bottom: calc(var(--safe-bottom) + 6.2rem); max-width: min(90vw, 28rem); padding: .75rem 1rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--panel-strong); text-align: center; font-size: .78rem; box-shadow: 0 10px 35px rgba(0,0,0,.3); }
.wake-ui { position: fixed; inset: 0; z-index: 20; width: 100%; height: 100%; padding: 0; border: 0; background: transparent; }

@media (max-width: 720px) {
  .topbar { width: calc(100% - 1rem); top: calc(var(--safe-top) + .5rem); }
  .tracking-status { position: absolute; top: calc(100% + .55rem); left: 50%; background: rgba(8,11,18,.65); transform: translateX(-50%); }
  .topbar__brand span { display: none; }
  .catalog { top: auto; left: .5rem; right: .5rem; bottom: calc(var(--safe-bottom) + .5rem); width: auto; height: min(64vh, 36rem); transform: translateY(0); }
  .catalog.is-closed { transform: translateY(calc(100% + 2rem)); }
  .catalog-open { left: .75rem; bottom: calc(var(--safe-bottom) + .75rem); }
  .object-controls { bottom: calc(var(--safe-bottom) + .5rem); width: calc(100% - 1rem); flex-direction: column; align-items: stretch; gap: .45rem; }
  .object-controls__identity { min-width: 0; padding: 0 0 .45rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .object-controls__tools { width: 100%; }
  .scale-control { min-width: 5rem; }
  .welcome__content { padding: 1.25rem; }
  .welcome__stats { gap: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
