:root{
  --bg: #0b1020;
  --panel: #101833;
  --panel2: #0f1730;
  --text: #e8ecff;
  --muted: #aab3d6;
  --border: rgba(255,255,255,0.10);
  --accent: #5b8cff;
  --accent2: #3f6de6;
  --danger: #ff5b7d;
  --shadow: 0 18px 50px rgba(0,0,0,0.35);
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin:0;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(91,140,255,0.25), transparent 60%),
              radial-gradient(900px 500px at 120% 10%, rgba(255,91,125,0.12), transparent 55%),
              var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  overflow: hidden; /* wrapper has no scroll; iframe scrolls */
}

.app-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(16,24,51,0.95), rgba(16,24,51,0.70));
  backdrop-filter: blur(10px);
}

.brand{
  display:flex;
  align-items:center;
  gap: 12px;
  min-width: 280px;
}
.logo{
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: linear-gradient(135deg, rgba(91,140,255,0.95), rgba(63,109,230,0.95));
  box-shadow: var(--shadow);
  font-weight: 800;
  letter-spacing: 0.5px;
}
.title{
  font-size: 16px;
  font-weight: 800;
  line-height: 1.1;
}
.subtitle{
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.stepper{
  display:flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items:center;
  justify-content:flex-end;
  padding-top: 3px;
}

.step-pill{
  display:flex;
  align-items:center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  cursor: pointer;
  user-select:none;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}
.step-pill:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,0.07);
}
.step-pill.active{
  border-color: rgba(91,140,255,0.60);
  background: rgba(91,140,255,0.12);
}
.step-num{
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 12px;
  font-weight: 800;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
}
.step-pill.active .step-num{
  background: rgba(91,140,255,0.25);
  border-color: rgba(91,140,255,0.55);
}
.step-title{
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.app-main{
  height: calc(100% - 70px);
  display:flex;
}

.sidebar{
  width: 320px;
  min-width: 260px;
  max-width: 400px;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(16,24,51,0.65), rgba(16,24,51,0.35));
  padding: 14px;
  overflow: auto; /* sidebar can scroll if many steps */
}

.sidebar-header{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  margin-bottom: 10px;
}
.sidebar-title{
  font-size: 14px;
  font-weight: 800;
}
.sidebar-hint{
  font-size: 12px;
  color: var(--muted);
}

.step-list{
  display:flex;
  flex-direction:column;
  gap: 10px;
}

.step-card{
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  padding: 10px 10px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.step-card:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,0.06);
}
.step-card.active{
  border-color: rgba(91,140,255,0.55);
  background: rgba(91,140,255,0.10);
}
.step-card-top{
  display:flex;
  gap: 10px;
  align-items:center;
}
.badge{
  width: 26px;
  height: 26px;
  border-radius: 10px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  font-weight: 900;
  font-size: 12px;
}
.step-card.active .badge{
  background: rgba(91,140,255,0.22);
  border-color: rgba(91,140,255,0.55);
}

.step-card-title{
  font-size: 13px;
  font-weight: 800;
}
.step-card-desc{
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.content{
  flex:1;
  display:flex;
  flex-direction:column;
  min-width: 0; /* allow iframe to shrink */
}

.content-header{
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}
.content-title{
  font-size: 14px;
  font-weight: 900;
}
.content-desc{
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
}

.iframe-wrap{
  position: relative;
  flex: 1;
  min-height: 0;
  background: rgba(0,0,0,0.15);
}
.app-frame{
  width: 100%;
  height: 100%;
  border: 0;
  background: white; /* most embedded apps assume white canvas */
}

.loading-overlay{
  position:absolute;
  inset: 0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap: 10px;
  background: rgba(11,16,32,0.75);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  z-index: 2;
}
.loading-overlay.hidden{ display:none; }

.spinner{
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 3px solid rgba(255,255,255,0.18);
  border-top-color: rgba(91,140,255,0.95);
  animation: spin 900ms linear infinite;
}
.loading-text{
  font-size: 12px;
  color: var(--muted);
}
@keyframes spin{
  to { transform: rotate(360deg); }
}

.controls{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}

.btn{
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 800;
  cursor:pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}
.btn:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,0.07);
}
.btn:disabled{
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn.primary{
  border-color: rgba(91,140,255,0.55);
  background: rgba(91,140,255,0.15);
}
.btn.primary:hover{
  background: rgba(91,140,255,0.20);
  border-color: rgba(91,140,255,0.70);
}
.btn.subtle{
  padding: 10px 10px;
}

.controls-right{
  display:flex;
  align-items:center;
  gap: 12px;
}
.link{
  color: rgba(91,140,255,0.95);
  font-weight: 800;
  text-decoration: none;
}
.link:hover{
  text-decoration: underline;
}

.error-panel{
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,91,125,0.45);
  background: rgba(255,91,125,0.10);
}
.error-title{
  font-weight: 900;
  margin-bottom: 6px;
}
.error-message{
  font-size: 12px;
  color: var(--text);
  opacity: 0.95;
  white-space: pre-wrap;
}
.error-hint{
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
code{
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
}

/* Mobile */
@media (max-width: 920px){
  body{ overflow:auto; } /* allow page scroll on small screens */
  .app-main{
    height: auto;
    flex-direction:column;
  }
  .sidebar{
    width: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-width: none;
  }
  .iframe-wrap{
    height: 65vh;
  }
}