/*
 * Extension Builder — Krista wizard theme.
 * Look & tokens follow krista-extensions-create_3.html ("Extension Builder" wizard). Class names are the
 * ones app.js / index.html already use, so this is a restyle only — no behaviour depends on it.
 */

:root {
  --ink-900: #16202B;
  --ink-700: #3A4655;
  --ink-500: #64748B;
  --ink-400: #94A3B8;
  --border: #E2E6EB;
  --panel: #EEF2F6;
  --primary: #1C6FEE;
  --primary-dark: #1557C4;
  --primary-tint: #EAF2FE;
  --success: #1E7A44;
  --success-bg: #E7F6EC;
  --success-line: #16A34A;
  --success-body: #2F6B48;
  --warn-text: #92450C;
  --warn-bg: #FBEED9;
  --info-bg: #DCEEFB;
  --info-text: #1D6FC4;
  --danger: #B3261E;
  --danger-bg: #FDECEC;
  --step-active: #45986F;
  --step-ink: #212121;
  --shadow-md: 0 4px 16px rgba(16, 24, 40, .10);
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #fff;
  color: var(--ink-900);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* class-level display rules (.btn, .field...) must never beat the HTML hidden attribute */
[hidden] { display: none !important; }

button { font-family: inherit; }
code { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

.shell { max-width: 900px; margin: 0 auto; padding: 28px 24px 60px; }

/* ---------- header ---------- */

header.hd { padding: 0 0 18px; }

h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.3px;
  margin: 0 0 8px;
}

.sub { color: var(--ink-500); margin: 0; font-size: 14px; line-height: 1.5; }

/* ---------- step rail (circles + progress bar) ---------- */

.stepbar { margin-bottom: 30px; }

.rail {
  display: flex;
  align-items: center;
  gap: 28px;
  margin: 0 0 14px;
  flex-wrap: wrap;
}

.rail-step {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.rail-num {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
  background: var(--step-ink);
  transition: background-color .15s ease;
}

.rail-num svg { width: 12px; height: 12px; }

.rail-label {
  font-size: 14.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--step-ink);
  transition: color .15s ease;
}

.rail-step[data-state="done"] .rail-num { background: var(--step-ink); }
.rail-step[data-state="done"]:hover .rail-num { background: var(--step-active); }
.rail-step[data-state="done"]:hover .rail-label { color: var(--step-active); }
.rail-step[data-state="now"] .rail-num { background: var(--step-active); }
.rail-step[data-state="now"] .rail-label { color: var(--step-active); }

.rail-track {
  position: relative;
  height: 4px;
  border-radius: 999px;
  background: var(--step-ink);
  overflow: hidden;
}

.rail-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  background: var(--step-active);
  border-radius: 999px;
  transition: width .25s ease;
}

/* ---------- step "panel": flat, like the wizard — header, body, footer bar ---------- */

.panel { background: transparent; border: 0; border-radius: 0; box-shadow: none; }

.step[data-active="true"] { display: block; animation: stepIn .22s ease; }
@keyframes stepIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.panel-hd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.panel-hd h2 { font-size: 24px; font-weight: 700; letter-spacing: -.3px; margin: 0 0 8px; }
.panel-hd p { margin: 0 0 9px; font-size: 14px; color: var(--ink-500); line-height: 1.5; }

.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; color: var(--ink-400); }

.panel-bd { padding: 0; }

.panel-ft {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 20px;
  margin-top: 20px;
  background: var(--panel);
  border-radius: 10px;
}

.ft-note { font-size: 12.5px; color: var(--ink-500); }

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

.field { display: grid; gap: 7px; margin-bottom: 20px; }
.field:last-child { margin-bottom: 0; }

label.lb { font-size: 12.5px; font-weight: 600; color: var(--ink-700); }
.hint { font-size: 12px; color: var(--ink-500); }

textarea, input[type="text"], input[type="password"], select {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink-900);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
}

