:root {
  --bg: #0f1115;
  --bg-elev: #131722;
  --panel: #161a22;
  --panel-2: #1c2230;
  --panel-3: #232a3b;
  --border: #2a3142;
  --border-strong: #3a4258;
  --text: #e7ebf3;
  --muted: #8a93a6;
  --accent: #8ab4ff;
  --accent-press: #6c9bff;
  --accent-soft: rgba(138, 180, 255, 0.12);
  --success: #6dd6a3;
  --danger: #ff8a8a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.32);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --t-fast: 140ms cubic-bezier(0.2, 0.6, 0.2, 1);
  --t-med:  280ms cubic-bezier(0.2, 0.6, 0.2, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 16px;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
body { line-height: 1.55; min-height: 100vh; display: flex; flex-direction: column; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -9999px; top: 8px; background: var(--accent); color: #0b0f18;
  padding: 10px 14px; border-radius: var(--radius-sm); font-weight: 600;
}
.skip-link:focus { left: 12px; z-index: 10; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }
button:focus-visible { outline-offset: 2px; }
main:focus { outline: none; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; width: 100%; }

/* ---------- Header ---------- */

.site-header {
  padding: 56px 0 32px;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(ellipse 80% 100% at 50% 0%, var(--accent-soft) 0%, transparent 60%),
    var(--bg);
}
.site-header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 12px;
  flex-wrap: wrap;
}
.lang-switcher {
  display: inline-flex; gap: 4px;
  padding: 3px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.lang-btn {
  background: transparent; color: var(--muted);
  padding: 6px 14px; min-height: 32px;
  border: 0; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.lang-btn:hover { color: var(--text); background: transparent; }
.lang-btn[aria-pressed="true"] {
  background: var(--accent); color: #0b0f18;
}
.lang-btn[aria-pressed="true"]:hover { background: var(--accent-press); }
.brand { display: flex; align-items: center; gap: 16px; margin-bottom: 0; }
.brand-logo {
  width: 56px; height: 56px; display: block; flex-shrink: 0;
  filter: drop-shadow(0 0 18px rgba(138, 180, 255, 0.22));
}
.site-header h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.tagline {
  margin: 0; color: var(--muted);
  max-width: 680px;
  font-size: 16px;
  line-height: 1.55;
}

/* ---------- Main ---------- */

main { flex: 1; padding: 40px 0 80px; display: flex; flex-direction: column; gap: 48px; }

/* ---------- Generator form ---------- */

.generator form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.generator form:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-md);
}
.generator label {
  font-weight: 600; font-size: 14px;
  color: var(--text);
}
.hint { color: var(--muted); font-size: 14px; margin: -4px 0 0; line-height: 1.5; }
.hint code { font-family: var(--mono); background: var(--panel-2); padding: 2px 6px; border-radius: 4px; font-size: 13px; }

.preview-line {
  margin: 0; min-height: 22px;
  font-family: var(--mono); font-size: 13px;
  line-height: 22px;
  opacity: 0.9;
  transition: opacity var(--t-fast);
}
.preview-line:empty { opacity: 0; }
.preview-line .pv-label { color: var(--muted); }
.preview-line .pv-value { color: var(--accent); }

.generator textarea {
  width: 100%; resize: vertical; min-height: 96px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--sans); font-size: 16px;  /* >=16px prevents iOS zoom-on-focus */
  line-height: 1.5;
  transition: border-color var(--t-fast);
}
.generator textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.generator textarea::placeholder { color: var(--muted); }

.row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.checkbox {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted); font-weight: 400; font-size: 14px;
  cursor: pointer;
}
.checkbox input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

/* ---------- Buttons ---------- */

