* { box-sizing: border-box; margin: 0; padding: 0; }
:root{
  --bg: #0a0e14;
  --glass: rgba(16,22,32,.55);
  --glass-2: rgba(22,30,44,.9);
  --line: rgba(130,170,210,.16);
  --accent: #4fd1ff;
  --accent-2: #7c5cff;
  --text: #eef3f9;
  --muted: #8b9cae;
  --r: 8px;
}
html,body{ height:100%; width:100%; overflow:hidden; background:#000;
  font-family:"Segoe UI",system-ui,-apple-system,Roboto,Helvetica,Arial,sans-serif;
  color:var(--text); font-size:14px; -webkit-font-smoothing:antialiased; }

#ui{ position:fixed; inset:0; pointer-events:none; z-index:10; }
#ui > *{ pointer-events:auto; }

/* ---------- Top bar ---------- */
#topbar{
  position:absolute; top:0; left:0; right:0; height:44px;
  display:flex; align-items:center; gap:12px; padding:0 12px;
  background:linear-gradient(180deg, rgba(6,9,14,.78), rgba(6,9,14,0));
  backdrop-filter:blur(7px);
}
.brand{ display:flex; align-items:center; gap:9px; }
.logo{ font-size:19px; color:var(--accent); filter:drop-shadow(0 0 6px rgba(79,209,255,.5)); }
.title{ font-size:13px; font-weight:650; letter-spacing:.2px; line-height:1.1; }
.subtitle{ font-size:10.5px; color:var(--muted); line-height:1.1; }
.meta{ flex:1; text-align:center; min-width:0; }
.cap-name{ font-size:12px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.cap-date{ font-size:10.5px; color:var(--muted); }
.actions{ display:flex; gap:5px; align-items:center; }

/* Gyro / Manual segmented toggle — highlights the active mode */
.gyro-toggle{ align-items:center; gap:2px; padding:2px; border-radius:999px;
  background:rgba(255,255,255,.07); border:1px solid var(--line); cursor:pointer; user-select:none; }
.gyro-toggle:not([hidden]){ display:inline-flex; }
.gt-opt{ padding:3px 10px; border-radius:999px; font-size:11px; font-weight:600;
  color:var(--muted); white-space:nowrap; transition:.15s; }
.gyro-toggle[data-mode="gyro"]   .gt-opt[data-mode="gyro"],
.gyro-toggle[data-mode="manual"] .gt-opt[data-mode="manual"]{
  background:linear-gradient(135deg,var(--accent),var(--accent-2)); color:#06121c; }

/* Viewer header (NOT editing): minimal on every screen — just the "VR Tour"
   title (left), an open centre (for a logo), and the Gyro/Manual toggle (right).
   The full toolbar comes back in editor mode. */
body:not(.editing) #topbar .meta,
body:not(.editing) .brand .logo,
body:not(.editing) #counter,
body:not(.editing) #topbar #btnZoomOut,
body:not(.editing) #topbar #btnZoomIn,
body:not(.editing) #topbar #btnZoomReset,
body:not(.editing) #topbar #btnAuto,
body:not(.editing) #topbar #btnGallery,
body:not(.editing) #topbar #btnFull,
body:not(.editing) #topbar #btnInfo,
body:not(.editing) #topbar #btnEdit{ display:none; }
body:not(.editing) #topbar .actions{ margin-left:auto; }

/* Centered brand logo — shown in viewer mode only (hidden while editing so it
   doesn't cover the caption/toolbar). Non-interactive. */
.brand-logo{ display:none; }
body:not(.editing) .brand-logo{
  display:block; position:absolute; left:50%; top:50%; transform:translate(-50%,-50%);
  height:30px; width:auto; max-width:44vw; object-fit:contain; pointer-events:none; z-index:1;
}
@media (max-width:640px){ body:not(.editing) .brand-logo{ height:26px; } }

.btn{
  pointer-events:auto; cursor:pointer; border:1px solid var(--line);
  background:var(--glass); color:var(--text); border-radius:var(--r);
  padding:5px 9px; font-size:12px; font-weight:600; backdrop-filter:blur(8px);
  transition:.15s; white-space:nowrap; line-height:1.3;
}
.btn:hover{ background:var(--glass-2); border-color:rgba(79,209,255,.55); }
.btn:active{ transform:translateY(1px); }
.btn.primary, .btn.active{ background:linear-gradient(135deg,var(--accent),var(--accent-2)); color:#06121c; border:none; }
.btn.sm{ padding:4px 8px; font-size:11px; border-radius:6px; }
.btn.danger{ border-color:rgba(255,99,128,.4); }
.btn.danger:hover{ background:rgba(255,99,128,.16); border-color:#ff6380; }

/* ---------- Side nav arrows ---------- */
.nav-arrow{
  position:absolute; top:50%; transform:translateY(-50%);
  width:34px; height:54px; border:1px solid var(--line); cursor:pointer;
  background:var(--glass); color:var(--text); font-size:24px; line-height:1;
  backdrop-filter:blur(8px); transition:.15s; border-radius:9px; opacity:.75;
}
.nav-arrow:hover{ background:var(--glass-2); border-color:var(--accent); opacity:1; }
.nav-arrow.left{ left:10px; } .nav-arrow.right{ right:10px; }

/* ---------- Progress ---------- */
#progress{ position:absolute; left:0; right:0; bottom:74px; height:2px; background:rgba(255,255,255,.07); }
#progressFill{ height:100%; width:0%; background:linear-gradient(90deg,var(--accent),var(--accent-2)); box-shadow:0 0 8px var(--accent); transition:width .35s; }

/* ---------- Filmstrip ---------- */
#filmstrip{
  position:absolute; left:0; right:0; bottom:0; height:74px;
  display:flex; gap:6px; align-items:center; padding:7px 10px;
  overflow-x:auto; overflow-y:hidden; scroll-behavior:smooth;
  background:linear-gradient(0deg, rgba(6,9,14,.88), rgba(6,9,14,0));
}
#filmstrip::-webkit-scrollbar{ height:6px; }
#filmstrip::-webkit-scrollbar-thumb{ background:rgba(130,170,210,.28); border-radius:6px; }
.thumb{
  position:relative; flex:0 0 auto; width:90px; height:50px; border-radius:6px;
  overflow:hidden; cursor:pointer; border:2px solid transparent; transition:.15s; background:#10161f;
}
.thumb img{ width:100%; height:100%; object-fit:cover; display:block; }
.thumb:hover{ border-color:rgba(79,209,255,.5); }
.thumb.active{ border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); }
.thumb .idx{ position:absolute; left:3px; top:3px; font-size:9px; padding:0 5px; border-radius:5px; background:rgba(0,0,0,.6); }

/* ---------- Gallery ---------- */
#gallery{ position:absolute; inset:0; background:rgba(6,9,14,.97); backdrop-filter:blur(10px); display:flex; flex-direction:column; z-index:20; }
#gallery.hidden, #help.hidden, #loader.hidden{ display:none; }
.gallery-head{ display:flex; align-items:center; gap:10px; padding:10px 16px; border-bottom:1px solid var(--line); }
#search{ flex:1; max-width:360px; padding:7px 11px; border-radius:var(--r); border:1px solid var(--line);
  background:rgba(255,255,255,.05); color:var(--text); font-size:13px; outline:none; }
#search:focus{ border-color:var(--accent); }
#galleryCount{ color:var(--muted); font-size:12px; }
#galleryGrid{ flex:1; min-height:0; overflow-y:auto; padding:14px 16px; display:grid;
  grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); grid-auto-rows:max-content;
  gap:12px; align-content:start; }