input[type="text"], input[type="password"], select { height: 44px; padding: 0 15px; }

textarea { padding: 13px 14px; min-height: 78px; line-height: 1.55; resize: vertical; }

/* the native <select> stays in the DOM as the source of truth; dropdown.js renders .wiz-select in its place */
select.dd-native { display: none; }

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.2'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px;
}

/* ---------- custom dropdown (from the wizard's .wiz-select) ---------- */

.wiz-select {
  position: relative;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  color: var(--ink-900);
  cursor: pointer;
  user-select: none;
}

.wiz-select:hover { border-color: #C6CDD6; }
.wiz-select.open, .wiz-select:focus-visible { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); outline: none; }
.wiz-select.disabled { background: var(--panel); color: var(--ink-500); cursor: not-allowed; }
.wiz-select.disabled:hover { border-color: var(--border); }

.wiz-select-current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.wiz-select > svg { width: 14px; height: 14px; flex: none; color: var(--ink-500); transition: transform .15s ease; }
.wiz-select.open > svg { transform: rotate(180deg); }

.wiz-select-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 280px;
  overflow-y: auto;
  padding: 5px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: var(--shadow-md);
}

.wiz-select.open .wiz-select-menu { display: block; }

.wiz-select-opt {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 11px;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--ink-700);
}

.wiz-select-opt:hover, .wiz-select-opt.active { background: var(--panel); }
.wiz-select-opt.sel { color: var(--primary); font-weight: 700; background: var(--primary-tint); }

.wiz-select-opt.add {
  color: var(--primary);
  font-weight: 700;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 12px;
  border-radius: 0 0 6px 6px;
}

.wiz-select-opt.add svg { width: 13px; height: 13px; flex: none; }
.wiz-select-opt.add:hover { background: var(--primary-tint); }

textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}

/* checkbox list */
.checks { display: grid; gap: 0; border-top: 1px solid var(--border); }

.checks label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--ink-900);
  cursor: pointer;
  user-select: none;
}

.checks input[type="checkbox"], .reuse-item-actions input[type="radio"] { accent-color: var(--primary); }

.checks input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1.5px solid #C6CDD6;
  border-radius: 5px;
  background: #fff center / 11px no-repeat;
  transition: background-color .1s ease, border-color .1s ease;
  cursor: pointer;
}

.checks label:hover input[type="checkbox"] { border-color: var(--primary); }

.checks input[type="checkbox"]:checked {
  background-color: var(--primary);
  border-color: var(--primary);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4'><path d='m5 12 5 5L20 7'/></svg>");
}

/* ---------- dropzone ---------- */

.drop {
  border: 1.5px dashed #C6CDD6;
  border-radius: 10px;
  padding: 28px 20px;
  text-align: center;
  background: var(--panel);
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}

.drop:hover, .drop:focus-visible, .drop[data-over="true"] { border-color: var(--primary); background: var(--primary-tint); outline: none; }
.drop-t { font-size: 14px; color: var(--ink-700); margin-bottom: 6px; }
.drop-t b { color: var(--primary); font-weight: 700; }
.drop-s { font-size: 12.5px; color: var(--ink-500); }

.filelist { display: grid; gap: 0; margin-top: 12px; }

.file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.file-nm { font-family: var(--mono); font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-900); }
.file-sz { font-family: var(--mono); font-size: 12px; color: var(--ink-400); font-variant-numeric: tabular-nums; flex: none; }

.kind {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--ink-500);
  flex: none;
}

/* ---------- questions ---------- */

.q { padding: 20px 0; border-bottom: 1px solid var(--border); }
.q:first-child { padding-top: 0; }
.q:last-child { border-bottom: 0; }

.q-progress {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-400);
  margin-bottom: 8px;
}

.q-hd { display: flex; gap: 10px; align-items: baseline; margin-bottom: 12px; }
.q-id { font-family: var(--mono); font-size: 12px; color: var(--ink-400); flex: none; }
.q-txt { font-size: 15.5px; font-weight: 700; }