button {
  background: var(--accent); color: #0b0f18; border: 0; border-radius: var(--radius-sm);
  padding: 12px 18px; font-weight: 600; font-size: 15px;
  cursor: pointer; min-height: 44px;  /* WCAG 2.5.5 + Apple HIG touch target */
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
button:hover { background: var(--accent-press); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

button.secondary {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
}
button.secondary:hover { background: var(--panel-3); border-color: var(--border-strong); }

button.primary {
  background: var(--accent); color: #0b0f18;
  box-shadow: 0 6px 18px rgba(138, 180, 255, 0.18);
}
button.primary:hover {
  background: var(--accent-press);
  box-shadow: 0 8px 22px rgba(138, 180, 255, 0.28);
}

#submit { min-width: 160px; }

/* ---------- Status banner ---------- */

.status {
  margin: 0; min-height: 1.4em;
  color: var(--muted); font-size: 14px;
  padding: 0; border-radius: var(--radius-sm);
  transition: background var(--t-fast), color var(--t-fast), padding var(--t-fast);
}
.status:not(:empty) {
  background: var(--panel-2);
  padding: 10px 14px;
  border: 1px solid var(--border);
  color: var(--text);
}
.status.error { color: var(--danger); border-color: rgba(255, 138, 138, 0.4); }
.status.busy  { color: var(--accent); border-color: rgba(138, 180, 255, 0.4); }
.status.busy::before {
  content: ""; display: inline-block; width: 10px; height: 10px;
  margin-right: 8px; border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
  vertical-align: middle;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50%      { opacity: 1;   transform: scale(1.15); }
}

/* ---------- Section headers (gallery) ---------- */

.section-header { margin-bottom: 20px; }
.section-header h2 {
  margin: 0 0 6px;
  font-size: clamp(18px, 2.5vw, 22px);
  font-weight: 700;
  letter-spacing: -0.005em;
}
.section-header .muted { font-size: 15px; max-width: 640px; }

/* ---------- Gallery ---------- */

.example-cards {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px;
}
.example-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px; display: flex; flex-direction: column; gap: 12px;
  transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.example-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.example-card.placeholder {
  color: var(--muted); justify-content: center; align-items: center; min-height: 120px;
}
.example-card.placeholder:hover { transform: none; box-shadow: none; }
.example-card .card-title { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.3; }
.example-card .card-idea { color: var(--muted); font-size: 14px; margin: 0; font-style: italic; line-height: 1.45; }
.example-card .card-desc { color: var(--text); font-size: 14px; margin: 0; flex: 1; line-height: 1.5; }
.example-card .card-meta { color: var(--muted); font-size: 12px; margin: 0; font-family: var(--mono); }
.example-card .card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.example-card button { font-size: 14px; padding: 10px 14px; min-height: 40px; }

/* ---------- Result section ---------- */

.result {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  animation: revealIn 320ms cubic-bezier(0.2, 0.6, 0.2, 1);
}

@keyframes revealIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(138, 180, 255, 0.04), transparent);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.result-header h2 {
  margin: 0 0 4px;
  font-size: clamp(18px, 2.5vw, 22px);
  font-weight: 700;
  letter-spacing: -0.005em;
}
.result-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.muted { color: var(--muted); font-size: 14px; margin: 0; }

.result-body { display: grid; grid-template-columns: 280px 1fr; min-height: 480px; }
@media (max-width: 720px) { .result-body { grid-template-columns: 1fr; min-height: 0; } }

.file-list {
  border-right: 1px solid var(--border);
  padding: 8px; overflow-y: auto; max-height: 70vh;
}
@media (max-width: 720px) {
  .file-list {
    border-right: 0; border-bottom: 1px solid var(--border);
    max-height: 240px;
  }
}
.file-list button {
  display: block; width: 100%; text-align: left; background: transparent; color: var(--text);
  padding: 10px 12px; border-radius: 6px; font-family: var(--mono); font-size: 13px; font-weight: 400;
  border: 1px solid transparent; min-height: 0;  /* file-list buttons are dense, override the global 44px */
  margin-bottom: 2px; box-shadow: none;
}
.file-list button:hover { background: var(--panel-2); }
.file-list button.active,
.file-list button[aria-current="true"] {
  background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}

.file-view { display: flex; flex-direction: column; min-width: 0; }
.file-view-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-bottom: 1px solid var(--border); gap: 12px;
}
.path { font-family: var(--mono); font-size: 13px; color: var(--muted); word-break: break-all; }
.file-view-header button { padding: 8px 12px; font-size: 13px; min-height: 36px; }

.file-content {
  margin: 0; padding: 18px 22px; overflow: auto; max-height: 70vh;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.6;
  background: var(--panel-2); white-space: pre-wrap; word-break: break-word;
}

/* ---------- Skeleton (loading state) ---------- */

.result-skeleton { display: none; padding: 22px; }
.result[data-loading="true"] .result-skeleton { display: block; }
.result[data-loading="true"] .result-header,
.result[data-loading="true"] .result-body { display: none; }

