:root {
  color-scheme: dark;
  --ink: #f4f1e8;
  --muted: #8e938d;
  --surface: #171a18;
  --surface-raised: #202420;
  --line: #343934;
  --acid: #d7ff45;
  --coral: #ff7657;
  --shadow: rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

html {
  scrollbar-gutter: stable;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% 8%, rgba(215, 255, 69, 0.08), transparent 25rem),
    #0d0f0e;
  color: var(--ink);
}

button,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.shell {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 4rem);
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.masthead {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1.6rem;
}

.eyebrow,
.shortcut,
footer,
.runtime-state,
.panel-index {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
}

.eyebrow {
  color: var(--acid);
  margin: 0 0 0.6rem;
}

h1 {
  font-size: clamp(3.5rem, 10vw, 8rem);
  line-height: 0.78;
  letter-spacing: -0.075em;
  margin: 0;
  font-weight: 850;
}

.intro {
  color: #b7bcb5;
  margin: 1.25rem 0 0;
  font-size: clamp(1rem, 2vw, 1.2rem);
}

.runtime-state {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  white-space: nowrap;
  color: #c9cec7;
}

.status-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 0 0.3rem rgba(215, 255, 69, 0.12);
}

.status-dot[data-state="working"] {
  animation: pulse 1s ease-in-out infinite;
}

.status-dot[data-state="error"] {
  background: var(--coral);
  box-shadow: 0 0 0 0.3rem rgba(255, 118, 87, 0.12);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
  gap: 1rem;
  flex: 0 0 auto;
  min-width: 0;
  min-height: 0;
}

.workspace.is-console-width-sized {
  grid-template-columns: minmax(320px, 1fr) var(--console-width);
}

.workspace.is-console-height-sized .panel {
  height: var(--console-height);
  max-height: none;
}

.panel {
  container-type: inline-size;
  height: clamp(30rem, 56vh, 42rem);
  max-height: clamp(30rem, 56vh, 42rem);
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 1.3rem 4rem var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.output-panel {
  contain: layout paint;
  position: relative;
}

.panel-bar {
  flex: 0 0 auto;
  min-height: 4.5rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}

.panel-bar > div:not(.panel-actions) {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  max-width: 100%;
  align-items: center;
  gap: 0.35rem;
}

.example-select {
  min-width: 0;
  max-width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: var(--surface-raised);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.example-select:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 2px;
}

.font-size-controls {
  flex: 0 0 auto;
  height: 2.15rem;
  margin-right: 0.25rem;
  border: 1px solid var(--line);
  display: flex;
  align-items: stretch;
}

.font-size-button {
  width: 2rem;
  border: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
}

.font-size-button:hover:not(:disabled),
.font-size-button:focus-visible:not(:disabled) {
  color: var(--acid);
  background: rgba(215, 255, 69, 0.08);
}

.font-size-button:disabled {
  color: #535852;
  cursor: not-allowed;
}

.font-size-value {
  min-width: 3rem;
  border-inline: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 0.65rem;
}

.panel h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
}

.panel-index {
  color: var(--acid);
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.5rem;
  cursor: pointer;
}

.text-button:hover,
.text-button:focus-visible {
  color: var(--ink);
}

.files-panel {
  min-width: 0;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  background: var(--surface);
}

.files-toolbar,
.file-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.files-toolbar h2 {
  margin: 0;
  font-size: 1rem;
}

.files-help,
.files-status {
  margin: 0.5rem 0;
  color: var(--muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.file-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 12rem;
  overflow-y: auto;
}

.file-list li {
  border-top: 1px solid var(--line);
  padding: 0.35rem 0;
}

.file-name {
  min-width: 0;
  flex: 1 1 12rem;
  overflow-wrap: anywhere;
}

.file-size {
  color: var(--muted);
  font-size: 0.8rem;
}

textarea {
  margin: 0;
  border: 0;
  border-radius: 0;
  flex: 1;
  padding: clamp(1.2rem, 3vw, 2rem);
  font: 500 0.95rem/1.8 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  tab-size: 4;
}

textarea {
  min-height: 0;
  width: 100%;
  resize: none;
  color: #eef7d0;
  background: var(--surface);
  outline: none;
  caret-color: var(--acid);
}

textarea:focus {
  background: #191d19;
}

#terminal {
  --terminal-font-size: 15px;
  height: 0;
  min-height: 0;
  min-width: 0;
  flex: 1 1 0;
  padding: clamp(1.2rem, 3vw, 2rem);
  overflow: hidden;
  contain: strict;
  cursor: text;
  color: var(--acid);
  background:
    linear-gradient(rgba(215, 255, 69, 0.025) 1px, transparent 1px) 0 0 / 100% 1em,
    #111311;
  font: 500 var(--terminal-font-size)/1 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  display: flex;
  flex-direction: column;
}

