:root {
  --bg: #0a0a0f;
  --surface: #111118;
  --surface2: #18181f;
  --border: #252530;
  --border2: #2e2e3d;
  --accent: #7c6af7;
  --accent2: #a598ff;
  --accent-glow: rgba(124, 106, 247, 0.18);
  --green: #3dd68c;
  --green-dim: rgba(61, 214, 140, 0.12);
  --red: #f87171;
  --text: #e8e8f0;
  --muted: #6b6b82;
  --muted2: #9090a8;
  --tab-active: #7c6af7;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Syne", sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Noise overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
}

/* Ambient blobs */
.blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.25;
}
.blob-1 {
  width: 600px;
  height: 600px;
  background: #7c6af7;
  top: -200px;
  right: -200px;
}
.blob-2 {
  width: 400px;
  height: 400px;
  background: #3dd68c;
  bottom: -100px;
  left: -100px;
  opacity: 0.12;
}

/* Layout */
.app {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 52px;
}
.logo-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-glow);
  border: 1px solid rgba(124, 106, 247, 0.3);
  border-radius: 100px;
  padding: 6px 14px;
  margin-bottom: 20px;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--accent2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.logo-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent2);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

h1 {
  font-size: clamp(36px, 6vw, 58px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
h1 span {
  background: linear-gradient(135deg, #a598ff 0%, #7c6af7 50%, #3dd68c 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.subtitle {
  font-size: 15px;
  color: var(--muted2);
  margin-top: 12px;
  font-weight: 400;
  line-height: 1.6;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

/* Input card */
.input-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}
.input-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(124, 106, 247, 0.5),
    transparent
  );
}

.input-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.field-group {
  flex: 1;
  min-width: 260px;
}
label {
  display: block;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.input-wrap {
  position: relative;
}
.input-wrap svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
input[type="text"],
input[type="password"] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 12px 14px 12px 40px;
  font-family: "DM Mono", monospace;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder {
  color: var(--muted);
}

.gen-btn {
  background: linear-gradient(135deg, #7c6af7, #5f4fe0);
  border: none;
  border-radius: 10px;
  padding: 12px 24px;
  font-family: "Syne", sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition:
    opacity 0.2s,
    transform 0.15s,
    box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(124, 106, 247, 0.3);
  display: flex;
  align-items: center;
  gap: 8px;
}
.gen-btn:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(124, 106, 247, 0.4);
}
.gen-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Options row */
.options-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.opt-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--muted2);
  cursor: pointer;
  transition: all 0.18s;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.opt-chip.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent2);
}
.opt-chip:hover {
  border-color: var(--border2);
  color: var(--text);
}

/* Progress */
.progress-wrap {
  margin-bottom: 28px;
  display: none;
}
.progress-wrap.visible {
  display: block;
}
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.progress-label {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  color: var(--muted2);
}
.progress-pct {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  color: var(--accent2);
}
.progress-bar-bg {
  background: var(--surface2);
  border-radius: 100px;
  height: 4px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #7c6af7, #3dd68c);
  border-radius: 100px;
  width: 0%;
  transition: width 0.4s ease;
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}
.step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "DM Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  transition: color 0.3s;
}
.step.done {
  color: var(--green);
}
.step.active {
  color: var(--text);
}
.step-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Tabs */
.tabs-wrap {
  display: none;
}
.tabs-wrap.visible {
  display: block;
}
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.tab-btn {
  background: none;
  border: none;
  padding: 12px 20px;
  font-family: "Syne", sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}
.tab-btn.active {
  color: var(--accent2);
}
.tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

.tab-badge {
  background: var(--accent-glow);
  border: 1px solid rgba(124, 106, 247, 0.3);
  border-radius: 100px;
  padding: 1px 7px;
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--accent2);
  margin-left: 6px;
}

.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* Doc card */
.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 16px 16px;
  overflow: hidden;
}

.doc-toolbar {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.doc-filename {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--muted2);
}
.copy-btn {
  background: none;
  border: 1px solid var(--border2);
  border-radius: 7px;
  padding: 5px 12px;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--muted2);
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent2);
}
.copy-btn.copied {
  border-color: var(--green);
  color: var(--green);
}

.doc-body {
  padding: 28px 32px;
  font-family: "DM Mono", monospace;
  font-size: 13px;
  line-height: 1.8;
  color: #c8c8d8;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 520px;
  overflow-y: auto;
}
.doc-body::-webkit-scrollbar {
  width: 6px;
}
.doc-body::-webkit-scrollbar-track {
  background: transparent;
}
.doc-body::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 3px;
}

/* Markdown-like styling inside doc-body */
.doc-body .md-h1 {
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
  font-family: "Syne", sans-serif;
}
.doc-body .md-h2 {
  color: var(--accent2);
  font-size: 14px;
  font-weight: 600;
  margin-top: 12px;
  font-family: "Syne", sans-serif;
}
.doc-body .md-code {
  background: var(--surface2);
  border-radius: 4px;
  padding: 1px 5px;
  color: #a598ff;
}
.doc-body .md-bold {
  color: var(--text);
  font-weight: 500;
}

