/* ===========================================================
   Lumina AR — tokens
=========================================================== */
:root{
  --bg: #0A0E14;
  --surface: #12161F;
  --surface-2: #191F2C;
  --border: #232B3B;
  --text: #E8EAF0;
  --text-dim: #7A8299;
  --text-faint: #4B5266;
  --accent: #7C5CFF;
  --accent-2: #4DE8D4;
  --accent-soft: rgba(124,92,255,0.14);
  --danger: #FF6B6B;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*{ box-sizing: border-box; }
html,body{
  margin:0; padding:0; height:100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button{ font-family: inherit; }
input{ font-family: inherit; }

#app{
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  isolation: isolate;
}

@media (min-width: 481px){
  body{
    background: #05070B;
  }
  #app{
    box-shadow: 0 0 0 1px var(--border), 0 40px 100px rgba(0,0,0,0.6);
  }
}

.screen{
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .32s ease, transform .32s ease;
}
.screen.active{
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.muted{ color: var(--text-dim); }
.small{ font-size: 12.5px; }

/* ===========================================================
   Reusable buttons
=========================================================== */
.btn-primary{
  display: flex; align-items:center; justify-content:center; gap:8px;
  background: linear-gradient(135deg, var(--accent), #6247E0);
  color: #fff;
  border: none;
  padding: 15px 22px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: .2px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(124,92,255,0.35);
  transition: transform .15s ease, box-shadow .15s ease;
  width: 100%;
}
.btn-primary:active{ transform: scale(.97); box-shadow: 0 4px 14px rgba(124,92,255,0.28); }

.btn-ghost{
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.btn-ghost:active{ background: var(--surface); color: var(--text); }
.btn-small{ padding: 11px 18px; font-size: 13px; }

.icon-btn{
  width: 40px; height: 40px;
  display: flex; align-items:center; justify-content:center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn.glass{
  background: rgba(18,22,31,0.55);
  backdrop-filter: blur(12px);
  border-color: rgba(255,255,255,0.12);
}
.icon-btn.accent{
  background: var(--accent-soft);
  border-color: rgba(124,92,255,0.4);
  color: var(--accent);
}
.icon-btn:active{ transform: scale(.93); }

/* ===========================================================
   HOME
=========================================================== */
#screen-home{ position: relative; padding: calc(20px + var(--safe-top)) 22px 28px; overflow:hidden; }

.home-glow{
  position: absolute;
  top: -140px; left: 50%;
  transform: translateX(-50%);
  width: 480px; height: 480px;
  background: radial-gradient(circle, rgba(124,92,255,0.28) 0%, rgba(124,92,255,0) 68%);
  pointer-events: none;
  z-index: 0;
}

.home-top{
  display:flex; align-items:center; justify-content:space-between;
  position: relative; z-index: 1;
}
.brand{ display:flex; align-items:center; gap:9px; }
.brand-mark{
  width: 26px; height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
}
.brand-name{ font-family: var(--font-display); font-size: 16px; letter-spacing: .2px; }
.brand-name b{ font-weight: 700; color: var(--accent-2); }

.home-hero{
  position: relative; z-index: 1;
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  gap: 26px;
  padding: 20px 0 40px;
}

.hero-frame{
  position: relative;
  width: 168px; height: 168px;
  display:flex; align-items:center; justify-content:center;
  color: var(--accent-2);
}
.hero-icon{ position: relative; z-index: 2; color: var(--text); opacity: .9; }
.corner{
  position: absolute;
  width: 26px; height: 26px;
  border-color: var(--accent-2);
  border-style: solid;
  opacity: .85;
}
.c-tl{ top:0; left:0; border-width: 2.5px 0 0 2.5px; border-top-left-radius: 8px; }
.c-tr{ top:0; right:0; border-width: 2.5px 2.5px 0 0; border-top-right-radius: 8px; }
.c-bl{ bottom:0; left:0; border-width: 0 0 2.5px 2.5px; border-bottom-left-radius: 8px; }
.c-br{ bottom:0; right:0; border-width: 0 2.5px 2.5px 0; border-bottom-right-radius: 8px; }

.hero-scanline{
  position: absolute;
  left: 8px; right: 8px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-2), transparent);
  box-shadow: 0 0 14px 2px var(--accent-2);
  animation: scan-move 2.4s ease-in-out infinite;
}
@keyframes scan-move{
  0%, 100%{ top: 12%; opacity: 0; }
  10%{ opacity: 1; }
  50%{ top: 88%; opacity: 1; }
  90%{ opacity: 1; }
}

.home-title{
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1.18;
  font-weight: 600;
  margin: 0;
  letter-spacing: -.3px;
}
.home-title span{ color: var(--accent-2); }

.home-sub{
  margin: 0;
  color: var(--text-dim);
  font-size: 14.5px;
  line-height: 1.55;
  max-width: 320px;
}

.home-bottom{
  position: relative; z-index: 1;
  display: flex; flex-direction: column; gap: 12px;
  padding-bottom: var(--safe-bottom);
}
.btn-scan{ font-size: 16px; padding: 17px 22px; }

/* ===========================================================
   SCANNER
=========================================================== */
#screen-scanner{ background: #000; }
.scanner-viewport{ position: relative; flex: 1; overflow: hidden; background:#000; }

#camera-feed, #experience-camera{
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background: #05070B;
}

.scanner-overlay{
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.scanner-overlay::before{
  content:"";
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 42%, rgba(0,0,0,0) 0%, rgba(0,0,0,0.55) 78%);
}

.scan-frame{
  position: relative;
  width: min(72vw, 300px);
  height: min(72vw, 300px);
  border-radius: 20px;
}
.scan-frame .corner{ width: 34px; height: 34px; color: var(--accent-2); }
.scan-frame.locked .corner{ border-color: var(--accent-2); }
.scan-frame.scanning .corner{ animation: pulse-corner 1.1s ease-in-out infinite; }
@keyframes pulse-corner{ 0%,100%{ opacity:.55; } 50%{ opacity: 1; } }

.scan-beam{
  position: absolute;
  left: 6%; right: 6%;
  height: 2px;
  top: 8%;
  background: linear-gradient(90deg, transparent, var(--accent-2), transparent);
  box-shadow: 0 0 16px 3px var(--accent-2);
  opacity: 0;
}
.scan-frame.scanning .scan-beam{
  opacity: 1;
  animation: beam-sweep 1.4s ease-in-out infinite;
}
@keyframes beam-sweep{
  0%{ top: 8%; }
  50%{ top: 88%; }
  100%{ top: 8%; }
}

.scanner-topbar{
  position: absolute;
  top: calc(16px + var(--safe-top)); left: 16px; right: 16px;
  display:flex; align-items:center; justify-content:space-between;
  z-index: 3;
}
.scanner-status{
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--text);
  background: rgba(18,22,31,0.55);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 9px 16px;
  border-radius: 999px;
}

.scanner-bottom{
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 3;
  padding: 26px 22px calc(26px + var(--safe-bottom));
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.75) 40%, rgba(0,0,0,0.92));
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.scanner-hint{ margin:0; color: var(--text-dim); font-size: 13px; text-align:center; }
.btn-scan-action{ max-width: 320px; }

