:root {
  --accent: #BE185D;
  --accent-hover: #9D174D;
  --accent-soft: rgba(190, 24, 93, 0.14);
  --accent-border: rgba(190, 24, 93, 0.35);

  --bg-app: #F7F5F2;
  --bg-surface: #FFFFFF;
  --bg-elevated: #F3EFEA;
  --bg-hover: #EBE6DF;
  --bg-glass: rgba(255, 255, 255, 0.78);

  --text-primary: #17141A;
  --text-secondary: #5B5361;
  --text-muted: #8C8394;

  --border: #E5DFD8;
  --border-strong: #D4CBC0;

  --shadow-sm: 0 2px 6px rgba(23, 20, 26, 0.06);
  --shadow-md: 0 12px 32px rgba(23, 20, 26, 0.10);
  --shadow-lg: 0 24px 64px rgba(23, 20, 26, 0.18);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --header-h: 58px;
  --font-ui: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-script: 'Dancing Script', cursive;
  --font-editorial: 'Cinzel', Georgia, serif;
  --font-mono: 'Space Mono', monospace;
}

[data-theme="dark"] {
  --bg-app: #0E0C12;
  --bg-surface: #17141E;
  --bg-elevated: #211D2B;
  --bg-hover: #2A2537;
  --bg-glass: rgba(23, 20, 30, 0.76);

  --text-primary: #FAF8FC;
  --text-secondary: #B7AEC2;
  --text-muted: #7C7388;

  --border: #2C2638;
  --border-strong: #3E364F;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 14px 36px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 28px 72px rgba(0, 0, 0, 0.7);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font-ui);
  background: var(--bg-app);
  color: var(--text-primary);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

a {
  color: inherit;
  text-decoration: none;
}

.font-serif { font-family: var(--font-serif); }
.font-script { font-family: var(--font-script); }
.font-editorial { font-family: var(--font-editorial); letter-spacing: 0.06em; }
.font-modern { font-family: var(--font-ui); }

/* App Shell */
.bg-app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.bg-app.is-kiosk .bg-hide-kiosk {
  display: none !important;
}

/* Header */
.bg-header {
  height: var(--header-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}

.bg-header-left, .bg-header-center, .bg-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bg-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.bg-brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #E11D48);
  color: #FFFFFF;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px var(--accent-soft);
}

.bg-brand-text {
  display: flex;
  flex-direction: column;
}

.bg-brand-name {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.bg-brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Step Pills */
.bg-step-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elevated);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
}

.bg-step-pill {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  transition: all 0.2s;
}

.bg-step-pill.active {
  background: var(--accent);
  color: #FFFFFF;
}

.bg-step-sep {
  color: var(--text-muted);
  opacity: 0.5;
}

/* Buttons */
.bg-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.16s ease;
  white-space: nowrap;
}

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

.bg-pill-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}

.bg-pill-btn.primary:hover {
  filter: brightness(1.08);
}

.bg-pill-btn.danger {
  color: #EF4444;
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.08);
}

.bg-pill-btn.danger:hover {
  background: rgba(239, 68, 68, 0.16);
}

.bg-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  display: grid;
  place-items: center;
  transition: all 0.16s;
}

.bg-icon-btn:hover {
  background: var(--bg-hover);
}

.bg-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--accent);
  color: #FFF;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
}

.bg-lang-switch {
  display: flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px;
}

.bg-lang-btn {
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.bg-lang-btn.active {
  background: var(--accent);
  color: #FFF;
}

/* Main Stage & Views */
.bg-main {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.bg-view {
  position: absolute;
  inset: 0;
  display: none;
  overflow-y: auto;
}

.bg-view.active {
  display: flex;
}

/* =====================================================================
   VIEW 1: WELCOME / ATTRACT SCREEN
===================================================================== */
#viewWelcome {
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, var(--accent-soft), transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(225, 29, 72, 0.10), transparent 45%),
    var(--bg-app);
}

.bg-welcome-card {
  position: relative;
  width: 100%;
  max-width: 720px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 36px 32px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.bg-welcome-logo {
  width: 76px;
  height: 76px;
  margin: 0 auto 14px;
  border-radius: 20px;
  overflow: hidden;
  border: 2px solid var(--accent-border);
  background: var(--bg-elevated);
  display: grid;
  place-items: center;
}

.bg-welcome-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.bg-mode-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.bg-welcome-title {
  margin: 0;
  font-size: clamp(32px, 6vw, 54px);
  line-height: 1.12;
  color: var(--text-primary);
}

.bg-welcome-subtitle {
  margin: 10px 0 4px;
  font-size: 15px;
  color: var(--text-secondary);
}

.bg-welcome-date {
  margin: 0 0 22px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.bg-quick-picker {
  margin: 0 auto 24px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.bg-quick-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.bg-template-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  justify-content: center;
  flex-wrap: wrap;
}

.bg-tpl-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  min-width: 96px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-surface);
  transition: all 0.16s;
}

