.play-page {
  --work-ink: #25364b;
  --work-muted: #526258;
  --work-edge: #d9d3bc;
  --work-paper: #fffefa;
  --work-shelf: #f5ecd3;
  --work-sage: #eef3e9;
  --work-sage-edge: #d5e1d1;
  --work-focus: #365d87;
  --work-coral: #ad422f;
  background: #fffaf0;
}

.play-wrap { width: min(100% - 4rem, 77rem); margin-inline: auto; }
.play-page .header-inner { padding-block: 0.7rem; }
.play-page .brand-mark { width: 2.5rem; }
.play-page main { padding-block: clamp(1.4rem, 4vw, 3rem) 3rem; }
.play-page [hidden] { display: none !important; }
.play-icons { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.play-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.85rem 1.25rem;
  margin-bottom: 1.25rem;
}
.play-heading h1 { font-size: clamp(2.35rem, 5vw, 3.55rem); }
.play-select { position: relative; max-width: 100%; }
.play-select::after {
  content: "";
  position: absolute;
  right: 1rem;
  top: 43%;
  width: 0.45rem;
  height: 0.45rem;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
  pointer-events: none;
}
.play-select select, .workspace button, .program-input input {
  font: 650 0.9rem/1.2 system-ui, sans-serif;
  color: var(--work-ink);
  background: var(--work-paper);
  border: 1px solid var(--work-edge);
  border-radius: 0.6rem;
  min-height: 2.4rem;
  padding: 0.48rem 0.75rem;
}
.play-select select {
  appearance: none;
  cursor: pointer;
  width: 12.3rem;
  max-width: 100%;
  padding-right: 2.1rem;
}
.play-notice { margin-bottom: 1rem; color: var(--work-coral); }