/* ===========================================================
   EXPERIENCE
=========================================================== */
#screen-experience{ background:#000; }
.experience-stage{ position: relative; flex:1; overflow:hidden; background:#000; }

.experience-content{
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.experience-content video,
.experience-content img{
  width: 84%;
  max-height: 68%;
  object-fit: cover;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.08);
  animation: content-in .5s cubic-bezier(.2,.8,.2,1);
}
.experience-content .exp-text{
  width: 84%;
  max-height: 68%;
  overflow-y: auto;
  background: rgba(18,22,31,0.72);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  padding: 26px 22px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  animation: content-in .5s cubic-bezier(.2,.8,.2,1);
  white-space: pre-wrap;
}

.model-preview{
  margin-top: 12px;
  width: 100%;
  height: 240px;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.22);
}
.model-preview model-viewer{ width:100%; height:100%; background:transparent; }
.experience-content .exp-model-3d{
  width: 92%;
  height: 72%;
  min-height: 320px;
  background: transparent;
  animation: content-in .5s cubic-bezier(.2,.8,.2,1);
}

.experience-content .exp-3d{
  width: 84%; max-height: 68%; aspect-ratio: 1/1;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.12);
  background:
    radial-gradient(circle at 50% 40%, rgba(124,92,255,0.35), transparent 60%),
    var(--surface);
  display: flex; align-items:center; justify-content:center;
  flex-direction: column;
  gap: 10px;
  animation: content-in .5s cubic-bezier(.2,.8,.2,1), rotate3d 6s linear infinite;
  color: var(--accent-2);
}
.exp-3d span{ font-family: var(--font-display); font-size: 12.5px; color: var(--text-dim); }
@keyframes rotate3d{
  0%{ transform: perspective(600px) rotateY(0deg); }
  100%{ transform: perspective(600px) rotateY(360deg); }
}
@keyframes content-in{
  from{ opacity: 0; transform: scale(.9) translateY(10px); }
  to{ opacity: 1; transform: scale(1) translateY(0); }
}