.terminal-output {
  flex: 1 1 0;
  width: 100%;
  height: 0;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.terminal-output > .xterm {
  height: 100%;
  min-width: var(--terminal-screen-width, 0px);
  min-height: var(--terminal-screen-height, 0px);
}

.terminal-output .xterm-viewport {
  background-color: transparent !important;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}

.terminal-output .xterm-rows .xterm-cursor {
  visibility: hidden;
}

.terminal.is-live .terminal-output .xterm-rows .xterm-cursor {
  visibility: visible;
}

.console-help {
  flex: 0 0 auto;
  min-height: 3.25rem;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 1.2rem;
  border-top: 1px solid var(--line);
  background: var(--surface-raised);
  color: var(--muted);
  font-size: 0.72rem;
}

.terminal-resize {
  position: relative;
  flex: 0 0 0.8rem;
  min-height: 0.8rem;
  border-top: 1px solid var(--line);
  background: var(--surface-raised);
  cursor: ns-resize;
  touch-action: none;
  outline: none;
}

.terminal-resize::before {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 3rem;
  height: 2px;
  border-radius: 999px;
  background: #596059;
  transform: translate(-50%, -50%);
  transition: width 120ms ease, background-color 120ms ease;
}

.terminal-resize:hover::before,
.terminal-resize:focus-visible::before,
.terminal-resize.is-resizing::before {
  width: 4.5rem;
  background: var(--acid);
}

.terminal-width-resize {
  position: absolute;
  z-index: 4;
  inset: 4.5rem auto 0.8rem 0;
  width: 0.8rem;
  cursor: ew-resize;
  touch-action: none;
  outline: none;
}

.terminal-width-resize::before {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 2px;
  height: 3rem;
  border-radius: 999px;
  background: #596059;
  transform: translate(-50%, -50%);
  transition: height 120ms ease, background-color 120ms ease;
}

.terminal-width-resize:hover::before,
.terminal-width-resize:focus-visible::before,
.terminal-width-resize.is-resizing::before {
  height: 4.5rem;
  background: var(--acid);
}

kbd {
  color: #cfd4cd;
  font: inherit;
  font-weight: 700;
}

.action-row {
  flex: 0 0 auto;
  padding: 0.9rem 1rem 0.9rem 1.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  background: var(--surface-raised);
}

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

.run-actions {
  display: flex;
  min-width: 0;
  max-width: 100%;
  align-items: stretch;
  gap: 0.5rem;
}

.stop-button,
.run-button {
  min-height: 3rem;
}

.stop-button {
  min-width: 8.5rem;
  border: 1px solid #6b443b;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--coral);
  background: #251a17;
  font-weight: 750;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease;
}

.stop-button:hover:not(:disabled),
.stop-button:focus-visible:not(:disabled) {
  border-color: var(--coral);
  background: #30201c;
  transform: translateY(-2px);
}

.stop-button:disabled {
  border-color: var(--line);
  color: #727771;
  background: #1b1e1b;
  cursor: not-allowed;
}

.run-button {
  min-width: 12rem;
  border: 0;
  padding: 0.9rem 1.1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  background: var(--acid);
  color: #11130d;
  font-weight: 750;
  cursor: pointer;
  transition: transform 150ms ease, filter 150ms ease;
}

.run-button:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.06);
}

.run-button:disabled {
  cursor: wait;
  filter: saturate(0.15) brightness(0.55);
}

footer {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.5rem;
}

.credits > div {
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
  align-items: center;
  gap: 0.55rem;
}

.credits a {
  color: #cfd4cd;
  text-decoration-color: #596059;
  text-underline-offset: 0.2rem;
}

.credits a:hover,
.credits a:focus-visible {
  color: var(--acid);
}

.credit-label {
  color: #6f756f;
}

.credit-tools {
  justify-content: flex-end;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes pulse {
  50% {
    opacity: 0.45;
    transform: scale(0.8);
  }
}

/* Panels can be narrow on desktop too, after dragging the width handle. */
@container (max-width: 34rem) {
  .shortcut {
    display: none;
  }

  .run-actions {
    width: 100%;
  }

  .run-button,
  .stop-button {
    min-width: 0;
    gap: 0.5rem;
    padding-inline: 0.75rem;
  }

  .run-button {
    flex: 1.4 1 0;
  }

  .stop-button {
    flex: 1 1 0;
  }

  .console-help {
    justify-content: flex-start;
    gap: 0.5rem 0.75rem;
  }
}

@media (max-width: 820px) {
  .masthead {
    align-items: start;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .workspace.is-console-width-sized,
  .workspace {
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .workspace.is-console-width-sized .output-panel {
    width: min(100%, var(--console-width));
    justify-self: end;
  }

  .panel {
    height: 30rem;
  }

  .terminal-width-resize {
    display: none;
  }
}

@media (max-width: 520px) {
  .shell {
    padding: 1rem;
  }

  footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .credit-tools {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .console-help {
    justify-content: space-between;
    gap: 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
