/* ═══════════════════════════════════════════════════════
   HomeForge — style.css
   Premium dark-mode 3D interior designer UI
═══════════════════════════════════════════════════════ */

/* ─── Utility ────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ─── Tokens ─────────────────────────────────────── */
:root {
  --bg-deep: #0d0b14;
  --bg-surface: #13101e;
  --bg-panel: #1a1628;
  --bg-card: #221c36;
  --bg-hover: #2a2245;
  --border: rgba(167, 139, 250, 0.15);
  --border-strong: rgba(167, 139, 250, 0.3);

  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --accent-glow: rgba(124, 58, 237, 0.35);
  --accent2: #2563eb;
  --accent2-light: #60a5fa;

  --text-primary: #f1eeff;
  --text-secondary: #b0a8cc;
  --text-muted: #6b6080;

  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.3);
  --success: #22c55e;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --transition: 0.2s ease;
  --shadow-panel: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 24px var(--accent-glow);
}

/* ─── Reset & Base ────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  user-select: none;
}

/* ─── Header ─────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  height: 56px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
  z-index: 100;
  position: relative;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-icon {
  width: 28px;
  height: 28px;
}

.brand-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-light), var(--accent2-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.3px;
}

/* ─── Toolbar ─────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}

.toolbar::-webkit-scrollbar {
  display: none;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  border-right: 1px solid var(--border);
}

.tool-group:last-child {
  border-right: none;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  font-family: inherit;
}

.tool-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.tool-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.tool-btn.active {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.3), rgba(37, 99, 235, 0.2));
  border-color: var(--accent-light);
  color: var(--accent-light);
  box-shadow: 0 0 12px var(--accent-glow);
}

.tool-btn.active-tool {
  background: rgba(167, 139, 250, 0.15);
  border-color: var(--accent-light);
  color: var(--accent-light);
}

.tool-btn.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger);
  color: var(--danger);
}

.header-right {
  display: flex;
  align-items: center;
  margin-left: auto;
}

.status-badge {
  padding: 4px 12px;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--success);
  letter-spacing: 0.3px;
}

.status-badge.drawing {
  background: rgba(167, 139, 250, 0.15);
  border-color: var(--accent-light);
  color: var(--accent-light);
}

.status-badge.placing {
  background: rgba(96, 165, 250, 0.15);
  border-color: var(--accent2-light);
  color: var(--accent2-light);
}

/* ─── App Layout ─────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: 220px 1fr 200px;
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* ─── Sidebars ────────────────────────────────────── */
.sidebar {
  background: var(--bg-panel);
  border-color: var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-left {
  border-right: 1px solid var(--border);
}

.sidebar-right {
  border-left: 1px solid var(--border);
}

.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.sidebar-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.5;
}

/* ─── Furniture Grid ──────────────────────────────── */
.furniture-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.furniture-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.furniture-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-glow), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.furniture-item:hover {
  border-color: var(--accent-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.furniture-item:hover::before {
  opacity: 1;
}

.furniture-item.selected {
  border-color: var(--accent-light);
  background: var(--bg-hover);
  box-shadow: 0 0 16px var(--accent-glow);
}

.furniture-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  position: relative;
  z-index: 1;
}

.furniture-name {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  position: relative;
  z-index: 1;
}

/* ─── Materials ───────────────────────────────────── */
.material-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.material-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.color-swatch {
  width: 36px;
  height: 24px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
  padding: 0;
  appearance: none;
}

.color-swatch::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color-swatch::-webkit-color-swatch {
  border-radius: 4px;
  border: none;
}

/* ─── Scene Stats ─────────────────────────────────── */
.scene-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.stat-val {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-light);
  font-family: 'Space Grotesk', sans-serif;
}

.camera-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.8;
}

/* ─── Properties Panel ────────────────────────────── */
.no-selection-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
  font-style: italic;
}

.prop-row {
  margin-bottom: 12px;
}

.prop-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.prop-val {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

.prop-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  padding: 6px 8px;
  font-family: inherit;
  transition: border-color var(--transition);
  margin-top: 4px;
}

.prop-input:focus {
  outline: none;
  border-color: var(--accent-light);
}

