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

body {
  background: #0a0a12;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

.app { position: relative; width: 100%; height: 100%; }

/* ===== 3D Canvas ===== */
.canvas-wrap {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* ===== Top bar ===== */
.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  z-index: 20;
  pointer-events: none;
}

.logo {
  font-size: 16px;
  font-weight: 700;
  color: rgba(255,255,255,0.8);
  text-shadow: 0 1px 6px rgba(0,0,0,0.5);
}

.platform-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(255,255,255,0.5);
}

/* ===== AR button section ===== */
.ar-section {
  position: absolute;
  bottom: 105px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 15;
  pointer-events: none;
}

.ar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, #007aff, #5856d6);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 20px rgba(0,122,255,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
.ar-btn:active {
  transform: scale(0.95);
  box-shadow: 0 2px 12px rgba(0,122,255,0.3);
}

.ar-hint {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
}

/* ===== Toolbar ===== */
.toolbar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px calc(env(safe-area-inset-bottom, 8px) + 12px);
  background: linear-gradient(transparent, rgba(0,0,0,0.5));
  z-index: 20;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 20px;
  border: none;
  border-radius: 14px;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.tool-btn svg { width: 26px; height: 26px; }
.tool-btn:active { transform: scale(0.93); }
.tool-btn.active { background: rgba(0,122,255,0.45); }

/* ===== Sub-panels ===== */
.sub-panel {
  position: absolute;
  bottom: 100px;
  left: 12px;
  right: 12px;
  max-width: 400px;
  margin: 0 auto;
  background: rgba(20,20,28,0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 20px;
  padding: 16px 20px;
  z-index: 30;
  display: none;
  flex-direction: column;
  gap: 12px;
  animation: slideUp 0.25s ease-out;
}
.sub-panel.open { display: flex; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  font-weight: 700;
}
.panel-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

/* Upload zone */
.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px;
  border: 2px dashed rgba(255,255,255,0.2);
  border-radius: 14px;
}
.upload-zone.dragover {
  border-color: rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.06);
}
.hint { font-size: 12px; color: rgba(255,255,255,0.35); }

/* Text field */
.text-field {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 15px;
  outline: none;
}
.text-field:focus { border-color: #007aff; }

/* Option / color rows */
.option-row {
  display: flex;
  gap: 16px;
}
.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.color-row label {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
}
.color-row input[type="color"] {
  width: 36px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: none;
  cursor: pointer;
}

/* Shape grid */
.shape-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.shape-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.75);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.shape-btn svg { width: 32px; height: 32px; }
.shape-btn:active { transform: scale(0.93); }
.shape-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.25);
}

/* Edit bar */
.edit-bar {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(20,20,28,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 14px;
  z-index: 25;
}
.edit-group {
  display: flex;
  gap: 2px;
}
.edit-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.edit-btn:active { background: rgba(255,255,255,0.25); }
.edit-delete {
  background: rgba(255,60,60,0.3);
  font-weight: bold;
}
.edit-delete:active { background: rgba(255,60,60,0.5); }

/* Color chips */
.color-mode-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.color-mode-label {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
}
.color-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.color-chip {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  background: none;
  padding: 2px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.color-chip:active { transform: scale(0.9); }
.color-chip.active { border-color: #007aff; }
.chip-swatch {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 5px;
}
.chip-custom {
  position: relative;
  overflow: hidden;
}
.chip-custom input[type="color"] {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  border: none;
  background: none;
  cursor: pointer;
}

/* Advanced section */
.advanced-section {
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 0;
}
.advanced-section summary {
  padding: 8px 12px;
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  list-style: none;
}
.advanced-section summary::before {
  content: '+ ';
}
.advanced-section[open] summary::before {
  content: '- ';
}
.advanced-options {
  display: flex;
  gap: 16px;
  padding: 4px 12px 10px;
}
.check-option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
}
.check-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #007aff;
}

/* Buttons */
.btn {
  width: 100%;
  padding: 12px 20px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: #007aff; color: #fff; }
.btn-primary:hover { background: #0062cc; }

/* Status toast */
.status {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: #fff;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 8px 18px;
  border-radius: 20px;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  white-space: nowrap;
  max-width: 90%;
  text-align: center;
}
.status.show { opacity: 1; }

@media (min-width: 768px) {
  .toolbar { max-width: 420px; left: 50%; transform: translateX(-50%); }
  .sub-panel { max-width: 380px; }
}