.bg-tpl-card:hover {
  border-color: var(--accent-border);
  transform: translateY(-1px);
}

.bg-tpl-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.bg-tpl-icon {
  font-size: 18px;
  line-height: 1;
}

.bg-tpl-name {
  font-size: 11.5px;
  font-weight: 700;
}

.bg-tpl-meta {
  font-size: 10px;
  color: var(--text-muted);
}

.bg-welcome-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.bg-cta-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 54px;
  padding: 0 32px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--accent), #E11D48);
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 28px var(--accent-soft);
  transition: transform 0.16s, box-shadow 0.16s;
}

.bg-cta-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px var(--accent-border);
}

.bg-cta-primary.full {
  width: 100%;
  height: 46px;
  font-size: 14.5px;
}

.bg-cta-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 54px;
  padding: 0 22px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
  transition: all 0.16s;
}

.bg-cta-secondary:hover {
  background: var(--bg-hover);
}

.bg-privacy-note {
  margin: 18px 0 0;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* =====================================================================
   VIEW 2: LIVE CAMERA STUDIO
===================================================================== */
.bg-studio-layout {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.bg-camera-stage {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  gap: 12px;
}

.bg-camera-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.bg-camera-controls-left, .bg-camera-controls-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bg-glass-btn, .bg-glass-select {
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bg-glass-select {
  max-width: 180px;
  cursor: pointer;
}

.bg-glass-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--text-secondary);
}

.bg-glass-icon.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.bg-retake-pill {
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: #F59E0B;
  color: #111;
  font-size: 12px;
  font-weight: 800;
}

.bg-camera-frame {
  flex: 1;
  min-height: 220px;
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #09080C;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.bg-camera-frame video,
.bg-camera-frame canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
}

.bg-camera-frame.mirrored video,
.bg-camera-frame.mirrored canvas {
  transform: scaleX(-1);
}

.bg-camera-guide {
  position: absolute;
  pointer-events: none;
  border: 2px dashed rgba(255, 255, 255, 0.45);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.28);
  transition: all 0.25s;
}

.bg-camera-fallback {
  position: absolute;
  inset: 0;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 8px;
}

.bg-fallback-icon {
  font-size: 42px;
}

.bg-camera-fallback h3 {
  margin: 0;
  font-size: 18px;
}

.bg-camera-fallback p {
  margin: 0 0 10px;
  max-width: 400px;
  color: var(--text-secondary);
}

.bg-fallback-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* Countdown & Flash */
.bg-countdown-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 15;
  pointer-events: none;
}

.bg-countdown-num {
  font-size: clamp(86px, 16vw, 150px);
  font-weight: 800;
  color: #FFFFFF;
  line-height: 1;
  text-shadow: 0 8px 36px rgba(0, 0, 0, 0.6);
  animation: popIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.bg-countdown-cue {
  margin-top: 10px;
  padding: 6px 18px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.6);
  color: #FFF;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

@keyframes popIn {
  0% { transform: scale(1.45); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.bg-flash-overlay {
  position: absolute;
  inset: 0;
  background: #FFFFFF;
  opacity: 0;
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.28s ease-out;
}

.bg-flash-overlay.active {
  opacity: 1;
  transition: none;
}

/* Studio Bottom Deck */
.bg-studio-deck {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.bg-filter-pills {
  display: flex;
  gap: 6px;
  max-width: 100%;
  overflow-x: auto;
  padding: 2px 4px;
}

.bg-chip {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.15s;
}

.bg-chip:hover {
  border-color: var(--accent-border);
}

.bg-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFF;
}

.bg-shutter-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.bg-shutter-btn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  padding: 5px;
  border: 3.5px solid var(--text-primary);
  display: grid;
  place-items: center;
  transition: transform 0.14s;
}

.bg-shutter-btn:hover {
  transform: scale(1.05);
}

.bg-shutter-btn:active {
  transform: scale(0.95);
}

.bg-shutter-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #E11D48);
  display: block;
}

.bg-deck-side-btn {
  height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bg-deck-side-btn.danger {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.4);
  color: #EF4444;
}

.bg-shot-counter {
  min-width: 72px;
  text-align: center;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
}

.bg-shutter-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* Shots Side Rail */
.bg-shots-rail {
  width: 210px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.bg-rail-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-weight: 700;
  font-size: 13px;
}

.bg-rail-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.bg-shots-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bg-shot-slot {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--border-strong);
  background: var(--bg-elevated);
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 12px;
}

