:root {
  --bg: #faf9f5;
  --bg-sunk: #f0eee6;
  --surface: #ffffff;
  --ink: #181818;
  --ink-soft: #3d3d3a;
  --muted: #73716a;
  --faint: #9b988f;
  --line: #e5e3dc;
  --line-strong: #d6d3c9;
  --accent: #d97757;
  --accent-ink: #ffffff;
  --accent-soft: #f7ece6;
  --accent-line: #eab89f;
  --ok: #4f7a4a;
  --warn: #a6712c;
  --err: #b3452f;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(24, 24, 24, 0.04);
  --shadow: 0 1px 3px rgba(24, 24, 24, 0.06), 0 8px 24px rgba(24, 24, 24, 0.05);
  --serif: 'Tiempos Text', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body { min-height: 100vh; }

a { color: var(--accent); }

/* ------------------------------------------------------------- structure */

.shell {
  max-width: 940px;
  margin: 0 auto;
  padding: 0 24px 120px;
}

.masthead {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.masthead .inner {
  max-width: 940px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.wordmark {
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: -0.01em;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 9px;
}
.wordmark .spark {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--accent);
  display: inline-block;
  flex: none;
}
.masthead .spacer { flex: 1; }

.crumbs {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}
.crumbs .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
  transition: background 0.2s ease, transform 0.2s ease;
}
.crumbs .dot.done { background: var(--accent-line); }
.crumbs .dot.now { background: var(--accent); transform: scale(1.45); }

/* ---------------------------------------------------------------- screen */

.screen { display: none; padding-top: 44px; animation: rise 0.34s cubic-bezier(0.2, 0.7, 0.3, 1); }
.screen.active { display: block; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 12px;
  font-weight: 500;
}

h1 {
  font-family: var(--serif);
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
  font-weight: 500;
}
h2 {
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.25;
  margin: 0 0 8px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.lede {
  color: var(--muted);
  font-size: 17px;
  max-width: 58ch;
  margin: 0 0 32px;
}

/* --------------------------------------------------------------- bubbles */

.bubbles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  gap: 12px;
  margin-bottom: 34px;
}

.bubble {
  position: relative;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.bubble:hover {
  border-color: var(--accent-line);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.bubble:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.bubble[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.bubble .b-label {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.25;
  display: block;
  margin-bottom: 3px;
}
.bubble .b-sub {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.45;
  display: block;
}

/* --------------------------------------------------------------- concepts */

.concepts { display: grid; gap: 14px; margin-bottom: 32px; }
@media (min-width: 760px) { .concepts { grid-template-columns: 1fr 1fr; } }

.concept {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}
.concept:hover { border-color: var(--accent-line); transform: translateY(-2px); box-shadow: var(--shadow); }
.concept:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.concept[aria-pressed='true'] { border-color: var(--accent); background: var(--accent-soft); }
.concept h3 { font-family: var(--serif); font-size: 21px; margin: 0; font-weight: 500; }
.concept .pitch { color: var(--ink-soft); font-size: 15px; margin: 0; }
.concept dl { margin: 4px 0 0; display: grid; gap: 7px; }
.concept dt {
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--faint); font-weight: 500;
}
.concept dd { margin: 1px 0 0; font-size: 14px; color: var(--muted); line-height: 1.45; }

.tag {
  display: inline-block; font-size: 11.5px; padding: 2px 9px; border-radius: 99px;
  border: 1px solid var(--line-strong); color: var(--muted); background: var(--bg-sunk);
  letter-spacing: 0.02em;
}

/* ----------------------------------------------------------------- cards */

.card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.card > h2 { margin-bottom: 14px; }

.asset-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: baseline; gap: 7px;
  border: 1px solid var(--line); background: var(--bg-sunk);
  border-radius: 9px; padding: 6px 11px; font-size: 13.5px;
}
.chip .role { color: var(--faint); font-size: 12px; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 74px; }
.swatch img {
  width: 74px; height: 74px; border-radius: 10px; display: block;
  border: 1px solid var(--line); object-fit: cover; background: var(--bg-sunk);
}
.swatch .nm {
  font-size: 11px; color: var(--muted); margin-top: 5px; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.kit-preview { display: flex; align-items: center; gap: 14px; }
.kit-dots { display: flex; gap: 5px; }
.kit-dots i { width: 22px; height: 22px; border-radius: 7px; border: 1px solid var(--line); display: block; }

/* --------------------------------------------------------------- models */

.model-list { display: grid; gap: 8px; max-height: 380px; overflow-y: auto; padding-right: 4px; }
.model {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius);
  padding: 13px 16px; cursor: pointer; font: inherit; color: inherit;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.model:hover { border-color: var(--accent-line); }
.model:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.model[aria-pressed='true'] { border-color: var(--accent); background: var(--accent-soft); }
.model .m-name { font-weight: 500; font-size: 15px; }
.model .m-id { font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.model .m-meta { margin-left: auto; text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; padding: 3px; background: var(--bg-sunk); margin-bottom: 16px; }
.segmented button {
  border: 0; background: transparent; font: inherit; font-size: 13.5px; color: var(--muted);
  padding: 6px 15px; border-radius: 99px; cursor: pointer;
}
.segmented button[aria-pressed='true'] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* -------------------------------------------------------------- progress */

.progress { margin: 26px 0 18px; }
.track { height: 5px; border-radius: 99px; background: var(--bg-sunk); overflow: hidden; border: 1px solid var(--line); }
.track > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.35s cubic-bezier(0.3, 0.8, 0.4, 1); }
.progress .now { margin-top: 11px; font-size: 14.5px; color: var(--ink-soft); display: flex; align-items: center; gap: 9px; }

.pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.35; transform: scale(0.82); } 50% { opacity: 1; transform: scale(1); } }

.logbox {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  background: var(--bg-sunk); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; max-height: 260px; overflow-y: auto; color: var(--muted);
}
.logbox div { padding: 1px 0; }
.logbox .warn { color: var(--warn); }
.logbox .err { color: var(--err); }

.specbox {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.65; white-space: pre-wrap;
  background: var(--bg-sunk); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; max-height: 420px; overflow-y: auto; color: var(--ink-soft);
}

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

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

.btn {
  font: inherit; font-size: 15px; font-weight: 500; border-radius: 10px;
  padding: 11px 22px; cursor: pointer; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink);
  transition: filter 0.14s ease, transform 0.14s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.06); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink-soft); border-color: var(--line-strong); }
