* { box-sizing: border-box; }

@font-face { font-family: Lato; src: url(fonts/lato-regular.woff2) format("woff2"); font-weight: 400; }
@font-face { font-family: Lato; src: url(fonts/lato-bold.woff2) format("woff2"); font-weight: 700; }

/* vlad.studio palette; theme follows the OS setting. */
:root {
  color-scheme: light dark;
  --text: light-dark(hsl(32 2% 20%), hsl(20 6% 94%));
  --text-2: light-dark(hsl(32 3% 34%), hsl(20 6% 78%));
  --text-3: light-dark(hsl(32 4% 47%), hsl(20 6% 60%));
  --accent: hsl(18 82% 55%);
  --link-hover: light-dark(hsl(24 67% 40%), hsl(24 70% 70%));
  --primary: light-dark(hsl(180 50% 40%), hsl(160 60% 30%));
  --primary-hover: light-dark(hsl(180 50% 34%), hsl(160 60% 36%));
  --panel: light-dark(hsl(24 80% 98%), hsl(210 5% 18%));
  --stage: light-dark(hsl(24 64% 94%), hsl(210 5% 12%));
  --field: light-dark(#fff, hsl(210 5% 14%));
  --button: light-dark(#fff, hsl(210 5% 22%));
  --border: light-dark(hsl(24 30% 80%), hsl(210 5% 40% / 0.7));
  --divider: light-dark(hsl(24 64% 70% / 0.3), hsl(210 5% 40% / 0.4));
  --hover: light-dark(hsl(24 80% 95%), hsl(210 5% 26%));
  --outline: light-dark(hsl(24 70% 64% / 0.3), hsl(24 70% 50% / 0.2));
  --err: light-dark(hsl(12 80% 55%), hsl(5 60% 50%));
  --check: light-dark(hsl(24 30% 88%), hsl(210 5% 24%));
  --overlay: light-dark(hsl(0 0% 100% / 0.92), hsl(210 5% 18% / 0.92));
  --shadow: light-dark(hsl(36 2% 24% / 0.15), rgba(0, 0, 0, 0.5));
  --range-fill: light-dark(hsl(18 82% 55% / 0.35), hsl(18 82% 56% / 0.45));
  --range-empty: light-dark(hsl(24 30% 50% / 0.18), hsl(210 5% 50% / 0.3));
  --track: light-dark(hsl(24 30% 50% / 0.12), rgba(255, 255, 255, 0.1));
  accent-color: var(--accent);
}

html, body {
  margin: 0;
  height: 100%;
  font: 13px/1.4 Lato, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
}

body { display: flex; }

#panel {
  width: 320px;
  flex: none;
  height: 100%;
  overflow-y: auto;
  padding: 16px 18px 24px;
  background: var(--panel);
  border-right: 1px solid var(--divider);
}

h1 { font-size: 17px; letter-spacing: -0.01em; margin: 0 0 12px; }
h1 a { color: var(--accent); text-decoration: none; }

h2 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin: 0 0 8px;
}

section { padding: 12px 0; border-top: 1px solid var(--divider); }

label { display: block; color: var(--text-2); }

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

input:not([type]), input[type="number"], select {
  width: 100%;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--field);
}

input[type="color"] {
  width: 36px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--field);
}

button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--button);
  cursor: pointer;
  white-space: nowrap;
}

button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button:focus-visible { outline: 2px solid var(--outline); outline-offset: 2px; }

/* No hover styles on touch screens, where they stick after a tap. */
@media (hover: hover) {
  button:hover { background: var(--hover); }
  button.primary:hover { background: var(--primary-hover); }
  h1 a:hover { color: var(--link-hover); }
}

.row { display: flex; gap: 6px; align-items: center; }
.grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }

