:root {
  --bg: #0b1020;
  --panel: #111827;
  --panel-2: #172033;
  --card: #1f2937;
  --soft: #263449;
  --text: #f8fafc;
  --muted: #a5b4c8;
  --faint: #64748b;
  --line: rgba(148, 163, 184, 0.22);
  --primary: #8b5cf6;
  --primary-2: #7c3aed;
  --cyan: #06b6d4;
  --good: #22c55e;
  --bad: #ef4444;
  --warn: #f59e0b;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 24px 70px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(139,92,246,.20), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(6,182,212,.14), transparent 32rem),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button, input, textarea, select { font: inherit; }
button { border: 0; }
textarea { resize: vertical; }

.app-shell { display: grid; grid-template-columns: 315px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 1.25rem;
  background: rgba(17,24,39,.92);
  backdrop-filter: blur(18px);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .85rem; padding: .5rem .25rem 1.25rem; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  font-family: Poppins, sans-serif; font-weight: 800; font-size: 1.35rem;
  box-shadow: 0 10px 30px rgba(139,92,246,.35);
}
.brand strong { display: block; font-family: Poppins, sans-serif; }
.brand span { display: block; color: var(--muted); font-size: .82rem; margin-top: .1rem; }

.progress-card {
  background: linear-gradient(180deg, rgba(139,92,246,.15), rgba(6,182,212,.08));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.progress-top { display: flex; justify-content: space-between; gap: 1rem; font-size: .9rem; color: var(--muted); }
.progress-top strong { color: var(--text); }
.progress-bar { height: 9px; background: rgba(15,23,42,.85); border-radius: 999px; overflow: hidden; margin: .75rem 0; }
.progress-bar div { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--cyan)); transition: width .35s ease; }
.progress-card small { color: var(--muted); }

.step-nav { display: flex; flex-direction: column; gap: .4rem; }
.step-link {
  display: grid; grid-template-columns: 32px 1fr auto;
  gap: .65rem; align-items: center;
  width: 100%; text-align: left;
  background: transparent; color: var(--muted);
  border-radius: 14px; padding: .72rem .75rem;
  cursor: pointer; transition: .2s ease;
}
.step-link:hover { background: rgba(255,255,255,.045); color: var(--text); }
.step-link.active { background: rgba(139,92,246,.18); color: var(--text); }
.step-link .num { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,.06); font-weight: 700; font-size: .8rem; }
.step-link.active .num { background: linear-gradient(135deg, var(--primary), var(--cyan)); color: white; }
.step-link .label { font-weight: 600; font-size: .93rem; }
.step-link .done { font-size: .75rem; color: var(--good); opacity: .7; }
.sidebar-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: 1rem; }

