:root {
  color-scheme: dark;
  --bg: #17181a;
  --panel: #202124;
  --field: #17181a;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --border: #3c4043;
  --accent: #8ab4f8;
  --accent-text: #0b1d3a;
  --ok: #81c995;
  --error: #f28b82;
  --tip: #303134;
}

* { box-sizing: border-box; }

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

.layout {
  display: grid;
  grid-template-columns: var(--options-width, 340px) 6px 1fr;
  height: 100vh;
}

.options {
  overflow-y: auto;
  padding: 16px;
  background: var(--panel);
}

h1 { font-size: 18px; font-weight: 600; margin: 0 0 12px; }

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0 0 12px;
  padding: 8px 12px 4px;
}

legend { color: var(--muted); padding: 0 4px; }

.field {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
}

.field[hidden] { display: none; }

.field .name { flex: 1; }

/* The "?" after a name; the whole row shows the explanation on hover or focus. */
.help-mark {
  display: inline-block;
  margin-left: 4px;
  width: 14px;
  height: 14px;
  border: 1px solid var(--muted);
  border-radius: 50%;
  color: var(--muted);
  font-size: 10px;
  line-height: 12px;
  text-align: center;
}

.tip {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 10;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--tip);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Explanations open only while the pointer is on the "?" mark. */
.field:has(.help-mark:hover) > .tip,
fieldset:has(> legend .help-mark:hover) > .legend-tip { display: block; }

.help-mark { cursor: help; }
fieldset { position: relative; }
.legend-tip { top: 14px; }

.input {
  position: relative;
  flex: none;
  width: 116px;
}

.input input, .input select {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
  font: inherit;
}

.input input { padding-right: 34px; }
.input input.unitless { padding-right: 6px; }
.input:has(select) { width: 150px; }

.unit {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.input input.invalid { border-color: var(--error); }

.field-error {
  color: var(--error);
  font-size: 12px;
  margin: -4px 0 8px;
}

.actions { display: flex; gap: 8px; }

button {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  cursor: pointer;
}

/* While generating automatically, the button is just a status. */
button#generate.state { background: transparent; color: var(--muted); border-color: var(--border); cursor: default; }
button#generate.state.done { color: var(--ok); }
button#generate.state.failed { color: var(--error); }
button#download { background: transparent; color: var(--accent); }
button:disabled { cursor: default; }
button#download:disabled { opacity: 0.5; }

.status { color: var(--muted); min-height: 3em; white-space: pre-line; }
.status.error { color: var(--error); }

.viewer { position: relative; background: #26292e; min-height: 300px; }

canvas { display: block; width: 100%; height: 100%; }

.hint {
  position: absolute;
  bottom: 8px;
  left: 12px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
}

/* Drag sideways to resize the options column. */
.resizer {
  cursor: col-resize;
  background: var(--border);
  touch-action: none;
  position: relative;
}
/* A wider, invisible grab area than the line itself. */
.resizer::before { content: ""; position: absolute; inset: 0 -5px; z-index: 5; }
.resizer:hover, .resizer.dragging { background: var(--accent); }
body.resizing { cursor: col-resize; user-select: none; }

@media (max-width: 720px) {
  .resizer { display: none; }
  .layout { grid-template-columns: 1fr !important; grid-template-rows: auto 60vh; height: auto; }
  .options { border-right: none; border-bottom: 1px solid var(--border); }
  .viewer { height: 60vh; }
}
