:root {
  --bg-page: #ffffff;
  --bg-surface: #ffffff;
  --bg-subtle: #f7f7f8;
  --text-primary: #0d0d0d;
  --text-secondary: #5e5e5e;
  --accent: #ff8000;
  --border-light: #ebebeb;
  --shadow-elevated: 0 10px 30px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
  --radius-card: 18px;
  --radius-pill: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg-page);
  color: var(--text-primary);
  overflow: hidden;
}

.app-shell {
  display: flex;
  height: 100dvh;
  width: 100vw;
  background: var(--bg-page);
}

/* Elevated Card System */
.elevated-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-elevated);
}

/* Primary Interaction Buttons */
.action-btn {
  background-color: #ff8000;
  color: #000000;
  border: 1.5px solid #ff8000;
  border-radius: var(--radius-pill);
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.1s ease;
  user-select: none;
}

.action-btn:hover {
  background-color: #ffffff;
  color: #000000;
  border-color: #000000;
}

.action-btn:active,
.action-btn.is-pressed {
  background-color: #000000;
  color: #ff8000;
  border-color: #000000;
  transform: scale(0.98);
}

.action-btn.compact {
  padding: 7px 12px;
  font-size: 0.82rem;
}

.action-btn.full-width {
  width: 100%;
}

/* Sidebar (ChatGPT Mobile & Desktop Drawer Pattern) */
.sidebar {
  width: 310px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 14px;
  z-index: 30;
  transition: transform 0.25s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.mode-nav {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  background: var(--bg-subtle);
  padding: 5px;
  border-radius: 14px;
}

.mode-tab {
  background: transparent;
  border: none;
  padding: 8px 6px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.mode-tab.active {
  background: #ffffff;
  color: #000000;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-box, input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  background: var(--bg-subtle);
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
}

.search-box:focus, input:focus, textarea:focus, select:focus {
  background: #ffffff;
  border-color: #000000;
}

.item-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.item-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.item-card:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

.item-card.selected {
  border: 2px solid #ff8000;
}

.item-card-title {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 4px;
}

.item-card-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Main Stage */
.main-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #ffffff;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-light);
  background: #ffffff;
  gap: 10px;
  z-index: 10;
}

.active-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.active-meta h1 {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  background: var(--bg-subtle);
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.viewer-container {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #ffffff;
}

#gl-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#splat-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Floating Inspector Card */
.inspector-card {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(680px, calc(100% - 32px));
  padding: 14px 18px;
  z-index: 15;
}

.item-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 10px;
}

.transform-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}

.transform-grid label {
  font-size: 0.75rem;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.transform-grid input[type="range"] {
  padding: 0;
  accent-color: #ff8000;
}

/* AR Overlay & Modal */
.ar-hud {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  width: min(420px, calc(100% - 32px));
}

.ar-banner {
  padding: 12px 16px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  width: min(460px, 100%);
  padding: 20px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-form label {
  font-size: 0.82rem;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.divider {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.hidden {
  display: none !important;
}

.mobile-only {
  display: none;
}

@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 84vw;
    max-width: 320px;
    transform: translateX(-100%);
    box-shadow: var(--shadow-elevated);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .mobile-only {
    display: inline-flex;
  }
  .transform-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}