:root {
  --bg: #0f1115;
  --surface: #161922;
  --surface-2: #1e2230;
  --border: #2a2f3d;
  --text: #e9ecf3;
  --text-dim: #9aa3b2;
  --primary: #6c8cff;
  --primary-hover: #5577f0;
  --success: #34d399;
  --error: #f87171;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ===== LOGIN ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-card .brand { margin-bottom: 20px; }
.login-card h1 {
  font-size: 22px;
  margin: 0 0 6px 0;
}
.login-form { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }

/* ===== TOPBAR ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #b48dff);
  box-shadow: 0 0 12px rgba(108, 140, 255, 0.6);
}
.brand-name { font-size: 16px; letter-spacing: 0.2px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-sub { color: var(--text-dim); font-size: 13px; }

/* ===== CONTAINER ===== */
.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ===== STEPPER ===== */
.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  padding: 0 8px;
}
.step { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 80px; }
.step-circle {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  color: var(--text-dim);
  transition: all 0.2s ease;
}
.step-label { font-size: 12px; color: var(--text-dim); text-align: center; }
.step.active .step-circle {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 0 0 4px rgba(108, 140, 255, 0.15);
}
.step.active .step-label { color: var(--text); }
.step.done .step-circle {
  background: var(--success);
  border-color: var(--success);
  color: #0f1115;
}
.step.done .step-circle::before { content: "✓"; }
.step.done .step-circle > * { display: none; }
.step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 8px;
  margin-bottom: 24px;
}

/* ===== CARD / PANEL ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}
.panel h1 {
  font-size: 20px;
  margin: 0 0 6px 0;
}
.subtitle {
  color: var(--text-dim);
  margin: 0 0 22px 0;
  font-size: 14px;
}

/* ===== FIELDS ===== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field-label { font-size: 13px; color: var(--text-dim); }
input[type="text"], input[type="url"], input[type="password"], select, textarea {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.15);
}
textarea { resize: vertical; font-family: inherit; }

/* ===== BUTTONS ===== */
.actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 22px;
  flex-wrap: wrap;
}
.btn-primary, .btn-secondary {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { background: var(--surface-2); color: var(--text-dim); cursor: not-allowed; }
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-link {
  background: transparent;
  color: var(--text-dim);
  border: 0;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 8px;
  font-family: inherit;
}
.btn-link:hover { color: var(--text); }

/* ===== STATUS / LOADER ===== */
.generation-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  gap: 16px;
}
.loader {
  width: 40px; height: 40px;
  border: 3px solid var(--surface-2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== RESULT ===== */
.result-badge {
  display: inline-block;
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.3);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 8px;
}
.result-summary { margin-bottom: 18px; }

.preview-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.tab {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-family: inherit;
}
.tab.active {
  color: var(--text);
  border-bottom-color: var(--primary);
}

.preview-box {
  background: white;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  height: 460px;
}
.preview-box iframe {
  width: 100%;
  height: 100%;
  border: 0;
}
.code-box {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 14px;
  max-height: 460px;
  overflow: auto;
}
.code-box pre { margin: 0; }
.code-box code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.message-box textarea {
  min-height: 240px;
  line-height: 1.6;
}

/* ===== ERROR ===== */
.error {
  background: rgba(248, 113, 113, 0.1);
  color: var(--error);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 12px;
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-dim);
  font-size: 12px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .topbar { padding: 12px 16px; }
  .topbar-sub { display: none; }
  .container { padding: 20px 14px 60px; }
  .card { padding: 20px; }
  .step-label { font-size: 11px; }
  .step-circle { width: 30px; height: 30px; font-size: 13px; }
  .actions { justify-content: stretch; }
  .actions button { flex: 1; }
}
