:root {
  --bg: #13100e;
  --panel: #1b1714;
  --card: #211c18;
  --raised: #25201b;
  --line: #342c25;
  --text: #ebe2d3;
  --label: #cdbfac;
  --muted: #9c907f;
  --accent: #cda65c;
  --accent-ink: #1a1408;
  --accent-soft: rgba(205, 166, 92, 0.16);
  --overlay: rgba(20, 16, 13, 0.72);
  --stage: #0f0c0a;
  --switch-off: #3c332b;
  --knob: #b5a998;
  --warn: #e0a54a;
  --warn-text: #ecc98e;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 var(--sans);
}

body { display: flex; flex-direction: column; }

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

button {
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--raised);
  cursor: pointer;
  white-space: nowrap;
}

button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

button.primary:hover { filter: brightness(1.08); }
button.primary:disabled { opacity: 0.6; cursor: progress; }
button.ghost { background: transparent; }
button.on { border-color: var(--accent); color: var(--accent); }

select option { background: var(--panel); color: var(--text); }

/* Shared layout for every maker. An app re-themes it by overriding the
   variables in :root from its own theme.css. */

/* ---- top bar ---- */

.bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

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

.mark {
  width: 28px;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent) 0 34%, #7d6337 34% 100%);
  transform: rotate(-24deg);
}

h1 { margin: 0; font: 600 20px/1 var(--serif); letter-spacing: 0.02em; }

