:root {
  --ink: #f4efe6;
  --muted: #e4d8c8;
  --stage: #100e0c;
  --glass: rgba(255, 252, 247, 0.86);
  --glass-ink: #1c1916;
  --line: rgba(244, 239, 230, 0.16);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--stage);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
  letter-spacing: -0.01em;
}

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

a { color: #f0d7a4; }

.top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem 0.35rem;
}

.brand {
  display: flex;
  flex-direction: column;
  min-width: 8rem;
}

.brand strong {
  font-family: Palatino, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.brand span,
.dock-label,
.credit,
#status,
#readout {
  color: var(--muted);
  font-size: 0.82rem;
}

.views, .actions { display: flex; gap: 0.35rem; align-items: center; }

.actions { margin-left: auto; }

.views button,
.ghost,
.save,
.photo,
.chip,
.var,
.swatch,
.handle,
.prompt button {
  border: 0;
  cursor: pointer;
}

.views button,
.ghost {
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  outline: 1px solid var(--line);
}

.views button[aria-pressed="true"],
.ghost[aria-pressed="true"] {
  background: var(--ink);
  color: #1a1612;
  outline: none;
}

.save {
  background: var(--ink);
  color: #1a1612;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-weight: 650;
}

.save:disabled,
.ghost:disabled,
.prompt button:disabled { opacity: 0.55; cursor: wait; }

.save:focus-visible,
.ghost:focus-visible,
.views button:focus-visible,
.chip:focus-visible,
.var:focus-visible,
.photo:focus-visible,
.swatch:focus-visible,
.prompt input:focus-visible,
.prompt button:focus-visible {
  outline: 2px solid #f4efe6;
  outline-offset: 2px;
}

main {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 0.35rem 1rem 0.5rem;
  container-type: size;
}

.stage {
  position: relative;
  width: min(100cqi, calc(100cqb * 5.333));
  aspect-ratio: 5760 / 1080;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.stage[data-view="panel"] {
  width: min(100cqi, calc(100cqb * 1.777));
  aspect-ratio: 16 / 9;
}

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

.handles {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.handle {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px #fff, 0 2px 8px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  touch-action: none;
}

.prompt {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(460px, calc(100% - 1.25rem));
  z-index: 2;
}

.prompt label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  height: 48px;
  padding: 0 5px 0 16px;
  border-radius: 999px;
  background: var(--glass);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.65);
}

.prompt input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--glass-ink);
  outline: none;
}

.prompt input::placeholder { color: rgba(28, 25, 22, 0.45); }

.prompt button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #1c1c1c;
  color: #fff;
  display: grid;
  place-items: center;
}

.dock {
  padding: 0.35rem 1rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 46vh;
  overflow: auto;
}

.dock-label { margin: 0 0 0.3rem; }

#readout, #status { margin: 0; }

.chip-row, .var-row, .photo-row, .slider-row, .swatch-row, .tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.chip {
  background: rgba(244, 239, 230, 0.08);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  outline: 1px solid var(--line);
}

.var {
  width: 148px;
  height: 64px;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  text-align: left;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.var span {
  position: absolute;
  left: 8px;
  bottom: 6px;
  background: rgba(16, 14, 12, 0.72);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font-size: 0.75rem;
}

.photo {
  width: 148px;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #211c17;
  text-align: left;
  color: var(--ink);
  outline: 1px solid transparent;
}

.photo[aria-current="true"] { outline: 2px solid #f0d7a4; }

.photo img {
  width: 100%;
  height: 64px;
  object-fit: cover;
  display: block;
}

.photo span {
  display: block;
  padding: 0.3rem 0.45rem 0.4rem;
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.credit { margin: 0.3rem 0 0; }

.photo-nav { display: flex; gap: 0.4rem; margin-top: 0.45rem; }

.slider {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 7.5rem;
  flex: 1;
  color: var(--muted);
  font-size: 0.75rem;
}

.slider input { width: 100%; accent-color: #f0d7a4; }

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

@media (max-width: 800px) {
  .top { flex-wrap: wrap; }
  .actions { margin-left: 0; width: 100%; }
  .save { flex: 1; }
  .stage { border-radius: 12px; }
  .var, .photo { width: calc(50% - 0.4rem); }
}
