:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: #1b1d22;
  --panel-2: #242831;
  --text: #f7f4ed;
  --muted: #aeb4bd;
  --accent: #ffcc4d;
  --accent-2: #45d6b5;
  --danger: #ff6f61;
  --line: rgba(255, 255, 255, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
}

.stage {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
  gap: 18px;
  padding: 18px;
  align-items: center;
  background:
    linear-gradient(90deg, rgba(255, 204, 77, 0.08), transparent 30%),
    linear-gradient(180deg, #14171d, #0f1013);
}

.camera-panel {
  position: relative;
  width: min(100%, 58vh);
  aspect-ratio: var(--camera-aspect, 2 / 3);
  justify-self: center;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #050607;
}

.preview-panel {
  position: relative;
  width: min(100%, 58vh);
  aspect-ratio: var(--preview-aspect, 2 / 3);
  justify-self: center;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #050607;
}

video,
canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

#captureCanvas {
  display: none;
}

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.35);
  font-size: clamp(80px, 16vw, 180px);
  font-weight: 800;
  color: var(--accent);
}

.controls {
  border-left: 1px solid var(--line);
  background: var(--panel);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #17110a;
  font-weight: 900;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.15;
}

h2 {
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
}

p,
label {
  color: var(--muted);
  font-size: 14px;
}

.toolbar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.actions .primary {
  grid-column: 1 / -1;
}

.toolbar .primary {
  min-width: 150px;
  flex: 0 0 auto;
}

.actions {
  margin-top: auto;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
}

button:hover {
  border-color: rgba(255, 255, 255, 0.28);
}

.primary {
  background: var(--accent);
  color: #191208;
  border-color: transparent;
  font-weight: 800;
}

.icon-button {
  min-width: 62px;
  padding: 0 10px;
  font-size: 13px;
}

.control-group {
  display: grid;
  gap: 12px;
}

.compact {
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compact label {
  display: grid;
  gap: 8px;
}

.toggle {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.background-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.background-option {
  height: 96px;
  padding: 0;
  overflow: hidden;
  border-radius: 8px;
  position: relative;
}

.background-option[aria-pressed="true"] {
  outline: 3px solid var(--accent-2);
}

.background-option img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-2);
}

input[type="number"] {
  width: 84px;
  min-height: 38px;
  color: var(--text);
  background: #121419;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

input[type="text"] {
  width: 100%;
  min-height: 38px;
  color: var(--text);
  background: #121419;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

select {
  width: 100%;
  min-height: 38px;
  color: var(--text);
  background: #121419;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .stage {
    grid-template-columns: 1fr;
  }

  .controls {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media print {
  body {
    background: white;
  }

  .controls,
  .camera-panel {
    display: none;
  }

  .app-shell,
  .stage {
    display: block;
    padding: 0;
    min-height: auto;
    background: white;
  }

  .preview-panel {
    width: 100vw;
    height: 100vh;
    border: 0;
  }
}