.bg-shot-slot.filled {
  border-style: solid;
  border-color: var(--accent);
}

.bg-shot-slot.active-slot {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.bg-shot-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bg-shot-slot-num {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #FFF;
  font-size: 10.5px;
  display: grid;
  place-items: center;
}

/* =====================================================================
   VIEW 3: REVIEW & SHARE
===================================================================== */
.bg-review-layout {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.bg-review-stage {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 14px;
  background:
    radial-gradient(circle at 50% 50%, var(--accent-soft), transparent 60%),
    var(--bg-app);
}

.bg-review-canvas-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bg-review-canvas-wrap canvas,
.bg-review-canvas-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  background: #FFF;
}

.bg-preview-mode-bar {
  display: flex;
  gap: 6px;
  background: var(--bg-surface);
  padding: 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
}

.bg-mode-tab {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.bg-mode-tab.active {
  background: var(--accent);
  color: #FFF;
}

.bg-review-panel {
  width: 370px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.bg-autoreset-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--accent-border);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.bg-hold-btn {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #FFF;
  font-size: 11px;
  font-weight: 700;
}

.bg-panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.bg-panel-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bg-section-title {
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.bg-review-shots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.bg-retake-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid var(--border);
  cursor: pointer;
}

.bg-retake-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bg-retake-thumb::after {
  content: '↻';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  color: #FFF;
  font-size: 18px;
  font-weight: 800;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.bg-retake-thumb:hover::after {
  opacity: 1;
}

.bg-chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bg-swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bg-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  position: relative;
  transition: transform 0.14s;
}

.bg-swatch:hover {
  transform: scale(1.1);
}

.bg-swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.bg-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.bg-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 42px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 12.5px;
  font-weight: 700;
  transition: all 0.15s;
}

.bg-action-btn:hover {
  background: var(--bg-hover);
}

.bg-action-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFF;
}

.bg-action-btn.accent-soft {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.bg-action-btn.full {
  width: 100%;
  margin-top: 8px;
}

.bg-panel-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

/* =====================================================================
   MODALS
===================================================================== */
.bg-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.bg-modal.open {
  display: flex;
}

.bg-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 6, 12, 0.72);
  backdrop-filter: blur(6px);
}

.bg-modal-dialog {
  position: relative;
  width: 100%;
  max-height: 90dvh;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bg-modal-dialog.sm { max-width: 340px; }
.bg-modal-dialog.lg { max-width: 680px; }
.bg-modal-dialog.xl { max-width: 960px; }

.bg-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.bg-modal-header h2 {
  margin: 0;
  font-size: 17px;
}

.bg-modal-header p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.bg-modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bg-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: grid;
  place-items: center;
  font-size: 14px;
}

.bg-modal-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 20px 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.bg-tab-btn {
  padding: 8px 14px 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.bg-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.bg-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.bg-modal-body.center {
  text-align: center;
}

.bg-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.bg-tab-pane {
  display: none;
}

.bg-tab-pane.active {
  display: block;
}

/* Forms */
.bg-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.bg-field.span-2 {
  grid-column: span 2;
}

.bg-field > span {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.bg-field-hint {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-muted);
}

.bg-field input[type="text"],
.bg-field input[type="password"],
.bg-field select {
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  outline: none;
}

.bg-field input:focus,
.bg-field select:focus {
  border-color: var(--accent);
}

.bg-color-input {
  display: flex;
  gap: 8px;
  align-items: center;
}

.bg-color-input input[type="color"] {
  width: 42px;
  height: 38px;
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
}

.bg-color-input input[type="text"] {
  flex: 1;
  font-family: var(--font-mono);
}

.bg-upload-row, .bg-pin-setup-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.bg-mini-preview {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: contain;
  border: 1px solid var(--border);
  background: repeating-conic-gradient(#8882 0% 25%, transparent 0% 50%) 50% / 12px 12px;
}

.bg-mini-preview.tall {
  height: 76px;
  width: auto;
}

.bg-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
}

.bg-switch-row strong {
  display: block;
  font-size: 13px;
}

.bg-switch-row small {
  color: var(--text-muted);
  font-size: 11.5px;
}

.bg-switch-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

/* PIN Pad */
.bg-pin-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 8px 0 10px;
}

