:root {
  color-scheme: dark;
  --bg: #100e0c;
  --raise: #1b1814;
  --ink: #f4efe6;
  --muted: #b3a696;
  --faint: #8c8174;
  --line: rgba(244, 239, 230, 0.14);
  --brass: #e2a14a;
  --on: #1a140c;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f4efe6;
    --raise: #fffdf8;
    --ink: #1c1916;
    --muted: #5c5348;
    --faint: #6f655a;
    --line: rgba(28, 25, 22, 0.12);
    --shadow: 0 18px 40px rgba(70, 48, 16, 0.08);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  font: 16px/1.45 var(--sans);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(226, 161, 74, 0.16), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(94, 208, 200, 0.08), transparent 50%),
    var(--bg);
}

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--brass);
  color: var(--on);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 5;
}
.skip:focus { top: 12px; }

.wrap {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  padding: 22px 0 16px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand svg { display: block; }
h1 {
  margin: 0;
  font: 600 28px/1.05 var(--serif);
  letter-spacing: -0.03em;
}
.lede { margin: 4px 0 0; color: var(--muted); max-width: 46ch; }
.pill {
  margin: 0;
  font: 12px/1 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  white-space: nowrap;
}

.layout {
  display: grid;
  gap: 18px;
  padding: 18px 0 28px;
}

.panel {
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 16px;
}

label[for="prompt"] {
  display: block;
  font-weight: 650;
  margin-bottom: 8px;
}

textarea {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 12px;
}
textarea:focus-visible,
button:focus-visible,
.recent-btn:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.hintrow {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}
#count { font-variant-numeric: tabular-nums; color: var(--faint); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip, .recent-btn, button {
  font: inherit;
  cursor: pointer;
}
.chip {
  text-align: left;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 6px 10px;
  font-size: 13px;
}
.chip:hover { border-color: var(--brass); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .primary { grid-column: 1 / -1; }
button.primary, button.secondary {
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 680;
}
button.primary { background: var(--brass); color: var(--on); border: 0; }
button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary:hover:not(:disabled) { filter: brightness(1.05); }

#status {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.recent-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 18px 0 8px;
}
.recent-head h2, .stage-title { font: 600 14px/1 var(--sans); margin: 0; letter-spacing: 0.04em; text-transform: uppercase; color: var(--faint); }
.linkish {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
#recent { list-style: none; margin: 0; padding: 0; }
@media (min-width: 960px) {
  #recent { max-height: 168px; overflow: auto; }
}
#recent li + li { margin-top: 6px; }
.quiet { color: var(--faint); font-size: 14px; }
.recent-btn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  text-align: left;
  background: transparent;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
}
.recent-btn small { color: var(--faint); white-space: nowrap; }
.recent-btn strong { font-weight: 650; overflow-wrap: anywhere; }

.stage { padding: 12px; display: flex; flex-direction: column; min-width: 0; }
.chrome {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 10px;
}
.dots { display: flex; gap: 5px; }
.dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
  display: block;
}
#filename { font: 12px/1 var(--mono); color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewport {
  position: relative;
  flex: 1;
  min-height: 420px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #14120f;
}
iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #14120f; }
.empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(226, 161, 74, 0.08), transparent 40%),
    #14120f;
  color: #f4efe6;
}
.empty h2 { font: 600 28px/1.15 var(--serif); margin: 0 0 8px; }
.empty p { margin: 0; color: #b3a696; max-width: 36ch; }
.steps { display: flex; gap: 16px; margin-top: 22px; padding: 0; list-style: none; color: #f4efe6; }
.steps li { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.steps b {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brass);
  color: var(--on);
  font-size: 12px;
}

.meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 4px 0;
  color: var(--muted);
  font-size: 14px;
}
.swatch { width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--line); }

.foot {
  padding: 0 0 22px;
  color: var(--faint);
  font-size: 13px;
}

@media (min-width: 960px) {
  body {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .top { flex: none; }
  .layout {
    flex: 1;
    min-height: 0;
    grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
    align-items: stretch;
    padding-bottom: 8px;
  }
  .composer, .stage { min-height: 0; }
  .composer { overflow: auto; }
  .stage { overflow: hidden; }
  .viewport { min-height: 0; flex: 1; }
  .foot { flex: none; padding-bottom: 14px; }
}

@media (max-width: 720px) {
  .wrap { width: min(1120px, calc(100% - 24px)); }
  .top { flex-direction: column; align-items: start; }
  h1 { font-size: 26px; }
  .pill { white-space: normal; }
  .viewport, .empty { min-height: 380px; }
  .steps { flex-direction: column; gap: 8px; }
  .recent-btn { flex-direction: column; }
}
