:root {
  color-scheme: light;

  --bg: #f6f6f4;
  --panel: #fff;
  --line: #e2e1dc;
  --text: #1c1c1a;
  --muted: #8d8b84;
  --accent: #7a4a33;

  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

header h1 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0;
}

header .back {
  color: var(--muted);
  text-decoration: none;
}

header .meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

nav {
  margin-left: auto;
  display: flex;
  gap: 0.3rem;
}

button,
select,
input[type="text"] {
  font: inherit;
  font-size: 0.78rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.32rem 0.6rem;
  cursor: pointer;
}

input[type="text"],
select {
  cursor: auto;
  width: 100%;
}

button:hover {
  border-color: #b9b7b0;
}

button.active {
  background: #1c1c1a;
  border-color: #1c1c1a;
  color: #fff;
}

button.wide {
  width: 100%;
}

button.ghost {
  color: var(--muted);
}

.shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

aside {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 0.7rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.field {
  display: block;
}

.field > span {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.field.slider b {
  font-family: var(--mono);
  font-weight: 500;
  color: var(--text);
}

.field input[type="range"] {
  width: 100%;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

#overrides {
  padding: 0.3rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

main {
  min-width: 0;
  overflow: auto;
}

.view {
  display: none;
  padding: 1rem;
}

.view.active {
  display: block;
}

#bench.view.active {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 1.4rem;
  align-items: start;
}

.stage {
  display: grid;
  place-items: center;
}

#canvas {
  width: 100%;
  max-width: 640px;
  aspect-ratio: 1 / 1;
  height: auto;
  border: 1px solid var(--line);
  background: #eae4d6;
}

.readout {
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.75;
}

.readout dl {
  display: grid;
  grid-template-columns: 5.6rem 1fr;
  gap: 0 0.6rem;
  margin: 0 0 0.9rem;
}

.readout dt {
  color: var(--muted);
}

.readout dd {
  margin: 0;
}

.readout .pct {
  color: #4a7a5c;
}

.readout .tier {
  color: var(--accent);
}

.plate-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.8rem;
}

.muted {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.7rem;
}

.cell {
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
}

.cell canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
}

.cell figcaption {
  font-family: var(--mono);
  font-size: 0.64rem;
  color: var(--muted);
  padding: 0.28rem 0.4rem;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--line);
}

.tables {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
}

.tables section {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 0.6rem 0.7rem;
}

.tables h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 0 0 0.4rem;
}

.tables ul {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.7;
}

.tables li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.tables li.on {
  color: var(--accent);
  font-weight: 600;
}

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

  aside {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  #bench.view.active {
    grid-template-columns: 1fr;
  }
}

/* Panel de variantes sobre el lienzo */

.stage {
  position: relative;
}

.picker {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

.picker[hidden] {
  display: none;
}

.picker > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--line);
  background: none;
}

.picker > header b {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.picker > header button {
  border: 0;
  padding: 0.1rem 0.3rem;
  color: var(--muted);
  background: none;
}

.picker > header button:hover {
  color: var(--text);
}

.picker .variants {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  align-content: start;
  gap: 0.45rem;
  padding: 0.6rem;
}

.trait-row {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: none;
  padding: 0.38rem 0.1rem;
  text-align: left;
}

.trait-row:last-child {
  border-bottom: 0;
}

.trait-row span {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.trait-row b {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text);
}

.trait-row:hover b,
.trait-row.on b {
  color: var(--accent);
}

.variant {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  background: var(--panel);
  display: block;
  text-align: left;
}

.variant canvas {
  display: block;
  width: 100%;
  height: auto;
}

.variant span {
  display: block;
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--muted);
  padding: 0.2rem 0.3rem;
  border-top: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.variant:hover {
  border-color: #b9b7b0;
}

.variant.on {
  border-color: var(--accent);
}

.variant.on span {
  color: var(--accent);
  font-weight: 600;
}
