/* Shared styles for the regular (non-viewer) pages. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #5b6475;
  --border: #e2e5eb;
  --accent: #1f7a8c;
  --accent-strong: #176273;
  --accent-soft: #e3f2f5;
  --danger: #b4232f;
  --danger-soft: #fbe9eb;
  --ok: #217a3c;
  --ok-soft: #e5f4e9;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --code-bg: #f1f3f6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c;
    --surface: #181d26;
    --text: #e6e9ef;
    --muted: #9aa3b5;
    --border: #2a3140;
    --accent: #5cc3d6;
    --accent-strong: #8ad6e4;
    --accent-soft: #1a2e35;
    --danger: #f07b84;
    --danger-soft: #3a1d22;
    --ok: #74d18f;
    --ok-soft: #18321f;
    --warn: #e8b85c;
    --warn-soft: #362b14;
    --code-bg: #0f1319;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: Inter, system-ui, sans-serif; line-height: 1.55;
}
a { color: var(--accent); }
code { font-family: "JetBrains Mono", monospace; font-size: 0.88em; background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }

.site-nav {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 14px clamp(16px, 4vw, 40px);
  background: linear-gradient(135deg, #0f3d4a, #1f7a8c);
  color: #fff;
}
.site-nav .brand { font-weight: 700; color: #fff; text-decoration: none; margin-right: auto; display: flex; align-items: center; }
.site-nav .brand img { display: block; height: 36px; width: auto; }
.site-nav a.link { color: rgba(255, 255, 255, 0.82); text-decoration: none; font-weight: 600; }
.site-nav a.link:hover, .site-nav a.link.active { color: #fff; text-decoration: underline; text-underline-offset: 4px; }

.page { max-width: 1040px; margin: 32px auto 64px; padding: 0 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { margin: 0; font-size: 1.8rem; letter-spacing: -0.01em; }
.muted { color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; border: 1px solid transparent;
  background: var(--accent); color: #fff; font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
@media (prefers-color-scheme: dark) { .btn { color: #0b1a1f; } }
.btn:hover { background: var(--accent-strong); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: transparent; color: var(--accent); border-color: var(--border); }
.btn.secondary:hover { background: var(--accent-soft); }
.btn.small { padding: 5px 12px; font-size: 0.9rem; }

label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type="text"], select, textarea {
  width: 100%; padding: 9px 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
input[type="text"]:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.notice { padding: 12px 16px; border-radius: 8px; margin: 16px 0; }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }

/* Tour grid */
.tour-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.tour-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.tour-card .thumb { aspect-ratio: 4 / 1.6; background: var(--code-bg) center / cover no-repeat; display: block; }
.tour-card .body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.tour-card h2 { margin: 0; font-size: 1.15rem; }
.tour-card h2 a { color: inherit; text-decoration: none; }
.tour-card .actions { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; }
.empty { text-align: center; padding: 48px 24px; }

footer.site-footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 0 16px 32px; }

/* Upload page */
.upload-layout { display: grid; gap: 20px; }
.step { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; font-size: 1.15rem; }
.step span {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: 0.9rem;
}
.new-tour { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border); }
.new-tour[hidden] { display: none; }