.experience-topbar{
  position: absolute; z-index: 3;
  top: calc(16px + var(--safe-top)); left:16px; right:16px;
  display:flex; align-items:center; justify-content:space-between;
}
.experience-tag{
  display:flex; align-items:center; gap:8px;
  background: rgba(18,22,31,0.6);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-family: var(--font-display);
  max-width: 62%;
}
.experience-tag .dot{
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 8px 2px var(--accent-2);
  flex-shrink:0;
}
.experience-tag span:last-child{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

.experience-bottom{
  position:absolute; z-index:3; left:0; right:0; bottom: 0;
  padding: 24px 22px calc(24px + var(--safe-bottom));
  display:flex; justify-content:center;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.6));
}
.experience-bottom .btn-ghost{
  width: auto;
  background: rgba(18,22,31,0.6);
  backdrop-filter: blur(12px);
}

/* ===========================================================
   ADMIN
=========================================================== */
#screen-admin{ background: var(--bg); }
.admin-top{
  display:flex; align-items:center; justify-content:space-between;
  padding: calc(16px + var(--safe-top)) 18px 14px;
  border-bottom: 1px solid var(--border);
}
.admin-top h2{
  font-family: var(--font-display);
  font-size: 16px; font-weight: 600; margin:0;
}

.admin-body{ flex:1; overflow-y: auto; padding: 18px 18px calc(90px + var(--safe-bottom)); }

.admin-empty{
  display:flex; flex-direction:column; align-items:center; text-align:center;
  gap: 8px;
  padding: 60px 20px 20px;
}
.empty-frame{
  position: relative;
  width: 92px; height: 92px;
  margin-bottom: 14px;
  color: var(--text-faint);
}
.empty-frame .corner{ width: 22px; height:22px; }
.admin-empty p{ margin: 2px 0; font-size: 14px; }
.admin-empty strong{ font-family: var(--font-display); font-size: 15px; }
.admin-empty .btn-primary{ width: auto; padding: 13px 26px; margin-top: 18px; }

.exp-list{ display:flex; flex-direction:column; gap: 12px; }

.exp-card{
  display: flex;
  gap: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  align-items: center;
}
.exp-thumb{
  width: 56px; height: 56px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface-2);
  display:flex; align-items:center; justify-content:center;
  color: var(--text-faint);
}
.exp-thumb img{ width:100%; height:100%; object-fit:cover; }