.main { padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 6rem; max-width: 1220px; width: 100%; margin: 0 auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.eyebrow { color: var(--cyan); text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; font-weight: 800; margin: 0 0 .35rem; }
h1, h2, h3 { font-family: Poppins, sans-serif; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(1.75rem, 3vw, 3rem); max-width: 900px; }
h2 { font-size: clamp(1.35rem, 2vw, 2.1rem); }
h3 { font-size: 1.05rem; }
p { color: var(--muted); line-height: 1.7; }
.icon-btn { display: none; width: 44px; height: 44px; border-radius: 12px; background: var(--panel-2); color: white; cursor: pointer; }
.save-pill { border: 1px solid var(--line); background: rgba(34,197,94,.10); color: #bbf7d0; padding: .65rem .85rem; border-radius: 999px; white-space: nowrap; font-size: .88rem; }

.hero-card {
  display: grid; grid-template-columns: 1.45fr .9fr; gap: 1rem;
  background: linear-gradient(135deg, rgba(139,92,246,.20), rgba(6,182,212,.10));
  border: 1px solid var(--line); border-radius: 28px;
  padding: clamp(1.25rem, 3vw, 2rem); box-shadow: var(--shadow); margin-bottom: 1rem;
}
.hero-card p { margin-bottom: 0; }
.hero-mini-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; align-self: stretch; }
.hero-mini-grid div { background: rgba(15,23,42,.55); border: 1px solid var(--line); border-radius: 18px; padding: 1rem; }
.hero-mini-grid strong { display: block; font-size: 1.1rem; }
.hero-mini-grid span { display: block; color: var(--muted); font-size: .85rem; margin-top: .25rem; }

.step-section { display: none; animation: fade .2s ease; }
.step-section.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.section-head {
  display: flex; gap: 1rem; align-items: flex-start;
  background: rgba(17,24,39,.78); border: 1px solid var(--line); border-radius: 24px;
  padding: 1.35rem; margin: 1rem 0;
}
.step-number { width: 48px; height: 48px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 15px; background: linear-gradient(135deg, var(--primary), var(--cyan)); font-weight: 800; }
.section-head p { margin: .45rem 0 0; }

.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .45rem; color: var(--text); font-weight: 700; font-size: .92rem; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); outline: none; color: var(--text);
  background: rgba(17,24,39,.78); border-radius: 14px; padding: .9rem 1rem;
  transition: border .2s ease, box-shadow .2s ease, background .2s ease;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: rgba(139,92,246,.75); box-shadow: 0 0 0 4px rgba(139,92,246,.13); background: rgba(15,23,42,.9);
}
.field textarea { min-height: 70px; font-family: Inter, sans-serif; }
.field ::placeholder { color: #6b7890; }

.check-card, .helper-box, .note-box, .recommendation-panel, .type-box, .compare-grid, .repair-card {
  background: rgba(17,24,39,.78); border: 1px solid var(--line); border-radius: 22px;
  padding: 1.2rem; margin: 1rem 0;
}
.check-card { display: grid; gap: .7rem; }
.check-card.two-col { grid-template-columns: repeat(2, minmax(0,1fr)); }
.check-card h3 { grid-column: 1 / -1; margin-bottom: .25rem; }
.check-card label { display: flex; align-items: flex-start; gap: .6rem; color: var(--muted); line-height: 1.45; }
.check-card input[type="checkbox"] { margin-top: .18rem; width: 18px; height: 18px; accent-color: var(--primary); }
.helper-box strong, .note-box strong { color: var(--text); }
.helper-box p, .note-box p { margin-bottom: 0; }
.note-box { border-color: rgba(6,182,212,.32); background: rgba(6,182,212,.075); color: var(--muted); line-height: 1.7; }

.recommendation-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.chip-list { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.chip { display: inline-flex; align-items: center; gap: .4rem; background: rgba(139,92,246,.15); color: #ddd6fe; border: 1px solid rgba(139,92,246,.28); padding: .45rem .65rem; border-radius: 999px; font-size: .88rem; }
.chip.feature { background: rgba(6,182,212,.13); color: #cffafe; border-color: rgba(6,182,212,.26); }
.type-box h3 { margin-bottom: .6rem; }
.type-box ul { margin: .5rem 0 0; color: var(--muted); line-height: 1.8; }
.type-box li::marker { color: var(--cyan); }

.action-row { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1rem 0; }
.sticky-actions { position: sticky; top: .75rem; z-index: 5; background: rgba(11,16,32,.82); backdrop-filter: blur(10px); padding: .75rem; border: 1px solid var(--line); border-radius: 18px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .78rem 1rem; border-radius: 13px; color: white; cursor: pointer;
  font-weight: 800; transition: .2s ease; text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: 0 10px 30px rgba(139,92,246,.22); }
.btn-soft { background: rgba(148,163,184,.12); color: var(--text); border: 1px solid var(--line); }
.btn-danger-soft { background: rgba(239,68,68,.12); color: #fecaca; border: 1px solid rgba(239,68,68,.26); }

#finalPrompt, #readmeOutput, .repair-card textarea {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: .88rem; line-height: 1.6;
}

.repair-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; }
.repair-card { margin: 0; display: flex; flex-direction: column; gap: .75rem; }
.repair-card p { margin: 0; }
.repair-card textarea { min-height: 170px; background: rgba(15,23,42,.85); }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.good-box, .bad-box { border-radius: 18px; padding: 1rem; border: 1px solid var(--line); }
.good-box { background: rgba(34,197,94,.08); border-color: rgba(34,197,94,.25); }
.bad-box { background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.25); }
pre { white-space: pre-wrap; margin: .75rem 0 0; color: var(--muted); font-family: "JetBrains Mono", monospace; font-size: .9rem; line-height: 1.6; }

.bottom-nav {
  position: fixed; bottom: 1rem; left: calc(315px + 1rem); right: 1rem; max-width: 1220px; margin: 0 auto;
  display: flex; justify-content: space-between; gap: 1rem; padding: .75rem;
  background: rgba(17,24,39,.86); border: 1px solid var(--line); border-radius: 18px; backdrop-filter: blur(14px); box-shadow: var(--shadow);
}

input[type="date"] { color-scheme: dark; }
select option { background: #111827; color: white; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(340px, 88vw); z-index: 50; transform: translateX(-105%); transition: transform .24s ease; }
  .sidebar.open { transform: translateX(0); }
  .icon-btn { display: grid; place-items: center; }
  .bottom-nav { left: 1rem; }
  .hero-card, .recommendation-panel, .compare-grid, .repair-grid, .grid.two, .check-card.two-col { grid-template-columns: 1fr; }
  .hero-mini-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .save-pill { display: none; }
}

@media (max-width: 640px) {
  .main { padding-left: .85rem; padding-right: .85rem; }
  .section-head { flex-direction: column; }
  .bottom-nav { bottom: .5rem; left: .5rem; right: .5rem; }
  .btn { padding: .75rem .85rem; }
}

/* Auth gate + signed-in header */
.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}
.auth-panel {
  width: min(560px, 100%);
  background: rgba(17, 24, 39, .94);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 2rem;
  box-shadow: var(--shadow);
}
.auth-brand { padding-bottom: 1rem; }
.auth-panel h1 {
  font-family: Poppins, sans-serif;
  font-size: clamp(2rem, 5vw, 3rem);
  margin: .5rem 0 1rem;
}
.auth-panel p { color: var(--muted); }
.auth-note {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, .7);
  color: var(--muted);
  line-height: 1.6;
}
.auth-note code {
  color: var(--cyan);
  font-family: "JetBrains Mono", monospace;
}
.auth-error {
  color: var(--bad);
  margin-top: 1rem;
  min-height: 1.5rem;
}
.btn-big {
  width: 100%;
  padding: 1rem 1.25rem;
  font-size: 1.05rem;
  margin-top: 1rem;
}
.app-shell { display: none; }
body.signed-in .app-shell { display: grid; }
body.signed-in .auth-gate { display: none; }

.user-pill {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .5rem .7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(17,24,39,.75);
  max-width: 340px;
}
.user-pill strong {
  display: block;
  font-size: .86rem;
  line-height: 1.1;
}
.user-pill small {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-photo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  color: white;
  font-weight: 800;
  overflow: hidden;
  flex-shrink: 0;
}
.user-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.user-photo.large {
  width: 68px;
  height: 68px;
  font-size: 1.5rem;
}
.mini-link {
  color: var(--cyan);
  background: transparent;
  padding: .25rem;
  cursor: pointer;
  font-weight: 700;
}
.mini-link:hover { color: var(--text); }

.identity-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(135deg, rgba(139, 92, 246, .14), rgba(6, 182, 212, .09));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
}
.identity-card strong {
  display: block;
  font-family: Poppins, sans-serif;
  font-size: 1.1rem;
}
.identity-card span {
  display: block;
  color: var(--cyan);
  font-size: .9rem;
}
.identity-card p {
  margin: .35rem 0 0;
  color: var(--muted);
}

@media (max-width: 720px) {
  .user-pill {
    width: 100%;
    max-width: none;
    justify-content: space-between;
  }
  .identity-card { align-items: flex-start; }
}