.prop-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

/* ─── Canvas Area ─────────────────────────────────── */
.canvas-area {
  position: relative;
  overflow: hidden;
  background: var(--bg-deep);
}

#main-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

#main-canvas.select-mode {
  cursor: default;
}

#main-canvas.placing {
  cursor: cell;
}

/* ─── Canvas Overlay ──────────────────────────────── */
.canvas-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease;
}

.canvas-overlay.hidden {
  opacity: 0;
}

.overlay-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: rgba(13, 11, 20, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 28px 36px;
  text-align: center;
  animation: hint-float 3s ease-in-out infinite;
}

.overlay-hint p {
  font-size: 14px;
  color: var(--text-primary);
}

.overlay-hint .hint-sub {
  font-size: 12px;
  color: var(--text-muted);
}

@keyframes hint-float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

/* ─── View Label ──────────────────────────────────── */
.view-label {
  position: absolute;
  bottom: 16px;
  right: 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent-light);
  background: rgba(13, 11, 20, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 20px;
  pointer-events: none;
}

/* ─── Context Menu ────────────────────────────────── */
.context-menu {
  position: fixed;
  z-index: 1000;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: var(--shadow-panel);
  min-width: 160px;
  backdrop-filter: blur(12px);
  animation: ctx-appear 0.12s ease;
}

.context-menu.hidden {
  display: none;
}

@keyframes ctx-appear {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-4px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  background: transparent;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: background var(--transition);
}

.ctx-item:hover {
  background: var(--bg-hover);
}

.ctx-item.danger {
  color: var(--danger);
}

.ctx-item.danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* ─── Toast ───────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: var(--shadow-panel);
  animation: toast-in 0.25s ease;
  backdrop-filter: blur(12px);
}

.toast.success {
  border-color: rgba(34, 197, 94, 0.5);
  color: var(--success);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.5);
  color: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Selection Highlight ─────────────────────────── */
.selection-info {
  font-size: 12px;
  color: var(--accent-light);
  margin-top: 6px;
  font-weight: 500;
}

/* ─── Scrollbar ───────────────────────────────────── */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* ═══════════════════════════════════════════════════════
   SCAN ROOM FEATURE STYLES
═══════════════════════════════════════════════════════ */

/* ─── Scan Room toolbar button ────────────────────────── */
.tool-btn.scan-btn {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(37, 99, 235, 0.15));
  border-color: var(--accent-light);
  color: var(--accent-light);
  font-weight: 600;
  animation: scan-pulse 3s ease-in-out infinite;
}

.tool-btn.scan-btn:hover {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.4), rgba(37, 99, 235, 0.3));
  box-shadow: 0 0 20px var(--accent-glow);
  transform: translateY(-1px);
}

@keyframes scan-pulse {

  0%,
  100% {
    box-shadow: 0 0 8px var(--accent-glow);
  }

  50% {
    box-shadow: 0 0 20px var(--accent-glow), 0 0 40px var(--accent-glow);
  }
}

/* ─── Camera Scan Modal ───────────────────────────────── */
.scan-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(5, 4, 10, 0.95);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modal-fade-in 0.3s ease;
}

.scan-modal.hidden {
  display: none;
}

@keyframes modal-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.scan-modal-inner {
  width: min(860px, 96vw);
  max-height: 92vh;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6), var(--shadow-glow);
  animation: modal-slide-up 0.3s ease;
}

@keyframes modal-slide-up {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ─── Scan modal header ───────────────────────────────── */
.scan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.scan-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.scan-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.scan-subtitle {
  font-size: 12px;
  color: var(--accent-light);
  background: rgba(167, 139, 250, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.3);
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
}

.scan-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  transition: all var(--transition);
}

.scan-close:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

/* ─── Step stepper ────────────────────────────────────── */
.scan-stepper {
  display: flex;
  gap: 6px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.scan-stepper::-webkit-scrollbar {
  display: none;
}

.step-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-card);
  white-space: nowrap;
  transition: all 0.3s ease;
  cursor: default;
  flex-shrink: 0;
}

.step-pill.done {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.4);
  color: var(--success);
}

