/* Scripted product demos: a simplified Dev404 window on top of a background image.
   Everything inside .win is sized in em, so the window scales with its stage. */
.stage {
  container: stage / inline-size;
  position: relative;
  display: grid;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  place-items: center;
  padding: 5.5% 6%;
  background: var(--surface) var(--stage-bg) center / cover no-repeat;
  border-radius: var(--radius-surface);
}

.stage-hero {
  margin-top: clamp(48px, 6vw, 88px);
}

.win {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  border-radius: 0.9em;
  box-shadow: 0 0 0 1px var(--line), 0 1.6em 4em #0006;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", var(--sans);
  font-size: clamp(9px, calc(var(--k, 1.2) * 1cqw), 15px);
  line-height: 1.5;
  text-align: left;
}

.win-narrow {
  width: min(100%, 34em);
}

.win button,
.win input {
  margin: 0;
  padding: 0;
  color: inherit;
  background: none;
  border: 0;
  font: inherit;
}

.win button {
  cursor: pointer;
}

.win button:disabled {
  cursor: default;
}

.win :focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 1px;
  border-radius: 0.4em;
}

.win small {
  color: var(--faint);
  font-size: 0.82em;
}

.win strong {
  font-weight: 500;
}

.win-bar {
  position: relative;
  display: flex;
  min-height: 2.6em;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--line-subtle);
}

.win-dots {
  position: absolute;
  left: 1em;
  display: flex;
  gap: 0.45em;
}

.win-dots i {
  width: 0.7em;
  height: 0.7em;
  background: var(--raised);
  border-radius: 50%;
}

.win-title {
  color: var(--muted);
  font-size: 0.86em;
}

.win-action {
  position: absolute;
  right: 0.8em;
  padding: 0.2em 0.7em !important;
  color: var(--muted) !important;
  border-radius: 0.5em;
  font-size: 0.82em !important;
}

/* Layouts */
.app {
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
}

.app > * {
  min-width: 0;
  min-height: 0;
}

.app > * + * {
  border-left: 1px solid var(--line-subtle);
}

.cols-3 {
  grid-template-columns: 15em minmax(0, 1fr) minmax(0, 1.05fr);
}

.cols-2 {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

.cols-ultra {
  grid-template-columns: 15em minmax(0, 1fr);
}

.cols-ide {
  grid-template-columns: 11em minmax(0, 1.25fr) minmax(0, 1fr);
}

/* Sidebar lists */
.side {
  display: flex;
  flex-direction: column;
  gap: 0.15em;
  padding: 0.7em 0.5em;
  overflow: hidden;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2em 0.6em 0.5em;
  color: var(--faint);
  font-size: 0.82em;
}

.side-item,
.agent {
  display: flex;
  width: 100%;
  align-items: flex-start;
  gap: 0.6em;
  padding: 0.5em 0.6em !important;
  border-radius: 0.55em;
  text-align: left;
}

.side-item > span,
.agent > span {
  display: grid;
  min-width: 0;
}

.side-item strong,
.side-item small,
.agent strong,
.agent small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-item[aria-current="true"],
.agent[aria-pressed="true"] {
  background: var(--raised);
}

.icon-plus {
  position: relative;
  width: 1.5em;
  height: 1.5em;
  border-radius: 0.4em;
}

.icon-plus::before,
.icon-plus::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.75em;
  height: 1px;
  background: var(--muted);
  content: "";
  translate: -50% -50%;
}

.icon-plus::after {
  rotate: 90deg;
}

.status {
  width: 0.85em;
  height: 0.85em;
  flex: 0 0 auto;
  margin-top: 0.3em;
  border: 1px solid var(--muted);
  border-radius: 50%;
}

.status.done {
  background: var(--green);
  border-color: var(--green);
}

.status.running,
.working i {
  border-color: var(--line);
  border-top-color: var(--text);
  animation: demo-spin 900ms linear infinite;
}

.agent b,
.post b {
  display: grid;
  width: 2.1em;
  height: 2.1em;
  flex: 0 0 auto;
  place-items: center;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 0.45em;
  font-size: 0.74em;
  font-weight: 500;
}

/* Chat */
.chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.chat-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 1em;
  padding: 0.8em 1.1em 0.6em;
}

.chat-head strong,
.chat-head small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 0.55em;
  padding: 0.4em 1.1em 1em;
  overflow-y: auto;
  scrollbar-width: none;
}