.workspace {
  --code-type: 0.975rem/1.7 var(--mono);
  color: var(--work-ink);
  display: grid;
  grid-template-columns: minmax(12rem, 21%) minmax(0, 1fr);
  background: var(--work-paper);
  border: 1px solid var(--work-edge);
  border-radius: 1.05rem;
  overflow: hidden;
  box-shadow: 0 0.3rem 0.85rem #493e1610, 0 1.2rem 2.7rem #493e160a;
}
.workspace h2 {
  color: inherit;
  font: 730 0.96rem/1.25 system-ui, sans-serif;
  letter-spacing: 0;
}
.workspace button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  cursor: pointer;
}
.workspace button:not(:disabled):hover { background: #f8f3e4; border-color: #a79d7b; }
.workspace button:disabled, .play-select select:disabled { cursor: default; opacity: 0.55; }
.workspace button svg, .pane-bar h2 svg {
  flex: 0 0 1.05rem;
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.file-shelf {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--work-shelf);
  padding: 1.25rem 0.95rem 0.95rem;
  border-inline-end: 1px solid var(--work-edge);
}
.file-shelf h2 { padding-inline: 0.25rem; }
.file-list {
  flex: 1;
  min-height: 0;
  max-height: 24rem;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 0.45rem;
  padding: 0.56rem 0.2rem;
  margin: 0.5rem -0.2rem 0.75rem;
  list-style: none;
}
.file-list > li { min-width: 0; }
.file-list .file-button {
  --tab-face: #faddc9;
  --tab-edge: #b0583b;
  position: relative;
  justify-content: start;
  width: 100%;
  padding: 0.7rem 0.6rem 0.7rem 0.8rem;
  border-color: #3b2e261f;
  background: var(--tab-face);
  box-shadow: inset 3px 0 var(--tab-edge);
  font: 620 0.84rem/1.2 var(--mono);
  white-space: nowrap;
}
.file-button.tab-1 { --tab-face: #d3ebe4; --tab-edge: #38796f; }
.file-button.tab-2 { --tab-face: #e8def2; --tab-edge: #805ea4; }
.file-button.tab-3 { --tab-face: #f8e5ad; --tab-edge: #956b28; }
.file-button.tab-4 { --tab-face: #d9e8f0; --tab-edge: #49758e; }
.file-list .file-button:hover, .file-list .file-button[aria-current] {
  border-color: var(--tab-edge);
  background: var(--tab-face);
}
.file-button[aria-current] { box-shadow: inset 4px 0 var(--tab-edge); }
.file-button span { overflow: hidden; text-overflow: ellipsis; }
.file-button svg { color: var(--tab-edge); }
.file-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.3rem; margin-block-start: auto; }
.file-actions button {
  flex-direction: column;
  font-size: 0.82rem;
  padding-inline: 0.15rem;
  padding-block: 0.53rem;
}

.play-panes { min-width: 0; }
.pane-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 3.5rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--work-edge);
}
.pane-bar h2 { display: flex; flex: 1; align-items: center; gap: 0.5rem; min-width: 0; }
.pane-bar .document-title { font-family: var(--mono); font-size: 0.9rem; }
.document-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane-bar .close-file { padding-inline: 0.48rem; border-color: transparent; background: transparent; }
.pane-bar .run-button, .pane-bar .run-button:hover:not(:disabled) {
  background: var(--work-coral);
  border-color: var(--work-coral);
  color: white;
}
.pane-bar .run-button:hover:not(:disabled) { background: #943522; border-color: #943522; }
.run-button kbd {
  background: #ffffff18;
  border-color: #ffffff55;
  color: white;
  margin-inline-start: 0.2rem;
  line-height: 1.1;
}
.code-editor {
  position: relative;
  display: grid;
  grid-template-columns: 3.3rem minmax(0, 1fr);
  height: clamp(16rem, 40vh, 25rem);
  font: var(--code-type);
}
.code-editor:focus-within { outline: 2px solid var(--work-focus); outline-offset: -2px; }
.line-gutter { position: relative; overflow: hidden; background: #f8f5eb; border-inline-end: 1px solid #eee8da; }
.line-gutter pre, .highlighted-code, .code-editor textarea {
  font: inherit;
  font-variant-ligatures: none;
  tab-size: 2;
  margin: 0;
  padding-block: 0.9rem;
  white-space: pre;
  overflow-wrap: normal;
  direction: ltr;
}
.line-gutter pre { color: #697168; text-align: right; padding-inline: 0.25rem 0.75rem; }
.code-surface { position: relative; overflow: hidden; }
.highlighted-code, .code-editor textarea {
  position: absolute;
  inset: 0;
  padding-inline: 0.9rem;
  min-width: 0;
  color: inherit;
}
.highlighted-code { pointer-events: none; }
.code-editor textarea {
  border: 0;
  border-radius: 0;
  background: transparent;
  resize: none;
  outline: 0;
  caret-color: var(--work-ink);
}
.code-editor.has-highlights textarea { color: transparent; }
.code-editor textarea::selection { background: #8ab5ea65; }
.syntax-comment { color: #626e66; }
.syntax-string-value { color: #17705e; }
.syntax-keyword { color: #824477; }
.syntax-call, .syntax-number { color: #914c2c; }

.output-pane { background: var(--work-sage); border-top: 1px solid var(--work-sage-edge); }
.output-pane .pane-bar { min-height: 3rem; padding-block: 0.36rem; border-color: var(--work-sage-edge); }
.output-pane button, .workspace-footer button { min-height: 2.1rem; background: #ffffff66; }
.console-view { height: clamp(8.5rem, 19vh, 11rem); overflow: auto; padding: 0.8rem 1.05rem; }
.console-view:focus-visible { outline-offset: -3px; }
.console-empty { display: flex; align-items: center; gap: 0.85rem; min-height: 100%; color: var(--work-muted); }
.console-empty img { width: 3.25rem; flex: 0 0 3.25rem; }
.console-empty p { font-size: 0.95rem; }
.program-output, .program-diagnostic { font: var(--code-type); margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.program-diagnostic { color: #943522; font-weight: 650; }
.program-input {
  display: flex;
  gap: 0.55rem;
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--work-sage-edge);
}
.program-input input { flex: 1; min-width: 0; font-weight: 500; font-size: 1rem; }
.program-input button { min-height: 2.4rem; }
.workspace-footer {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  min-height: 2.75rem;
  padding: 0.45rem 1rem;
  color: var(--work-muted);
  background: #fbf7ea;
  border-top: 1px solid var(--work-edge);
  font-size: 0.85rem;
}
#run-status { flex: 1 1 auto; }
#run-status[data-state="error"] { color: #943522; }
.code-position { white-space: nowrap; font: 0.82rem/1.4 var(--mono); }

@media (max-width: 760px) {
  .play-wrap { width: calc(100% - 2rem); }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .file-shelf {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.3rem;
    border-inline-end: 0;
    border-bottom: 1px solid var(--work-edge);
    padding: 0.65rem 0.75rem 0.35rem;
  }
  .file-list {
    grid-area: 2 / 1 / 3 / -1;
    display: flex;
    margin-block: 0.1rem 0.25rem;
  }
  .file-list li { flex: 0 0 auto; max-width: 13rem; }
  .file-actions { margin: 0; }
  .file-actions button { flex-direction: row; padding: 0.45rem 0.5rem; }
  .file-actions button svg { display: none; }
  .code-editor { grid-template-columns: 2.65rem minmax(0, 1fr); height: clamp(12rem, 32vh, 19rem); }
  .pane-bar { padding-inline: 0.65rem; }
  .run-button kbd { display: none; }
}
@media (max-width: 410px) {
  .play-page .header-inner { column-gap: 0.65rem; }
  .play-heading h1 { font-size: 2.05rem; }
  .play-select select { width: 8.8rem; }
  .pane-bar { gap: 0.22rem; }
  .pane-bar button { padding-inline: 0.45rem; }
}
@media (forced-colors: active) {
  .highlighted-code { display: none; }
  .code-editor.has-highlights textarea { color: CanvasText; caret-color: CanvasText; }
}
