:root {
  --bg: #0e1116;
  --bg-soft: #161b22;
  --panel: #1c222c;
  --line: #2a323d;
  --text: #e8ecf1;
  --muted: #97a3b4;
  --brand: #2f81f7;
  --brand-2: #12b6c9;
  --danger: #ef4b5b;
  --ok: #2ea86a;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: inherit;
}

/* ---------- 通用组件 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: #232b36; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: #2571df; }
.btn--ghost { background: transparent; }
.btn--danger { color: var(--danger); border-color: rgba(239, 75, 91, .5); background: rgba(239, 75, 91, .1); }
.btn--sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 13px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  background: #10151c;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); }
.textarea { resize: vertical; min-height: 80px; }

.card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(47, 129, 247, .15);
  color: #7ab6ff;
}
.tag--ok { background: rgba(46, 168, 106, .15); color: #58d69b; }
.tag--gray { background: rgba(151, 163, 180, .15); color: var(--muted); }

.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 20px);
  background: rgba(20, 25, 32, .96);
  border: 1px solid var(--line);
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 999;
  font-size: 14px;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 站点头部 ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 17, 22, .9);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: .3px; }
.brand__logo {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.brand span { font-size: 16px; }
.user-chip { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.user-chip strong { color: var(--text); font-weight: 600; }

/* ---------- 登录 / 首页 ---------- */