.chat-list::-webkit-scrollbar {
  display: none;
}

.msg {
  margin: 0.2em 0;
}

.msg.user {
  max-width: 88%;
  align-self: flex-end;
  padding: 0.6em 0.9em;
  background: var(--raised);
  border-radius: 1.1em 1.1em 0.35em 1.1em;
}

.step {
  color: var(--muted);
}

.step span {
  color: var(--faint);
}

.file {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.45em 0.7em !important;
  background: var(--surface);
  border-radius: 0.55em;
  box-shadow: 0 0 0 1px var(--line-subtle);
  font-family: var(--mono);
  font-size: 0.86em;
  text-align: left;
}

.file-name {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.add {
  color: var(--green);
}

.del {
  color: var(--red);
}

.plan {
  display: grid;
  gap: 0.5em;
  padding: 0.8em 0.9em;
  background: var(--surface);
  border-radius: 0.7em;
  box-shadow: 0 0 0 1px var(--line-subtle);
}

.plan ol {
  display: grid;
  gap: 0.25em;
  padding-left: 1.3em;
  color: var(--muted);
  list-style: decimal;
}

.plan-actions {
  display: flex;
  justify-content: flex-end;
}

.button-mini {
  padding: 0.3em 0.8em !important;
  border-radius: 0.5em;
  font-size: 0.86em !important;
  white-space: nowrap;
}

.button-mini.primary {
  color: var(--bg) !important;
  background: var(--text) !important;
}

.button-mini:disabled {
  color: var(--muted) !important;
  background: var(--raised) !important;
}

.working {
  display: flex;
  align-items: center;
  gap: 0.6em;
  color: var(--faint);
}

.working i {
  width: 0.85em;
  height: 0.85em;
  border-width: 1px;
  border-style: solid;
  border-radius: 50%;
}

.enter {
  animation: demo-in 220ms var(--ease);
}

/* Composer */
.composer {
  display: grid;
  gap: 0.3em;
  margin: 0 0.8em 0.8em;
  padding: 0.6em;
  background: var(--surface);
  border-radius: 1.2em;
  box-shadow: 0 0 0 1px var(--line-subtle);
}

.composer-input {
  width: 100%;
  padding: 0.3em 0.5em !important;
  outline: 0 !important;
}

.composer-input::placeholder {
  color: var(--faint);
}

.composer:focus-within {
  box-shadow: 0 0 0 1px var(--line);
}

.composer-row,
.composer-right {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4em;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.3em 0.6em !important;
  color: var(--muted) !important;
  border-radius: 0.5em;
  font-size: 0.82em !important;
  white-space: nowrap;
}

.chip[aria-pressed="true"] {
  color: var(--text) !important;
  background: var(--raised) !important;
}

.caret {
  width: 0.4em;
  height: 0.4em;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  rotate: 45deg;
  translate: 0 -0.1em;
}

.menu-anchor {
  position: relative;
}

.menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.5em);
  z-index: 2;
  display: grid;
  min-width: 11em;
  padding: 0.3em;
  background: var(--raised);
  border-radius: 0.7em;
  box-shadow: var(--floating-shadow);
}

.menu[hidden] {
  display: none;
}

.menu button {
  display: flex;
  justify-content: space-between;
  padding: 0.45em 0.6em;
  border-radius: 0.45em;
  font-size: 0.9em;
  text-align: left;
}

.menu button[aria-checked="true"]::after {
  content: "✓";
}

.send {
  position: relative;
  width: 2em;
  height: 2em;
  background: var(--text) !important;
  border-radius: 50%;
}

.send::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.55em;
  height: 0.55em;
  border-top: 1.5px solid var(--bg);
  border-left: 1.5px solid var(--bg);
  content: "";
  rotate: 45deg;
  translate: -50% -30%;
}

.is-running .send::before {
  width: 0.6em;
  height: 0.6em;
  background: var(--bg);
  border: 0;
  border-radius: 1.5px;
  rotate: 0deg;
  translate: -50% -50%;
}