.q-why {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-700);
  background: var(--panel);
  border-left: 3px solid var(--primary);
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  margin: 0 0 12px;
}

.q-why b { color: var(--primary-dark); font-weight: 700; }

/* ---------- domain-reuse review ---------- */

.reuse-bulk-row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }

.reuse-scroll {
  max-height: 60vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.reuse-list h4 {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-500);
  margin: 18px 0 8px;
}

.reuse-list:first-of-type h4 { margin-top: 0; }

.reuse-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
}

.reuse-item-hd { display: flex; align-items: baseline; gap: 8px; font-size: 14px; font-weight: 700; margin-bottom: 4px; }

.reuse-item-area {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--primary-tint);
  border-radius: 5px;
  padding: 3px 8px;
}

.reuse-item-desc { font-size: 13px; color: var(--ink-700); margin-bottom: 8px; }
.reuse-item-io { font-size: 12.5px; color: var(--ink-700); margin-bottom: 10px; display: grid; gap: 2px; }
.reuse-item-io b { color: var(--ink-900); }

.reuse-item-actions { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; margin-bottom: 8px; }
.reuse-item-actions label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

.reuse-item-note { width: 100%; min-height: 56px; font-size: 13px; }

/* ---------- plan ---------- */

.summary {
  display: flex;
  flex-wrap: wrap;
  margin: 0 0 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.cell { flex: 1; min-width: 150px; padding: 14px 16px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: #fff; }
.cell:last-child { border-right: 0; }
.cell dt { font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-400); margin-bottom: 6px; }
.cell dd { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink-900); word-break: break-word; }
.cell dd.m { font-family: var(--mono); font-size: 12.5px; font-weight: 500; }

.area { margin-bottom: 20px; }
.area:last-child { margin-bottom: 0; }

.area-hd { display: flex; align-items: baseline; gap: 9px; margin-bottom: 8px; }
.area-nm { font-size: 14.5px; font-weight: 700; }
.area-ct { font-family: var(--mono); font-size: 12px; color: var(--ink-400); }

.tw { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }

table { width: 100%; min-width: 620px; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-500);
  font-weight: 400;
  padding: 11px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--ink-700); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.m { font-family: var(--mono); font-size: 12px; }
td.nm { color: var(--ink-900); font-weight: 700; font-size: 13.5px; }

.pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
}

.pill.q { background: var(--info-bg); color: var(--info-text); }
.pill.c { background: var(--warn-bg); color: var(--warn-text); }

/* the "from <file>.json" tag on the right of a step header */
.panel-hd > .pill.q {
  font-weight: 400;
  background: var(--primary-tint);
  color: var(--primary-dark);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  letter-spacing: 0;
}

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

.banner {
  display: flex;
  gap: 9px;
  padding: 16px 18px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 20px;
  align-items: flex-start;
}

.banner b { display: block; font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.banner-ic { font-weight: 700; flex: none; line-height: 1.4; }

/* the build's own notes can run to a wall of text — keep the banner compact, scroll for the rest */
#build-banner .banner > span:last-child { max-height: 9.5em; overflow-y: auto; }
.banner > span { min-width: 0; overflow-wrap: anywhere; }

.banner.ok { background: var(--success-bg); color: var(--success-body); }
.banner.ok b, .banner.ok .banner-ic { color: var(--success); }
.banner.warn { background: var(--warn-bg); color: var(--warn-text); }
.banner.bad { background: var(--danger-bg); color: var(--danger); }
.banner.info { background: var(--info-bg); color: var(--info-text); }

/* ---------- generating ---------- */

.runbar {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 14px 0;
  margin-bottom: 4px;
}

.phase-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 7px;
  background: var(--primary-tint);
  color: var(--primary-dark);
}

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); flex: none; }

@media (prefers-reduced-motion: no-preference) {
  .dot { animation: pulse 1s ease-in-out infinite; }
  @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
}