.bg-pin-dots span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
}

.bg-pin-dots span.filled {
  background: var(--accent);
  border-color: var(--accent);
}

.bg-pin-error {
  min-height: 18px;
  margin: 0 0 10px;
  color: #EF4444;
  font-size: 12px;
  font-weight: 600;
}

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

.bg-keypad button {
  height: 52px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 18px;
  font-weight: 700;
}

.bg-keypad button:hover {
  background: var(--bg-hover);
}

/* Gallery */
.bg-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

.bg-gallery-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.bg-gallery-thumb {
  aspect-ratio: 2 / 3;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 6px;
}

.bg-gallery-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.bg-gallery-meta {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bg-gallery-time {
  font-size: 10.5px;
  color: var(--text-muted);
}

.bg-gallery-actions {
  display: flex;
  gap: 6px;
}

.bg-gallery-actions button {
  flex: 1;
  height: 28px;
  border-radius: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
}

.bg-gallery-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}

/* Toast */
.bg-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: #18141F;
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  z-index: 200;
  transition: all 0.22s ease;
}

.bg-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Pro Badge, Legal Footer, Stickers & QR Modal */
.bg-pro-btn {
  color: #D97706;
  border-color: rgba(217, 119, 6, 0.38);
  background: rgba(245, 158, 11, 0.11);
}

.bg-pro-btn.is-pro {
  color: #10B981;
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.12);
}

.bg-legal-bar {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.bg-legal-bar button {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  transition: color 0.15s;
}

.bg-legal-bar button:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.bg-legal-bar button.pro-link {
  color: var(--accent);
}

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

.bg-link-mini {
  font-size: 11px;
  font-weight: 700;
  color: #EF4444;
}

.bg-qr-box {
  width: 224px;
  height: 224px;
  margin: 0 auto 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: #FFFFFF;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
}

.bg-qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.bg-qr-url {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
}

.bg-pro-active-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #10B981;
  font-weight: 700;
  font-size: 13px;
}

.bg-pro-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.bg-pro-card {
  position: relative;
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bg-pro-card.highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.bg-pro-tag {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #FFF;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.bg-pro-card h3 {
  margin: 0;
  font-size: 15px;
}

.bg-pro-price {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
}

.bg-pro-period {
  font-size: 11.5px;
  color: var(--text-muted);
}

.bg-pro-list {
  margin: 4px 0 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.bg-pro-activate-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.bg-pro-input {
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-family: var(--font-mono);
  font-size: 12px;
  width: 200px;
  text-transform: uppercase;
}

.bg-legal-tab {
  padding: 8px 14px 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
}

.bg-legal-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.bg-legal-content h4 {
  margin: 14px 0 6px;
  font-size: 14px;
  color: var(--text-primary);
}

.bg-legal-content h4:first-child {
  margin-top: 0;
}

.bg-legal-content p {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

@media (max-width: 780px) {
  .bg-pro-grid {
    grid-template-columns: 1fr;
  }
}

/* Print Sheet */
.bg-print-sheet {
  display: none;
}

@media print {
  @page {
    margin: 0;
    size: auto;
  }
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #FFFFFF !important;
    overflow: visible !important;
    height: auto !important;
  }
  .bg-app {
    display: none !important;
  }
  .bg-print-sheet {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    page-break-inside: avoid;
  }
  .bg-print-sheet img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }
}

/* Responsive (Tablet & Mobile) */
@media (max-width: 900px) {
  .bg-step-pills { display: none; }
  .bg-studio-layout, .bg-review-layout {
    flex-direction: column;
  }
  .bg-shots-rail {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    padding: 10px 14px;
  }
  .bg-shots-grid {
    flex-direction: row;
    overflow-x: auto;
  }
  .bg-shot-slot {
    width: 88px;
    flex-shrink: 0;
  }
  .bg-review-panel {
    width: 100%;
    max-height: 48%;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 600px) {
  .bg-hide-mobile { display: none !important; }
  .bg-header { padding: 0 12px; }
  .bg-welcome-card { padding: 24px 18px; border-radius: 22px; }
  .bg-form-grid { grid-template-columns: 1fr; }
  .bg-field.span-2 { grid-column: span 1; }
}
