:root {
  --gray-950: #0a0a0a;
  --gray-900: #171717;
  --gray-800: #262626;
  --gray-700: #404040;
  --gray-600: #525252;
  --gray-500: #737373;
  --gray-400: #a3a3a3;
  --gray-300: #d4d4d4;
  --gray-200: #e5e5e5;
  --gray-100: #f5f5f5;
  --gray-50: #fafafa;

  --primary: #4a5843;
  --primary-hover: #354230;
  --accent: #596a48;
  --accent-hover: #3e5032;

  --bg: var(--gray-50);
  --surface: white;
  --border: var(--gray-200);
  --text: var(--gray-950);
  --text-muted: var(--gray-600);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--gray-950);
    --surface: var(--gray-900);
    --border: var(--gray-800);
    --text: var(--gray-100);
    --text-muted: var(--gray-400);
  }
}

:root[data-theme="dark"] {
  --bg: var(--gray-950);
  --surface: var(--gray-900);
  --border: var(--gray-800);
  --text: var(--gray-100);
  --text-muted: var(--gray-400);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-dot {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--primary);
  border-radius: 50% 50% 6px 6px;
}

.brand h1 {
  font-size: 16px;
  font-weight: 600;
}

.brand p {
  font-size: 12px;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.btn {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover {
  background: var(--gray-100);
  border-color: var(--gray-300);
}

.btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-accent {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-accent:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--gray-100);
}

.btn-icon {
  padding: 4px 8px;
  font-size: 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.btn-icon:hover {
  color: var(--text);
}

#main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

#sidebar {
  width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-section h2 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-section ul {
  list-style: none;
}

.sidebar-section ul li {
  padding: 8px 12px;
  margin-bottom: 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.sidebar-section ul li:hover {
  background: var(--gray-100);
}

.sidebar-section ul li.active {
  background: var(--primary);
  color: white;
}

.hint-box {
  padding: 12px;
  background: var(--gray-100);
  border-radius: 8px;
}

.hint-box p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.price-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  margin-bottom: 12px;
  background: var(--gray-100);
  border-radius: 8px;
}

.price-total span {
  font-size: 13px;
  color: var(--text-muted);
}

.price-total strong {
  font-size: 18px;
  color: var(--accent);
}

.full-width {
  width: 100%;
}

#viewport {
  flex: 1;
  position: relative;
}

#scene-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  color: white;
  text-shadow: 0 0 4px rgba(0,0,0,0.5);
  pointer-events: none;
}

#loading-overlay {
  position: absolute;
  inset: 0;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

#loading-overlay.hidden {
  display: none;
}

.loader {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#tooltip {
  position: absolute;
  padding: 8px 12px;
  background: rgba(0,0,0,0.8);
  color: white;
  font-size: 13px;
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 100;
}

#tooltip.hidden {
  display: none;
}

#furniture-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 520px;
  max-height: 70vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
  z-index: 200;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#furniture-panel.hidden {
  display: none;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.panel-list {
  overflow-y: auto;
  padding: 16px;
}

.furniture-option {
  display: flex;
  gap: 16px;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.furniture-option:hover {
  border-color: var(--primary);
  background: var(--gray-50);
}

.furniture-option.selected {
  border-color: var(--primary);
  background: var(--gray-100);
  box-shadow: 0 0 0 2px var(--primary);
}

.furniture-option .thumb {
  width: 120px;
  height: 90px;
  border-radius: 6px;
  background: var(--gray-200);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-muted);
}

.furniture-option .info {
  flex: 1;
}

.furniture-option .info h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.furniture-option .info p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.furniture-option .price {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
}

#toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: rgba(0,0,0,0.85);
  color: white;
  border-radius: 8px;
  font-size: 14px;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s;
}

#toast:not(.hidden) {
  opacity: 1;
}

.hidden {
  display: none !important;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn:hover {
    background: var(--gray-800);
    border-color: var(--gray-700);
  }

  :root:not([data-theme="light"]) .sidebar-section ul li:hover {
    background: var(--gray-800);
  }

  :root:not([data-theme="light"]) .hint-box {
    background: var(--gray-800);
  }

  :root:not([data-theme="light"]) .price-total {
    background: var(--gray-800);
  }

  :root:not([data-theme="light"]) .furniture-option:hover {
    background: var(--gray-800);
  }

  :root:not([data-theme="light"]) .furniture-option.selected {
    background: var(--gray-800);
  }
}

:root[data-theme="dark"] .btn:hover {
  background: var(--gray-800);
  border-color: var(--gray-700);
}

:root[data-theme="dark"] .sidebar-section ul li:hover {
  background: var(--gray-800);
}

:root[data-theme="dark"] .hint-box {
  background: var(--gray-800);
}

:root[data-theme="dark"] .price-total {
  background: var(--gray-800);
}

:root[data-theme="dark"] .furniture-option:hover {
  background: var(--gray-800);
}

:root[data-theme="dark"] .furniture-option.selected {
  background: var(--gray-800);
}

/* 让画面而不是操作栏成为主角。 */
#main, #viewport { min-height: 0; min-width: 0; }
#app { height: 100dvh; }
.brand h1 { font-family: "Songti SC", "STSong", serif; font-size: 23px; letter-spacing: 2px; }
#sidebar { width: 244px; flex-shrink: 0; }
.topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
.btn { padding: 8px 12px; }
#furniture-panel { width: min(520px, calc(100vw - 32px)); }
.furniture-option .info { min-width: 0; }
.furniture-option .thumb { width: 68px; }
:focus-visible { outline: 3px solid #a28a56; outline-offset: 3px; }
@media(max-width: 760px) {
 #topbar { align-items: flex-start; flex-direction: column; gap: 10px; padding: 12px 16px; }
 .topbar-actions { justify-content: flex-start; gap: 5px; }
 .topbar-actions .btn { font-size: 12px; padding: 7px 9px; }
 #main { flex-direction: column-reverse; }
 #viewport { flex: 1; min-height: 210px; }
 #sidebar { width: 100%; max-height: 28dvh; padding: 12px 16px; border-right: 0; border-top: 1px solid var(--border); display: flex; gap: 22px; }
 .sidebar-section { min-width: 150px; margin-bottom: 0; }
 .sidebar-section.hint-box { display: none; }
 .sidebar-section ul li { padding: 5px 8px; }
 #sidebar { overflow-x: auto; }
 .furniture-option { padding: 10px; gap: 10px; }
 #toast { width: calc(100% - 32px); text-align: center; padding: 10px; }
}
@media(prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }