:root {
  color-scheme: light;
  --bg: #f2f4f7;
  --panel: rgba(255,255,255,0.9);
  --line: rgba(15, 23, 42, 0.1);
  --text: #101828;
  --muted: #667085;
  --accent: #111827;
  --danger: #b42318;
}
* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: radial-gradient(circle at top, #ffffff, var(--bg) 58%);
  color: var(--text);
}
button, input, select { font: inherit; }
.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  overflow: hidden;
}
.panel {
  height: 100vh;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
.controls section { margin-top: 26px; position: relative; }
.top-row, .section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toolbar-actions { display: flex; gap: 8px; }
.lang-picker { display: inline-flex; align-items: center; max-width: 160px; }
.lang-picker select {
  width: 100%; appearance: none; border: 1px solid var(--line); border-radius: 12px; background: white; color: var(--text);
  padding: 8px 34px 8px 12px; line-height: 1.2; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, #667085 50%), linear-gradient(135deg, #667085 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
}
.eyebrow { text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-size: 12px; margin: 0 0 6px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: 28px; line-height: 1.08; margin-bottom: 12px; }
h2 { font-size: 15px; margin-bottom: 12px; }
.lead, .hint { color: var(--muted); }
.lead { line-height: 1.55; margin-bottom: 2px; }
.hint { font-size: 13px; line-height: 1.45; }
label { display: grid; gap: 8px; margin-bottom: 14px; font-size: 14px; }
.mode-grid label { margin-bottom: 0; }
input[type="range"] { width: 100%; }
button { border: 0; border-radius: 14px; padding: 11px 14px; background: var(--accent); color: white; cursor: pointer; transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease, transform .12s ease; }
button.ghost { background: white; color: var(--text); border: 1px solid var(--line); }
button.small { padding: 8px 12px; font-size: 12px; border-radius: 12px; }
button.active { background: #344054; color: white; border-color: transparent; box-shadow: 0 8px 20px rgba(52, 64, 84, 0.18); }
button.danger { color: var(--danger); border-color: rgba(180, 35, 24, 0.18); }
button:hover:not(:disabled) { transform: translateY(-1px); }
button:disabled, input:disabled, select:disabled { opacity: 0.45; cursor: not-allowed; }
.preset-grid, .mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-row button { flex: 1; min-width: 120px; }
.scene-grid { grid-template-columns: repeat(3, 1fr); }
.scene-grid button.active { background: #344054; color: white; border-color: transparent; }
.toggle-row, .field-row { display: flex; gap: 12px; align-items: center; }
.toggle-row.wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.field-row.compact label { flex: 1; }
.eye-tracking-label { position: relative; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.mode-grid {
  position: relative;
}
.mode-grid-with-popover {
  position: relative;
}
.mode-grid label {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,0.82);
}
.mode-grid input[type="radio"] {
  margin: 0;
  width: 18px;
  height: 18px;
  accent-color: #344054;
}
.mode-grid label:has(input:checked) {
  border-color: rgba(52, 64, 84, 0.32);
  background: rgba(255,255,255,0.96);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.06);
}
.info-button {
  width: 26px; height: 26px; min-width: 26px; padding: 0; border-radius: 999px; font-size: 13px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.info-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: min(320px, calc(100vw - 56px));
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.98);
  border: 1px solid var(--line);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.12);
}
.info-popover p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.add-hint,
.motion-intensity-row,
.scene-reset-row {
  margin-top: 12px;
}
.stage-wrap {
  min-width: 0; height: 100vh; padding: 18px; display: flex; flex-direction: column; gap: 12px; overflow: hidden;
}
.stage-toolbar { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 14px; }
.stage-subhint { margin-top: -4px; }
body.preview-only .panel { display: none; }
body.preview-only .app-shell { grid-template-columns: 1fr; }
.stage {
  position: relative; flex: 1; min-height: 0; border-radius: 24px; overflow: hidden; border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08); cursor: default; isolation: isolate;
}
.scene-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 0; background-position: center; background-size: cover; background-repeat: no-repeat; }
.motion-layer, .floater-layer, .draw-layer { position: absolute; inset: 0; }
.motion-layer { z-index: 1; transform: translate(0, 0); will-change: transform; pointer-events: auto; }
.motion-layer.hidden-eye { opacity: 0; pointer-events: none; }
.motion-layer.active-eye-layer { z-index: 2; }
.floater-layer { pointer-events: none; }
.draw-layer { width: 100%; height: 100%; pointer-events: none; }
.stage.scene-beach { background: linear-gradient(180deg, #9ddcff 0%, #dff3ff 40%, #fbf6e1 68%, #f3dfb0 100%); }
.stage.scene-beach .scene-overlay {
  background-image: linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.08)), url('./assets/beach-scene.jpg');
}
.stage.scene-snow { background: linear-gradient(180deg, #d5e6f6 0%, #edf6fb 45%, #ffffff 100%); }
.stage.scene-snow .scene-overlay {
  background-image: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.04)), url('./assets/snow-scene.jpg');
}
.stage.scene-plain { background: #f7f8fa; }
.stage.scene-plain .scene-overlay { background: none; }
.floater-item {
  position: absolute; inset: auto; transform-origin: center; opacity: 0.85; mix-blend-mode: multiply; cursor: grab; pointer-events: auto;
  touch-action: none; overflow: visible; z-index: 2;
}
.floater-item.dragging { cursor: grabbing; z-index: 30; }
.floater-item.selected { outline: 2px solid rgba(17, 24, 39, 0.45); outline-offset: 8px; border-radius: 22px; }
.floater-svg { overflow: visible; }
.drawing-hit { cursor: grab; pointer-events: auto; }
.drawing-group.selected .drawing-hit { cursor: grabbing; }
body.drawing-mode .stage,
body.drawing-mode .stage *,
body.drawing-mode .floater-item,
body.drawing-mode .drawing-hit {
  cursor: crosshair !important;
}
body.exporting-pdf .floater-item.selected {
  outline: none;
}
body.exporting-pdf .drawing-group.selected rect {
  display: none;
}
#cameraFeed { display: none; }
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.22);
  font-size: 13px;
  line-height: 1.4;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
body.rtl { direction: rtl; }
body.rtl .panel { border-right: 0; border-left: 1px solid var(--line); }
body.rtl .lang-picker select { padding: 8px 12px 8px 34px; background-position: 18px calc(50% - 2px), 24px calc(50% - 2px); }
@media (max-width: 1040px) {
  .app-shell {
    height: 100svh;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(280px, 46svh) minmax(0, 1fr);
    overflow: hidden;
  }
  .panel {
    height: auto;
    min-height: 0;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  body.rtl .panel { border-left: 0; }
  .stage-wrap { height: auto; min-height: 0; }
  .top-row, .stage-toolbar, .section-head, .stack-mobile { flex-wrap: wrap; }
}