.btn.ghost:hover:not(:disabled) { background: var(--bg-sunk); filter: none; }
.btn.big { font-size: 16px; padding: 14px 30px; }

.notice {
  border: 1px solid var(--accent-line); background: var(--accent-soft);
  border-radius: var(--radius); padding: 13px 16px; font-size: 14px; color: var(--ink-soft);
  margin-bottom: 16px;
}
.notice.bad { border-color: #e6b3a6; background: #fbeeea; color: var(--err); }

.stat-row { display: flex; gap: 26px; flex-wrap: wrap; margin: 18px 0 4px; }
.stat .k { font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--faint); }
.stat .v { font-family: var(--serif); font-size: 22px; }

.dl {
  display: inline-flex; align-items: center; gap: 11px;
  font-size: 16px; font-weight: 500; padding: 15px 28px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 12px; text-decoration: none;
}
.dl:hover { filter: brightness(1.06); }

.hint { font-size: 13.5px; color: var(--muted); margin-top: 10px; }

.skeleton {
  background: linear-gradient(90deg, var(--bg-sunk) 25%, #e9e7de 50%, var(--bg-sunk) 75%);
  background-size: 300% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-lg);
  height: 132px; border: 1px solid var(--line);
}
@keyframes shimmer { from { background-position: 300% 0; } to { background-position: -300% 0; } }

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

@media (max-width: 620px) {
  .shell { padding: 0 18px 90px; }
  .masthead .inner { padding: 12px 18px; }
  .bubbles { grid-template-columns: 1fr 1fr; gap: 9px; }
  .bubble { padding: 14px 15px; border-radius: 14px; }
  .bubble .b-label { font-size: 16px; }
  .bubble .b-sub { font-size: 12.5px; }
  .card { padding: 18px; }
}
