* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body, html {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none; background: #eef2f6;
}

#canvas-container {
  width: 100%; height: 100%; position: absolute; top: 0; left: 0; touch-action: none;
}
/* Sub-panel Lantai */
#floor-subpanel {
  position: fixed; bottom: 86px; left: 50%; transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  padding: 6px 12px; border-radius: 30px;
  display: flex; align-items: center; gap: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  border: 1px solid rgba(255, 255, 255, 0.8);
  z-index: 20; transition: all 0.25s;
  max-width: 92vw; overflow-x: auto;
}
#floor-subpanel.hidden {
  opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(12px);
}
.floor-sub-btn {
  padding: 6px 10px; border-radius: 16px; border: 1.5px solid transparent;
  background: #f1f5f9; color: #334155; font-size: 11px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
}
.floor-sub-btn.active {
  background: #f0fdf4; border-color: #16a34a; color: #16a34a;
}
.dock-btn.active-floor {
  background: #f0fdf4; color: #16a34a;
}
/* Modal / Overlay */
.overlay-screen {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 100;
}
.modal-card {
  background: #ffffff; width: 100%; max-width: 440px;
  border-radius: 20px; padding: 24px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
  max-height: 90vh; overflow-y: auto;
}
.modal-card h2 { margin: 0 0 6px 0; font-size: 20px; color: #1e293b; }
.modal-card p { margin: 0 0 16px 0; font-size: 13px; color: #64748b; line-height: 1.4; }

.form-group { margin-bottom: 14px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
label { display: block; font-size: 12px; font-weight: 600; color: #334155; margin-bottom: 6px; }
input[type="number"], input[type="color"], input[type="file"] {
  width: 100%; padding: 12px; border: 1.5px solid #cbd5e1;
  border-radius: 10px; font-size: 15px; background: #f8fafc; outline: none;
}
input[type="number"]:focus { border-color: #3b82f6; background: #fff; }
input[type="color"] { height: 48px; padding: 4px; cursor: pointer; }

.btn-primary {
  width: 100%; padding: 14px; background: #2563eb; color: #ffffff;
  border: none; border-radius: 12px; font-size: 15px; font-weight: 700;
  cursor: pointer; margin-top: 10px;
}
.btn-primary:active { transform: scale(0.98); background: #1d4ed8; }
.btn-secondary {
  width: 100%; padding: 12px; background: #f1f5f9; color: #475569;
  border: none; border-radius: 12px; font-size: 14px; font-weight: 600;
  cursor: pointer; margin-top: 8px;
}

#top-bar { position: absolute; top: 16px; right: 16px; z-index: 20; }
.icon-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.95); border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; cursor: pointer;
}

#floor-panel {
  position: absolute; right: 16px; top: 80px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-radius: 14px; padding: 6px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  border: 1px solid rgba(255, 255, 255, 0.8); z-index: 20;
}
.floor-btn {
  width: 36px; height: 36px; border-radius: 10px;
  border: none; background: #f1f5f9; color: #475569;
  font-size: 16px; font-weight: bold; cursor: pointer;
}
.floor-btn:active { background: #e2e8f0; transform: scale(0.95); }
.floor-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.floor-label { font-size: 12px; font-weight: bold; color: #1e293b; margin: 4px 0; }

#active-furn-pill {
  position: fixed; bottom: 86px; left: 50%; transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  padding: 8px 16px; border-radius: 30px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  border: 1px solid rgba(255, 255, 255, 0.8);
  z-index: 20; cursor: pointer; transition: all 0.25s;
}
#active-furn-pill.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(12px); }
.pill-text { font-size: 12px; font-weight: 700; color: #1e293b; display: flex; align-items: center; gap: 6px; }
.pill-badge { font-size: 11px; background: #eff6ff; color: #2563eb; padding: 2px 8px; border-radius: 10px; }

#camera-subpanel, #opening-subpanel {
  position: fixed; bottom: 86px; left: 50%; transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  padding: 6px 12px; border-radius: 30px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  border: 1px solid rgba(255, 255, 255, 0.8);
  z-index: 20; transition: all 0.25s;
}
#camera-subpanel.hidden, #opening-subpanel.hidden {
  opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(12px);
}
.subpanel-label {
  font-size: 12px; font-weight: 700; color: #334155;
  display: flex; align-items: center; gap: 8px; cursor: pointer;
}
.subpanel-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: #2563eb; cursor: pointer; }

.opening-sub-btn {
  padding: 6px 12px; border-radius: 16px; border: 1.5px solid transparent;
  background: #f1f5f9; color: #334155; font-size: 11px; font-weight: 700; cursor: pointer;
}
.opening-sub-btn.active { background: #eff6ff; border-color: #2563eb; color: #2563eb; }

#furniture-edit-panel {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  padding: 6px 12px; border-radius: 30px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 25; transition: all 0.2s;
}
#furniture-edit-panel.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(-10px); }
.edit-action-btn {
  padding: 6px 12px; border-radius: 20px; border: none;
  font-size: 12px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; gap: 4px;
}
.btn-rotate { background: #3b82f6; color: white; }
.btn-delete-furn { background: #ef4444; color: white; }
.btn-close-edit { background: #334155; color: #94a3b8; }

#bottom-dock {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  padding: 6px; border-radius: 20px;
  display: flex; gap: 6px; z-index: 20;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15); border: 1px solid rgba(255,255,255,0.7);
}
.dock-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 62px; padding: 10px 6px; border-radius: 14px; border: none;
  background: transparent; color: #64748b; font-size: 11px; font-weight: 700;
  cursor: pointer; transition: all 0.2s;
}
.dock-btn span.icon { font-size: 18px; margin-bottom: 2px; }
.dock-btn.active-cam { background: #eff6ff; color: #2563eb; }
.dock-btn.active-build { background: #f0fdf4; color: #16a34a; }
.dock-btn.active-openings { background: #fff7ed; color: #ea580c; }
.dock-btn.active-destroy { background: #fef2f2; color: #dc2626; }
.dock-btn.active-furn { background: #faf5ff; color: #9333ea; }

.catalog-modal-card {
  background: #ffffff; width: 100%; max-width: 580px;
  border-radius: 24px; padding: 20px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.25);
  max-height: 85vh; display: flex; flex-direction: column;
}
.catalog-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid #e2e8f0;
}
.catalog-header h2 { margin: 0; font-size: 18px; color: #0f172a; }
.catalog-close-btn {
  background: #f1f5f9; border: none; width: 36px; height: 36px;
  border-radius: 50%; font-size: 16px; font-weight: bold;
  color: #64748b; cursor: pointer;
}
.catalog-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px; overflow-y: auto; padding: 4px;
}
.catalog-card {
  background: #f8fafc; border: 1.5px solid #e2e8f0;
  border-radius: 16px; padding: 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
  transition: all 0.2s;
}
.catalog-card:active { transform: scale(0.96); }
.catalog-card.active-selected { border-color: #9333ea; background: #faf5ff; }
.catalog-thumb-box {
  width: 100%; height: 90px; border-radius: 10px;
  background: #ffffff; display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px; overflow: hidden;
}
.catalog-thumb-box img { width: 100%; height: 100%; object-fit: contain; }
.catalog-name { font-size: 12px; font-weight: 700; color: #1e293b; text-align: center; }
.catalog-dim { font-size: 10px; color: #64748b; margin-top: 2px; }