* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: #1a1a1a;
  color: #fff;
  font-family: 'Inter', -apple-system, sans-serif;
  overflow: hidden;
  height: 100vh;
  display: flex;
}

/* Login View */
#login-view {
  display: none;
  width: 100%;
  height: 100vh;
  background: #1a1a1a;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 24px;
}
#login-view.visible { display: flex; }
#login-view h1 { font-size: 28px; font-weight: 700; color: #eee; }
#login-view p { color: #666; font-size: 14px; }
#login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 280px;
}
#login-form input {
  background: #1e1e1e;
  color: #fff;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
}
#login-form input:focus { border-color: #888; }
.login-google-btn {
  background: #fff;
  color: #333;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px 28px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}
.login-google-btn:hover { background: #f0f0f0; }
.login-divider {
  display: flex;
  align-items: center;
  margin: 12px 0;
  color: #666;
  font-size: 12px;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #444;
}
.login-divider span { padding: 0 10px; }
#login-btn {
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 28px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
#login-btn:hover { background: #2563eb; }
.login-secondary-btn {
  background: transparent;
  color: #888;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.login-secondary-btn:hover { border-color: #888; color: #ccc; }
#login-error { color: #e55; font-size: 13px; display: none; }
#login-loading { color: #888; font-size: 13px; display: none; }
.auth-user-info {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #888;
}
.auth-user-info img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}
.auth-logout-btn {
  background: none;
  border: 1px solid #444;
  color: #888;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.auth-logout-btn:hover { border-color: #888; color: #ccc; }

/* Left Sidebar */
#sidebar {
  width: 260px;
  min-width: 260px;
  height: 100vh;
  background: #222;
  border-right: 1px solid #333;
  display: flex;
  flex-direction: column;
  z-index: 50;
}

/* Panel Headers */
.panel-header {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #888;
  background: #2a2a2a;
  border-bottom: 1px solid #333;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-header-btn {
  background: none;
  border: 1px solid #555;
  color: #aaa;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.panel-header-btn:hover { background: #444; color: #fff; }

/* Hierarchy Panel */
#hierarchy-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid #333;
  min-height: 0;
}
#hierarchy-tree {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}
.tree-item {
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
  user-select: none;
}
.tree-item:hover { background: #2a2a2a; }
.tree-item.selected { background: #335; color: #8af; }
.tree-item .icon {
  font-size: 12px;
  width: 16px;
  text-align: center;
  color: #777;
  flex-shrink: 0;
}
.tree-item.selected .icon { color: #8af; }
.tree-item .label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-item.indent-1 { padding-left: 28px; }
.tree-item.indent-2 { padding-left: 42px; }
.tree-item .visibility-toggle {
  font-size: 11px;
  color: #666;
  cursor: pointer;
  padding: 2px;
  flex-shrink: 0;
}
.tree-item .visibility-toggle:hover { color: #aaa; }
.tree-item .visibility-toggle.hidden-obj { color: #444; }
.tree-drag-over { border-top: 2px solid #8af; }
.hierarchy-drop-zone {
  padding: 8px 14px;
  font-size: 11px;
  color: #555;
  text-align: center;
  border: 2px dashed transparent;
  transition: all 0.2s;
  margin: 4px 8px;
  border-radius: 6px;
}
.hierarchy-drop-zone.drag-active {
  border-color: #8af;
  color: #8af;
  background: rgba(136,170,255,0.05);
}
#hierarchy-footer {
  display: flex;
  gap: 2px;
  padding: 4px 8px;
  border-top: 1px solid #333;
}
.hierarchy-toggle {
  background: transparent;
  border: 1px solid #444;
  border-radius: 5px;
  color: #555;
  font-size: 11px;
  padding: 3px 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.hierarchy-toggle:hover { border-color: #666; color: #888; }
.hierarchy-toggle.on { border-color: #5a5; color: #8d8; background: rgba(85,170,85,0.1); }

/* Assets Panel */
#assets-panel {
  height: 220px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
}
#assets-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}
.asset-item {
  padding: 5px 14px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: grab;
  transition: background 0.15s;
  user-select: none;
}
.asset-item:hover { background: #2a2a2a; }
.asset-item.selected { background: #2a3a4a; }
.asset-item:active { cursor: grabbing; }
.asset-item .asset-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.asset-item .asset-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #ccc;
}
.asset-item .asset-type {
  font-size: 10px;
  color: #666;
  text-transform: uppercase;
  flex-shrink: 0;
}
.asset-item .asset-size {
  font-size: 10px;
  color: #555;
  flex-shrink: 0;
  min-width: 48px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Asset Folders */
.asset-folder {
  padding: 5px 14px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  color: #aaa;
  transition: background 0.15s;
}
.asset-folder:hover { background: #2a2a2a; }
.asset-folder .folder-arrow {
  font-size: 10px;
  width: 12px;
  text-align: center;
  transition: transform 0.15s;
  color: #666;
}
.asset-folder .folder-arrow.open { transform: rotate(90deg); }
.asset-folder .folder-icon { font-size: 13px; }
.asset-folder .folder-name { flex: 1; font-weight: 500; }
.asset-folder .folder-count { font-size: 10px; color: #555; }
.asset-folder .folder-delete {
  font-size: 12px; color: #555; cursor: pointer; display: none;
}
.asset-folder:hover .folder-delete { display: inline; }
.asset-folder .folder-delete:hover { color: #c33; }
.asset-folder-items .asset-item { padding-left: 28px; }

/* Asset Context Menu */
.asset-ctx-menu {
  position: fixed;
  z-index: 9999;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 4px 0;
  min-width: 140px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  font-size: 12px;
}
.asset-ctx-menu .ctx-item {
  padding: 6px 14px;
  cursor: pointer;
  color: #ccc;
  display: flex;
  align-items: center;
  gap: 8px;
}
.asset-ctx-menu .ctx-item:hover { background: #3a3a3a; }
.asset-ctx-menu .ctx-item.danger { color: #e55; }
.asset-ctx-menu .ctx-item.danger:hover { background: #3a2020; }
.asset-ctx-menu .ctx-sep { height: 1px; background: #444; margin: 4px 0; }

/* Project Size Indicator */
#project-size-btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}
#project-size-btn:hover { background: rgba(0,0,0,0.85); border-color: #666; }
#project-size-btn .size-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
#project-size-btn .size-dot.ok { background: #4c4; box-shadow: 0 0 4px #4c4; }
#project-size-btn .size-dot.warn { background: #ec0; box-shadow: 0 0 4px #ec0; }
#project-size-btn .size-dot.over { background: #e44; box-shadow: 0 0 4px #e44; }
#project-size-btn .size-label { white-space: nowrap; }

/* QR Button */
#scene-top-right {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 100;
  display: flex;
  gap: 6px;
  align-items: center;
}
#scene-top-right button {
  background: rgba(0,0,0,0.7);
  border: 1px solid #444;
  border-radius: 8px;
  color: #aaa;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
#scene-top-right button:hover { background: rgba(0,0,0,0.85); border-color: #666; color: #fff; }
#scene-reset-btn {
  padding: 8px 12px;
  font-size: 20px;
  line-height: 1;
}
#deploy-btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: rgba(60,60,60,0.85);
  border-color: #555;
  color: #777;
  pointer-events: none;
  transition: all 0.3s;
}
#deploy-btn.dirty {
  background: rgba(40,80,40,0.85);
  border-color: #4a8a4a;
  color: #ccc;
  pointer-events: auto;
}
#deploy-btn.dirty:hover { background: rgba(50,100,50,0.9) !important; border-color: #5a9a5a !important; color: #fff !important; }
#deploy-btn.deploying { opacity: 0.6; pointer-events: none; }
#deploy-btn.waiting {
  background: rgba(40,60,80,0.85);
  border-color: #4a7a9a;
  color: #aac;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
#qr-btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
  letter-spacing: 0.5px;
}

/* QR Modal */
#qr-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.7);
  align-items: center;
  justify-content: center;
}
#qr-modal.visible { display: flex; }
#qr-modal .qr-img { border-radius: 8px; background: #fff; }
#qr-modal .qr-url {
  font-size: 11px;
  color: #888;
  word-break: break-all;
  margin: 12px 0;
  padding: 8px 10px;
  background: #333;
  border-radius: 6px;
  user-select: all;
  text-align: left;
}

/* Size Detail Popup */
#size-detail {
  display: none;
  position: absolute;
  top: 54px;
  right: 12px;
  z-index: 101;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 10px;
  padding: 14px 16px;
  width: 280px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}
#size-detail.visible { display: block; }
#size-detail h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888;
  margin-bottom: 10px;
}
.size-bar-wrapper {
  margin-bottom: 10px;
}
.size-bar-bg {
  width: 100%;
  height: 6px;
  background: #333;
  border-radius: 3px;
  overflow: hidden;
}
.size-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}
.size-bar-fill.ok { background: linear-gradient(90deg, #4c4, #6e6); }
.size-bar-fill.warn { background: linear-gradient(90deg, #ec0, #fa0); }
.size-bar-fill.over { background: linear-gradient(90deg, #e44, #f66); }
.size-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #888;
  margin-top: 4px;
}
.size-bar-label .current { font-weight: 700; }
.size-breakdown {
  border-top: 1px solid #333;
  padding-top: 8px;
  margin-top: 4px;
}
.size-breakdown-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  padding: 2px 0;
  color: #aaa;
}
.size-breakdown-row .bk-label { color: #888; }
.size-breakdown-row .bk-value { font-variant-numeric: tabular-nums; }
.size-asset-list { max-height: 200px; overflow-y: auto; margin-top: 4px; }
.size-asset-list .size-breakdown-row { font-size: 10px; }

/* Resize handle between panels */
.panel-resizer {
  height: 4px;
  background: #333;
  cursor: ns-resize;
  flex-shrink: 0;
}
.panel-resizer:hover { background: #555; }

/* Viewport */
#viewport {
  flex: 1;
  position: relative;
  min-width: 0;
}
#canvas3d {
  display: block;
  width: 100%;
  height: 100%;
}
#marker-tabs {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
}
#marker-selector-btn {
  background: rgba(0,0,0,0.7);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  color: #aaa;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.5px;
}
#marker-selector-btn:hover { background: rgba(0,0,0,0.85); border-color: #666; color: #fff; }
#marker-selector-btn .arrow { font-size: 8px; transition: transform 0.2s; }
#marker-selector-btn.open .arrow { transform: rotate(180deg); }
#marker-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 4px 0;
  min-width: 180px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
#marker-dropdown.visible { display: block; }
.marker-dropdown-item {
  padding: 7px 14px;
  font-size: 12px;
  color: #aaa;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}
.marker-dropdown-item:hover { background: #3a3a3a; }
.marker-dropdown-item.active { color: #fff; font-weight: 600; }
.marker-dropdown-item .check { width: 14px; font-size: 12px; color: #5a5; }
.marker-dropdown-item .del-btn {
  margin-left: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid #555;
  color: #888;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.marker-dropdown-item:hover .del-btn { opacity: 1; }
.marker-dropdown-item .del-btn:hover { background: #c33; border-color: #c33; color: #fff; }
.marker-dropdown-item .del-btn.confirm { background: #e90; border-color: #e90; color: #fff; opacity: 1; }
.marker-dropdown-add {
  padding: 7px 14px;
  font-size: 12px;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid #393939;
  margin-top: 4px;
}
.marker-dropdown-add:hover { background: #3a3a3a; color: #aaa; }

/* Add Marker Modal */
/* New Project Modal */
#new-project-modal {
  display: none; position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.7); align-items: center; justify-content: center;
}
#new-project-modal.visible { display: flex; }
.template-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px;
}
.template-card {
  background: #2a2a2a; border: 2px solid #444; border-radius: 10px;
  padding: 16px 12px; text-align: center; cursor: pointer; position: relative;
  transition: border-color 0.15s, background 0.15s;
}
.template-card:hover:not(.disabled) { border-color: #666; background: #333; }
.template-card.selected { border-color: #5af; background: #1a2a3a; }
.template-card.disabled {
  opacity: 0.45; cursor: not-allowed; pointer-events: none;
}
.template-icon { font-size: 32px; margin-bottom: 8px; }
.template-name { font-size: 14px; font-weight: 600; color: #eee; margin-bottom: 4px; }
.template-desc { font-size: 11px; color: #888; }
.template-badge {
  position: absolute; top: 8px; right: 8px;
  background: #555; color: #ccc; font-size: 9px; padding: 2px 6px;
  border-radius: 4px; text-transform: uppercase; letter-spacing: 0.5px;
}

#add-marker-modal {
  display: none; position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.7); align-items: center; justify-content: center;
}
#add-marker-modal.visible { display: flex; }
.modal-box {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 12px;
  padding: 24px;
  width: 380px;
  max-width: 90vw;
}
.modal-box h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  color: #eee;
}
.modal-field {
  margin-bottom: 14px;
}
.modal-field label {
  display: block;
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.modal-file-btn {
  width: 100%;
  padding: 10px;
  background: #333;
  border: 2px dashed #555;
  border-radius: 8px;
  color: #aaa;
  font-size: 12px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.modal-file-btn:hover { border-color: #888; color: #fff; }
.modal-file-btn.has-file { border-color: #5a5; border-style: solid; color: #8f8; }
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}
.modal-actions button {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #444;
  transition: all 0.15s;
}
.modal-cancel { background: #333; color: #aaa; }
.modal-cancel:hover { background: #444; color: #fff; }
.modal-confirm { background: #2a4a2a; border-color: #3a6a3a; color: #8f8; }
.modal-confirm:hover { background: #3a5a3a; }
.modal-confirm:disabled { opacity: 0.4; cursor: not-allowed; }
.modal-error {
  font-size: 11px;
  color: #f66;
  margin-top: 8px;
  display: none;
}
#info-bar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 13px;
  color: #999;
  z-index: 100;
  white-space: nowrap;
}
#toast {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #2a2a2a;
  border: 2px solid #0f0;
  border-radius: 12px;
  padding: 24px 40px;
  z-index: 9999;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: #0f0;
  animation: fadeInOut 2s ease forwards;
}
@keyframes fadeInOut {
  0% { opacity: 0; }
  20% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* Right Panel */
#right-panel {
  width: 300px;
  min-width: 300px;
  height: 100vh;
  background: #222;
  border-left: 1px solid #333;
  display: flex;
  flex-direction: column;
  z-index: 50;
}

/* Inspector Panel */
#inspector-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid #333;
  min-height: 0;
}
#inspector-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}
.inspector-section {
  border-bottom: 1px solid #2a2a2a;
}
.inspector-section-header {
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #262626;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.inspector-section-header:hover { background: #2a2a2a; }
.inspector-section-header .arrow { font-size: 8px; color: #666; }
.inspector-row {
  display: flex;
  align-items: center;
  padding: 4px 14px;
  gap: 8px;
  font-size: 12px;
}
.inspector-row label {
  width: 50px;
  color: #888;
  font-size: 11px;
  flex-shrink: 0;
}
.inspector-row input[type="number"] {
  flex: 1;
  min-width: 0;
  background: #333;
  border: 1px solid #444;
  color: #fff;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-family: inherit;
}
.inspector-row input[type="number"]:focus {
  border-color: #8af;
  outline: none;
}
/* XYZ horizontal row */
.inspector-row-xyz {
  display: flex;
  align-items: center;
  padding: 4px 14px;
  gap: 4px;
  font-size: 12px;
}
.inspector-xyz-field {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 1;
  min-width: 0;
}
.inspector-xyz-field label {
  color: #666;
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
  width: 12px;
  text-align: center;
}
.inspector-xyz-field label.axis-x { color: #c66; }
.inspector-xyz-field label.axis-y { color: #6c6; }
.inspector-xyz-field label.axis-z { color: #68c; }
.inspector-xyz-field input[type="number"] {
  flex: 1;
  min-width: 0;
  background: #333;
  border: 1px solid #444;
  color: #fff;
  padding: 3px 4px;
  border-radius: 4px;
  font-size: 10px;
  font-family: inherit;
}
.inspector-xyz-field input[type="number"]:focus {
  border-color: #8af;
  outline: none;
}
.lock-btn {
  width: 20px;
  height: 20px;
  background: none;
  border: 1px solid #444;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  margin-left: auto;
  transition: all 0.15s;
  color: #555;
  font-size: 12px;
  line-height: 1;
}
.lock-btn:hover { border-color: #888; color: #aaa; }
.lock-btn.locked { border-color: #8af; color: #8af; background: rgba(136,170,255,0.1); }
.inspector-info {
  padding: 12px 14px;
  font-size: 12px;
  color: #666;
  text-align: center;
}
.inspector-btn-row {
  padding: 6px 14px;
  display: flex;
  gap: 6px;
}
.inspector-btn {
  flex: 1;
  background: #333;
  border: 1px solid #444;
  color: #ccc;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.inspector-btn:hover { background: #444; color: #fff; }
.inspector-btn.primary {
  background: #2a4a2a;
  border-color: #3a6a3a;
  color: #8f8;
}
.inspector-btn.primary:hover { background: #3a5a3a; }

/* Mobile Preview */
#preview-panel {
  height: 340px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
}
#preview-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  min-height: 0;
}
.phone-frame {
  position: relative;
  width: 140px;
  aspect-ratio: 9 / 19.5;
  max-height: 100%;
  background: #111;
  border-radius: 18px;
  border: 2px solid #444;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5), inset 0 0 0 1px #333;
}
.phone-notch {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 14px;
  background: #111;
  border-radius: 0 0 10px 10px;
  z-index: 10;
}
.phone-screen {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}
#preview-canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.preview-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
.preview-ui .preview-capture-btn,
.preview-ui .preview-camera-switch {
  pointer-events: auto; cursor: pointer;
}
.preview-ui .preview-capture-btn:active { transform: translateX(-50%) scale(0.9); }
.preview-ui .preview-camera-switch:active { transform: scale(0.9); }
/* Emulator UI Buttons */
.preview-capture-btn {
  position: absolute;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(145deg, #4a4a4a 0%, #2a2a2a 50%, #1a1a1a 100%);
  box-shadow: 0 2px 6px rgba(0,0,0,0.7), inset 0 -1px 3px rgba(0,0,0,0.8), inset 0 1px 3px rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}
.preview-capture-btn.emu-recording {
  width: 36px; height: 36px;
  background: linear-gradient(145deg, #5a5a5a 0%, #3a3a3a 50%, #2a2a2a 100%);
}
.preview-capture-btn.emu-pressed { animation: emuBtnPress 0.3s ease-out; }
@keyframes emuBtnPress {
  0% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.2); }
  100% { transform: translateX(-50%) scale(1); }
}
.preview-capture-inner {
  width: 80%;
  height: 80%;
  border-radius: 50%;
  background: linear-gradient(145deg, #fff 0%, #e8e8e8 50%, #d0d0d0 100%);
  box-shadow: 0 1px 3px rgba(0,0,0,0.5), inset 0 -1px 2px rgba(0,0,0,0.25), inset 0 1px 2px rgba(255,255,255,0.9);
  transition: all 0.3s ease;
}
.preview-capture-inner.emu-rec-start {
  width: 70%; height: 70%;
  background: linear-gradient(145deg, #f55 0%, #f00 50%, #c00 100%);
  box-shadow: 0 1px 4px rgba(255,0,0,0.7), inset 0 -1px 2px rgba(0,0,0,0.6), inset 0 1px 2px rgba(255,150,150,0.7);
}
.preview-capture-inner.emu-recording {
  width: 30%; height: 30%;
  border-radius: 2px;
  background: #f00;
  box-shadow: none;
}
.preview-mute-btn {
  position: absolute;
  bottom: 6.5%;
  left: 8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(145deg, #3a3a3a 0%, #2a2a2a 50%, #1a1a1a 100%);
  box-shadow: 0 2px 6px rgba(0,0,0,0.7), inset 0 -1px 3px rgba(0,0,0,0.8), inset 0 1px 3px rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-mute-btn::before {
  content: '';
  width: 60%;
  height: 60%;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/></svg>') center/contain no-repeat;
  transition: background 0.2s;
}
.preview-mute-btn.muted::before {
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"/></svg>');
}
.preview-camera-switch {
  position: absolute;
  bottom: 6.5%;
  right: 8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(145deg, #3a3a3a 0%, #2a2a2a 50%, #1a1a1a 100%);
  box-shadow: 0 2px 6px rgba(0,0,0,0.7), inset 0 -1px 3px rgba(0,0,0,0.8), inset 0 1px 3px rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-camera-switch::before {
  content: '';
  width: 60%;
  height: 60%;
  background: url('./assets/camera-switch.png') center/contain no-repeat;
}
/* Recording Timer */
.emu-record-timer {
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  font-size: 9px;
  background: linear-gradient(145deg, #2a2a2a 0%, #1a1a1a 50%, #0a0a0a 100%);
  color: #fff;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.6), inset 0 -1px 2px rgba(0,0,0,0.8), inset 0 1px 2px rgba(255,255,255,0.15);
  z-index: 10;
  pointer-events: none;
}
.emu-record-timer.visible { display: block; }
/* Emulator Photo/Video Preview */
.emu-preview-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.emu-preview-overlay.visible { display: flex; }
.emu-preview-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.8);
  pointer-events: none;
}
.emu-preview-media {
  position: relative;
  max-width: 85%;
  max-height: 60%;
  border-radius: 6px;
  border: 2px solid #000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.8);
  z-index: 1;
  object-fit: contain;
  background: #000;
}
.emu-preview-close {
  position: absolute;
  top: 16%;
  right: 12%;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(145deg, #2a2a2a 0%, #1a1a1a 50%, #0a0a0a 100%);
  box-shadow: 0 2px 6px rgba(0,0,0,0.6), inset 0 -1px 3px rgba(0,0,0,0.8), inset 0 1px 3px rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  cursor: pointer;
  pointer-events: auto;
}
.emu-preview-close::before, .emu-preview-close::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 1.5px;
  background: #fff;
  border-radius: 1px;
}
.emu-preview-close::before { transform: rotate(45deg); }
.emu-preview-close::after { transform: rotate(-45deg); }
.emu-share-btn {
  position: relative;
  z-index: 2;
  margin-top: 8px;
  background: linear-gradient(145deg, #2a2a2a 0%, #1a1a1a 50%, #0a0a0a 100%);
  border: none;
  color: #fff;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.6), inset 0 -1px 3px rgba(0,0,0,0.8), inset 0 1px 3px rgba(255,255,255,0.15);
  transition: all 0.2s;
}
.emu-share-btn:active {
  transform: translateY(-1px);
  background: linear-gradient(145deg, #1a1a1a 0%, #0a0a0a 50%, #000 100%);
}
/* Save tools bar */
.preview-save-bar {
  display: flex; align-items: center; gap: 3px; margin-left: 4px;
  border-left: 1px solid #444; padding-left: 4px;
}
.preview-save-btn {
  background: none; border: 1px solid #555; color: #aaa;
  width: 22px; height: 22px; border-radius: 4px; cursor: pointer;
  font-size: 11px; display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.preview-save-btn:hover { border-color: #888; color: #fff; }
/* Fullscreen emulator sizes */
.preview-fs-phone .preview-capture-btn { width: 48px; height: 48px; }
.preview-fs-phone .preview-capture-btn.emu-recording { width: 60px; height: 60px; }
.preview-fs-phone .preview-capture-inner { width: 80%; height: 80%; border-radius: 50%; }
.preview-fs-phone .preview-mute-btn { width: 32px; height: 32px; left: 16px; }
.preview-fs-phone .preview-camera-switch { width: 32px; height: 32px; right: 16px; }
.preview-fs-phone .emu-record-timer { font-size: 14px; padding: 4px 10px; border-radius: 8px; }
.preview-fs-phone .emu-preview-media { border-radius: 10px; border-width: 3px; }
.preview-fs-phone .emu-preview-close { width: 32px; height: 32px; }
.preview-fs-phone .emu-preview-close::before, .preview-fs-phone .emu-preview-close::after { width: 14px; height: 2px; }
.preview-fs-phone .emu-share-btn { font-size: 13px; padding: 8px 24px; border-radius: 30px; }

/* Preview panel header actions */
#preview-panel .panel-header { display: flex; align-items: center; justify-content: space-between; }
.panel-header-actions { display: flex; align-items: center; gap: 4px; }
#preview-bg-select {
  background: #333; border: 1px solid #555; color: #aaa;
  font-size: 10px; padding: 2px 4px; border-radius: 4px; cursor: pointer; outline: none;
}
#preview-bg-select:hover { border-color: #888; color: #fff; }
#preview-reset-angle-btn, #preview-expand-btn {
  background: none; border: 1px solid #555; color: #aaa;
  width: 22px; height: 22px; border-radius: 4px; cursor: pointer;
  font-size: 12px; display: flex; align-items: center; justify-content: center;
}
#preview-reset-angle-btn:hover, #preview-expand-btn:hover { border-color: #888; color: #fff; }

/* Fullscreen preview modal */
#preview-fullscreen-modal {
  display: none; position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.9); align-items: center; justify-content: center;
}
#preview-fullscreen-modal.visible { display: flex; }
.preview-fs-container { position: relative; display: flex; align-items: center; gap: 24px; }
#preview-fs-close {
  position: absolute; top: -40px; right: 0;
  background: none; border: 1px solid #555; border-radius: 50%;
  width: 32px; height: 32px; color: #aaa; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
#preview-fs-close:hover { border-color: #888; color: #fff; }
.preview-fs-phone {
  position: relative; width: 320px; aspect-ratio: 9 / 19.5;
  max-height: 80vh; background: #111; border-radius: 36px;
  border: 3px solid #444; overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), inset 0 0 0 1px #333;
}
.preview-fs-phone .phone-notch { width: 120px; height: 28px; }
.preview-fs-phone #preview-fs-canvas { display: block; width: 100%; height: 100%; }
.preview-fs-sidebar {
  display: flex; flex-direction: column; gap: 6px;
  background: rgba(255,255,255,0.05); border-radius: 8px;
  padding: 16px; min-width: 140px;
}
.preview-fs-label { color: #888; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
#preview-fs-bg-select {
  background: #333; border: 1px solid #555; color: #ccc;
  font-size: 12px; padding: 6px 8px; border-radius: 4px; cursor: pointer; outline: none;
}
.preview-fs-btn {
  background: #333; border: 1px solid #555; color: #ccc;
  font-size: 12px; padding: 6px 8px; border-radius: 4px; cursor: pointer;
}
.preview-fs-btn:hover { border-color: #888; color: #fff; }

/* Scrollbar styling */
#hierarchy-tree::-webkit-scrollbar,
#assets-list::-webkit-scrollbar,
#inspector-content::-webkit-scrollbar {
  width: 6px;
}
#hierarchy-tree::-webkit-scrollbar-track,
#assets-list::-webkit-scrollbar-track,
#inspector-content::-webkit-scrollbar-track {
  background: transparent;
}
#hierarchy-tree::-webkit-scrollbar-thumb,
#assets-list::-webkit-scrollbar-thumb,
#inspector-content::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 3px;
}
#hierarchy-tree::-webkit-scrollbar-thumb:hover,
#assets-list::-webkit-scrollbar-thumb:hover,
#inspector-content::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Hidden file input */
#asset-file-input { display: none; }

/* Projects View */
#projects-view {
  width: 100%;
  height: 100vh;
  background: #1a1a1a;
  padding: 40px;
  overflow-y: auto;
  display: none;
}
#projects-view.visible { display: block; }
.projects-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
}
.projects-title {
  font-size: 22px;
  font-weight: 700;
  color: #eee;
}
.projects-new-btn {
  background: #2a4a2a;
  border: 1px solid #3a6a3a;
  color: #8f8;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.projects-new-btn:hover { background: #3a5a3a; }
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  max-width: 1000px;
  margin: 0 auto;
}
.project-card {
  background: #222;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.project-card:hover { border-color: #555; background: #282828; transform: translateY(-2px); }
.project-card .project-name {
  font-size: 15px;
  font-weight: 600;
  color: #eee;
  margin-bottom: 6px;
}
.project-card .project-meta {
  font-size: 11px;
  color: #666;
}
.project-card .project-markers {
  font-size: 12px;
  color: #888;
  margin-top: 4px;
  margin-bottom: 4px;
}
.project-card .project-delete {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: 1px solid #444;
  color: #666;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.project-card:hover .project-delete { display: flex; }
.project-card .project-delete:hover { border-color: #c33; color: #c33; }
.project-card .project-preview {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  color: #68a;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.project-card .project-preview:hover { color: #8bf; text-decoration: underline; }
.projects-empty {
  display: none;
  text-align: center;
  padding: 80px 0;
  color: #555;
  font-size: 15px;
  max-width: 1000px;
  margin: 0 auto;
}
.projects-empty.visible { display: block; }
.projects-empty p { margin-bottom: 20px; }

/* Editor View */
#editor-view {
  display: none;
  width: 100%;
  height: 100vh;
}
#editor-view.visible { display: flex; }

/* Back to Projects */
#back-to-projects-btn {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 100;
  background: rgba(0,0,0,0.7);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #aaa;
  cursor: pointer;
  transition: all 0.2s;
}
#back-to-projects-btn:hover { background: rgba(0,0,0,0.85); border-color: #666; color: #fff; }

/* Transform Toolbar */
#transform-toolbar {
  position: absolute;
  top: 56px;
  left: 12px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#view-angle-toolbar {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 100;
  display: flex;
  gap: 3px;
}
.view-angle-btn {
  width: 36px;
  height: 36px;
  background: rgba(0,0,0,0.7);
  border: 1px solid #444;
  border-radius: 8px;
  color: #888;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
  letter-spacing: 0.3px;
}
.view-angle-btn:hover { background: rgba(0,0,0,0.85); border-color: #666; color: #fff; }
.view-angle-btn.active { border-color: #8af; color: #8af; background: rgba(136,170,255,0.15); }
.transform-btn {
  width: 48px;
  height: 48px;
  background: rgba(0,0,0,0.7);
  border: 1px solid #444;
  border-radius: 10px;
  color: #888;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
}
.transform-btn:hover { background: rgba(0,0,0,0.85); border-color: #666; color: #ccc; }
.transform-btn.active { border-color: #8af; color: #8af; background: rgba(136,170,255,0.15); }
.transform-btn .btn-label {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* Mask Picker */
.mask-picker-btn {
  flex: 1;
  background: #333;
  border: 1px dashed #555;
  color: #888;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mask-picker-btn:hover { border-color: #888; color: #aaa; }
.mask-picker-btn.has-mask { border-style: solid; border-color: #5a5; color: #8f8; }
.mask-clear-btn {
  width: 20px;
  height: 20px;
  background: none;
  border: 1px solid #555;
  border-radius: 4px;
  color: #888;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
.mask-clear-btn:hover { border-color: #c33; color: #c33; }

/* Mask Section */
.mask-preview-thumb {
  width: 100%; height: 64px; object-fit: contain;
  background: #1a1a1a; border: 1px solid #444; border-radius: 4px;
  display: block; margin-bottom: 6px;
}
.mask-preview-thumb.video-thumb { height: 64px; }
.mask-type-badge {
  display: inline-block; font-size: 9px; padding: 1px 6px; border-radius: 3px;
  background: #2a2a2a; border: 1px solid #555; color: #aaa; margin-left: 6px;
  vertical-align: middle;
}
.mask-type-badge.default { border-color: #555; color: #888; }
.mask-type-badge.custom-img { border-color: #5a5; color: #8f8; }
.mask-type-badge.custom-vid { border-color: #55a; color: #8af; }
.mask-toggle-row {
  display: flex; align-items: center; gap: 6px; padding: 2px 14px; margin-bottom: 2px;
}
.mask-toggle-row > label:first-child { width: 50px; font-size: 11px; color: #888; flex-shrink: 0; }
.mask-toggle-switch {
  position: relative; width: 28px; height: 14px; cursor: pointer; flex-shrink: 0;
}
.mask-toggle-switch input { display: none; }
.mask-toggle-track {
  position: absolute; inset: 0; background: #444; border-radius: 8px; transition: background 0.2s;
}
.mask-toggle-switch input:checked + .mask-toggle-track { background: #5a5; }
.mask-toggle-track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px;
  background: #ccc; border-radius: 50%; transition: transform 0.2s;
}
.mask-toggle-switch input:checked + .mask-toggle-track::after { transform: translateX(14px); }
.mask-file-row {
  display: flex; align-items: center; gap: 4px;
}