.dropzone {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 36px 16px; border: 2px dashed var(--border); border-radius: 12px;
  font-weight: 400; cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-settings { position: relative; display: flex; align-items: center; order: 99; }   /* after the links, top right */
@media (min-width: 701px) { .nav-links { flex: 1 1 0; min-width: 0; justify-content: flex-end; } }
@media (max-width: 700px) { .nav-settings { order: 0; margin-left: auto; } }               /* phone: beside the ☰ */
.nav-gear { background: none; border: 0; color: inherit; padding: 8px; cursor: pointer; display: grid; place-items: center; border-radius: 8px; opacity: .85; }
.nav-gear:hover, .nav-gear[aria-expanded="true"] { opacity: 1; background: var(--accent-soft); }
.settings-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 210px; background: var(--surface, #1b1f27);
  border: 1px solid var(--border, #333); border-radius: 10px; padding: 12px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.settings-panel .settings-title { margin: 0 0 8px; font-weight: 600; }
.settings-panel fieldset { border: 0; margin: 0; padding: 0; }
.settings-panel legend { font-size: .85rem; color: var(--muted); margin-bottom: 4px; padding: 0; }
.settings-panel label { display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 4px 0; cursor: pointer; }
.settings-panel .settings-status:empty { display: none; }
.settings-panel .settings-status { margin: 6px 0 0; }
.combine-form { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border, #333); border-radius: 10px; }
.combine-form label { display: block; margin: 6px 0; font-weight: 400; }
.combine-form .choice { display: flex; gap: 8px; align-items: flex-start; }
.combine-form .choice input { margin-top: 4px; }
.combine-form select { margin-left: 6px; }
.combine-form [hidden] { display: none; }
.add-to { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.add-to p { margin: 0 0 8px; }
.add-to .choice { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 8px 0; cursor: pointer; }
.add-to .choice input { margin-top: 4px; }
.video-list { list-style: none; margin: 10px 0 0; padding: 0; font-size: .9rem; }
.video-list:empty { display: none; }
.video-list li { display: flex; align-items: center; gap: 8px; padding: 4px 0; color: var(--muted); }
.video-list li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-list button { border: 0; background: none; color: inherit; font-size: 1.2rem; line-height: 1; padding: 2px 6px; cursor: pointer; }
.link-like { color: var(--accent); text-decoration: underline; }
.small { font-size: 0.85rem; }

.file-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.file-item {
  display: grid; grid-template-columns: 160px 1fr auto; gap: 14px; align-items: center;
  padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
}
.file-thumb { width: 160px; height: 40px; border-radius: 6px; overflow: hidden; background: var(--code-bg); }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-main { min-width: 0; display: grid; gap: 4px; }
.file-meta { font-size: 0.85rem; overflow-wrap: anywhere; }
.file-item[data-status="invalid"] .file-meta,
.file-item[data-status="error"] .file-meta { color: var(--danger); }
.file-item[data-status="done"] .file-meta { color: var(--ok); }
.file-item[data-status="invalid"] { opacity: 0.75; }
.file-remove {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font-size: 1.2rem; line-height: 1; cursor: pointer;
}
.file-remove:hover { color: var(--danger); border-color: var(--danger); }
.file-remove[hidden] { visibility: hidden; display: block; }
.progress { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.progress[hidden] { display: none; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .15s; }

.upload-actions { display: flex; align-items: center; gap: 14px; margin-top: 18px; flex-wrap: wrap; }

@media (max-width: 600px) {
  .file-item { grid-template-columns: 1fr auto; }
  .file-thumb { grid-column: 1 / -1; width: 100%; height: 56px; }
}

/* Forms (login, setup) */
.page.narrow { max-width: 440px; }
.form-title { margin: 0 0 8px; font-size: 1.5rem; }
.stack { display: grid; gap: 16px; margin-top: 16px; }
input[type="email"], input[type="password"] {
  width: 100%; padding: 9px 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
input[type="email"]:focus, input[type="password"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Nav: user + log out */
.nav-logout { display: flex; align-items: center; gap: 12px; margin: 0; }
.nav-user { color: rgba(255, 255, 255, 0.7); font-size: 0.9rem; }
.site-nav button.link { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; cursor: pointer; color: rgba(255, 255, 255, 0.82); }
.site-nav button.link:hover { color: #fff; text-decoration: underline; text-underline-offset: 4px; }

/* Manage page */
.crumb { margin: 0 0 2px; }
.crumb a { color: inherit; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.section-title { margin: 0 0 12px; font-size: 1.15rem; }
.empty-note[hidden] { display: none; }
.scene-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.scene-row {
  display: grid; gap: 8px 16px; align-items: center;
  grid-template-columns: auto 200px minmax(0, 1fr) auto;
  grid-template-areas: "order thumb info actions";
  padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
}
.scene-order { grid-area: order; }
.scene-thumb { grid-area: thumb; }
.scene-info { grid-area: info; }
.scene-actions { grid-area: actions; }
.scene-thumb { display: block; width: 200px; height: 50px; border-radius: 6px; overflow: hidden; background: var(--code-bg); }
.scene-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scene-info { min-width: 0; display: grid; gap: 2px; }
.scene-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; }
.scene-title a { color: inherit; text-decoration: none; }
.scene-title a:hover { text-decoration: underline; }
.badge-start { font-size: 0.75rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.badge-start[hidden] { display: none; }
.scene-message:empty { display: none; }
.scene-message { color: var(--muted); }
.scene-message.error { color: var(--danger); }
.scene-actions { display: flex; align-items: center; gap: 8px; }
.scene-actions .confirm { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.scene-actions .confirm[hidden], .scene-actions button[hidden] { display: none; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(1.1); background: var(--danger); }
.btn.danger-outline { background: transparent; color: var(--danger); border-color: var(--border); }
.btn.danger-outline:hover { background: var(--danger-soft); }
@media (prefers-color-scheme: dark) { .btn.danger { color: #1a0a0c; } }


/* Upload page: tabs, stitching */
.mode-tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.mode-tabs button {
  font: inherit; font-weight: 600; padding: 8px 16px; cursor: pointer;
  background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); margin-bottom: -1px;
}
.mode-tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.mode-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[role="tabpanel"][hidden] { display: none; }

.worker-status { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 0.92rem; }
.worker-status .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.worker-status.online { background: var(--ok-soft); color: var(--ok); }
.worker-status.online .dot { background: var(--ok); }
.worker-status.offline { background: var(--code-bg); color: var(--muted); }
.worker-status.offline .dot { background: var(--muted); }

.tips { margin: 0 0 18px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; }
.tips summary { cursor: pointer; font-weight: 600; }
.tips ul { margin: 10px 0 2px; padding-left: 1.2em; }
.tips li { margin: 4px 0; }

.photo-grid { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.photo { position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg); }
.photo-img { height: 80px; background: var(--code-bg); }
.photo-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-name { display: block; padding: 4px 6px; font-size: 0.75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo.invalid { border-color: var(--danger); }
.photo.invalid .photo-name { color: var(--danger); }
.photo.sent .photo-img { opacity: 0.45; }
.photo-remove {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 1rem; line-height: 1; cursor: pointer;
}
.stitch-upload-progress { margin-top: 12px; }

/* Stitching job cards */
.job-list { display: grid; gap: 10px; margin-top: 16px; }
.job-list:empty { display: none; }
.job-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--bg); display: grid; gap: 6px; }
.job-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.job-badge { font-size: 0.75rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--code-bg); color: var(--muted); }
.job-card[data-status="processing"] .job-badge, .job-card[data-status="pending"] .job-badge { background: var(--accent-soft); color: var(--accent); }
.job-card[data-status="done"] .job-badge { background: var(--ok-soft); color: var(--ok); }
.job-card[data-status="failed"] .job-badge { background: var(--danger-soft); color: var(--danger); }
.job-card[data-status="failed"] .job-text { color: var(--danger); }
.job-text { margin: 0; color: var(--muted); }
.job-notes { margin: 0; padding-left: 1.2em; color: var(--muted); }
.job-notes:empty { display: none; }
.job-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.job-actions:empty { display: none; }
.job-progress[hidden] { display: none; }
.jobs-section { margin-top: 20px; }
.jobs-section[hidden] { display: none; }
.jobs-section .job-list { margin-top: 0; }
.my-jobs { margin-top: 20px; }
.my-jobs[hidden] { display: none; }
.my-jobs .job-list { margin-top: 0; }
.job-tour { margin-top: -4px; }

/* Compact job rows ("Your jobs"): title · tour · badge, then one line of status + buttons */
.job-card.compact { grid-template-columns: 1fr auto; column-gap: 10px; row-gap: 2px; padding: 8px 12px; align-items: center; }
.job-card.compact[hidden] { display: none; }
.job-card.compact .job-head { display: contents; }
.job-card.compact .job-title { grid-column: 1; grid-row: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.95rem; }
.job-card.compact .job-badge { grid-column: 2; grid-row: 1; justify-self: end; }
.job-tour-inline { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.job-card.compact .job-progress { grid-column: 1 / -1; }
.job-card.compact .job-text { grid-column: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.82rem; }
.job-card.compact .job-actions { grid-column: 2; justify-self: end; gap: 6px; flex-wrap: nowrap; }
.job-card.compact .job-actions .btn.small { padding: 3px 10px; font-size: 0.8rem; }
.job-list.compact { gap: 6px; }
.job-more { margin-top: 8px; background: none; border: 0; padding: 0; cursor: pointer; }
.job-more[hidden] { display: none; }

/* "Sending N photos…" (photos saved on this phone by guided capture) */
.send-bar { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 50;
  max-width: calc(100% - 32px); padding: 8px 16px; border-radius: 999px; font-size: 0.85rem;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18); }
.send-bar[hidden], body.capturing .send-bar { display: none; }
.job-card[data-status="uploading"] .job-badge { background: var(--warn-soft); color: var(--warn); }
.job-card[data-sending="1"] .job-badge { background: var(--accent-soft); color: var(--accent); }

/* Guided capture */
.cap-modes { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin: 0; display: grid; gap: 10px; }
.cap-modes legend { font-weight: 600; padding: 0 4px; }
.cap-mode { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 0; cursor: pointer; }
.cap-mode input { margin-top: 5px; accent-color: var(--accent); }
body.capturing { overflow: hidden; }
.cap-screen { position: fixed; inset: 0; z-index: 1000; background: #000; color: #fff; touch-action: none; user-select: none; -webkit-user-select: none; }
.cap-screen[hidden] { display: none; }
.cap-screen video, .cap-screen canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.cap-screen video { object-fit: cover; }
.cap-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cap-flash.on { animation: cap-flash 0.25s ease-out; }
@keyframes cap-flash { from { opacity: 0.7; } to { opacity: 0; } }
.cap-top {
  position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px; background: linear-gradient(rgba(0,0,0,0.55), transparent);
}
.cap-count { font-size: 1.3rem; font-weight: 700; text-shadow: 0 1px 3px #000; }
.cap-close, .cap-finish {
  font: inherit; font-weight: 600; color: #fff; border: 1px solid rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.35); border-radius: 999px; cursor: pointer;
}
.cap-close { width: 42px; height: 42px; font-size: 1.6rem; line-height: 1; }
.cap-finish { padding: 9px 20px; }
.cap-finish:not(:disabled) { background: #50dc78; color: #062b12; border-color: #50dc78; }
.cap-finish:disabled { opacity: 0.45; }
.cap-hint {
  position: absolute; left: 50%; top: calc(50% + 120px); transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px); text-align: center;
  padding: 8px 16px; border-radius: 18px; background: rgba(0,0,0,0.55); font-weight: 600;
}
.cap-hint:empty { display: none; }
.cap-debug {
  position: absolute; left: 8px; right: 8px; bottom: calc(env(safe-area-inset-bottom, 0px) + 48px);
  font: 11px/1.3 "JetBrains Mono", monospace; color: #ffe08a; text-shadow: 0 1px 2px #000; text-align: center; white-space: pre-line;
}
.cap-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font-size: 0.9rem;
  padding: 12px 14px calc(env(safe-area-inset-bottom, 0px) + 14px); background: linear-gradient(transparent, rgba(0,0,0,0.55));
}
.cap-rotate { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,0.85); font-size: 1.2rem; font-weight: 600; text-align: center; padding: 24px; }
.cap-rotate[hidden] { display: none; }
.capture-callout { margin: 0 0 14px; padding: 10px 14px; border-radius: 8px; background: var(--accent-soft); }

/* Public / private */
.private-badge {
  display: inline-block; vertical-align: middle; margin-left: 6px;
  font-size: 0.72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--code-bg); color: var(--muted); border: 1px solid var(--border);
}
.visibility { margin-bottom: 20px; }
.vis-options { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.vis-option { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 0; padding: 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.vis-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.vis-option input { margin-top: 4px; accent-color: var(--accent); }
.vis-status { margin: 10px 0 0; color: var(--muted); }
.vis-status:empty { display: none; }
.vis-status.error { color: var(--danger); }

/* Manage page: details, ordering, rename, danger zone */
.details, .visibility { margin-bottom: 20px; }
.form-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.form-status { color: var(--muted); margin: 0; }
.form-status.error, .scene-message.error { color: var(--danger); }
.form-status:empty { display: none; }
.scene-order { display: grid; gap: 2px; }
.order-btn {
  width: 28px; height: 24px; padding: 0; font-size: 0.7rem; line-height: 1; cursor: pointer;
  border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--muted);
}
.order-btn:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.order-btn:disabled { opacity: 0.3; cursor: default; }
.scene-title[hidden], .rename-form[hidden], .js-start[hidden] { display: none; }
.rename-form { display: flex; gap: 6px; align-items: center; }
.rename-form input { flex: 1; min-width: 0; padding: 5px 8px; }
.scene-actions { flex-wrap: wrap; justify-content: flex-end; }
.danger-zone { margin-top: 20px; border-color: var(--danger-soft); }
.danger-zone .section-title { color: var(--danger); }
.danger-zone input { max-width: 340px; }
/* Phones: a stacked card. Thumbnail on top, title + order arrows, then the buttons. */
@media (max-width: 640px) {
  .scene-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "thumb thumb" "info order" "actions actions";
    align-items: start;
  }
  .scene-thumb { width: 100%; height: 72px; }
  .scene-order { display: flex; gap: 6px; }
  .order-btn { width: 36px; height: 32px; font-size: 0.8rem; }
  .scene-actions { justify-content: flex-start; }
  .scene-actions .confirm { justify-content: flex-start; }
}

/* Menu: links in a row on wide screens; on phones a ☰ button opens them as a list */
.nav-links { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.nav-toggle { display: none; }
@media (max-width: 700px) {
  .site-nav { position: relative; flex-wrap: nowrap; padding: 12px 16px; z-index: 30; }
  .nav-toggle {
    display: grid; align-content: center; gap: 5px; width: 40px; height: 36px; padding: 0 9px;
    background: transparent; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 8px; cursor: pointer;
  }
  .nav-toggle span { display: block; height: 2px; background: #fff; border-radius: 1px; transition: transform .2s, opacity .2s; }
  .site-nav.open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .site-nav.open .nav-toggle span:nth-child(2) { opacity: 0; }
  .site-nav.open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .nav-links {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: #0f3d4a; border-top: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  }
  .site-nav.open .nav-links { display: flex; }
  .nav-links a.link, .nav-links button.link {
    display: block; padding: 13px 20px; font-size: 1rem; text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
  .nav-links a.link.active { text-decoration: none; background: rgba(255, 255, 255, 0.08); }
  .nav-logout { flex-direction: column; align-items: stretch; gap: 0; }
  .nav-user { display: block; padding: 10px 20px 0; font-size: 0.85rem; }
}
@media (max-width: 600px) {
  .head-actions { gap: 6px; }
  .head-actions .btn { padding: 6px 11px; font-size: 0.88rem; }
  .page-head h1 { font-size: 1.5rem; }
}

/* Accounts */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }   /* bot trap */
.verify-banner { padding: 10px 16px; text-align: center; background: #f0b429; color: #2b1d00; font-weight: 600; font-size: 0.92rem; }
.verify-banner a { color: inherit; }
.account .card { margin-top: 16px; }
.account .section-title { margin: 0; }
.verify-card { border-color: #f0b429; }
.usage { display: grid; gap: 10px; }
.usage > div:not(.meter) { display: flex; justify-content: space-between; gap: 12px; }
.usage span { color: var(--muted); }
.meter { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); }
.user-list { display: grid; gap: 12px; }
.user-card { display: flex; justify-content: space-between; gap: 16px; align-items: center; flex-wrap: wrap; padding: 16px 18px; }
.user-card.disabled { opacity: 0.7; }
.user-main { display: grid; gap: 3px; min-width: 0; }
.user-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-name .private-badge { margin-left: 0; }
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Manage: share link and embed code */
.share { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); display: grid; gap: 8px; }
.share[hidden] { display: none; }
.share p { margin: 0; }
.copy-row { display: flex; gap: 8px; align-items: flex-start; }
.copy-row input, .copy-row textarea { flex: 1; min-width: 0; font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; }
.copy-row textarea { resize: vertical; }
.embed-box summary { cursor: pointer; font-weight: 600; font-size: 0.92rem; }
.embed-box[open] summary { margin-bottom: 8px; }
.embed-box p { margin-bottom: 8px; }
#share-manage[hidden] { display: none; }

/* My tours */
/* Tours page: the user's counts and limits, one compact line */
.usage-line { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: -14px 0 18px; color: var(--text); }
.usage-line a { color: inherit; }
.usage-strip { display: flex; flex-wrap: wrap; gap: 14px 32px; align-items: flex-end; margin-bottom: 20px; }
.usage-item { display: grid; gap: 2px; min-width: 120px; }
.usage-item .meter { margin-top: 4px; }
.section-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-head .section-title { margin: 0; }
.new-tour-form { display: flex; gap: 8px; flex: 0 1 360px; }
.new-tour-form input { flex: 1; min-width: 0; }
.mytours .form-status:empty { display: none; }
.my-tour-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.my-tour { display: grid; grid-template-columns: 120px 1fr auto; gap: 14px; align-items: center;
  border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: var(--bg); }
.my-tour-thumb { display: block; height: 60px; border-radius: 6px; background: var(--code-bg) center / cover no-repeat; }
.my-tour-info { min-width: 0; display: grid; gap: 4px; }
.my-tour-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.my-tour-title a { font-weight: 600; color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.my-tour-title a:hover { text-decoration: underline; }
.my-tour-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.vis-badge { flex: none; font-size: 0.72rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.vis-badge.public { background: var(--ok-soft); color: var(--ok); }
.vis-badge.private { background: var(--code-bg); color: var(--muted); }
.vis-badge.shared { background: var(--accent-soft); color: var(--accent); }
/* My scenes (myscenes.php): a tick box before each row */
.my-tour.scene-item { grid-template-columns: auto 120px 1fr auto; }
.scene-pick { display: flex; align-items: center; padding: 0 2px 0 6px; cursor: pointer; }
.scene-pick input { width: 18px; height: 18px; margin: 0; }
.scene-item .rename-form, .scene-item .duplicate-form { display: flex; gap: 6px; flex-wrap: wrap; }
.scene-item .rename-form[hidden], .scene-item .duplicate-form[hidden], .scene-item .confirm[hidden],
.scene-item button[hidden] { display: none; }
.scene-item .rename-form input, .scene-item .duplicate-form input { flex: 1; min-width: 120px; }
.scene-item .confirm { display: flex; gap: 6px; flex-wrap: wrap; }
.scene-item .scene-message:empty { display: none; }
.scene-item .scene-message.error { color: var(--danger, #c0392b); }
.scene-item.highlight { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.myscenes .form-status.error { color: var(--danger, #c0392b); }
@media (max-width: 640px) {
  .my-tour.scene-item { grid-template-columns: auto 88px 1fr; grid-template-areas: "pick thumb info" "actions actions actions"; }
  .scene-pick { grid-area: pick; }
}
@media (max-width: 640px) {
  .my-tour { grid-template-columns: 88px 1fr; grid-template-areas: "thumb info" "actions actions"; }
  .my-tour-thumb { grid-area: thumb; height: 52px; }
  .my-tour-info { grid-area: info; }
  .my-tour-actions { grid-area: actions; justify-content: flex-start; }
  .new-tour-form { flex: 1 1 100%; }
}

/* Terms and Privacy */
.legal h2 { font-size: 1.15rem; margin: 28px 0 8px; }
.legal h3 { font-size: 1rem; margin: 18px 0 6px; }
.legal p, .legal li { line-height: 1.6; }
.legal ul { padding-left: 1.3em; }
.legal li + li { margin-top: 4px; }
.site-footer a { color: inherit; }
.page.narrow.legal { max-width: 720px; }

/* Upload page, "3D scene" tab (assets/js/upload-3d.js) */
.splat-preview {
  position: relative; margin-top: 16px; aspect-ratio: 2 / 1; width: 100%;
  border-radius: 10px; overflow: hidden; background: #0b0f14;
}
.splat-preview[hidden] { display: none; }
.splat-preview canvas { display: block; touch-action: none; }
.splat-preview .splat-controls .ico { display: none; }   /* labels only here (splat-view.js gives each button both) */
.splat-preview-status {
  position: absolute; left: 10px; bottom: 8px; padding: 3px 8px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.55); color: #f2f5f8; font-size: 0.8rem; pointer-events: none;
}
.splat-preview-status:empty { display: none; }

/* Upload page, "3D scene" tab: from a video (assets/js/upload-video.js) or a .sog (upload-3d.js) */
.source-switch { display: flex; gap: 18px; flex-wrap: wrap; margin: 0 0 16px; }
.source-switch label { display: flex; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; margin: 0; }
/* Compact job rows: a failure message wraps instead of being cut off (no hover on phones) */
.job-card.compact[data-status="failed"] .job-text { white-space: normal; overflow: visible; }
.job-card.compact .job-notes { grid-column: 1 / -1; font-size: 0.8rem; margin-top: 2px; }

/* Upload page, 3D tab: record a video in the page (assets/js/video-recorder.js) */
.record-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.record-row[hidden] { display: none; }
.recorder { position: fixed; inset: 0; z-index: 1000; background: #000; display: grid; place-items: center; }
.recorder-view { width: 100%; height: 100%; object-fit: contain; background: #000; }
.recorder-close {
  position: absolute; top: 14px; left: 14px; width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.3); background: rgba(0,0,0,.5); color: #fff; font-size: 28px; line-height: 1;
}
.recorder-time {
  position: absolute; top: 20px; left: 50%; transform: translateX(-50%); padding: 4px 12px; border-radius: 999px;
  background: #c62828; color: #fff; font: 600 16px/1.4 system-ui, sans-serif; font-variant-numeric: tabular-nums;
}
.recorder-time[hidden] { display: none; }
.recorder-msg {
  position: absolute; left: 16px; right: 16px; bottom: 120px; margin: 0; text-align: center; color: #fff;
  text-shadow: 0 1px 3px #000; font: 15px/1.4 system-ui, sans-serif;
}
.recorder-msg:empty { display: none; }
.recorder-go {
  position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%); width: 76px; height: 76px;
  border-radius: 50%; border: 4px solid #fff; background: transparent; display: grid; place-items: center; padding: 0;
}
.recorder-go span { width: 58px; height: 58px; border-radius: 50%; background: #e53935; transition: all .15s; }
.recorder.recording .recorder-go span { width: 30px; height: 30px; border-radius: 6px; }
.recorder-go:disabled { opacity: .4; }

/* Manage page: "Add from My scenes" */
.add-scene-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.add-scene { display: grid; grid-template-columns: auto 72px 1fr; gap: 10px; align-items: center; cursor: pointer;
  border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px 6px 8px; background: var(--bg); font-weight: 400; }
.add-scene:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.add-scene input { width: 18px; height: 18px; margin: 0; }
.add-scene-thumb { height: 40px; border-radius: 6px; background: var(--code-bg) center / cover no-repeat; }
.add-scene-info { display: grid; gap: 2px; min-width: 0; }
.add-scene-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.add-scenes .form-status.error { color: var(--danger); }
