.playground-page {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.playground-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr);
  gap: 56px;
  align-items: end;
  margin-bottom: 18px;
}

.playground-intro h1 {
  max-width: 900px;
  margin: 8px 0 0;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1;
  letter-spacing: -.055em;
}

.playground-intro > p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 1.02rem;
}

.playground-workspace {
  display: grid;
  grid-template-columns: minmax(420px, .9fr) minmax(520px, 1.1fr);
  min-height: 780px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.editor-panel,
.output-panel {
  min-width: 0;
}

.editor-panel {
  display: flex;
  flex-direction: column;
  background: var(--code);
  color: var(--code-ink);
}

.output-panel {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
}

.playground-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 11px 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
}

.playground-toolbar label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #aebed0;
  font-size: .78rem;
  font-weight: 750;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.playground-toolbar select {
  max-width: 220px;
  padding: 8px 28px 8px 10px;
  border: 1px solid #344454;
  border-radius: 8px;
  background: #172330;
  color: #f5f8fc;
  font-family: inherit;
  font-size: .88rem;
  font-weight: 650;
  line-height: 1.2;
}

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

.quiet-button,
.run-button,
.download-button {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 750;
}

.quiet-button {
  border: 1px solid #3b4a59;
  background: transparent;
  color: #c8d4e0;
}

.run-button {
  border: 1px solid #83a6ff;
  background: #83a6ff;
  color: #0c1930;
}

.run-button span {
  margin-left: 7px;
  font-size: .72rem;
  opacity: .72;
}

.run-button:disabled,
.download-button:disabled {
  cursor: not-allowed;
  opacity: .52;
}

.editor-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.code-editor-wrap {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1;
  background: var(--code);
}

.code-editor,
.code-diagnostics {
  width: 100%;
  height: 100%;
  padding: 22px;
  font: 14px/1.72 "Cascadia Code", "SFMono-Regular", ui-monospace, monospace;
  tab-size: 2;
  white-space: pre;
}

.code-diagnostics {
  position: absolute;
  inset: 0;
  min-height: 710px;
  margin: 0;
  overflow: hidden;
  color: var(--code-ink);
  pointer-events: none;
}

.code-diagnostics .unknown-api {
  text-decoration: underline wavy #ff6961 1.5px;
  text-decoration-skip-ink: none;
  text-underline-offset: 3px;
}

.code-editor {
  position: relative;
  z-index: 1;
  min-height: 710px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: transparent;
  caret-color: var(--code-ink);
  -webkit-text-fill-color: transparent;
}

.code-editor::selection {
  background: rgb(91 141 239 / 34%);
  color: transparent;
}

.editor-completions {
  position: absolute;
  z-index: 8;
  width: min(430px, calc(100% - 28px));
  max-height: 280px;
  overflow: auto;
  border: 1px solid #405267;
  border-radius: 9px;
  background: #111c28;
  box-shadow: 0 16px 36px rgb(0 0 0 / 32%);
}

.editor-completions[hidden],
.editor-api-tooltip[hidden] {
  display: none;
}

