:root {
  --bg: #f4f6f2;
  --panel: #ffffff;
  --text: #1f2a22;
  --muted: #637066;
  --line: #dde3dc;
  --accent: #3f7a4f;
  --accent-soft: #e3eee5;
  --error: #a33a2c;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151a16;
    --panel: #1d241f;
    --text: #e4eae5;
    --muted: #9aa69d;
    --line: #2f3a32;
    --accent: #7cbf8b;
    --accent-soft: #263a2b;
    --error: #ef8a7a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.app {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  /* The visible height: 100vh reaches under the browser's toolbars on iPad. */
  height: 100vh;
  height: 100dvh;
}

.controls {
  overflow-y: auto;
  padding: 20px 20px 40px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

h1 { margin: 0 0 4px; font-size: 1.5rem; }
header p { margin: 0 0 16px; color: var(--muted); }

.models {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.models a {
  flex: 1;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--text);
  text-align: center;
  text-decoration: none;
}
.models a:hover { background: var(--accent-soft); }
.models a[aria-current="page"] { background: var(--accent); color: var(--panel); font-weight: 600; }

.base { margin: 0 0 14px; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); font-size: 0.85rem; }
.base a { color: var(--accent); font-weight: 600; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }

button {
  font: inherit;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
button.quiet { color: var(--muted); }

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

details.group { border-top: 1px solid var(--line); padding: 12px 0 4px; }
details.group summary { font-weight: 600; color: var(--accent); cursor: pointer; }
details.group summary .quiet { margin-left: 6px; font-weight: 400; font-size: 0.85rem; color: var(--muted); }
details.group fieldset { border: 0; padding: 4px 0 0; }

.field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 2px 8px;
  margin: 8px 0 12px;
}
.field .name { font-weight: 500; }
.field .value { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.field .value input {
  width: 7ch;
  margin-right: 4px;
  padding: 2px 4px;
  font: inherit;
  text-align: right;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.field .value input:invalid { box-shadow: none; }
.field .value input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.field input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }
.field .hint { grid-column: 1 / -1; font-size: 0.85rem; color: var(--muted); }
.field.check { grid-template-columns: auto 1fr; }
.field.vector .cells { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.field.vector .cell { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 0.8rem; color: var(--muted); }
.field.vector input[type="checkbox"] { width: 20px; height: 20px; margin: 4px 0; accent-color: var(--accent); }
.field.vector select {
  font: inherit;
  font-size: 0.95rem;
  padding: 3px 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
}
.field.check input { accent-color: var(--accent); }

.preview { position: relative; min-height: 0; }
#viewer { position: absolute; inset: 0; z-index: 0; }  /* keeps the labels' z-indexes inside */
#viewer canvas { display: block; width: 100%; height: 100%; }
#viewer .labels { position: absolute; inset: 0; pointer-events: none; }
/* Labels that belong to a group of settings show while that group is open. */
body:has(details[data-labels]:not([open])) #viewer .labels { visibility: hidden; }
.label {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--panel);
  font-size: 0.8rem;
  font-weight: 600;
}

.status {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 1;
  pointer-events: none;
}
.status p {
  display: inline-block;
  margin: 4px 0 0;
  padding: 6px 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--line);
  pointer-events: auto;
}
/* The render's summary stays hidden until Details opens it; a tap on it
   closes it again. */
.status .summary { display: block; width: fit-content; max-width: 100%; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.status .summary:not(.open) { display: none; }
.status .summary span { display: block; }
#exports p { display: flex; width: fit-content; }
.status .busy { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; color: var(--muted); }
.status .elapsed { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.status progress { width: 120px; height: 6px; accent-color: var(--accent); }
.status .error { color: var(--error); border-color: var(--error); }
.status .actions { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; width: fit-content; }
.status button.link {
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  white-space: nowrap;
}
.status .quiet { color: var(--muted); font-size: 0.85rem; }

.footer { margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 0.85rem; }
.footer a, .document a { color: var(--accent); }

/* The licences page: a plain document. */
.document { max-width: 860px; margin: 0 auto; padding: 24px 20px 60px; }
.document h2 { margin-top: 32px; }
.document code { font-size: 0.9em; }
.document .note { color: var(--muted); font-size: 0.9rem; }
.document .files { padding-left: 20px; }
.document .files li { margin: 4px 0; }
.packages { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.packages th, .packages td { text-align: left; vertical-align: top; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.packages th { color: var(--muted); font-weight: 600; }
.packages .text-link + .text-link::before { content: " · "; color: var(--muted); }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 55svh auto; height: auto; }
  .preview { order: -1; height: 55svh; }
  .controls { border-right: 0; border-top: 1px solid var(--line); }

  .status { left: 8px; right: 8px; bottom: 8px; font-size: 0.9rem; }
  .status .wide { display: none; }
}

