:root {
  --bg: #100f0c;
  --panel: #1b1914;
  --ink: #f4efe6;
  --muted: #b3aa9c;
  --line: #3c352c;
  --accent: #ff5a1f;
  --accent-ink: #1a0d07;
  --well: #070706;
  --danger: #ff8d7a;
  --focus: #ffb088;
  --sans: Outfit, "Avenir Next", "Segoe UI", sans-serif;
  --display: Anton, Impact, "Arial Black", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(255, 90, 31, 0.22), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
}

button, input { font: inherit; color: inherit; }

button { cursor: pointer; }

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.top {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--display);
  font-size: 28px;
  line-height: 1;
  border-radius: 12px;
}

.kicker {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 0.02em;
}

h1 { font-size: 2.35rem; line-height: 0.9; }

.lede {
  margin: 0;
  color: var(--muted);
  max-width: 42ch;
}

main {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.stage { order: -1; }

.panel {
  background: rgba(27, 25, 20, 0.94);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  min-width: 0;
}

fieldset {
  border: 0;
  margin: 0 0 14px;
  padding: 0;
}

legend, .field > span:first-child {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.choices button,
.file span,
.actions button,
.shelf-head button,
.photo-row button,
.shelf-list .remove {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #262219;
  padding: 0 14px;
}

.choices button[aria-pressed="true"] {
  background: var(--ink);
  color: #16140f;
  border-color: transparent;
  font-weight: 600;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.swatch {
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  padding: 0;
  border-radius: 50%;
  border: 2px solid #4a433a;
}

.swatch[aria-pressed="true"] {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink);
}

.field { display: block; margin-bottom: 14px; }

.field[hidden],
button[hidden],
.empty[hidden] { display: none !important; }

.field input[type="text"] {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--well);
}

.topic-row, .photo-row, .actions, .shelf-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.topic-row input { flex: 1 1 140px; }

#forge-btn, #clear-photo, #clear-shelf {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #262219;
  padding: 0 14px;
}

.hint, .empty, .status {
  color: var(--muted);
  font-size: 0.82rem;
}

.hint { display: block; margin-top: 6px; }

.file { position: relative; }

.file input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.file span {
  display: inline-flex;
  align-items: center;
}

.canvas-wrap {
  background: var(--well);
  border-radius: 14px;
  padding: 10px;
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  background: #000;
}

.canvas-wrap.hot { outline: 2px dashed var(--accent); outline-offset: -6px; }

.status { min-height: 1.2em; margin: 10px 0 0; }

.status[data-kind="error"] { color: var(--danger); }

.actions { margin-top: 10px; }

.actions .primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 600;
  flex: 1 1 140px;
}

.shelf { margin-top: 22px; }

.shelf-head { justify-content: space-between; margin-bottom: 10px; }

.shelf-head h2 { font-size: 1.6rem; }

.shelf-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.shelf-list li {
  display: grid;
  gap: 6px;
}

.thumb {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--well);
  overflow: hidden;
}

.thumb img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.shelf-list .remove {
  width: 100%;
  min-height: 36px;
  font-size: 0.82rem;
}

button:hover, .file span:hover { border-color: #6d5f50; }

.primary:hover { filter: brightness(1.05); }

button:focus-visible,
input:focus-visible,
.file:focus-within span {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (min-width: 900px) {
  .wrap { padding: 22px 28px 48px; }
  .top {
    grid-template-columns: auto 1fr;
    align-items: end;
    gap: 24px;
    margin-bottom: 18px;
  }
  .lede { justify-self: end; text-align: right; }
  main {
    grid-template-columns: 320px minmax(0, 1fr);
    align-items: start;
    gap: 18px;
  }
  .stage { order: 0; }
  .controls {
    position: sticky;
    top: 12px;
    max-height: calc(100vh - 24px);
    overflow: auto;
  }
  .canvas-wrap canvas {
    width: auto;
    max-width: 100%;
    max-height: calc(100vh - 220px);
    margin-inline: auto;
  }
}

@media (max-width: 374px) {
  .choices { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