.auth-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(47, 129, 247, .18), transparent 60%);
}
.auth-box { width: 100%; max-width: 380px; }
.auth-box h1 { margin: 0 0 6px; font-size: 22px; }
.auth-box p.sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.auth-card { padding: 22px; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.auth-tabs .btn { flex: 1; }
.auth-tabs .btn.is-active { background: rgba(47, 129, 247, .18); border-color: var(--brand); color: #9cc6ff; }
.auth-hint { margin-top: 14px; font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- 工作台 ---------- */

.page { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { margin: 0 0 4px; font-size: 20px; }
.page-head p { margin: 0; color: var(--muted); font-size: 14px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.proj-card { overflow: hidden; display: flex; flex-direction: column; }
.proj-card__cover {
  aspect-ratio: 16 / 9;
  background: #0b0e13 center / cover no-repeat;
  position: relative;
}
.proj-card__cover .fallback {
  display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 13px;
}
.proj-card__body { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.proj-card__title { font-weight: 600; font-size: 15px; }
.proj-card__meta { color: var(--muted); font-size: 13px; }
.proj-card__actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.proj-card__badges { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- 编辑器 ---------- */

.editor {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - 57px);
  overflow: hidden;
}
.sidebar {
  border-right: 1px solid var(--line);
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar__section { padding: 14px; border-bottom: 1px solid var(--line); }
.sidebar__section h3 { margin: 0 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .5px; }
.sidebar__scroll { overflow: auto; flex: 1; min-height: 0; }

.scene-item {
  display: flex; gap: 10px; align-items: center;
  padding: 8px; border-radius: 10px; cursor: pointer; border: 1px solid transparent;
}
.scene-item:hover { background: rgba(255, 255, 255, .04); }
.scene-item.is-active { background: rgba(47, 129, 247, .14); border-color: rgba(47, 129, 247, .5); }
.scene-item__thumb {
  width: 56px; height: 36px; border-radius: 6px; object-fit: cover; background: #0b0e13; flex: none;
}
.scene-item__name { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stage { position: relative; min-width: 0; background: #05070a; }
.stage__toolbar {
  position: absolute; top: 12px; left: 12px; right: 12px; z-index: 5;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  pointer-events: none;
}
.stage__toolbar > * { pointer-events: auto; }
.stage__hint {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(10, 13, 18, .8); border: 1px solid var(--line);
  padding: 7px 14px; border-radius: 999px; font-size: 13px; color: var(--muted); z-index: 5;
}

.spot-list { display: flex; flex-direction: column; gap: 8px; }
.spot-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px;
}
.spot-item.is-active { border-color: var(--brand); background: rgba(47, 129, 247, .1); }
.spot-item__main { flex: 1; min-width: 0; }
.spot-item__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spot-item__meta { color: var(--muted); font-size: 12px; }

/* ---------- 播放器 ---------- */

.pano-root { position: fixed; inset: 0; background: #000; overflow: hidden; }
.pano-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.pano-hotspot-layer { position: absolute; inset: 0; pointer-events: none; }

.pano-hotspot {
  position: absolute; left: 0; top: 0;
  pointer-events: auto; cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
  will-change: transform;
}
.pano-hotspot__icon, .pano-hotspot__arrow {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(10, 14, 20, .55);
  border: 2px solid rgba(255, 255, 255, .9);
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 15px; font-style: italic;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .4);
  backdrop-filter: blur(2px);
}
.pano-hotspot__arrow {
  position: relative;
  background: rgba(255, 255, 255, .92);
  border-color: rgba(255, 255, 255, .95);
  animation: spot-pulse 2.2s ease-out infinite;
}
.pano-hotspot__arrow::after {
  content: ''; width: 0; height: 0; margin-left: 2px;
  border-left: 8px solid #12181f;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}
@keyframes spot-pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .55); }
  70% { box-shadow: 0 0 0 16px rgba(255, 255, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}
.pano-hotspot__label {
  margin-top: 6px; padding: 2px 8px; border-radius: 999px;
  background: rgba(8, 11, 16, .72); color: #fff; font-size: 12px;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: none;
}
.pano-hotspot__label:not(:empty) { display: block; }
.pano-hotspot.is-editable .pano-hotspot__icon,
.pano-hotspot.is-editable .pano-hotspot__arrow { outline: 2px dashed rgba(47, 129, 247, .9); outline-offset: 3px; }

.pano-fade {
  position: absolute; inset: 0; background: #000; opacity: 0;
  transition: opacity .32s ease; pointer-events: none; z-index: 2;
}
.pano-loading {
  position: absolute; inset: 0; display: none; place-items: center;
  background: rgba(0, 0, 0, .55); z-index: 3;
}
.pano-loading.is-active { display: grid; }
.pano-spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .25); border-top-color: #fff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pano-root.is-vr .pano-hotspot-layer { display: none; }
.vr-divider {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 2px;
  background: rgba(255, 255, 255, .35); z-index: 4; display: none;
}
.pano-root.is-vr .vr-divider { display: block; }

/* 播放器 UI */
.ui-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  padding: 12px 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  background: linear-gradient(rgba(0, 0, 0, .55), transparent);
  pointer-events: none;
}
.ui-top > * { pointer-events: auto; }
.ui-title { font-size: 16px; font-weight: 600; text-shadow: 0 1px 6px rgba(0, 0, 0, .6); }
.ui-title small { display: block; font-weight: 400; color: rgba(255, 255, 255, .7); font-size: 12px; margin-top: 2px; }
.ui-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.ui-btn {
  width: 38px; height: 38px; border-radius: 10px;
  background: rgba(12, 16, 22, .62); border: 1px solid rgba(255, 255, 255, .18);
  color: #fff; display: grid; place-items: center; cursor: pointer;
  backdrop-filter: blur(6px); font-size: 15px;
}
.ui-btn.is-on { background: rgba(47, 129, 247, .85); border-color: rgba(47, 129, 247, .9); }

.ui-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, .6));
}
.scene-bar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.scene-chip {
  flex: none; display: flex; flex-direction: column; gap: 4px; align-items: center;
  padding: 4px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(12, 16, 22, .6); cursor: pointer; color: #fff; width: 88px;
}
.scene-chip img { width: 80px; height: 45px; object-fit: cover; border-radius: 6px; background: #0b0e13; }
.scene-chip span { font-size: 11px; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scene-chip.is-active { border-color: #fff; background: rgba(47, 129, 247, .75); }

.info-modal {
  position: absolute; inset: 0; z-index: 20; display: none; place-items: center;
  background: rgba(0, 0, 0, .6); padding: 24px;
}
.info-modal.is-show { display: grid; }
.info-modal__box {
  width: min(420px, 100%); background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 14px; padding: 20px; box-shadow: var(--shadow); max-height: 80vh; overflow: auto;
}
.info-modal__box h3 { margin: 0 0 10px; font-size: 17px; }
.info-modal__box img { max-width: 100%; border-radius: 8px; margin-top: 10px; }
.info-modal__box p { margin: 0; line-height: 1.7; color: #cbd5e1; white-space: pre-wrap; }

/* ---------- 响应式 ---------- */

@media (max-width: 860px) {
  .editor { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .sidebar { order: 2; border-right: none; border-top: 1px solid var(--line); max-height: 46vh; }
  .stage { order: 1; }
}

.hidden { display: none !important; }