.gcard{ border-radius:9px; overflow:hidden; cursor:pointer; background:#0b1118; border:1px solid var(--line); transition:.14s; }
.gcard:hover{ border-color:var(--accent); box-shadow:0 6px 18px rgba(0,0,0,.45); }
.gcard img{ display:block; width:100%; aspect-ratio:2/1; object-fit:cover; background:#070b11; }
.gcard .cap{ padding:6px 9px; font-size:11px; color:var(--muted); display:flex; justify-content:space-between; gap:6px; }
.gcard .cap b{ color:var(--text); font-weight:600; }

/* ---------- Help ---------- */
#help{ position:absolute; inset:0; display:flex; align-items:center; justify-content:center; z-index:25; background:rgba(4,7,12,.72); backdrop-filter:blur(4px); }
.help-card{ background:var(--glass-2); border:1px solid var(--line); border-radius:14px; padding:22px 26px; max-width:440px; box-shadow:0 16px 50px rgba(0,0,0,.6); }
.help-card h2{ margin-bottom:14px; font-size:17px; }
.help-card ul{ list-style:none; display:flex; flex-direction:column; gap:8px; margin-bottom:18px; }
.help-card li{ font-size:12.5px; color:var(--muted); }
.help-card b{ color:var(--accent); }

/* ---------- Empty state ---------- */
#empty{ position:absolute; inset:0; display:flex; align-items:center; justify-content:center; z-index:35; background:#070b11; }
#empty.hidden{ display:none; }
.empty-card{ text-align:center; max-width:400px; padding:28px; }
.empty-icon{ font-size:44px; color:var(--accent); filter:drop-shadow(0 0 10px rgba(79,209,255,.45)); margin-bottom:8px; }
.empty-card h2{ font-size:19px; margin-bottom:6px; }
.empty-card p{ color:var(--muted); font-size:13px; margin-bottom:16px; }
.empty-card .empty-sub{ font-size:11px; margin-top:16px; margin-bottom:0; }
.empty-card .empty-sub b{ color:var(--text); }

/* ---------- In-app link viewer (iframe modal) ---------- */
#linkModal{ position:absolute; inset:0; z-index:30; display:flex; align-items:center; justify-content:center;
  background:rgba(4,7,12,.78); backdrop-filter:blur(6px); padding:3vh 3vw; }
#linkModal.hidden{ display:none !important; }       /* always wins over .anchored */
.lm-panel{ position:relative; width:min(1100px,96vw); height:min(86vh,860px); display:flex; flex-direction:column;
  background:#fff; border:1px solid var(--line); border-radius:12px; overflow:hidden;
  box-shadow:0 24px 70px rgba(0,0,0,.65); }
/* anchored mode: a popup opened right beside the clicked info icon — resizable */
#linkModal.anchored{ background:rgba(4,7,12,.32); backdrop-filter:none; display:block; }
#linkModal.anchored .lm-panel{ position:absolute; width:min(680px,88vw); height:min(72vh,620px);
  min-width:320px; min-height:240px; max-width:96vw; max-height:90vh; resize:both;
  border-color:rgba(79,209,255,.45); box-shadow:0 18px 50px rgba(0,0,0,.6); }
