*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body.no-transition * {
  transition: none !important;
}

:root {
  --header-height: 64px;
  --color-bg: #f5f5f5;
  --color-header-bg: #ffffff;
  --color-border: #e2e8f0;
  --color-primary: #0066cc;
  --color-primary-hover: #0052a3;
  --color-text: #1a202c;
  --color-text-muted: #718096;
  --shadow-header: 0 1px 3px rgba(0,0,0,0.1);
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  height: 100vh;
  overflow: hidden;
}

/* ── Header ── */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--color-header-bg);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-header);
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}

.header-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.header-logo img {
  height: 32px;
  width: auto;
  display: block;
}

.header-divider {
  width: 1px;
  height: 32px;
  background: var(--color-border);
  flex-shrink: 0;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

/* Site Selector */
.site-selector-wrapper {
  position: relative;
}

.site-selector-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text);
  white-space: nowrap;
  min-width: 200px;
  transition: border-color 0.15s;
}

.site-selector-btn:hover {
  border-color: #a0aec0;
}

.site-selector-btn .btn-label {
  flex: 1;
  text-align: left;
  font-weight: 500;
}

.site-selector-btn .btn-desc {
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 400;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-selector-btn .chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform 0.2s;
}

.site-selector-btn.open .chevron {
  transform: rotate(180deg);
}

.site-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 280px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 2000;
  overflow: hidden;
  display: none;
}

.site-dropdown.open {
  display: block;
}

.site-dropdown-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.1s;
}

.site-dropdown-item:last-child {
  border-bottom: none;
}

.site-dropdown-item:hover {
  background: #f7fafc;
}

.site-dropdown-item.active {
  background: #ebf4ff;
}

.site-dropdown-item .item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.site-dropdown-item .item-desc {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
  line-height: 1.4;
}

/* View Mode Toggle */
.view-mode-group {
  display: flex;
  align-items: center;
  background: #f0f0f0;
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

.view-mode-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: all 0.15s;
  white-space: nowrap;
}

.view-mode-btn svg {
  width: 15px;
  height: 15px;
}

.view-mode-btn:hover {
  color: var(--color-text);
  background: #e0e0e0;
}