.exp-info{ flex:1; min-width:0; }
.exp-name{
  font-family: var(--font-display);
  font-size: 14.5px; font-weight: 600;
  margin: 0 0 4px;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.exp-meta{ display:flex; align-items:center; gap:7px; }
.type-pill{
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.status-pill{
  font-size: 11.5px;
  color: var(--text-dim);
  display:flex; align-items:center; gap:5px;
}
.status-pill .dot{ width:6px; height:6px; border-radius:50%; background: var(--text-faint); }
.status-pill.on .dot{ background: var(--accent-2); box-shadow: 0 0 6px 1px var(--accent-2); }
.status-pill.on{ color: var(--accent-2); }

.exp-actions{ display:flex; flex-direction:column; gap:6px; }
.exp-actions button{
  width: 32px; height: 32px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  display:flex; align-items:center; justify-content:center;
  cursor: pointer;
}
.exp-actions button:active{ background: var(--surface-2); }
.exp-actions button.danger:active{ color: var(--danger); border-color: var(--danger); }

.fab{
  position: absolute;
  right: 20px;
  bottom: calc(24px + var(--safe-bottom));
  width: 54px; height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  border: none;
  color: #0A0E14;
  display: none;
  align-items: center; justify-content: center;
  box-shadow: 0 10px 26px rgba(124,92,255,0.4);
  cursor: pointer;
}
.fab.visible{ display:flex; }
.fab:active{ transform: scale(.92); }

/* ===========================================================
   MODAL / EDITOR SHEET
=========================================================== */
.modal-backdrop{
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 40;
  display: flex; align-items: flex-end;
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.modal-backdrop.open{ opacity: 1; pointer-events: auto; }

.modal-sheet{
  width: 100%;
  max-height: 88vh;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.2,.8,.2,1);
}
.modal-backdrop.open .modal-sheet{ transform: translateY(0); }

.sheet-handle{
  width: 38px; height: 4px;
  background: var(--border);
  border-radius: 99px;
  margin: 10px auto 2px;
}
.sheet-header{
  display:flex; align-items:center; justify-content:space-between;
  padding: 10px 18px 14px;
  border-bottom: 1px solid var(--border);
}
.sheet-header h3{ font-family: var(--font-display); font-size: 16px; margin:0; }

.sheet-body{ padding: 18px; overflow-y: auto; flex:1; }
.sheet-footer{
  display:flex; gap: 10px;
  padding: 14px 18px calc(14px + var(--safe-bottom));
  border-top: 1px solid var(--border);
}
.sheet-footer .btn-ghost{ flex: 0 0 auto; width: auto; padding: 14px 20px; }
.sheet-footer .btn-primary{ flex: 1; }

.field-label{
  display:block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin: 20px 0 8px;
}
.sheet-body .field-label:first-child{ margin-top: 0; }

.field-input, textarea.field-input{
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  outline: none;
  transition: border-color .15s ease;
  font-family: inherit;
}
.field-input:focus{ border-color: var(--accent); }
textarea.field-input{ resize: vertical; min-height: 90px; line-height: 1.5; }

.upload-box{
  display:flex; align-items:center; justify-content:center;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  min-height: 130px;
  cursor: pointer;
  overflow: hidden;
  background: var(--surface-2);
  position: relative;
}
.upload-empty{
  display:flex; flex-direction:column; align-items:center; gap:8px;
  color: var(--text-faint);
  font-size: 13px;
  padding: 20px;
  text-align: center;
}
.upload-preview{ width:100%; height: 160px; object-fit: cover; }
.upload-box.has-file .upload-empty{ display:none; }

.type-tabs{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.type-tab{
  padding: 11px 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.type-tab.active{
  background: var(--accent-soft);
  border-color: rgba(124,92,255,0.5);
  color: var(--accent);
  font-weight: 600;
}

.toggle-row{
  display:flex; align-items:center; justify-content:space-between;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  gap: 16px;
}
.switch{ position: relative; display:inline-block; width: 46px; height: 27px; flex-shrink:0; }
.switch input{ opacity:0; width:0; height:0; }
.switch-track{
  position:absolute; inset:0; background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px; transition: background .2s ease;
}
.switch-thumb{
  position:absolute; top:2px; left:2px;
  width: 21px; height: 21px; border-radius: 50%;
  background: var(--text-dim);
  transition: transform .2s ease, background .2s ease;
}
.switch input:checked + .switch-track{ background: var(--accent-soft); border-color: rgba(124,92,255,0.5); }
.switch input:checked + .switch-track .switch-thumb{ transform: translateX(19px); background: var(--accent); }

/* ===========================================================
   TOAST
=========================================================== */
.toast{
  position: absolute;
  left: 50%; bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  white-space: nowrap;
}
.toast.show{ opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===========================================================
   Scrollbar / misc
=========================================================== */
.admin-body::-webkit-scrollbar, .sheet-body::-webkit-scrollbar{ width: 4px; }
.admin-body::-webkit-scrollbar-thumb, .sheet-body::-webkit-scrollbar-thumb{
  background: var(--border); border-radius: 4px;
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