.editor-completion {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid #263646;
  background: transparent;
  color: #e9f0f8;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.editor-completion:last-child { border-bottom: 0; }
.editor-completion:hover,
.editor-completion[aria-selected="true"] { background: #21344a; }
.editor-completion code { overflow: hidden; color: #9fc0ff; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.editor-completion small { color: #879aaf; font-size: 10px; }
.editor-completion span { grid-column: 1 / -1; overflow: hidden; color: #b8c6d5; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.editor-api-tooltip {
  position: fixed;
  z-index: 20;
  width: min(390px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 13px 14px;
  border: 1px solid #405267;
  border-radius: 9px;
  background: #111c28;
  color: #dce7f3;
  box-shadow: 0 16px 38px rgb(0 0 0 / 36%);
  pointer-events: none;
}

.editor-api-tooltip > code { display: block; color: #9fc0ff; font-size: 12px; font-weight: 750; }
.editor-api-tooltip > p { margin: 7px 0 0; color: #b8c6d5; font-size: 11px; line-height: 1.5; }
.editor-api-tooltip dl { display: grid; grid-template-columns: max-content 1fr; gap: 5px 10px; margin: 10px 0 0; padding-top: 9px; border-top: 1px solid #2b3b4c; }
.editor-api-tooltip dt { color: #dce7f3; font: 700 10px/1.45 "Cascadia Code", ui-monospace, monospace; }
.editor-api-tooltip dd { margin: 0; color: #93a5b8; font-size: 10px; line-height: 1.45; }

.editor-api-schema {
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid #2b3b4c;
}

.editor-api-schema > strong { color: #dce7f3; font-size: 11px; }
.editor-api-properties { display: grid; gap: 8px; margin-top: 8px; }
.editor-api-properties > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; }
.editor-api-properties code { color: #a9c6ff; font-size: 10px; overflow-wrap: anywhere; }
.editor-api-properties small { color: #7890a8; font-size: 9px; }
.editor-api-properties span { grid-column: 1 / -1; color: #a7b6c6; font-size: 10px; line-height: 1.4; }
.editor-api-example { display: grid; gap: 4px; margin-top: 10px !important; }
.editor-api-example span { color: #7890a8; font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.editor-api-example code { color: #dce7f3; font-size: 10px; overflow-wrap: anywhere; }

.output-toolbar {
  color: var(--ink);
  background: var(--surface);
}

.output-toolbar > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.run-status {
  color: var(--muted);
  font-size: .82rem;
}

.run-status.error { color: #b63838; }
.run-status.success { color: var(--success); }

.download-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
}

.sheet-tabs {
  display: flex;
  min-height: 43px;
  overflow-x: auto;
  padding: 4px 10px 0 48px;
  background: #f3f4f6;
  border-top: 1px solid #c9ced6;
  border-bottom: 1px solid var(--line);
}

.sheet-tabs button {
  min-width: 92px;
  padding: 7px 15px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-left: 1px solid transparent;
  border-right: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: .86rem;
  font-weight: 700;
  white-space: nowrap;
}

.sheet-tabs button[aria-selected="true"] {
  border-right-color: #d5d9df;
  border-bottom-color: #217346;
  border-left-color: #d5d9df;
  background: white;
  color: var(--ink);
}

.workbook-preview {
  flex: 1;
  min-height: 440px;
  overflow: auto;
  padding: 0;
  background: #fff;
}

.preview-empty {
  display: grid;
  min-height: 390px;
  place-items: center;
  color: #647286;
  text-align: center;
}

.sheet-frame {
  display: inline-block;
  min-width: 100%;
  background: white;
}

.sheet-table {
  min-width: 100%;
  border-collapse: collapse;
  color: #111827;
  font-family: Aptos, "Segoe UI", sans-serif;
  font-size: 14px;
  table-layout: fixed;
}

.sheet-table th,
.sheet-table td {
  box-sizing: border-box;
  border: 1px solid #d6d9de;
}

.sheet-table td {
  min-width: 84px;
  height: 26px;
  padding: 4px 8px;
  background: white;
  white-space: pre-wrap;
}

.sheet-table .sheet-corner,
.sheet-table .column-marker,
.sheet-table .row-marker {
  background: #f3f4f6;
  color: #4b5563;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  user-select: none;
}

.sheet-table .sheet-corner,
.sheet-table .column-marker {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 25px;
}

.sheet-table .sheet-corner,
.sheet-table .row-marker {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 46px;
  min-width: 46px;
}

.sheet-table .sheet-corner {
  z-index: 4;
}

.sheet-table .row-marker {
  padding: 0 7px;
}

.console-panel {
  border-top: 1px solid var(--line);
  background: var(--code);
  color: var(--code-ink);
}

.console-panel summary {
  padding: 10px 14px;
  cursor: pointer;
  color: #b9c6d5;
  font-size: .82rem;
  font-weight: 700;
}

.console-panel pre {
  max-height: 150px;
  margin: 0;
  overflow: auto;
  padding: 0 14px 14px;
  color: #dce6f0;
  font-size: .78rem;
  white-space: pre-wrap;
}

.playground-limit {
  margin-top: 18px;
  color: var(--muted);
  font-size: .82rem;
}

@media (max-width: 980px) {
  .playground-intro,
  .playground-workspace {
    grid-template-columns: 1fr;
  }
  .playground-intro { gap: 18px; }
  .output-panel { border-left: 0; border-top: 1px solid var(--line); }
  .code-editor, .code-diagnostics { min-height: 540px; }
}

@media (max-width: 620px) {
  .playground-page { width: min(100% - 16px, 1500px); padding-top: 36px; }
  .playground-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .output-toolbar { flex-direction: row; align-items: center; }
  .sheet-tabs { padding-left: 46px; }
}