.lm-body{ position:relative; flex:1; min-height:0; background:#fff; }
#linkModalFrame{ position:absolute; inset:0; width:100%; height:100%; border:0; background:#fff; }
#linkModalFrame.hidden{ display:none; }
#linkModalImg{ position:absolute; inset:0; width:100%; height:100%; object-fit:contain; background:#06090e; }
#linkModalImg.hidden{ display:none; }
/* video player: black behind the embed instead of white */
#linkModal.video .lm-body, #linkModal.video #linkModalFrame{ background:#000; }
/* image viewer: shrink the popup to the picture — no black box around it,
   but keep the floating ✕ / ↗ buttons */
#linkModal.image .lm-panel{ width:auto; height:auto; min-width:0; min-height:0;
  max-width:min(1100px,94vw); max-height:min(90vh,900px);
  background:transparent; border:none; box-shadow:none; overflow:visible; resize:none; }
#linkModal.image .lm-body{ position:static; flex:none; background:transparent; }
#linkModal.image #linkModalImg{ position:static; width:auto; height:auto; display:block;
  max-width:min(1100px,94vw); max-height:min(90vh,900px); object-fit:contain;
  background:transparent; border-radius:12px; box-shadow:0 24px 70px rgba(0,0,0,.6); }
/* floating round controls in the top-right corner, above the iframe */
.lm-x, .lm-newtab{ position:absolute; top:9px; z-index:5; width:32px; height:32px; border-radius:50%;
  display:flex; align-items:center; justify-content:center; font-size:15px; line-height:1; cursor:pointer;
  color:#fff; background:rgba(12,16,22,.72); border:1px solid rgba(255,255,255,.22);
  backdrop-filter:blur(6px); transition:.15s; text-decoration:none; }
.lm-x{ right:9px; }
.lm-newtab{ right:49px; font-size:14px; }
.lm-x:hover{ background:#ff6380; border-color:#ff6380; }
.lm-newtab:hover{ background:var(--accent); border-color:var(--accent); color:#06121c; }
.lm-blocked{ position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:14px; text-align:center; padding:24px; background:#0b1118; color:var(--text); }
.lm-blocked.hidden{ display:none; }
.lm-blocked p{ color:var(--muted); font-size:14px; max-width:420px; }
.lm-blocked .btn{ text-decoration:none; }

/* ---------- Loader ---------- */
#loader{ position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px; background:#05080d; z-index:40; }
.spinner{ width:42px; height:42px; border-radius:50%; border:3px solid rgba(79,209,255,.16); border-top-color:var(--accent); animation:rot .9s linear infinite; }
@keyframes rot{ to{ transform:rotate(360deg);} }
#loaderText{ color:var(--muted); font-size:13px; letter-spacing:.3px; }

@media (max-width:640px){
  .meta{ display:none; }
  #filmstrip{ height:66px; } .thumb{ width:78px; height:44px; }
  #progress{ bottom:66px; }
}