/* Work panel */
.work,
.editor-col {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.tabs {
  display: flex;
  align-items: center;
  gap: 0.2em;
  padding: 0.5em 0.7em;
  border-bottom: 1px solid var(--line-subtle);
}

.tabs .button-mini {
  margin-left: auto;
}

.tab {
  padding: 0.3em 0.7em !important;
  color: var(--muted) !important;
  border-radius: 0.5em;
  font-size: 0.86em !important;
}

.tab[aria-selected="true"] {
  color: var(--text) !important;
  background: var(--raised) !important;
}

.work-body,
.editor {
  padding: 0.8em;
  overflow: auto;
  scrollbar-width: none;
}

.file-list {
  display: grid;
  gap: 0.35em;
  margin-bottom: 0.8em;
}

.file-list .file {
  width: 100%;
}

.file-list .file[aria-pressed="true"] {
  background: var(--raised) !important;
}

.code {
  display: grid;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.8em;
  line-height: 1.7;
}

.code-line {
  position: relative;
  padding: 0 0.6em;
  white-space: pre;
}

.code-line i {
  display: inline-block;
  width: 2em;
  color: var(--dim);
  font-style: normal;
}

.code-line.add {
  color: var(--green);
  background: color-mix(in srgb, var(--green) 9%, transparent);
}

.code-line.del {
  color: var(--red);
  background: color-mix(in srgb, var(--red) 9%, transparent);
}

.peer {
  margin-left: 0.4em;
  padding: 0.05em 0.45em;
  color: var(--bg);
  background: var(--amber);
  border-radius: 0.3em;
  font-family: var(--sans);
  font-size: 0.85em;
  font-style: normal;
}

.agent-peer {
  background: var(--green);
}

.test-list {
  display: grid;
  gap: 0.5em;
}

.test-list li {
  display: flex;
  gap: 0.6em;
}

.test-list li::before {
  color: var(--green);
  content: "✓";
}

.summary,
.empty {
  color: var(--muted);
}

/* Ultra Code */
.post {
  display: flex;
  gap: 0.7em;
  padding: 0.5em 0;
}

.post div {
  display: grid;
  min-width: 0;
  gap: 0.1em;
}

.post p {
  color: var(--muted);
}

.meter {
  height: 3px;
  margin: 0 1.1em 1.1em;
  background: var(--raised);
  border-radius: 3px;
}

.meter i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--text);
  border-radius: 3px;
  transition: width 500ms var(--ease);
}

/* Fullstack preview */
.mini-app {
  display: grid;
  max-width: 22em;
  gap: 0.5em;
  margin: 0.6em auto;
}

.mini-app > strong {
  font-size: 1.3em;
}

.habit {
  display: flex;
  align-items: center;
  gap: 0.7em;
  padding: 0.7em 0.8em !important;
  background: var(--surface) !important;
  border-radius: 0.7em;
  box-shadow: 0 0 0 1px var(--line-subtle);
  text-align: left;
}

.habit span {
  flex: 1;
}

.habit i {
  width: 1.1em;
  height: 1.1em;
  border: 1px solid var(--muted);
  border-radius: 50%;
}

.habit[aria-pressed="true"] i {
  background: var(--green);
  border-color: var(--green);
}

.habit[aria-pressed="true"] span {
  color: var(--muted);
  text-decoration: line-through;
}

/* IDE */
.cloud-row {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.8em;
  margin-top: 0.5em;
}

@media (hover: hover) {
  .side-item:hover,
  .agent:hover,
  .chip:hover,
  .tab:hover,
  .menu button:hover,
  .win-action:hover,
  .icon-plus:hover {
    background: var(--surface);
  }
}

/* Narrow stages keep one or two columns and a readable type size. */
@container stage (max-width: 620px) {
  .win {
    font-size: 12.5px;
  }

  .cols-3,
  .cols-2,
  .cols-ultra,
  .cols-ide {
    grid-template-columns: minmax(0, 1fr);
  }

  .cols-3 > .side,
  .cols-3 > .work,
  .cols-ultra > .side,
  .cols-2 > .chat,
  .cols-ide > .side,
  .cols-ide > .editor-col {
    display: none;
  }

  .app > * {
    border-left: 0;
  }
}

@media (max-width: 720px) {
  .stage {
    aspect-ratio: 5 / 6;
    padding: 10px;
    border-radius: 14px;
  }

  .win {
    border-radius: 10px;
  }
}

@keyframes demo-in {
  from {
    opacity: 0;
    translate: 0 4px;
  }
}

@keyframes demo-spin {
  to {
    rotate: 360deg;
  }
}

@media (prefers-reduced-motion: reduce) {
  .enter,
  .status.running,
  .working i {
    animation: none;
  }

  .meter i {
    transition: none;
  }
}