.check { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.row .check { margin-top: 0; }

.shapes { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.shapes svg {
  width: 34px;
  height: 34px;
  background: var(--field);
  border: 1px solid var(--divider);
  border-radius: 4px;
}
.msg { font-size: 12px; color: var(--text-3); margin: 6px 0 0; }
.msg.err { color: var(--err); }
.msg:empty { display: none; }

.colors { display: grid; grid-template-columns: 1fr 1fr 52px; gap: 8px; }
.colors input[type="color"] { flex: none; width: 28px; }
.colors input:not([type]) { min-width: 0; font-variant-numeric: tabular-nums; }

.swatches { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.swatches span {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.slider { display: grid; grid-template-columns: 78px 1fr 64px; gap: 8px; align-items: center; margin-bottom: 6px; }
.slider input[type="range"] { width: 100%; }

/* Thin track: subtle orange up to the knob (--fill, set by paintRange), a faint line after it. */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 16px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--range-fill) var(--fill, 0%), var(--range-empty) 0);
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--range-empty); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--range-fill); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
}
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border: none; border-radius: 50%; background: var(--accent); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--outline); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--outline); }
.slider input[type="number"] { padding: 3px 5px; }
.slider.sub label { color: var(--text-3); }
.hint { font-size: 11px; color: var(--text-3); margin: -2px 0 0; }

/* Groups with a select show their sliders only for one option (see buildSliders). */
.has-select > select { margin-bottom: 8px; }
.has-select.collapsed > select { margin-bottom: 0; }
.has-select.collapsed .slider, .has-select.collapsed .hint { display: none; }

button.wide { width: 100%; margin-top: 10px; padding: 8px; }

.actions { display: flex; gap: 8px; }
.actions button { flex: 1; padding: 8px; }

#stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--stage);
}

#viewport {
  position: absolute;
  inset: 0;
  overflow: auto;
  display: flex;
}

#frame { margin: auto; }

#frame svg {
  display: block;
  cursor: zoom-in;
  background-color: var(--field);
  background-image: conic-gradient(var(--check) 25%, var(--field) 0 50%, var(--check) 0 75%, var(--field) 0);
  background-size: 16px 16px;
}

#frame.actual svg { cursor: zoom-out; }

#status, #pending .label {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 11px;
  border-radius: 4px;
  background: var(--overlay);
  box-shadow: 0 1px 4px var(--shadow);
  color: var(--text-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}

#status { bottom: 14px; }
#status:empty { display: none; }

/* Shown only while a generation runs longer than a moment (see setPending). */
#pending { display: none; position: absolute; inset: 0 0 auto; pointer-events: none; }
body.pending #pending { display: block; }
#pending .bar { height: 3px; background: var(--track); }
#pending .bar span { display: block; width: 0; height: 100%; background: var(--accent); transition: width 0.15s linear; }
#pending .label { top: 14px; }

button:disabled { opacity: 0.45; cursor: default; }
button:disabled:hover { background: var(--button); }
button.primary:disabled:hover { background: var(--primary); }

/* Phones: preview on top, controls scroll below it, Generate/Download pinned to the bottom. */
@media (max-width: 720px) {
  html, body { height: 100dvh; }
  body { flex-direction: column; }

  #stage { flex: none; height: 45dvh; order: -1; }

  #panel {
    flex: 1;
    width: auto;
    height: auto;
    min-height: 0;
    padding: 12px 16px 0;
    border-right: none;
    border-top: 1px solid var(--divider);
  }

  /* 16px stops iOS from zooming in when a field gets focus. */
  input:not([type]), input[type="number"], select { font-size: 16px; padding: 7px 9px; }
  input[type="color"] { height: 36px; }
  .colors input[type="color"] { width: 36px; }
  .colors { grid-template-columns: 1fr 1fr 64px; }
  button { padding: 9px 14px; }
  .slider { grid-template-columns: 78px 1fr 72px; margin-bottom: 10px; }
  .slider input[type="number"] { padding: 5px 7px; }
  .check input { width: 20px; height: 20px; }

  .main-actions {
    position: sticky;
    bottom: 0;
    z-index: 1;
    margin: 0 -16px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: var(--panel);
  }
  .main-actions + .actions { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}
