body.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.tools {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  align-self: start;
  max-height: 100%;
  overflow: auto;
}

.tools h2, .home h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mut);
}

.tool-row, .colors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tool[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: transparent;
}

.tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  font-weight: 600;
}

.swatch {
  width: var(--tap);
  padding: 0;
  position: relative;
}

.swatch-pink { background: #ff5fa2; }
.swatch-blue { background: #0a62ff; }
.swatch-purple { background: #7b61ff; }
.swatch-cyan { background: #00d2ff; }
.swatch-amber { background: #ffd60a; }
.swatch-white { background: #ffffff; }

.swatch[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 8px;
  border: 2px solid var(--fg);
}

.meta { display: grid; gap: 6px; margin: 0; }
.meta div { display: flex; justify-content: space-between; gap: 12px; }
.meta dt { color: var(--mut); }
.meta dd { margin: 0; font-variant-numeric: tabular-nums; }

.notice {
  margin: 0;
  color: var(--mut);
  font-size: 14px;
  line-height: 1.45;
}

.stage-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.stage-card {
  position: relative;
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 0;
  padding: 16px;
  overflow: hidden;
  container-type: size;
}

.device {
  width: fit-content;
  max-width: 100%;
  background: #000;
  border-radius: 32px;
  padding: 12px;
  box-shadow: var(--sh-3);
}

.screen {
  --fw: 390;
  --fh: 844;
  position: relative;
  width: min(100cqi - 56px, calc((100cqb - 56px) * var(--fw) / var(--fh)));
  aspect-ratio: var(--fw) / var(--fh);
  border-radius: 22px;
  overflow: hidden;
  background: #111;
  touch-action: none;
}

.screen img, .screen canvas, .screen video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.screen img, .screen video { object-fit: contain; background: #000; }
.screen canvas { cursor: crosshair; }

.screen img[hidden],
.screen video[hidden],
.empty[hidden] {
  display: none;
}

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  color: #f2f2f5;
}

.empty p { margin: 0; color: #a0a0a8; line-height: 1.45; }

.banner {
  display: none;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.banner.show { display: block; }
.banner.error { border-color: color-mix(in srgb, var(--live) 50%, var(--line)); }

.text-form {
  display: none;
  gap: 8px;
  align-items: center;
}

.text-form.show { display: flex; }

.text-form input {
  flex: 1;
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0 12px;
}

.home { padding: 24px 16px 48px; display: grid; justify-items: center; }
.home-card { width: min(720px, 100%); padding: 28px 22px 32px; }
.eyebrow { margin: 0; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.home h1 { margin: 8px 0 0; font-size: clamp(28px, 4vw, 40px); letter-spacing: -0.03em; line-height: 1.1; }
.lede { font-size: 17px; line-height: 1.45; }
.home ol { padding-left: 18px; line-height: 1.5; }
.home .pill { margin: 8px 0 18px; }

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

@media (max-width: 800px) {
  .workspace {
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 8px;
    overflow: hidden;
  }
  .stage-wrap { order: -1; flex: 1; height: auto; min-height: 0; }
  .stage-card { padding: 8px; }
  .tools {
    position: static;
    align-self: stretch;
    flex: 0 1 auto;
    height: auto;
    min-height: 0;
    max-height: 240px;
    overflow: auto;
  }
  .topbar { gap: 8px; }
  #code { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .text-form { flex-wrap: wrap; }
}
