:root {
  --page: #0b0c0e;
  --panel: #111316;
  --panel-soft: #15181b;
  --ink: #f2f0e9;
  --muted: #777d7a;
  --line: #292d2d;
  --accent: #c8ff1a;
  --accent-soft: rgba(200, 255, 26, 0.12);
  --danger: #ff5d45;
  --radius: 2px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { color-scheme: dark; scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.noise {
  position: fixed;
  inset: 0;
  z-index: 99;
  pointer-events: none;
  opacity: 0.028;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

.topbar {
  height: 76px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 220px 1fr auto;
  align-items: center;
  gap: 24px;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.17em;
}

.brand-mark { display: grid; grid-template-columns: repeat(3, 4px); gap: 2px; align-items: end; height: 15px; }
.brand-mark i { display: block; width: 4px; background: var(--accent); }
.brand-mark i:nth-child(1) { height: 7px; }
.brand-mark i:nth-child(2) { height: 15px; }
.brand-mark i:nth-child(3) { height: 10px; }

.topbar-note,
.topbar-status {
  margin: 0;
  color: var(--muted);
  font: 600 10px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.16em;
}

.topbar-note { text-align: center; }
.topbar-note span { color: #4e5352; }
.topbar-status { display: flex; align-items: center; gap: 8px; }
.live-dot { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 14px var(--accent); }

.workspace {
  display: grid;
  grid-template-columns: 188px minmax(420px, 1fr) 344px;
  min-height: calc(100vh - 120px);
}

.library,
.inspector { background: var(--panel); }
.library { border-right: 1px solid var(--line); padding: 18px 14px 32px; }
.inspector { border-left: 1px solid var(--line); padding: 18px; }

.library-section + .library-section { margin-top: 30px; }
.section-kicker { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.section-kicker span,
.section-kicker b {
  font: 600 9px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .16em;
}
.section-kicker span { color: var(--muted); }
.section-kicker b { color: var(--accent); font-weight: 500; }

.thumb-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.thumb {
  position: relative;
  padding: 0;
  border: 1px solid var(--line);
  background: #090a0b;
  cursor: pointer;
  aspect-ratio: 1;
  overflow: hidden;
  transition: border-color .18s ease, transform .18s ease;
}
.thumb:hover { border-color: var(--accent); transform: translateY(-1px); }
.thumb svg { display: block; width: 100%; height: 100%; }
.thumb-edition { position: absolute; left: 3px; bottom: 3px; background: rgba(11,12,14,.88); padding: 3px 4px; font: 500 7px/1 ui-monospace, monospace; }
.thumb-delete { position: absolute; inset: 2px 2px auto auto; border: 0; background: rgba(11,12,14,.88); color: var(--muted); width: 18px; height: 18px; cursor: pointer; opacity: 0; }
.thumb:hover .thumb-delete { opacity: 1; }
.thumb-delete:hover { color: var(--danger); }
.empty-state { margin: 18px 2px 0; color: #4e5352; font: 500 9px/1.7 ui-monospace, monospace; letter-spacing: .08em; }

.canvas-column {
  min-width: 0;
  padding: 18px 26px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background:
    linear-gradient(rgba(255,255,255,.017) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.017) 1px, transparent 1px),
    var(--page);
  background-size: 40px 40px;
}

.canvas-toolbar,
.canvas-footer { width: min(100%, 700px); }
.canvas-toolbar { min-height: 44px; display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 14px; }
.canvas-toolbar > div:first-child { display: flex; flex-direction: column; gap: 5px; }
.eyebrow { color: var(--accent); font: 600 8px/1 ui-monospace, monospace; letter-spacing: .2em; }
#posterTitle { font-size: 11px; letter-spacing: .14em; font-weight: 600; }
.refresh-button {
  position: absolute;
  right: 32px;
  bottom: 32px;
  z-index: 4;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--page);
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .34);
  font: 800 10px/1 ui-monospace, monospace;
  letter-spacing: .09em;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.refresh-button span { font-size: 18px; transition: transform .3s ease; }
.refresh-button:hover { background: var(--ink); color: var(--page); transform: translateY(-2px); }
.refresh-button:hover span { transform: rotate(180deg); }
.refresh-button:active { transform: translateY(0); }
.canvas-meta { display: flex; align-items: center; gap: 12px; color: var(--muted); font: 500 8px/1 ui-monospace, monospace; letter-spacing: .11em; }
.rarity-badge { border: 1px solid var(--line); padding: 5px 7px; color: var(--muted); }
.rarity-badge.rare { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.canvas-shell {
  width: min(100%, 700px);
  flex: 1;
  min-height: 460px;
  position: relative;
  display: grid;
  place-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  background: rgba(8, 9, 10, .68);
}

.stage { width: 100%; height: 100%; display: grid; place-items: center; }
.stage svg { display: block; width: 100%; height: auto; max-height: calc(100vh - 195px); filter: drop-shadow(0 22px 38px rgba(0,0,0,.28)); }
.stage[data-format="poster"] svg { width: auto; height: min(100%, calc(100vh - 195px)); max-width: 100%; }

.corner { position: absolute; width: 12px; height: 12px; pointer-events: none; }
.corner-tl { left: 7px; top: 7px; border-left: 1px solid var(--accent); border-top: 1px solid var(--accent); }
.corner-tr { right: 7px; top: 7px; border-right: 1px solid var(--accent); border-top: 1px solid var(--accent); }
.corner-bl { left: 7px; bottom: 7px; border-left: 1px solid var(--accent); border-bottom: 1px solid var(--accent); }
.corner-br { right: 7px; bottom: 7px; border-right: 1px solid var(--accent); border-bottom: 1px solid var(--accent); }

.canvas-footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 12px; color: #565b59; font: 500 8px/1 ui-monospace, monospace; letter-spacing: .12em; }

.primary-action {
  width: 100%;
  min-height: 67px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #0a0b0c;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  padding: 11px 13px;
  transition: filter .18s ease, transform .18s ease;
}
.primary-action:hover { filter: brightness(1.08); transform: translateY(-1px); }
.primary-action:active { transform: translateY(0); }
.action-icon { font-size: 23px; font-weight: 300; }
.primary-action > span:nth-child(2) { font-size: 12px; letter-spacing: .11em; font-weight: 800; line-height: 1.25; }
.primary-action small { display: block; font-size: 7px; letter-spacing: .16em; font-weight: 600; opacity: .58; }
kbd { border: 1px solid rgba(0,0,0,.28); padding: 5px 6px; font: 600 7px/1 ui-monospace, monospace; }

.control-card { margin-top: 12px; padding: 15px; border: 1px solid var(--line); background: rgba(255,255,255,.008); }
.control-heading { margin-bottom: 13px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.control-heading > div { display: flex; align-items: center; gap: 9px; }
.control-heading span { color: var(--accent); font: 500 8px/1 ui-monospace, monospace; }
.control-heading h2 { margin: 0; font-size: 10px; letter-spacing: .18em; font-weight: 700; }
.control-heading p { margin: 8px 0 0 24px; color: var(--muted); font-size: 9px; letter-spacing: .05em; }
.control-heading.compact { display: flex; justify-content: space-between; align-items: center; }
.control-heading output { color: var(--accent); font: 600 11px/1 ui-monospace, monospace; }

.trait-row { display: grid; grid-template-columns: 68px 1fr 25px 43px; align-items: center; gap: 6px; min-height: 34px; }
.trait-row + .trait-row { border-top: 1px solid rgba(41,45,45,.6); }
.trait-label { color: var(--muted); font: 500 8px/1 ui-monospace, monospace; letter-spacing: .12em; }
.trait-value { border: 0; background: transparent; text-align: left; padding: 5px 0; cursor: pointer; font-size: 9px; font-weight: 700; letter-spacing: .1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trait-value:hover { color: var(--accent); }
.reroll-button,
.lock-button { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 5px 2px; }
.reroll-button:hover,
.lock-button:hover { color: var(--ink); }
.lock-button { font: 600 7px/1 ui-monospace, monospace; letter-spacing: .08em; text-align: right; }
.lock-button.active { color: var(--accent); }

.range-wrap { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; color: var(--muted); font: 500 7px/1 ui-monospace, monospace; letter-spacing: .09em; }
input[type="range"] { appearance: none; height: 2px; background: linear-gradient(90deg, var(--accent) var(--fill, 50%), var(--line) var(--fill, 50%)); outline: none; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 11px; height: 16px; border: 1px solid var(--accent); background: var(--panel); cursor: ew-resize; }
input[type="range"]::-moz-range-thumb { width: 10px; height: 15px; border: 1px solid var(--accent); border-radius: 0; background: var(--panel); cursor: ew-resize; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; min-height: 31px; color: var(--muted); font: 500 8px/1 ui-monospace, monospace; letter-spacing: .12em; }
.toggle { width: 32px; height: 17px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: #0b0c0e; cursor: pointer; }
.toggle i { display: block; width: 11px; height: 11px; border-radius: 50%; background: #555b59; transition: .18s ease; }
.toggle.active { border-color: var(--accent); }
.toggle.active i { background: var(--accent); transform: translateX(15px); }

.field-label { display: block; margin: 0 0 6px; color: var(--muted); font: 500 7px/1 ui-monospace, monospace; letter-spacing: .12em; }
.seed-label { margin-top: 11px; }
.text-field,
.select-field { width: 100%; height: 34px; border: 1px solid var(--line); border-radius: 0; background: #0d0f11; color: var(--ink); padding: 0 10px; outline: none; font: 600 9px/1 ui-monospace, monospace; letter-spacing: .1em; }
.text-field:focus,
.select-field:focus { border-color: var(--accent); }
.text-field::placeholder { color: #484c4b; }
.inline-field { display: grid; grid-template-columns: 1fr auto; }
.inline-field .text-field { border-right: 0; }
.small-button { border: 1px solid var(--line); background: #171a1d; padding: 0 11px; color: var(--muted); font: 600 8px/1 ui-monospace, monospace; cursor: pointer; }
.small-button:hover { color: var(--accent); border-color: var(--accent); }
.select-field { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 14px) 14px, calc(100% - 10px) 14px; background-size: 4px 4px; background-repeat: no-repeat; }
.button-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 9px; }
.outline-button,
.soft-button { min-height: 34px; cursor: pointer; font: 700 8px/1 ui-monospace, monospace; letter-spacing: .12em; }
.outline-button { display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--ink); background: transparent; padding: 0 10px; }
.outline-button:hover { background: var(--ink); color: var(--page); }
.outline-button span { color: var(--accent); }
.outline-button:hover span { color: var(--page); }
.secondary-actions { margin-top: 7px; }
.soft-button { border: 1px solid var(--line); background: var(--panel-soft); color: var(--muted); }
.soft-button:hover { color: var(--accent); border-color: var(--accent); }

.site-footer { min-height: 44px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 0 24px; color: #4e5352; font: 500 8px/1 ui-monospace, monospace; letter-spacing: .13em; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; padding: 12px 16px; background: var(--accent); color: #080909; font: 700 9px/1 ui-monospace, monospace; letter-spacing: .1em; transform: translateY(24px); opacity: 0; pointer-events: none; transition: .22s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1120px) {
  .workspace { grid-template-columns: minmax(390px, 1fr) 330px; }
  .library { grid-column: 1 / -1; grid-row: 2; border-right: 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
  .library-section + .library-section { margin-top: 0; }
  .thumb-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .topbar { height: 64px; grid-template-columns: 1fr auto; padding: 0 16px; }
  .topbar-note { display: none; }
  .topbar-status { font-size: 7px; }
  .workspace { display: flex; flex-direction: column; }
  .canvas-column { order: 1; padding: 14px; }
  .inspector { order: 2; border-left: 0; border-top: 1px solid var(--line); padding: 14px; }
  .library { order: 3; display: block; padding: 16px 14px 28px; }
  .library-section + .library-section { margin-top: 26px; }
  .thumb-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .canvas-shell { min-height: 320px; padding: 12px; }
  .stage svg { max-height: 66vh; }
  .canvas-footer { font-size: 6px; }
  .site-footer { padding: 0 16px; font-size: 6px; }
}

@media (max-width: 420px) {
  .topbar-status { display: none; }
  .topbar { grid-template-columns: 1fr; }
  .canvas-meta { flex-direction: column; align-items: flex-end; gap: 5px; }
  .refresh-button { right: 22px; bottom: 22px; min-height: 38px; padding: 0 12px; font-size: 9px; }
  .canvas-footer span:nth-child(2) { display: none; }
  .thumb-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