.step-pill.active {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.25), rgba(37, 99, 235, 0.15));
  border-color: var(--accent-light);
  color: var(--accent-light);
  box-shadow: 0 0 12px var(--accent-glow);
  animation: step-glow 1.5s ease-in-out infinite;
}

@keyframes step-glow {

  0%,
  100% {
    box-shadow: 0 0 8px var(--accent-glow);
  }

  50% {
    box-shadow: 0 0 20px var(--accent-glow);
  }
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ─── Camera video wrap ───────────────────────────────── */
.scan-camera-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
  overflow: hidden;
}

#scan-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ─── SVG guide overlay ───────────────────────────────── */
.scan-guide-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ─── Instruction card ────────────────────────────────── */
.scan-instruction {
  position: absolute;
  bottom: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(13, 11, 20, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 16px;
  max-width: 380px;
  animation: instr-slide-up 0.4s ease;
}

@keyframes instr-slide-up {
  from {
    transform: translateY(8px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.scan-instruction-icon {
  font-size: 26px;
  flex-shrink: 0;
}

.scan-instruction-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.scan-instruction-text strong {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 600;
}

.scan-instruction-text span {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ─── No camera fallback ──────────────────────────────── */
.scan-no-camera {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(13, 11, 20, 0.9);
}

.scan-no-camera p {
  font-size: 14px;
  color: var(--text-primary);
}

.scan-no-camera .hint {
  font-size: 12px;
  color: var(--text-muted);
}

.upload-btn {
  padding: 8px 20px;
  background: var(--accent);
  border-radius: var(--radius);
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}

.upload-btn:hover {
  background: var(--accent-light);
}

.hidden-input {
  display: none;
}

/* ─── Photo thumbnails ────────────────────────────────── */
.scan-thumbs {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  min-height: 76px;
  align-items: center;
  scrollbar-width: none;
}

.scan-thumbs::-webkit-scrollbar {
  display: none;
}

.scan-thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
  transition: border-color var(--transition);
  cursor: pointer;
}

.scan-thumb.done {
  border-color: var(--success);
}

.scan-thumb.active {
  border-color: var(--accent-light);
  box-shadow: 0 0 10px var(--accent-glow);
}

.thumb-slot {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}

.thumb-slot-num {
  font-size: 16px;
  font-weight: 700;
  color: var(--border-strong);
}

/* ─── Scan action buttons ─────────────────────────────── */
.scan-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.scan-btn-primary {
  padding: 10px 24px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: var(--radius);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.scan-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--accent-glow);
}

.scan-btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.scan-btn-secondary {
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
}

.scan-btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--accent-light);
  color: var(--text-primary);
}

.scan-btn-analyze {
  padding: 10px 28px;
  background: linear-gradient(135deg, #059669, #0d9488);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  box-shadow: 0 4px 16px rgba(5, 150, 105, 0.3);
  animation: analyze-pulse 2s ease-in-out infinite;
}

.scan-btn-analyze:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(5, 150, 105, 0.4);
}

.scan-btn-analyze.hidden {
  display: none;
}

@keyframes analyze-pulse {

  0%,
  100% {
    box-shadow: 0 4px 16px rgba(5, 150, 105, 0.3);
  }

  50% {
    box-shadow: 0 4px 30px rgba(5, 150, 105, 0.5);
  }
}

/* ─── Generic modal backdrop ──────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: rgba(5, 4, 10, 0.85);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modal-fade-in 0.25s ease;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  width: min(480px, 92vw);
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-panel), var(--shadow-glow);
  animation: modal-slide-up 0.25s ease;
}

.modal-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}

.modal-desc strong {
  color: var(--accent-light);
}

.modal-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  padding: 10px 12px;
  font-family: inherit;
  transition: border-color var(--transition);
  outline: none;
}

.modal-input:focus {
  border-color: var(--accent-light);
}

.modal-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 8px;
  margin-bottom: 20px;
}

.modal-hint a {
  color: var(--accent-light);
  text-decoration: none;
}

.modal-hint a:hover {
  text-decoration: underline;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

/* ─── Result grid ─────────────────────────────────────── */
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.result-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ─── Analyzing spinner ───────────────────────────────── */
.scan-analyzing {
  position: absolute;
  inset: 0;
  background: rgba(13, 11, 20, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
}

.scan-analyzing.hidden {
  display: none;
}

.spin-ring {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.scanning-text {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════
   MOBILE RESPONSIVE STYLES (≤ 768px)
═══════════════════════════════════════════════════════ */

@media (max-width: 768px) {

  /* ─── Header ─── */
  .header {
    padding: 0 10px;
    height: 52px;
    flex-wrap: wrap;
    gap: 0;
  }

  .brand-name {
    display: none;
  }

  .brand-icon {
    width: 28px;
    height: 28px;
  }

  /* ─── Toolbar: scroll horizontally ─── */
  .toolbar {
    overflow-x: auto;
    scrollbar-width: none;
    gap: 4px;
    padding: 4px 0;
    flex: 1;
  }

  .toolbar::-webkit-scrollbar {
    display: none;
  }

  .tool-group {
    gap: 4px;
  }

  .tool-btn {
    font-size: 11px;
    padding: 6px 8px;
    gap: 3px;
    min-width: unset;
    height: 36px;
  }

  .tool-btn svg {
    width: 14px;
    height: 14px;
  }

  .header-right {
    display: none;
  }

  /* ─── Layout: stack vertically ─── */
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    height: calc(100dvh - 52px);
  }

  /* Hide sidebars — replaced by bottom sheet ─── */
  .sidebar-left,
  .sidebar-right {
    display: none;
  }

  /* ─── Canvas fills screen ─── */
  .canvas-area {
    grid-column: 1;
    grid-row: 1;
    height: 100%;
  }

  /* ─── Compact hint overlay ─── */
  .overlay-hint {
    padding: 16px 20px;
  }

  .overlay-hint p {
    font-size: 13px;
  }

  /* ─── Scan modal: full screen on mobile ─── */
  .scan-modal-inner {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .scan-header {
    padding: 12px 14px;
  }

  .scan-title {
    font-size: 14px;
  }

  /* ─── Stepper: compact pills ─── */
  .scan-stepper {
    padding: 8px 10px;
    gap: 4px;
  }

  .step-pill {
    padding: 5px 8px;
    font-size: 10.5px;
  }

  /* ─── Camera: slightly smaller video area ─── */
  .scan-camera-wrap {
    min-height: 220px;
  }

  /* ─── Instruction card: compact ─── */
  .scan-instruction {
    bottom: 10px;
    left: 10px;
    right: 10px;
    max-width: 100%;
    padding: 10px 12px;
  }

  .scan-instruction-icon {
    font-size: 20px;
  }

  .scan-instruction-text strong {
    font-size: 12px;
  }

  .scan-instruction-text span {
    font-size: 11px;
  }

  /* ─── Thumbnail strip: smaller ─── */
  .scan-thumbs {
    padding: 8px 10px;
    min-height: 64px;
  }

  .scan-thumb {
    width: 46px;
    height: 46px;
  }

  .thumb-slot {
    width: 46px;
    height: 46px;
  }

  /* ─── Action buttons: full width row ─── */
  .scan-actions {
    padding: 10px 14px;
    gap: 8px;
  }

  .scan-btn-primary,
  .scan-btn-secondary,
  .scan-btn-analyze {
    font-size: 13px;
    padding: 10px 14px;
    flex: 1;
  }

  /* ─── Modal card ─── */
  .modal-card {
    width: 96vw;
    padding: 20px 18px;
    border-radius: var(--radius);
  }

  .modal-title {
    font-size: 17px;
  }

  /* ─── Result grid: 1 column ─── */
  .result-grid {
    grid-template-columns: 1fr;
  }

  /* ─── Toast: wider on mobile ─── */
  .toast-container {
    width: 90vw;
  }

  .toast {
    font-size: 12px;
    padding: 8px 14px;
  }
}

/* Landscape phone: more video height */
@media (max-width: 768px) and (orientation: landscape) {
  .scan-modal-inner {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .scan-camera-wrap {
    flex: 1;
    min-height: 0;
  }
}