:root {
  --bg-dark: #090d16;
  --bg-panel: #111827;
  --bg-card: #1e293b;
  --bg-input: #0f172a;
  --border: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --brand-orange: #ea580c;
  --brand-orange-light: #ff5a1f;
  --primary: #4f46e5;
  --accent: #06b6d4;
  --success: #10b981;
}

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

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   TOP SAAS HEADER (Responsive Desktop + Mobile)
   ========================================================================== */
.topbar {
  min-height: 64px;
  width: 100%;
  background: #fffaf5;
  color: #1c1917;
  border-bottom: 1px solid #fed7aa;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(234, 88, 12, 0.08);
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #1c1917;
  flex-shrink: 0;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #ea580c, #ff5a1f);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.35);
  flex-shrink: 0;
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: #1c1917;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.brand-title .orange {
  color: #ea580c;
}

.domain-badge {
  font-size: 11px;
  background: #ffedd5;
  color: #c2410c;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 700;
}

.saas-nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.saas-nav-link {
  color: #44403c;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s;
}

.saas-nav-link:hover {
  color: #ea580c;
}

/* Convert Dropdown Menu */
.convert-dropdown-wrap {
  position: relative;
}

.convert-trigger {
  background: #ffedd5;
  border: 1px solid #fdba74;
  color: #c2410c;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.convert-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 280px;
  max-width: calc(100vw - 24px);
  max-height: 380px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #e7e5e4;
  border-radius: 14px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.22);
  padding: 8px;
  display: none;
  z-index: 300;
}

.convert-dropdown-menu.open {
  display: block;
}

@media (hover: hover) and (min-width: 961px) {
  .convert-dropdown-wrap:hover .convert-dropdown-menu {
    display: block;
  }
}

.convert-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 13px;
  color: #1c1917;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s;
}

.convert-menu-item:hover {
  background: #fff7ed;
}

.convert-menu-item strong {
  font-weight: 700;
  color: #1c1917;
}

.convert-menu-item span {
  color: #78716c;
  font-size: 11.5px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.telemetry-pill {
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  color: #047857;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
  flex-shrink: 0;
}

.mobile-menu-btn {
  display: none;
  background: #ffedd5;
  border: 1px solid #fdba74;
  color: #c2410c;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  font-size: 18px;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-secondary {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 9px;
}

.btn-secondary:hover {
  background: #334155;
}

.btn-convert {
  background: linear-gradient(135deg, #ea580c 0%, #ff5a1f 100%);
  color: #ffffff;
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(234, 88, 12, 0.35);
}

.btn-convert:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(234, 88, 12, 0.5);
}

/* ==========================================================================
   WARM SAAS HERO BANNER
   ========================================================================== */
.hero-banner {
  width: 100%;
  background: linear-gradient(180deg, #fff7ed 0%, #ffedd5 100%);
  color: #1c1917;
  padding: 16px 24px;
  border-bottom: 1px solid #fed7aa;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.hero-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.hero-pill {
  background: #ffedd5;
  border: 1px solid #fdba74;
  color: #ea580c;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  display: inline-block;
}

.hero-headline {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: #1c1917;
  line-height: 1.25;
}

.hero-headline .accent-orange {
  color: #ea580c;
}

.hero-platform-checks {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: #ffffff;
  border: 1px solid #fdba74;
  padding: 8px 16px;
  border-radius: 14px;
  font-size: 12.5px;
  font-weight: 700;
  color: #292524;
  max-width: 100%;
}

.hero-platform-checks label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.hero-platform-checks input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #ea580c;
}

/* ==========================================================================
   MAIN 3-COLUMN WORKSPACE (Desktop) -> STACKED (Mobile)
   ========================================================================== */
.workspace {
  flex: 1;
  width: 100%;
  max-width: 100vw;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 460px;
  min-height: calc(100vh - 130px);
}

/* Left Service Navigation Sidebar */
.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.nav-group-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 6px 10px;
  font-weight: 700;
}