.runstat { font-family: var(--mono); font-size: 12.5px; color: var(--ink-500); font-variant-numeric: tabular-nums; }
.runstat b { color: var(--ink-900); font-weight: 700; }

.log {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  background: var(--panel);
  border-radius: 10px;
  padding: 18px 20px;
  max-height: 360px;
  height: 360px;
  overflow-y: auto;
  overflow-x: auto;
}

.log div { white-space: pre-wrap; word-break: break-word; padding: 3px 0; }
.log .t { color: var(--ink-400); font-style: italic; }
.log .tool { color: var(--primary-dark); }
.log .good { color: var(--success-line); font-weight: 600; }
.log .bad { color: var(--danger); }
.log .fix { color: var(--warn-text); }

/* ---------- artifacts ---------- */

.arts { display: grid; gap: 0; }

.art {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}

.art:last-child { border-bottom: 0; }
.art .kind { padding: 3px 9px; }
.art-nm { font-family: var(--mono); font-size: 13.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-900); }
.art-nm.hero { font-weight: 600; }
.kind.hero-k { background: var(--primary-tint); color: var(--primary-dark); border-color: var(--primary); }
.art-sz { font-family: var(--mono); font-size: 12px; color: var(--ink-400); font-variant-numeric: tabular-nums; min-width: 70px; text-align: right; flex: none; }

/* every artifact action looks like the wizard's quiet "Download" button */
.art .btn, .art .btn.ghost, .art a.btn {
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-700);
  background: #fff;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  flex: none;
}

.art .btn:hover, .art a.btn:hover { background: var(--panel); border-color: #C6CDD6; filter: none; color: var(--ink-700); }

/* ---------- buttons ---------- */

.btn {
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 700;
  height: 40px;
  padding: 0 20px;
  border-radius: 8px;
  border: 0;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(28, 111, 238, .3);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background .12s ease, transform .08s ease;
}

.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.btn.ghost {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--ink-700);
  font-weight: 600;
  box-shadow: none;
  padding: 0 18px;
}

.btn.ghost:hover { background: var(--panel); }

.btn.sm { height: 34px; padding: 0 14px; font-size: 12.5px; }
.btn-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.step { display: none; }

#feedbackWrap { display: none; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
#feedbackWrap[data-open="true"] { display: block; }

/* ---------- add ecosystem / domain dialogs ---------- */

.via-dialog { display: none !important; }

.modal-veil {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 24, 39, .42);
}

.modal-veil.show { display: flex; }

.modal {
  width: 100%;
  max-width: 360px;
  padding: 24px;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  animation: modalIn .18s ease;
  /* the wizard's dialog uses the app-shell tokens, a touch different from the step pages */
  color: #1F2937;
  font-size: 16px;
  line-height: normal;
}

@keyframes modalIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }

.modal h3 { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
.modal p { margin: 0 0 20px; font-size: 13px; line-height: 1.5; color: #6B7280; }
.modal label.lb { display: block; margin-bottom: 7px; }
.modal input[type="text"] { margin-bottom: 16px; }
.modal-err { margin: -6px 0 12px; font-size: 12.5px; line-height: 1.4; color: var(--danger); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

.modal .btn.ghost {
  height: 38px;
  padding: 0 16px;
  font-size: 13px;
  color: #37414D;
  border-color: #E5E7EB;
}

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  .shell { padding: 20px 16px 48px; }
  .rail { gap: 14px; }
  .rail-step { gap: 6px; }
  .rail-step:not([data-state="now"]) .rail-label { display: none; }
  .summary .cell { min-width: 100%; border-right: 0; }
}

@media (max-width: 620px) {
  h1, .panel-hd h2 { font-size: 20px; }
  .panel-ft { flex-direction: column; align-items: stretch; }
  .art { flex-wrap: wrap; row-gap: 8px; }
  .art-nm { flex-basis: 40%; }
}