.presets {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

/* the preset chips flow inline with "Surprise me" and "Reset" */
.chips { display: contents; }
.divider { flex: none; width: 1px; height: 18px; margin: 0 4px; background: var(--line); }

.chip {
  flex: none;
  height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  font-size: 12px;
}

.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.actions { display: flex; align-items: center; gap: 8px; flex: none; }

.name, .actions select {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}

.name { width: 150px; font-family: var(--serif); font-size: 14px; }
.name::placeholder { color: var(--muted); font-style: italic; }

/* ---- layout ---- */

main { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 240px;
  overflow: hidden;
  background: var(--stage);
}

#scene, #view {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

#scene { pointer-events: none; }
#view { touch-action: none; cursor: grab; }
#view:active { cursor: grabbing; }

.overlay {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.overlay > * { pointer-events: auto; }
.top-left { top: 12px; left: 12px; }
.top-right { top: 12px; right: 12px; }

.bottom {
  left: 12px;
  right: 12px;
  bottom: 10px;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.overlay button, .scene-pick {
  background: var(--overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.toggle-group { display: flex; }
.toggle-group button { border-radius: 0; margin-left: -1px; }
.toggle-group button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.toggle-group button:last-child { border-radius: 0 6px 6px 0; }
.toggle-group button.on { position: relative; }

.scene-pick {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 32px;
  padding: 0 2px 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.scene-pick span { color: var(--muted); font-size: 12px; }
.scene-lock.on { border-color: var(--accent); color: var(--accent); }

.scene-pick select {
  height: 30px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  font-family: var(--serif);
  font-size: 14px;
  cursor: pointer;
}

.stats, .help, .notes {
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.stats { display: flex; flex-wrap: wrap; gap: 2px 16px; font-variant-numeric: tabular-nums; }
.stats:empty { display: none; }
.stats span { color: var(--muted); }
.stats b { margin-left: 5px; font-weight: 500; color: var(--text); }
.help { color: var(--muted); font-size: 11.5px; opacity: 0.85; }
.notes { color: var(--label); font-size: 12px; }
.notes:empty { display: none; }

.warnings { display: flex; flex-direction: column; gap: 4px; max-width: 560px; }

.warnings div {
  padding: 4px 10px;
  border-left: 2px solid var(--warn);
  border-radius: 0 4px 4px 0;
  background: var(--overlay);
  color: var(--warn-text);
  font-size: 12px;
}

.status {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 420px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
}

/* ---- control dock: every category visible at once ---- */

.dock {
  flex: 0 1 auto;
  max-height: 58vh;
  overflow-y: auto;
  border-top: 1px solid var(--line);
  background: var(--panel);
  scrollbar-color: var(--line) transparent;
}

.cards {
  columns: 262px;
  column-gap: 10px;
  padding: 10px 12px 0;
}

.card {
  break-inside: avoid;
  margin: 0 0 10px;
  padding: 5px 10px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

.card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 24px;
  margin-bottom: 1px;
}

.card h3 { margin: 0; font: 600 13.5px/1 var(--serif); letter-spacing: 0.01em; }
.card h3 label { cursor: pointer; }
.card.off h3 { color: var(--muted); }
.card.off .row { opacity: 0.42; }
.card.off .row:hover, .card.off .row:focus-within { opacity: 0.85; }

.row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 50px;
  align-items: center;
  gap: 8px;
  min-height: 22px;
}

.row > label, .row > .lbl {
  overflow: hidden;
  color: var(--label);
  font-size: 11.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.row .hinted {
  text-decoration: underline dotted var(--accent);
  text-underline-offset: 3px;
  cursor: help;
}

.row output {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.row.na { opacity: 0.3; }
.card.off .row.na { opacity: 0.2; }
.row .seg, .row select, .row .swatch-row { grid-column: 2 / 4; }

.swatch-row { display: flex; flex-wrap: wrap; gap: 3px; padding: 4px 0 4px 2px; }

.swatch {
  flex: none;
  width: 14px;
  height: 14px;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
}

.swatch.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--accent); }

input[type="range"] {
  width: 100%;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  background: transparent;
}
input[type="range"][list] { height: 22px; }  /* room for the notch marks */

.row select {
  height: 22px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  font-size: 11.5px;
}

.seg { display: flex; }

.seg button {
  flex: 1;
  height: 22px;
  margin-left: -1px;
  padding: 0 4px;
  border-radius: 0;
  background: var(--bg);
  font-size: 11.5px;
}

.seg button:first-child { margin-left: 0; border-radius: 5px 0 0 5px; }
.seg button:last-child { border-radius: 0 5px 5px 0; }
.seg button.on { position: relative; z-index: 1; background: var(--accent-soft); }

.text-in {
  min-width: 0;
  height: 25px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  font: 600 14px/1 var(--serif);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.text-in::placeholder { color: var(--muted); opacity: 0.7; font-weight: 400; letter-spacing: 0.04em; text-transform: none; font-style: italic; }
.mini { height: 23px; padding: 0 6px; font-size: 11px; }

.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 28px;
  height: 16px;
  margin: 0;
  border-radius: 8px;
  background: var(--switch-off);
  cursor: pointer;
  transition: background 0.12s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--knob);
  transition: transform 0.12s, background 0.12s;
}

.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(12px); background: var(--accent-ink); }

/* ---- steps: the controls split into numbered pages ---- */

.steps {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 14px 0 5px;
  border-color: transparent;
  border-radius: 15px;
  background: transparent;
  color: var(--muted);
  font: 600 14px/1 var(--serif);
}

.step .num {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  font: 700 11px/1 var(--sans);
}

.step.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.step.on .num { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.step.done .num { border-color: var(--accent); color: var(--accent); }
.step-line { flex: none; width: 26px; height: 1px; background: var(--line); }
.steps .spacer { flex: 1; }

.steps .go {
  height: 30px;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.steps .go.back { border-color: var(--line); background: transparent; color: var(--text); font-weight: 400; }

/* a roomy page keeps at least half the screen for the 3D view; the controls scroll */
.roomy .stage { min-height: 50vh; }
.roomy .dock { max-height: 44vh; }

/* each step takes only the room it needs, so the 3D view grows on short steps */
.pane.away { display: none; }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  align-content: start;
  gap: 10px;
  padding-bottom: 10px;
  columns: auto;
}

.cards-grid .card { margin: 0; }
.card.wide { column-span: all; }

/* ---- full-width choices: emoji tiles, standard sizes, large swatches ---- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.row-full { margin: 3px 0 6px; }
.row-full > .lbl { display: block; margin: 2px 0 5px; color: var(--label); font-size: 11.5px; }

.tiles { display: flex; flex-wrap: wrap; gap: 5px; }

.tile {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 27px;
  padding: 0 9px 0 6px;
  border-radius: 14px;
  background: var(--bg);
  font-size: 11.5px;
}

.tile .ico {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: 14px;
  line-height: 1;
}

.tile.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }

/* the second ("every other") pick: a dashed outline and a small 2 */
.tile.alt { border-style: dashed; border-color: var(--accent); }

.tile.alt::after {
  content: "2";
  position: absolute;
  top: -6px;
  right: -4px;
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font: 700 9px/1 var(--sans);
}

.picking-alt .tile.on:not(.alt) { opacity: 0.55; }
.picking-alt .tiles { outline: 1px dashed var(--accent-soft); outline-offset: 4px; border-radius: 8px; }

.tile-mode { display: flex; align-items: center; gap: 5px; margin: 0 0 7px; }
.tile-mode button { height: 24px; padding: 0 10px; border-radius: 12px; background: var(--bg); font-size: 11.5px; }
.tile-mode button.on { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.tile-mode .mini { height: 22px; }

.rows-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  column-gap: 22px;
  margin-top: 2px;
}

.step-tools { display: flex; gap: 6px; margin-right: 6px; }

/* shape buttons: a picture of each style above its name */
.tiles.shapes { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; }

.tiles.shapes .tile {
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  height: auto;
  min-width: 0;
  padding: 6px 1px 5px;
  border-radius: 9px;
  font-size: 10.5px;
}

.tile svg.shape { width: 34px; height: 15px; fill: var(--muted); fill-rule: evenodd; }
.tile:hover svg.shape { fill: var(--text); }
.tile.on svg.shape { fill: var(--accent); }

/* hieroglyph buttons: the glyph drawn as lines, as it is carved */
.tile svg.glyph {
  width: 13px;
  height: 17px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tile:hover svg.glyph { stroke: var(--text); }
.tile.on svg.glyph { stroke: var(--accent); }

.tiles.tall { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }

.tiles.tall .tile {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 1px 9px;
  height: auto;
  padding: 8px 12px;
  border-radius: 10px;
  text-align: left;
}

.tiles.tall .ico { grid-row: span 2; font-size: 24px; }
.tiles.tall .txt { font: 600 14px/1.2 var(--serif); }
.tiles.tall .note { color: var(--muted); font-size: 11px; }

.quick { display: grid; gap: 5px; margin: 4px 0 6px; }

.quick button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  height: auto;
  padding: 6px 2px;
  border-radius: 9px;
  background: var(--bg);
  font-size: 12.5px;
}

.quick button small { color: var(--muted); font-size: 10.5px; }
.quick button.on { border-color: var(--accent); background: var(--accent-soft); }

.swatch-row.large { gap: 8px 2px; padding: 2px 0; }

.swatch-big {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 54px;
  height: auto;
  padding: 2px 0;
  border: 0;
  background: transparent;
}

.swatch-big .dot {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
}

.swatch-big .lab { color: var(--muted); font-size: 10.5px; line-height: 1.2; text-align: center; }
.swatch-big.on .dot { border-color: var(--text); box-shadow: 0 0 0 2px var(--accent); }
.swatch-big.on .lab { color: var(--text); }

/* ---- accounts: dialogs, menu, saved designs, toast ---- */

.actions .account { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.actions .account.signed-in { border-color: var(--accent); color: var(--accent); }

dialog.sheet {
  width: min(860px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 48px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

dialog.sheet.narrow { width: min(400px, calc(100vw - 32px)); }
dialog.sheet [hidden] { display: none; }
dialog.sheet::backdrop { background: rgba(10, 6, 12, 0.6); backdrop-filter: blur(3px); }
dialog.sheet form, dialog.sheet > .design-grid { padding: 0 20px 20px; }

dialog.sheet header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px 12px;
  background: var(--panel);
}

dialog.sheet h2 { flex: 1; margin: 0; font: 600 20px/1.2 var(--serif); }
dialog.sheet .close { width: 32px; padding: 0; }
dialog.sheet .lead { margin: 0 0 14px; color: var(--muted); }

.auth-tabs { display: flex; margin-bottom: 14px; border-bottom: 1px solid var(--line); }

.auth-tabs button {
  height: 34px;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.auth-tabs button.on { border-bottom-color: var(--accent); color: var(--text); }
.field { display: block; margin-bottom: 12px; color: var(--label); font-size: 12.5px; }
.field .opt { color: var(--muted); font-size: 11.5px; }

.field input {
  display: block;
  width: 100%;
  height: 36px;
  margin-top: 5px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg);
  font-size: 14px;
}

.form-error { min-height: 18px; margin: 0 0 10px; color: var(--warn-text); font-size: 12.5px; }
button.wide { width: 100%; height: 38px; }

.account-menu {
  position: fixed;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 190px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.account-menu[hidden] { display: none; }
.account-menu button { justify-content: flex-start; border: 0; background: transparent; text-align: left; }
.account-menu button:hover, .account-menu button:focus-visible { background: var(--accent-soft); }
.account-menu .menu-link {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 14px;
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
}
.account-menu .menu-link:hover, .account-menu .menu-link:focus-visible { background: var(--accent-soft); }
a.home-link { color: inherit; text-decoration: none; }

.design-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  overflow-y: auto;
}

.design-grid .empty { grid-column: 1 / -1; margin: 20px 0 30px; color: var(--muted); text-align: center; }

.design-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}

/* the Save dialog: the picture that will be kept, the name, and the choices */
.save-pic {
  position: relative;
  aspect-ratio: 16 / 10;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--thumb-bg, #2b2229);
}

.save-pic img { display: block; width: 100%; height: 100%; object-fit: cover; }
.save-pic img:not([src]) { visibility: hidden; }

.save-pic .pic-note {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

.save-pic .pic-note[hidden] { display: none; }
.save-sheet .field input { font-family: var(--serif); font-size: 15px; }
.save-sheet .field input[aria-invalid="true"] { border-color: var(--warn); }
.save-note { margin: -4px 0 6px; color: var(--muted); font-size: 12px; }
.save-actions { display: flex; justify-content: flex-end; gap: 8px; }
.save-actions button { height: 38px; }
.save-actions .primary { min-width: 120px; }

.unsaved-note {
  margin: 0 20px 14px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--warn-text);
  font-size: 12.5px;
}

.unsaved-note[hidden] { display: none; }

.design-card .pic { position: relative; aspect-ratio: 16 / 10; background: var(--thumb-bg, #2b2229); }
.design-card img { display: block; width: 100%; height: 100%; object-fit: cover; }

.design-card .badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 600;
}

.design-card h3 {
  margin: 10px 12px 2px;
  overflow: hidden;
  font: 600 14.5px/1.3 var(--serif);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.design-card .date { margin: 0 12px 10px; color: var(--muted); font-size: 11.5px; }
.card-actions { display: flex; gap: 6px; margin-top: auto; padding: 0 12px 12px; }
.card-actions button { flex: 1; height: 30px; }
.card-actions .confirm { border-color: var(--warn); color: var(--warn-text); }
.card-actions .primary.confirm { background: transparent; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1360px) {
  .bar { flex-wrap: wrap; row-gap: 8px; }
  .presets { order: 3; flex-basis: 100%; }
  .actions { margin-left: auto; }
}

@media (max-width: 720px) {
  .steps .go { display: none; }
  .step { padding-right: 8px; font-size: 12.5px; }
  .bar { padding: 8px 12px; }
  .name { width: 120px; }
  #quality, .help, .scene-pick span { display: none; }
  .dock { max-height: 50vh; }
  .stage { min-height: 42vh; }
}
