:root {
      --bg: #0c0e12;
      --panel: rgba(14, 18, 24, 0.88);
      --line: rgba(255, 255, 255, 0.1);
      --text: #f2f4f7;
      --muted: #9aa3af;
      --accent: #2f8cff;
      --accent-soft: rgba(47, 140, 255, 0.18);
      --ok: #2ec995;
      --danger: #ff5c6c;
      --radius: 14px;
      --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
      --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    }

    * { box-sizing: border-box; }
    html, body {
      margin: 0;
      height: 100%;
      background: var(--bg);
      color: var(--text);
      font-family: var(--font);
      overflow: hidden;
      user-select: none;
    }

    #viewer {
      position: absolute;
      inset: 0;
      cursor: grab;
      touch-action: none;
    }
    #viewer.dragging { cursor: grabbing; }
    #viewer canvas { display: block; width: 100%; height: 100%; }

    .transition-veil {
      position: absolute;
      inset: 0;
      z-index: 7;
      background: #05070a;
      opacity: 0;
      pointer-events: none;
      transition: opacity .08s linear;
      will-change: opacity;
    }

    .hotspot-layer {
      position: absolute;
      inset: 0;
      pointer-events: none;
      overflow: hidden;
      z-index: 5;
    }

    .hotspot {
      position: absolute;
      width: 54px;
      height: 54px;
      margin-left: -27px;
      margin-top: -27px;
      pointer-events: auto;
      cursor: pointer;
      display: none;
      filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.45));
      will-change: transform;
      transition: opacity .2s ease;
    }
    .hotspot-layer.is-hiding .hotspot { opacity: 0; pointer-events: none; }

    .hotspot .ring {
      width: 42px;
      height: 42px;
      margin: 6px auto 0;
      border-radius: 50%;
      border: 2px solid rgba(255, 255, 255, 0.95);
      background: radial-gradient(circle at 50% 40%, rgba(47, 140, 255, 0.95), rgba(20, 90, 200, 0.9));
      display: grid;
      place-items: center;
      animation: pulse 1.8s ease-in-out infinite;
      position: relative;
    }

    .hotspot .ring::after {
      content: "";
      position: absolute;
      inset: -8px;
      border-radius: 50%;
      border: 1px solid rgba(47, 140, 255, 0.55);
      animation: ripple 1.8s ease-out infinite;
    }

    .hotspot .arrow {
      width: 0;
      height: 0;
      border-left: 7px solid transparent;
      border-right: 7px solid transparent;
      border-bottom: 12px solid #fff;
      transform: translateY(-1px);
    }

    .hotspot .label {
      position: absolute;
      top: calc(100% + 2px);
      left: 50%;
      transform: translateX(-50%);
      white-space: nowrap;
      padding: 4px 8px;
      border-radius: 8px;
      background: rgba(10, 14, 20, 0.82);
      border: 1px solid rgba(255, 255, 255, 0.12);
      color: #fff;
      font-size: 12px;
      pointer-events: none;
    }

    @keyframes pulse {
      0%, 100% { transform: scale(1); }
      50% { transform: scale(1.06); }
    }
    @keyframes ripple {
      0% { transform: scale(0.85); opacity: 0.7; }
      100% { transform: scale(1.35); opacity: 0; }
    }

    .topbar {
      position: absolute;
      top: 16px;
      left: 16px;
      right: 16px;
      z-index: 20;
      display: flex;
      gap: 12px;
      align-items: center;
      pointer-events: none;
    }
    .topbar > * { pointer-events: auto; }

    .brand {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 10px 14px;
      background: var(--panel);
      backdrop-filter: blur(14px);
      border: 1px solid var(--line);
      border-radius: 999px;
      box-shadow: var(--shadow);
      min-width: 0;
    }
    .brand-dot {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background: var(--ok);
      box-shadow: 0 0 0 4px rgba(46, 201, 149, 0.2);
      flex: 0 0 auto;
    }
    .brand strong { font-size: 14px; font-weight: 650; white-space: nowrap; }
    .brand span {
      color: var(--muted);
      font-size: 13px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .actions {
      margin-left: auto;
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      justify-content: flex-end;
      align-items: center;
    }

    .brightness {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 12px;
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 999px;
      box-shadow: var(--shadow);
      backdrop-filter: blur(14px);
      font-size: 12px;
      color: var(--muted);
    }
    .brightness input[type="range"] {
      width: 90px;
      accent-color: var(--accent);
      cursor: pointer;
    }

    button {
      appearance: none;
      border: 1px solid var(--line);
      background: var(--panel);
      color: var(--text);
      border-radius: 999px;
      padding: 10px 14px;
      font: inherit;
      font-size: 13px;
      cursor: pointer;
      backdrop-filter: blur(14px);
      box-shadow: var(--shadow);
      transition: background .15s ease, border-color .15s ease, transform .12s ease;
    }
    button:hover {
      background: rgba(255, 255, 255, 0.08);
      border-color: rgba(255, 255, 255, 0.22);
    }
    button:active { transform: translateY(1px); }
    button.primary {
      background: var(--accent);
      border-color: transparent;
      color: #fff;
    }
    button.danger {
      background: rgba(255, 92, 108, 0.15);
      border-color: rgba(255, 92, 108, 0.35);
      color: #ffb4bc;
    }
    button.active {
      background: var(--accent-soft);
      border-color: rgba(47, 140, 255, 0.55);
      color: #cfe4ff;
    }

    .sidebar {
      position: absolute;
      top: 76px;
      left: 16px;
      bottom: 16px;
      width: min(280px, calc(100vw - 32px));
      z-index: 20;
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      backdrop-filter: blur(16px);
      box-shadow: var(--shadow);
      display: flex;
      flex-direction: column;
      overflow: hidden;
      transition: transform .22s ease, opacity .22s ease;
    }
    .sidebar.collapsed {
      transform: translateX(calc(-100% - 24px));
      opacity: 0;
      pointer-events: none;
    }
    .sidebar-head {
      padding: 14px 14px 10px;
      border-bottom: 1px solid var(--line);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }
    .sidebar-head h2 {
      margin: 0;
      font-size: 13px;
      font-weight: 650;
      color: var(--muted);
    }
    .scene-list {
      overflow: auto;
      padding: 8px;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .scene-item {
      display: grid;
      grid-template-columns: 56px 1fr auto;
      gap: 10px;
      align-items: center;
      padding: 8px;
      border-radius: 12px;
      border: 1px solid transparent;
      background: transparent;
      color: inherit;
      text-align: left;
      width: 100%;
    }
    body[data-mode="config"] .scene-item {
      grid-template-columns: 56px 1fr auto auto;
    }
    .scene-item:hover {
      background: rgba(255, 255, 255, 0.05);
      border-color: var(--line);
    }
    .scene-item.current {
      background: var(--accent-soft);
      border-color: rgba(47, 140, 255, 0.45);
    }
    .scene-thumb {
      width: 56px;
      height: 40px;
      border-radius: 8px;
      background: linear-gradient(135deg, #1a2433, #243246);
      display: grid;
      place-items: center;
      color: #8fa0b5;
      font-size: 12px;
      font-weight: 650;
    }
    .scene-item .scene-rename,
    .scene-item .scene-order button {
      padding: 6px 8px;
      font-size: 11px;
      box-shadow: none;
      border-radius: 8px;
      white-space: nowrap;
    }
    .scene-order {
      display: flex;
      flex-direction: column;
      gap: 2px;
    }
    .scene-order button {
      min-width: 28px;
      padding: 4px 6px;
      line-height: 1;
    }
    .scene-order button:disabled {
      opacity: 0.35;
      cursor: not-allowed;
    }
    .scene-start-tag {
      display: inline-block;
      margin-left: 6px;
      padding: 1px 6px;
      border-radius: 999px;
      font-size: 10px;
      font-weight: 600;
      color: #b8f5dc;
      background: rgba(46, 201, 149, 0.18);
      border: 1px solid rgba(46, 201, 149, 0.35);
      vertical-align: middle;
    }
    .scene-meta strong { display: block; font-size: 13px; font-weight: 600; }
    .scene-meta small {
      display: block;
      color: var(--muted);
      font-size: 11px;
      max-width: 140px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .check-row {
      display: flex;
      align-items: flex-start;
      gap: 8px;
      margin: 12px 0 4px;
      font-size: 13px;
      color: var(--text);
      cursor: pointer;
    }
    .check-row input { margin-top: 3px; accent-color: var(--accent); }

    .hint {
      position: absolute;
      left: 50%;
      bottom: 22px;
      transform: translateX(-50%);
      z-index: 20;
      padding: 10px 16px;
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 999px;
      color: var(--muted);
      font-size: 13px;
      box-shadow: var(--shadow);
      backdrop-filter: blur(14px);
      pointer-events: none;
      opacity: 0;
      transition: opacity .25s ease;
      white-space: nowrap;
      max-width: calc(100vw - 32px);
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .hint.show { opacity: 1; }

    .loader {
      position: absolute;
      inset: 0;
      z-index: 8;
      display: none;
      align-items: center;
      justify-content: center;
      background: rgba(8, 10, 14, 0.35);
      color: #fff;
      font-size: 14px;
      letter-spacing: 0.02em;
    }
    .loader.show { display: flex; }
    .loader span {
      padding: 12px 18px;
      border-radius: 999px;
      background: rgba(14, 18, 24, 0.9);
      border: 1px solid var(--line);
    }

    .edit-banner {
      position: absolute;
      top: 76px;
      left: 50%;
      transform: translateX(-50%);
      z-index: 21;
      display: none;
      align-items: center;
      gap: 10px;
      padding: 8px 12px;
      background: rgba(47, 140, 255, 0.16);
      border: 1px solid rgba(47, 140, 255, 0.4);
      color: #d7e9ff;
      border-radius: 999px;
      font-size: 13px;
      backdrop-filter: blur(12px);
      box-shadow: var(--shadow);
      white-space: nowrap;
    }
    .edit-banner.show { display: flex; }

    .modal-mask {
      position: absolute;
      inset: 0;
      z-index: 40;
      background: rgba(0, 0, 0, 0.55);
      display: none;
      align-items: center;
      justify-content: center;
      padding: 20px;
    }
    .modal-mask.open { display: flex; }
    .modal {
      width: min(440px, 100%);
      background: #12161d;
      border: 1px solid var(--line);
      border-radius: 18px;
      box-shadow: var(--shadow);
      overflow: hidden;
    }
    .modal header {
      padding: 16px 18px 8px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    .modal header h3 { margin: 0; font-size: 16px; }
    .modal .body { padding: 8px 18px 18px; }
    .modal .foot {
      padding: 0 18px 18px;
      display: flex;
      gap: 8px;
      justify-content: flex-end;
    }
    label.field {
      display: block;
      margin-bottom: 12px;
      font-size: 13px;
      color: var(--muted);
    }
    label.field input,
    label.field select {
      display: block;
      width: 100%;
      margin-top: 6px;
      padding: 10px 12px;
      border-radius: 10px;
      border: 1px solid var(--line);
      background: #0c1016;
      color: var(--text);
      font: inherit;
      outline: none;
    }

    .toast {
      position: absolute;
      top: 80px;
      right: 16px;
      z-index: 50;
      padding: 10px 14px;
      background: #142018;
      border: 1px solid rgba(46, 201, 149, 0.35);
      color: #b8f5dc;
      border-radius: 12px;
      box-shadow: var(--shadow);
      opacity: 0;
      transform: translateY(-6px);
      transition: opacity .2s ease, transform .2s ease;
      pointer-events: none;
      font-size: 13px;
    }
    .toast.show { opacity: 1; transform: translateY(0); }
    .toast.error {
      background: #221015;
      border-color: rgba(255, 92, 108, 0.4);
      color: #ffc2c9;
    }

    @media (max-width: 720px) {
      .brand span { display: none; }
      .sidebar {
        top: auto;
        left: 12px;
        right: 12px;
        bottom: 12px;
        width: auto;
        height: 38vh;
      }
      .sidebar.collapsed { transform: translateY(calc(100% + 24px)); }
      .edit-banner {
        top: auto;
        bottom: calc(38vh + 28px);
        max-width: calc(100vw - 24px);
        white-space: normal;
        text-align: center;
      }
    .hint { bottom: calc(38vh + 28px); }
  }

.mode-tag {
  margin-left: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  color: #cfe4ff;
  background: rgba(47, 140, 255, 0.2);
  border: 1px solid rgba(47, 140, 255, 0.35);
  white-space: nowrap;
}

a.btn-link {
  appearance: none;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  border: 1px solid rgba(46, 201, 149, 0.4);
  background: rgba(46, 201, 149, 0.14);
  color: #b8f5dc;
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

a.btn-link:hover {
  background: rgba(46, 201, 149, 0.24);
}

/* 展厅预览页：强制隐藏一切配置相关控件（防止缓存/误嵌） */
body[data-mode="view"] #btnEditMode,
body[data-mode="view"] #btnSyncAssets,
body[data-mode="view"] #btnExport,
body[data-mode="view"] #btnImport,
body[data-mode="view"] #importFile,
body[data-mode="view"] #editBanner,
body[data-mode="view"] #hotspotModal,
body[data-mode="view"] #sceneModal,
body[data-mode="view"] .scene-rename,
body[data-mode="view"] .scene-order,
body[data-mode="view"] .scene-start-tag,
body[data-mode="view"] .mode-tag,
body[data-mode="view"] a.btn-link {
  display: none !important;
}