.view-mode-btn.active {
  background: #fff;
  color: var(--color-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Spacer */
.header-spacer {
  flex: 1;
}

/* Get Started Button */
.btn-get-started {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: var(--color-primary);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}

.btn-get-started:hover {
  background: var(--color-primary-hover);
}

.btn-get-started:active {
  transform: scale(0.98);
}

/* ── Device container (wraps iframe-wrapper + floating QR) ── */
.device-container {
  position: relative;
  display: flex;
  flex-direction: column;
}

.preview-area.mode-desktop .device-container {
  width: 100%;
  height: 100%;
}

/* ── QR wrap – floats outside top-right of device ── */
.qr-wrap {
  position: absolute;
  top: 20px;
  left: 100%;
  margin-left: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  z-index: 100;
}

.qr-wrap[hidden] {
  display: none;
}

.qr-trigger-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all 0.15s;
}

.qr-trigger-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.qr-trigger-btn.active {
  background: #ebf4ff;
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.qr-popover {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.qr-popover[hidden] {
  display: none;
}

.qr-code-canvas canvas,
.qr-code-canvas img {
  display: block;
  border-radius: 4px;
}

.qr-hint {
  font-size: 11px;
  color: var(--color-text-muted);
  text-align: center;
  max-width: 140px;
  line-height: 1.4;
}

/* Hide QR entirely on actual mobile browsers */
@media (max-width: 768px) {
  .qr-wrap {
    display: none !important;
  }
}

/* ── Orientation button ── */
.orientation-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}

.orientation-btn:hover {
  color: var(--color-text);
  border-color: #a0aec0;
}

.orientation-btn[hidden] {
  display: none;
}

/* ── Preview Area ── */
.preview-area {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: #e2e8f0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  padding: 32px;
}

.preview-area.mode-desktop {
  padding: 0;
  align-items: stretch;
}

/* ── iframe wrapper ── */
.iframe-wrapper {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  transition: width 0.3s ease, height 0.3s ease, border-radius 0.3s ease;
}

/* Desktop */
.preview-area.mode-desktop .iframe-wrapper {
  width: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
  border: none;
}

/* Mobile portrait – 375×812 */
.preview-area.mode-mobile-portrait .iframe-wrapper {
  width: 375px;
  height: 812px;
  border-radius: 44px;
  border: 10px solid #1a202c;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35), inset 0 0 0 1px #2a2a2a;
}

/* Mobile landscape – 812×375 */
.preview-area.mode-mobile-landscape .iframe-wrapper {
  width: 812px;
  height: 375px;
  border-radius: 44px;
  border: 10px solid #1a202c;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35), inset 0 0 0 1px #2a2a2a;
}

/* Tablet landscape – 1280×800 */
.preview-area.mode-tablet-landscape .iframe-wrapper {
  width: 1280px;
  height: 800px;
  border-radius: 14px;
  border: 8px solid #2d3748;
  box-shadow: 0 12px 48px rgba(0,0,0,0.25);
}

/* Tablet portrait – 800×1280 */
.preview-area.mode-tablet-portrait .iframe-wrapper {
  width: 800px;
  height: 1280px;
  border-radius: 14px;
  border: 8px solid #2d3748;
  box-shadow: 0 12px 48px rgba(0,0,0,0.25);
}

/* ── Device chrome – flex children in flow ── */
.device-chrome {
  display: none;
  align-items: center;
  flex-shrink: 0;
}

.preview-area.mode-mobile-portrait .device-chrome,
.preview-area.mode-mobile-landscape .device-chrome,
.preview-area.mode-tablet-landscape .device-chrome,
.preview-area.mode-tablet-portrait .device-chrome {
  display: flex;
}

/* Top spacer */
.device-top {
  justify-content: center;
}

.device-island {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 99px;
  padding: 3px 10px 3px 8px;
}

.device-speaker {
  width: 28px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255,255,255,0.35);
}

.device-camera {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1a3a5c;
  box-shadow: 0 0 0 1.5px rgba(255,255,255,0.2), inset 0 0 0 2px rgba(60,140,220,0.5);
}

/* Tablet: just a camera dot, no island pill */
.preview-area.mode-tablet-landscape .device-island,
.preview-area.mode-tablet-portrait .device-island {
  background: transparent;
  padding: 0;
  gap: 0;
}

.preview-area.mode-tablet-landscape .device-speaker,
.preview-area.mode-tablet-portrait .device-speaker {
  display: none;
}

.preview-area.mode-tablet-landscape .device-camera,
.preview-area.mode-tablet-portrait .device-camera {
  width: 7px;
  height: 7px;
  background: #1a3a5c;
  box-shadow: 0 0 0 1.5px rgba(255,255,255,0.2), inset 0 0 0 2px rgba(60,140,220,0.5);
}

.preview-area.mode-mobile-portrait .device-top,
.preview-area.mode-mobile-landscape .device-top {
  height: 28px;
  background: #1a202c;
}

.preview-area.mode-tablet-landscape .device-top,
.preview-area.mode-tablet-portrait .device-top {
  height: 20px;
  background: #2d3748;
}

.status-section {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
}

.status-left  { justify-content: flex-start; }
.status-center { justify-content: center; flex: 0 0 auto; }
.status-right { justify-content: flex-end; }

.status-pill {
  height: 7px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.preview-area.mode-tablet-landscape .status-pill,
.preview-area.mode-tablet-portrait .status-pill {
  height: 6px;
}

/* Notch – only visible on mobile */
.device-notch {
  display: none;
  width: 90px;
  height: 22px;
  background: rgba(26, 32, 44, 0.20);
  border-radius: 0 0 16px 16px;
}

.preview-area.mode-mobile .device-notch {
  display: block;
}

/* Home bar – bottom */
.device-bottom {
  justify-content: center;
}

.preview-area.mode-mobile-portrait .device-bottom,
.preview-area.mode-mobile-landscape .device-bottom {
  height: 34px;
  background: #fff;
}

.preview-area.mode-tablet-landscape .device-bottom,
.preview-area.mode-tablet-portrait .device-bottom {
  height: 24px;
  background: rgba(255, 255, 255, 0.20);
}

.home-indicator {
  width: 120px;
  height: 5px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.35);
}

.preview-area.mode-tablet-landscape .home-indicator,
.preview-area.mode-tablet-portrait .home-indicator {
  width: 90px;
  height: 4px;
}

/* ── Iframe scroll area (fills full wrapper) ── */
.iframe-scroll {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ── Snackbar ── */
.snackbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #1a202c;
  color: #fff;
  padding: 10px 20px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 2000;
}

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

/* ── Collapse button (hidden on desktop) ── */
.header-collapse-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  color: var(--color-text-muted);
  flex-shrink: 0;
  transition: all 0.15s;
}
.header-collapse-btn:hover { color: var(--color-text); border-color: #a0aec0; }

/* ── Mini bar (hidden by default) ── */
.header-mini-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
}

.mini-bar-expand {
  display: flex;
  align-items: center;
  padding: 5px 16px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-top: none;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: 0.02em;
}

/* ── Mobile layout ── */
@media (max-width: 768px) {
  /* Header tweaks */
  .site-header {
    padding: 0 12px;
    gap: 8px;
    transition: transform 0.3s ease;
  }
  .site-selector-btn { min-width: 0; }
  .site-selector-btn .btn-desc { display: none; }
  .btn-get-started span { display: none; }
  .btn-get-started { padding: 9px 12px; }

  /* Hide desktop-only controls */
  .view-mode-group,
  .orientation-btn { display: none !important; }

  /* Show collapse button */
  .header-collapse-btn { display: flex; }

  /* Collapsed state */
  body.header-collapsed .site-header {
    transform: translateY(-100%);
  }
  body.header-collapsed .preview-area {
    top: 0;
  }
  body.header-collapsed .header-mini-bar {
    display: block;
  }
}