.nav-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: #cbd5e1;
  padding: 11px 12px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  transition: all 0.15s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
}

.nav-item.active {
  background: rgba(234, 88, 12, 0.18);
  border-color: rgba(251, 146, 60, 0.5);
  color: #fff;
}

.sidebar-footer {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Center Configuration Editor */
.editor-pane {
  padding: 20px 24px;
  overflow-y: auto;
  background: #0b1120;
  min-width: 0;
  width: 100%;
}

.tab-panel {
  display: none;
  max-width: 760px;
  width: 100%;
}

.tab-panel.active {
  display: block;
}

.panel-header {
  margin-bottom: 16px;
}

.panel-header h2 {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.3;
}

.panel-header p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
  width: 100%;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

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

.form-group {
  margin-bottom: 12px;
  min-width: 0;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.input, select.input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: #fff;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}

.input:focus {
  border-color: #f97316;
}

.url-bar-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.url-actions-group {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.preset-chip {
  background: #1e293b;
  border: 1px solid #334155;
  color: #fdba74;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  cursor: pointer;
}

.preset-chip:hover {
  background: #334155;
  color: #fff;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}

.toggle-row:last-child {
  border-bottom: none;
}

.toggle-info {
  min-width: 0;
  flex: 1;
}

.toggle-info strong {
  display: block;
  font-size: 13px;
  color: #f1f5f9;
  margin-bottom: 2px;
}

.toggle-info span {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

.switch {
  position: relative;
  width: 44px;
  height: 24px;
  display: inline-block;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #334155;
  transition: 0.2s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #ea580c;
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* ==========================================================================
   RIGHT LIVE SIMULATOR & OUTPUT CONSOLE
   ========================================================================== */
.preview-pane {
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px;
  overflow: hidden;
  min-width: 0;
  width: 100%;
}

.device-switcher {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  background: var(--bg-input);
  padding: 5px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  flex-shrink: 0;
}

.dev-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 7px 4px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dev-btn.active {
  background: #ea580c;
  color: #fff;
}

/* True-Viewport Auto-Scaling Stage (412x860 Real Phone Viewport!) */
.simulator-stage {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  overflow: hidden;
  position: relative;
}

.sim-scale-box {
  position: relative;
  overflow: hidden;
}

.device-frame {
  background: #0f172a;
  border: 10px solid #334155;
  border-radius: 38px;
  width: 432px;
  height: 860px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.65);
  transform-origin: top left;
  position: absolute;
  top: 0;
  left: 0;
}

.device-frame.mode-tablet {
  width: 820px;
  height: 980px;
  border-radius: 26px;
}

.device-frame.mode-windows {
  width: 960px;
  height: 600px;
  border-radius: 12px;
  border-width: 4px;
  border-color: #475569;
}

.sim-statusbar {
  height: 28px;
  background: #4f46e5;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

.sim-appbar {
  height: 46px;
  background: #4f46e5;
  color: #fff;
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

.sim-body-wrap {
  flex: 1;
  display: flex;
  overflow: hidden;
  background: #fff;
  position: relative;
}

.sim-tablet-rail {
  display: none;
  width: 150px;
  background: #1e293b;
  color: #f8fafc;
  padding: 12px 8px;
  flex-direction: column;
  gap: 8px;
  border-right: 1px solid #334155;
  flex-shrink: 0;
}

.device-frame.mode-tablet .sim-tablet-rail {
  display: flex;
}

.rail-item {
  font-size: 13px;
  padding: 9px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.sim-webview {
  border: none;
  width: calc(100% + 17px);
  height: 100%;
  background: #ffffff;
  flex-shrink: 0;
}

.sim-bottomnav {
  height: 56px;
  background: #0f172a;
  border-top: 1px solid #334155;
  display: none;
  align-items: center;
  justify-content: space-around;
  color: #cbd5e1;
  font-size: 12px;
  flex-shrink: 0;
}

.device-frame.mode-tablet .sim-bottomnav {
  display: none !important;
}

.sim-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  color: #94a3b8;
  font-weight: 600;
}

.sim-tab-btn.active {
  color: #38bdf8;
}

.splash-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #ea580c, #4f46e5);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  z-index: 20;
}

.splash-overlay.show {
  display: flex;
}

/* Output Result Card */
.build-result-box {
  background: #0f172a;
  border: 2px solid #10b981;
  border-radius: 12px;
  padding: 12px;
  margin-top: 8px;
  margin-bottom: 8px;
  display: none;
  flex-shrink: 0;
}

.build-result-box.show {
  display: block;
}

.dl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.dl-link {
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.dl-link:hover {
  background: #334155;
  border-color: #38bdf8;
}

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

.service-item {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
}

.service-item strong {
  display: block;
  color: #fb923c;
  margin-bottom: 3px;
}

/* ==========================================================================
   GLOBAL STANDARD MOBILE & TABLET RESPONSIVE DESIGN (<= 960px)
   100% Zero Horizontal Overflow, Touch-Optimized Controls & Clean Drawer
   ========================================================================== */
@media (max-width: 960px) {
  .topbar {
    padding: 10px 14px;
    flex-wrap: wrap;
  }

  .domain-badge {
    display: none;
  }

  .telemetry-pill {
    display: none;
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .topbar-actions .btn-convert {
    padding: 8px 14px;
    font-size: 12.5px;
  }

  /* Collapsible Mobile Menu Drawer */
  .saas-nav {
    display: none;
    width: 100%;
    order: 4;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    background: #ffffff;
    border: 1px solid #fed7aa;
    border-radius: 12px;
    padding: 10px;
    margin-top: 6px;
  }

  .saas-nav.mobile-open {
    display: flex;
  }

  .saas-nav-link {
    padding: 9px 12px;
    border-radius: 8px;
    background: #fff7ed;
    font-size: 14px;
  }

  .convert-dropdown-wrap {
    width: 100%;
  }

  .convert-trigger {
    width: 100%;
    justify-content: space-between;
    padding: 10px 14px;
    font-size: 14px;
  }

  .convert-dropdown-menu {
    position: static;
    width: 100%;
    max-width: 100%;
    max-height: 280px;
    margin-top: 6px;
    box-shadow: none;
    border: 1px solid #fdba74;
  }

  /* Mobile Hero Banner */
  .hero-banner {
    padding: 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .hero-headline {
    font-size: 19px;
  }

  .hero-platform-checks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px 12px;
    width: 100%;
  }

  .hero-platform-checks .targets-label {
    grid-column: span 2;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  /* Workspace Single Column on Mobile */
  .workspace {
    display: flex;
    flex-direction: column;
    min-height: auto;
  }

  /* Touch Scrollable Module Pills Bar */
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar > div {
    display: flex;
    gap: 8px;
    align-items: center;
    width: max-content;
  }

  .nav-group-label,
  .sidebar-footer {
    display: none;
  }

  .nav-item {
    width: auto;
    white-space: nowrap;
    margin-bottom: 0;
    padding: 9px 14px;
    font-size: 12.5px;
    border-radius: 999px;
    background: #1e293b;
  }

  /* Editor Cards on Mobile */
  .editor-pane {
    padding: 14px;
    overflow: visible;
  }

  .card {
    padding: 14px;
  }

  .url-bar-row {
    flex-direction: column;
    gap: 10px;
  }

  .url-actions-group {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 8px;
  }

  .url-actions-group .btn {
    width: 100%;
    padding: 11px 12px;
  }

  .form-grid,
  .service-badge-grid,
  .dl-grid {
    grid-template-columns: 1fr;
  }

  .form-group[style*="grid-column: span 2"],
  .dl-link[style*="grid-column:span 2"] {
    grid-column: span 1 !important;
  }

  /* Preview Pane on Mobile */
  .preview-pane {
    border-left: none;
    border-top: 1px solid var(--border);
    padding: 14px;
  }

  .simulator-stage {
    min-height: 460px;
  }
}