/* Repo info */
.repo-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
  display: none;
  gap: 24px;
  flex-wrap: wrap;
  align-items: center;
}
.repo-info.visible {
  display: flex;
}
.repo-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-label {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat-val {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* Error */
.error-box {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: 10px;
  padding: 14px 18px;
  font-family: "DM Mono", monospace;
  font-size: 12px;
  color: var(--red);
  margin-bottom: 20px;
  display: none;
}
.error-box.visible {
  display: block;
}

/* Loading spinner inline */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Fade in animation */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.fade-up {
  animation: fadeUp 0.4s ease forwards;
}

.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 13px;
}
.empty-state .icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* API key hint */
.api-hint {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  margin-top: 6px;
}
.api-hint a {
  color: var(--accent2);
  text-decoration: none;
}
.api-hint a:hover {
  text-decoration: underline;
}

/* Model selector */
.model-selector-wrap {
  margin-top: 18px;
}
.model-hint {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: #fbbf24;
  margin-top: 6px;
}
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.model-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.18s;
  position: relative;
  overflow: hidden;
}
.model-card:hover {
  border-color: var(--border2);
}
.model-card.selected {
  background: var(--accent-glow);
  border-color: var(--accent);
}
.model-card.selected::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.model-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.model-card.selected .model-name {
  color: var(--accent2);
}
.model-meta {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.model-tier {
  display: inline-block;
  font-family: "DM Mono", monospace;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 100px;
  font-weight: 500;
}
.tier-flash {
  background: rgba(61, 214, 140, 0.12);
  color: var(--green);
  border: 1px solid rgba(61, 214, 140, 0.25);
}
.tier-pro {
  background: rgba(251, 191, 36, 0.1);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.25);
}
.tier-ultra {
  background: rgba(248, 113, 113, 0.1);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.25);
}
.model-check {
  position: absolute;
  top: 8px;
  right: 10px;
  color: var(--accent2);
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.2s;
}
.model-card.selected .model-check {
  opacity: 1;
}

/* Divider */
.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* Developer card */
.dev-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 28px;
  margin-top: 40px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  position: relative;
  overflow: hidden;
}
.dev-card::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(124, 106, 247, 0.3),
    transparent
  );
}
.dev-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c6af7, #3dd68c);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  font-weight: 700;
  color: #fff;
  font-family: "Syne", sans-serif;
  box-shadow:
    0 0 0 3px var(--accent-glow),
    0 0 20px rgba(124, 106, 247, 0.2);
}
.dev-info {
  flex: 1;
  min-width: 180px;
}
.dev-label {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.dev-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}
.dev-role {
  font-size: 12px;
  color: var(--muted2);
}
.dev-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}
.dev-link {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--muted2);
  text-decoration: none;
  transition: all 0.18s;
}
.dev-link:hover {
  border-color: var(--accent);
  color: var(--accent2);
}
.dev-link svg {
  flex-shrink: 0;
}

@media (max-width: 1024px) {
  .app {
    padding: 40px 20px 72px;
  }

  .input-card {
    padding: 24px;
  }

  .doc-body {
    padding: 24px;
    max-height: 58vh;
  }

  .repo-info {
    gap: 16px;
  }
}

@media (max-width: 768px) {
  .app {
    padding: 28px 16px 56px;
  }

  .header {
    margin-bottom: 36px;
  }

  .subtitle {
    font-size: 14px;
  }

  .input-card {
    padding: 18px;
    border-radius: 14px;
  }

  .input-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .field-group {
    min-width: 100%;
  }

  .gen-btn {
    width: 100%;
    justify-content: center;
  }

  .options-row {
    gap: 8px;
  }

  .opt-chip {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }

  .model-grid {
    grid-template-columns: 1fr;
  }

  .tab-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .tab-btn {
    white-space: nowrap;
    padding: 11px 14px;
  }

  .doc-toolbar {
    padding: 10px 12px;
    gap: 8px;
  }

  .doc-body {
    padding: 18px;
    font-size: 12px;
    line-height: 1.7;
    max-height: 52vh;
  }

  .repo-stat {
    min-width: calc(50% - 10px);
  }

  .dev-card {
    padding: 18px;
    margin-top: 28px;
    gap: 14px;
  }

  .dev-info {
    min-width: 0;
    flex-basis: 100%;
  }

  .dev-links {
    margin-left: 0;
    width: 100%;
  }

  .dev-link {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
    padding: 9px 12px;
  }
}

@media (max-width: 480px) {
  .blob-1 {
    width: 360px;
    height: 360px;
    top: -120px;
    right: -120px;
  }

  .blob-2 {
    width: 260px;
    height: 260px;
    bottom: -80px;
    left: -80px;
  }

  h1 {
    font-size: clamp(28px, 10vw, 40px);
  }

  .logo-badge {
    font-size: 10px;
    padding: 6px 12px;
  }

  .opt-chip {
    flex-basis: 100%;
  }

  .repo-stat {
    min-width: 100%;
  }

  .dev-link {
    flex-basis: 100%;
  }
}