.sk-row, .sk-line, .sk-block {
  background: linear-gradient(90deg, var(--panel-2) 0%, var(--panel-3) 50%, var(--panel-2) 100%);
  background-size: 200% 100%;
  border-radius: 6px;
  animation: shimmer 1.4s ease-in-out infinite;
}
.sk-row-title { height: 22px; width: 60%; margin-bottom: 10px; }
.sk-row-meta  { height: 14px; width: 38%; margin-bottom: 22px; }
.sk-grid { display: grid; grid-template-columns: 240px 1fr; gap: 18px; }
@media (max-width: 720px) { .sk-grid { grid-template-columns: 1fr; } }
.sk-col { display: flex; flex-direction: column; gap: 10px; }
.sk-line { height: 14px; width: 100%; }
.sk-line.sk-w-95 { width: 95%; }
.sk-line.sk-w-90 { width: 90%; }
.sk-line.sk-w-85 { width: 85%; }
.sk-line.sk-w-75 { width: 75%; }
.sk-line.sk-w-70 { width: 70%; }
.sk-line.sk-w-60 { width: 60%; }
.sk-col-content .sk-line { height: 12px; }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Badge ---------- */

.badge {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; padding: 4px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--border);
  margin-left: 10px; vertical-align: middle;
}
.result-title { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px; }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  color: var(--muted); font-size: 14px;
}
.site-footer code { font-family: var(--mono); }
.footer-legal {
  margin-top: 12px;
  font-size: 13px;
}
.footer-legal a {
  color: var(--accent);
  text-decoration: none;
  margin: 0 4px;
}
.footer-legal a:hover { color: var(--accent-press); text-decoration: underline; }

/* ---------- Mobile (≤ 540px): comfortable touch UI ---------- */

@media (max-width: 540px) {
  .container { padding: 0 16px; }
  .site-header { padding: 36px 0 24px; }
  .brand-logo { width: 44px; height: 44px; }
  main { padding: 28px 0 64px; gap: 36px; }

  .generator form { padding: 18px; gap: 12px; border-radius: var(--radius-md); }
  .generator textarea { padding: 12px; font-size: 16px; }

  .row { flex-direction: column; align-items: stretch; }
  .row .checkbox { order: 2; }
  .row #submit { order: 1; width: 100%; padding: 14px 18px; font-size: 16px; min-height: 48px; }

  .result-header { padding: 16px 18px; flex-direction: column; align-items: flex-start; gap: 12px; }
  .result-actions { flex-direction: row-reverse; align-items: center; align-self: stretch; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
  .result-actions button { flex: 0 0 auto; min-height: 44px; padding: 10px 16px; }

  .file-content { padding: 14px 16px; font-size: 13px; }
  .file-view-header { padding: 10px 14px; }

  .example-card { padding: 16px; }
  .example-card .card-actions { gap: 8px; }
  .example-card .card-actions button { min-height: 44px; padding: 10px 14px; flex: 1 1 auto; }
}

/* ---------- Result stats card (post-generate "47 sections, 6842 words") ---------- */

.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(138, 180, 255, 0.04), transparent);
}
@media (max-width: 540px) { .result-stats { grid-template-columns: repeat(2, 1fr); } }

.result-stat {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 6px 4px;
}
.result-stat-value {
  font-family: var(--mono);
  font-size: clamp(20px, 3.5vw, 26px);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.result-stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* ---------- Result preview (first 30 lines of MASTERPLAN.md) ---------- */

.result-preview {
  margin: 0;
  border-bottom: 1px solid var(--border);
}
.result-preview-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px;
  background: var(--panel);
  gap: 12px; flex-wrap: wrap;
}
.result-preview-tag {
  display: inline-flex; align-items: center;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px; border-radius: 4px;
  letter-spacing: 0.02em;
}
.result-preview-hint { font-size: 12px; }
.result-preview-body {
  position: relative;
  margin: 0;
  padding: 18px 22px 32px;
  background: var(--panel-2);
  font-family: var(--mono); font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap; word-break: break-word;
  max-height: 320px;
  overflow: hidden;
  /* fade-out at the bottom edge */
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 78%, transparent 100%);
          mask-image: linear-gradient(180deg, #000 0%, #000 78%, transparent 100%);
}
.result-preview-body:empty {
  /* When no preview yet (e.g. example panel mid-load) hide the fade-out
     so the empty box doesn't look weird. */
  display: none;
}

