/* ========================================
   CHEMAR WEB — VANILLA · Mobile-first
   ======================================== */
:root {
  --bg-body:      #FDF8F3;
  --bg-card:      #FFFFFF;
  --bg-card-alt:  #F9F2E7;
  --text-primary: #4A1E2E;
  --text-muted:   #8B6B5A;
  --accent:       #D49B4E;
  --accent-hover: #C0883A;
  --border:       #E8DDD0;
  --shadow:       0 2px 10px rgba(74, 30, 46, 0.08);
  --radius:       12px;
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
  --safe-top:     env(safe-area-inset-top, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
}

body { display: flex; }

/* Full-screen app — no top header bar */
#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  max-width: 100vw;
}

/* Header not rendered; keep rule harmless if injected later */
#header {
  display: none !important;
}

#viewport {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-body);
}

#viewport canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Bottom controls — desktop + phone */
#controls {
  position: absolute;
  left: 50%;
  bottom: calc(16px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  z-index: 100;
  max-width: min(96vw, 520px);
  padding: 0 8px;
  pointer-events: none;
}

#controls button {
  pointer-events: auto;
  min-width: 72px;
  min-height: 44px;
  height: auto;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: 0.15s;
  touch-action: manipulation;
}

#controls button:hover {
  background: var(--bg-card-alt);
}

#controls button:active {
  transform: scale(0.97);
}

/* Phone */
@media (max-width: 640px) {
  #controls {
    bottom: calc(12px + var(--safe-bottom));
    gap: 6px;
    max-width: 100vw;
  }
  #controls button {
    min-width: 0;
    flex: 1 1 auto;
    padding: 10px 8px;
    font-size: 0.72rem;
  }
}

/* Hide any leftover debug DOM panels */
#debug-panel,
.debug-panel,
[id*="debug-panel"] {
  display: none !important;
}