/* ---------- File-list color-coding by category ---------- */

.file-list button[data-cat="strategy"] { border-left: 3px solid #8ab4ff; }
.file-list button[data-cat="tech"]     { border-left: 3px solid #6dd6a3; }
.file-list button[data-cat="brief"]    { border-left: 3px solid #c89dff; }
.file-list button[data-cat="prompts"]  { border-left: 3px solid #ffb066; }
.file-list button[data-cat="meta"]     { border-left: 3px solid #6f7891; }
.file-list button {
  border-left: 3px solid transparent;
  padding-left: 9px; /* 12 - 3 */
}

/* ---------- Share row (post-generate viral loop) ---------- */

.result-share {
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px 22px;
  background: linear-gradient(180deg, transparent, rgba(138, 180, 255, 0.04));
  border-bottom: 1px solid var(--border);
}
@media (min-width: 720px) {
  .result-share { flex-direction: row; align-items: center; }
}
.result-share-label {
  font-size: 13px; font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.result-share-buttons {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.share-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  text-decoration: none;
  cursor: pointer; min-height: 36px;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.share-btn:hover {
  background: var(--panel-3);
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
}
.share-btn:active { transform: translateY(0); }
.share-btn svg { flex-shrink: 0; }
.share-btn-copy { font-family: inherit; }

/* ---------- Use-your-kit panel ---------- */

.use-your-kit {
  padding: 24px 22px 22px;
  background: linear-gradient(180deg, rgba(138, 180, 255, 0.06), transparent 60%);
  border-bottom: 1px solid var(--border);
}
.use-top { margin-bottom: 18px; }
.use-top h3 {
  margin: 0 0 4px;
  font-size: clamp(17px, 2.2vw, 20px);
  font-weight: 700;
  letter-spacing: -0.005em;
}
.use-top .muted { font-size: 14px; }

.kit-steps {
  list-style: none; padding: 0; margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  counter-reset: kit-step;
}
@media (max-width: 820px) {
  .kit-steps { grid-template-columns: 1fr; }
}

.kit-step {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex; flex-direction: column;
  gap: 8px;
  position: relative;
}
.kit-step-num {
  position: absolute;
  top: -10px; left: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: var(--accent); color: #0b0f18;
  border-radius: 50%;
  font-size: 13px; font-weight: 700;
  box-shadow: 0 4px 10px rgba(138, 180, 255, 0.35);
}
.kit-step h4 {
  margin: 6px 0 0;
  font-size: 16px; font-weight: 700;
  color: var(--text);
  letter-spacing: -0.005em;
  line-height: 1.3;
}
.kit-step p {
  margin: 0; flex: 1;
  font-size: 14px; line-height: 1.5;
  color: var(--text);
}
.kit-step p code {
  font-family: var(--mono); font-size: 12.5px;
  background: var(--bg); padding: 2px 6px; border-radius: 4px;
  color: var(--accent);
}
.muted-inline { color: var(--muted); }
.kit-step-action {
  margin-top: 8px;
  align-self: stretch; text-align: center;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.kit-step-action.primary { /* link styled as button */ color: #0b0f18; }
.ext-ico { font-size: 14px; line-height: 1; }
.ico-clip { font-size: 16px; vertical-align: middle; }

/* Step 3: prompt block + copy */
.kit-prompt {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 14px 12px;
  margin-top: 6px;
}
.kit-prompt pre {
  margin: 0; padding: 0;
  font-family: var(--mono); font-size: 13px;
  color: var(--text); line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  /* leave room for the absolute-positioned button on wide screens */
  padding-right: 96px;
}
.kit-prompt-copy {
  position: absolute; top: 10px; right: 10px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  padding: 6px 12px; min-height: 32px;
  font-size: 12px; font-weight: 500; border-radius: 6px;
  box-shadow: none;
}
.kit-prompt-copy:hover { background: var(--panel-3); border-color: var(--border-strong); }
@media (max-width: 540px) {
  .kit-prompt pre { padding-right: 0; padding-bottom: 38px; }
  .kit-prompt-copy { top: auto; right: 10px; bottom: 8px; }
}

/* ---------- Sub-steps inside a kit-step (e.g. GitHub how-to) ---------- */

.kit-substeps {
  margin-top: 8px;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
}
.kit-substeps > summary {
  list-style: none; cursor: pointer;
  font-size: 13px; font-weight: 500;
  color: var(--accent);
  padding: 4px 0;
  display: inline-flex; align-items: center; gap: 6px;
}
.kit-substeps > summary::-webkit-details-marker { display: none; }
.kit-substeps > summary::before {
  content: "▸"; color: var(--muted);
  transition: transform var(--t-fast);
}
.kit-substeps[open] > summary::before { transform: rotate(90deg); }
.kit-substeps > summary:hover { color: var(--accent-press); }
.kit-substeps .alt-steps { margin-top: 10px; padding-left: 22px; gap: 10px; }
.kit-substeps .alt-steps li { font-size: 13px; }

/* ---------- Alt-paths (other ways to use your kit) ---------- */

.alt-paths {
  margin-top: 18px;
  border-top: 1px dashed var(--border);
  padding-top: 18px;
}
.alt-paths-summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; color: var(--text);
  transition: background var(--t-fast);
}
.alt-paths-summary::-webkit-details-marker { display: none; }
.alt-paths-summary::before {
  content: "▸"; color: var(--muted);
  transition: transform var(--t-fast);
  display: inline-block; flex-shrink: 0;
}
.alt-paths[open] .alt-paths-summary::before { transform: rotate(90deg); }
.alt-paths-summary:hover { background: var(--panel-2); }
.alt-paths-hint { font-weight: 400; font-size: 13px; }

.alt-paths-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 14px;
}
.alt-paths-body-single {
  grid-template-columns: 1fr;
  max-width: 720px;
}
@media (max-width: 820px) {
  .alt-paths-body { grid-template-columns: 1fr; }
}

.alt-path {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}
.alt-path-head { margin-bottom: 12px; }
.alt-path h5 {
  margin: 0 0 6px;
  font-size: 15px; font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--text);
}
.alt-path-head .muted { font-size: 13px; line-height: 1.5; margin: 0; }

.alt-steps {
  list-style: decimal;
  padding-left: 22px;
  margin: 0;
  display: flex; flex-direction: column; gap: 12px;
  counter-reset: alt-step;
}
.alt-steps li {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
}
.alt-steps li code {
  font-family: var(--mono); font-size: 12.5px;
  background: var(--bg);
  color: var(--accent);
  padding: 1px 6px; border-radius: 4px;
}
.alt-steps li em { color: var(--accent); font-style: normal; font-weight: 600; }
.alt-steps li strong { color: var(--text); font-weight: 700; }
.alt-steps li a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.alt-step-hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-style: italic;
}
.alt-code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 6px 0;
  font-family: var(--mono); font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
  overflow-x: auto;
}
.alt-code code {
  background: transparent; color: inherit; padding: 0;
}

/* Inline mini-prompt block for the GitHub flow's last step */
.alt-mini-prompt {
  display: block;
  margin: 8px 0 6px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.alt-mini-copy {
  background: var(--panel-3); color: var(--text); border: 1px solid var(--border);
  padding: 6px 12px; min-height: 32px;
  font-size: 12px; font-weight: 500; border-radius: 6px;
  box-shadow: none;
}
.alt-mini-copy:hover { background: var(--panel-2); border-color: var(--border-strong); }

/* ---------- Files-details (collapsed-by-default file viewer) ---------- */

.files-details { border-top: 0; }
.files-summary {
  list-style: none; cursor: pointer;
  padding: 16px 22px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  font-size: 14px; font-weight: 600; color: var(--text);
  transition: background var(--t-fast);
}
.files-summary::-webkit-details-marker { display: none; }
.files-summary::before {
  content: "▸"; color: var(--muted);
  transition: transform var(--t-fast);
  display: inline-block;
}
.files-details[open] .files-summary::before { transform: rotate(90deg); }
.files-summary:hover { background: var(--panel-2); }
.files-summary-hint { font-weight: 400; font-size: 13px; }
.files-details[open] .files-summary { border-bottom-color: var(--border-strong); }

/* ---------- Wizard ---------- */

.wizard {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.wizard-top { margin-bottom: 24px; }
.wizard-top h2 {
  margin: 0 0 6px;
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.wizard-top .muted { font-size: 15px; max-width: 600px; margin-bottom: 18px; }

/* Step indicator with progress-fill bar between items */
.wizard-steps {
  list-style: none; padding: 0; margin: 0;
  display: flex; gap: 8px; flex-wrap: wrap;
  counter-reset: step;
  position: relative;
}
/* Progress-bar background line connecting the step pills */
.wizard-steps::before {
  content: "";
  position: absolute;
  top: 50%; left: 12px; right: 12px;
  height: 2px;
  background: var(--border);
  transform: translateY(-50%);
  z-index: 0;
  border-radius: 2px;
}
/* Progress-bar fill — width set inline via --progress CSS var (0..100) */
.wizard-steps::after {
  content: "";
  position: absolute;
  top: 50%; left: 12px;
  height: 2px;
  width: calc(var(--progress, 0) * 1%);
  max-width: calc(100% - 24px);
  background: linear-gradient(90deg, var(--accent), var(--accent-press));
  transform: translateY(-50%);
  border-radius: 2px;
  transition: width 380ms cubic-bezier(0.2, 0.6, 0.2, 1);
  z-index: 0;
}
@media (prefers-reduced-motion: reduce) {
  .wizard-steps::after { transition: none; }
}
.wizard-steps li { position: relative; z-index: 1; }
.wizard-steps li {
  flex: 1 1 100px; min-width: 80px;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--muted);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.wizard-steps li.done {
  background: var(--accent-soft);
  border-color: rgba(138, 180, 255, 0.35);
  color: var(--accent);
}
.wizard-steps li.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0f18;
  font-weight: 600;
}
.wizard-steps .step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.2);
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.wizard-steps li.active .step-num { background: rgba(0, 0, 0, 0.3); }
.wizard-steps li.done .step-num { background: var(--accent-soft); }
.wizard-steps .step-label { white-space: nowrap; }

/* Step panels — directional slide-in animation when switching steps.
   .panel-enter-forward / .panel-enter-back classes are toggled in JS
   by gotoWizardStep() based on whether the user clicked Next or Back. */
.wizard-panels { min-height: 280px; position: relative; overflow: hidden; }
.wizard-panel {
  border: 0; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 12px;
}
.wizard-panel.panel-enter-forward {
  animation: panel-slide-in-right 320ms cubic-bezier(0.2, 0.6, 0.2, 1);
}
.wizard-panel.panel-enter-back {
  animation: panel-slide-in-left 320ms cubic-bezier(0.2, 0.6, 0.2, 1);
}
@keyframes panel-slide-in-right {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes panel-slide-in-left {
  from { opacity: 0; transform: translateX(-24px); }
  to   { opacity: 1; transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .wizard-panel.panel-enter-forward,
  .wizard-panel.panel-enter-back { animation: none; }
}
.wizard-question {
  margin: 0;
  font-size: clamp(17px, 2.5vw, 20px);
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}
.wz-optional { color: var(--muted); font-weight: 400; font-size: 0.85em; }
.wizard-help { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* Step 1 — option grid (no icons, clean text-only tiles) */
.wizard-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}
@media (max-width: 720px) {
  .wizard-options { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}
@media (max-width: 420px) {
  .wizard-options { grid-template-columns: 1fr; }
}

.wz-option {
  position: relative;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 14px 12px;
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  text-align: left;
  cursor: pointer; min-height: 0;
  font-weight: 500;
  transition: transform var(--t-fast), border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.wz-option:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.wz-option[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px rgba(138, 180, 255, 0.2);
}
.wz-option[aria-checked="true"]::before {
  content: "";
  position: absolute;
  top: 10px; right: 10px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(138, 180, 255, 0.6);
}

.wz-title {
  font-size: 15px; font-weight: 600; color: var(--text);
  letter-spacing: -0.005em;
  line-height: 1.3;
}
.wz-option[aria-checked="true"] .wz-title { color: var(--accent); }
.wz-sub {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}

/* Special "Something else" tile — slightly distinct, dashed border */
.wz-option-other {
  border-style: dashed;
}
.wz-option-other[aria-checked="true"] {
  border-style: solid;
}

/* Free-input wrapper that expands when "Something else" is selected */
.wz-other-wrap {
  margin-top: 10px;
  padding: 14px 16px;
  background: var(--accent-soft);
  border: 1px solid rgba(138, 180, 255, 0.3);
  border-radius: var(--radius-sm);
  display: flex; flex-direction: column; gap: 8px;
  animation: wz-nudge-in 280ms cubic-bezier(0.2, 0.6, 0.2, 1);
}
.wz-other-wrap[hidden] { display: none; }
.wz-other-label {
  font-size: 13px; font-weight: 600;
  color: var(--accent);
}

/* Step 2 + 3 — wizard nudge (sparse-input hint) */
.wz-nudge {
  margin-top: 8px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--accent-soft), rgba(108, 155, 255, 0.04));
  border: 1px solid rgba(138, 180, 255, 0.32);
  border-radius: var(--radius-sm);
  display: flex; flex-direction: column; gap: 4px;
  animation: wz-nudge-in 280ms cubic-bezier(0.2, 0.6, 0.2, 1);
}
.wz-nudge[hidden] { display: none; }
.wz-nudge-title {
  margin: 0;
  font-size: 14px; font-weight: 600;
  color: var(--accent);
}
.wz-nudge-body {
  margin: 0;
  font-size: 13.5px; line-height: 1.5;
  color: var(--text);
}
.wz-nudge-body em { font-style: normal; color: var(--accent); }
@keyframes wz-nudge-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .wz-nudge { animation: none; }
}

/* Step 2 + 3 — text input + suggestions */
.wz-input {
  width: 100%;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--sans); font-size: 16px;
  line-height: 1.5;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.wz-input:focus {
  outline: 2px solid var(--accent); outline-offset: 1px;
  border-color: var(--accent);
}
.wz-input::placeholder { color: var(--muted); }

.wizard-suggestions {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.wz-pill {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px; font-weight: 500;
  cursor: pointer; min-height: 36px;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.wz-pill:hover { background: var(--panel-3); border-color: var(--border-strong); }
.wz-pill:active { transform: translateY(1px); }

/* Step 4 — summary card */
.wz-summary-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.wz-summary-text {
  margin: 0;
  font-size: 18px;
  line-height: 1.5;
  color: var(--text);
  font-weight: 500;
}
.wz-persist-row { padding: 0 4px; }

/* Wizard footer / nav */
.wizard-nav {
  display: flex; gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.wizard-nav button { flex: 1 1 auto; min-width: 120px; }
#wz-generate { background: var(--accent); color: #0b0f18; box-shadow: 0 6px 18px rgba(138, 180, 255, 0.18); }
#wz-generate:hover { background: var(--accent-press); box-shadow: 0 8px 22px rgba(138, 180, 255, 0.28); }

/* Skip / linkish text-button */
.wizard-skip {
  margin: 18px 0 0;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}
.linkish {
  background: transparent; color: var(--accent); border: 0;
  padding: 4px 6px; min-height: 0;
  font-weight: 500; font-size: inherit;
  text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}
.linkish:hover { color: var(--accent-press); background: transparent; }

/* Mode toggle — top-of-main segmented control between guided wizard and
   direct-text input. Two equally-weighted tabs so users immediately see
   that the wizard is one of two ways in, not the only way. */
.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 32px 0 18px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.mode-tab {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  gap: 4px;
  background: transparent; color: var(--muted);
  padding: 14px 18px; min-height: 64px;
  border: 1px solid transparent; border-radius: var(--radius-md);
  text-align: left; cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.mode-tab:hover { background: var(--panel-2); color: var(--text); }
.mode-tab.is-active {
  background: var(--accent-soft); color: var(--text);
  border-color: var(--accent);
  box-shadow: 0 1px 0 var(--accent-soft);
}
.mode-tab-title {
  font-size: 16px; font-weight: 600; letter-spacing: 0.005em;
}
.mode-tab.is-active .mode-tab-title { color: var(--accent); }
.mode-tab-sub {
  font-size: 13px; color: var(--muted); font-weight: 400;
}
@media (max-width: 540px) {
  .mode-toggle { gap: 6px; padding: 5px; margin-top: 24px; }
  .mode-tab { padding: 12px 14px; min-height: 60px; }
  .mode-tab-title { font-size: 15px; }
  .mode-tab-sub { font-size: 12px; }
}

/* Mobile wizard tweaks */
@media (max-width: 540px) {
  .wizard { padding: 20px; }
  .wizard-steps li { flex-basis: 0; padding: 8px 10px; }
  .wizard-steps .step-label { display: none; }
  .wizard-steps li.active .step-label { display: inline; }
  .wizard-options { grid-template-columns: 1fr 1fr; }
  .wz-option { padding: 14px 12px; min-height: 86px; }
  .wizard-nav button { font-size: 15px; padding: 12px 16px; min-height: 48px; }
  .wz-summary-text { font-size: 16px; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
