/* ── Scrollbar styling ── */
.playground-page *::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.playground-page *::-webkit-scrollbar-track {
  background: transparent;
}

.playground-page *::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.playground-page *::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Firefox */
.playground-page * {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* ── Full-page playground layout ── */
.playground-page {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pg-layout {
  flex: 1;
  display: flex;
  min-height: 0;
  margin-top: 60px;
}

/* ── Sidebar ── */
.pg-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #0e0e16;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pg-sidebar-header {
  padding: 14px 16px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #555;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.pg-example-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.pg-group-label {
  padding: 10px 12px 4px;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #3a3a3a;
  user-select: none;
}

.pg-group-label:not(:first-child) {
  margin-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  padding-top: 12px;
}

.pg-example {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 2px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease;
  text-align: left;
}

.pg-example:hover {
  background: rgba(255, 255, 255, 0.03);
}

.pg-example.active {
  background: rgba(16, 185, 129, 0.08);
}

.pg-example-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #ccc;
  margin-bottom: 3px;
}

.pg-example.active .pg-example-title {
  color: #10b981;
}

.pg-example-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ── Main area ── */
.pg-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Top bar ── */
.pg-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: #0e0e16;
}

.pg-topbar-left,
.pg-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pg-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 6px;
  background: rgba(52, 211, 153, 0.08);
  color: #34d399;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  user-select: none;
  transition: all 0.2s ease;
}

.pg-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  animation: pg-pulse 2s ease-in-out infinite;
}

@keyframes pg-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.pg-live-badge.is-stale {
  background: rgba(251, 191, 36, 0.08);
  color: #fbbf24;
}

.pg-live-badge.is-stale .pg-live-dot {
  background: #fbbf24;
  animation: none;
}

.pg-eval-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: #555;
  transition: opacity 0.2s ease;
}

/* Dim result while stale */
.pg-result-body.is-stale {
  opacity: 0.4;
  transition: opacity 0.15s ease;
}

.pg-topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: transparent;
  color: #777;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pg-topbar-btn:hover {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
}

.pg-topbar-btn.copied {
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.3);
}

/* ── Editor grid ── */
.pg-editor-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 0;
}

.pg-editor-left {
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  min-height: 0;
}

.pg-editor-right {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── Panes ── */
.pg-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.pg-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.pg-pane-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #555;
}

.pg-pane-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  color: #3a3a3a;
}

/* ── Expression pane ── */
.pg-expr-pane {
  flex: 1;
  min-height: 80px;
}

.pg-expr-editor {
  position: relative;
  flex: 1;
  display: flex;
  min-height: 0;
}

.pg-expr-highlight {
  position: absolute;
  inset: 0;
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  pointer-events: none;
  color: transparent;
  overflow: auto;
}

.pg-expr-highlight .hl-var {
  color: transparent;
  background: rgba(16, 185, 129, 0.12);
  border-radius: 3px;
  padding: 1px 0;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.pg-expr-highlight .hl-transform {
  color: transparent;
  background: rgba(96, 165, 250, 0.10);
  border-radius: 3px;
  padding: 1px 0;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  border-bottom: 1px dashed rgba(96, 165, 250, 0.3);
}

/* ── Transform tooltip ── */
.pg-transform-tooltip {
  position: fixed;
  z-index: 1000;
  transform: translate(-50%, -100%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #1a1a24;
  border: 1px solid rgba(96, 165, 250, 0.2);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  pointer-events: none;
  animation: pg-tt-in 0.15s ease;
}

@keyframes pg-tt-in {
  from { opacity: 0; transform: translate(-50%, -100%) translateY(4px); }
  to { opacity: 1; transform: translate(-50%, -100%) translateY(0); }
}

.pg-tt-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  color: #60a5fa;
}

.pg-tt-module {
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(96, 165, 250, 0.1);
  color: #60a5fa;
}

.pg-tt-desc {
  font-size: 0.72rem;
  color: #999;
}

/* Context variable tooltip variant */
.pg-var-tooltip {
  border-color: rgba(16, 185, 129, 0.2);
}

.pg-tt-var-name {
  color: #10b981;
}

.pg-tt-var-type {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
}

.pg-tt-var-val {
  font-family: 'JetBrains Mono', monospace;
  color: #888;
}

#expr-input {
  flex: 1;
  width: 100%;
  background: transparent;
  border: none;
  padding: 16px;
  color: #e8e4df;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  line-height: 1.6;
  resize: none;
  caret-color: #10b981;
  outline: none;
}

/* ── Context pane ── */
.pg-ctx-pane {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex: 1;
  min-height: 80px;
}

.pg-ctx-add {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 5px;
  background: transparent;
  color: #666;
  font-size: 0.68rem;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pg-ctx-add:hover {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
}

.pg-ctx-vars {
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pg-ctx-row {
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  padding: 8px 10px;
  transition: border-color 0.15s ease;
}

.pg-ctx-row:focus-within {
  border-color: rgba(16, 185, 129, 0.2);
}

.pg-ctx-row-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.pg-ctx-row-name {
  width: 160px;
  background: none;
  border: none;
  color: #10b981;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 2px 4px;
  outline: none;
}

.pg-ctx-row-name::placeholder { color: #444; font-weight: 400; }

.pg-ctx-row-sep {
  color: #3a3a3a;
  font-size: 0.8rem;
  user-select: none;
}

.pg-ctx-row-value {
  flex: 1;
  min-width: 0;
  min-height: 28px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 4px;
  color: #e8e4df;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 6px 8px;
  outline: none;
  resize: none;
  field-sizing: content;
  max-height: 120px;
  overflow-y: auto;
}

.pg-ctx-row-value::placeholder { color: #3a3a3a; }

.pg-ctx-row-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  align-self: flex-start;
  padding-top: 4px;
}

.pg-ctx-row-type {
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.58rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  user-select: none;
}

.pg-ctx-row-delete {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #444;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}

.pg-ctx-row-delete:hover {
  color: #e06c6c;
  background: rgba(220, 50, 50, 0.1);
}

.pg-ctx-empty {
  padding: 16px;
  color: #3a3a3a;
  font-size: 0.78rem;
  text-align: center;
}

.pg-ctx-empty-add {
  background: none;
  border: none;
  color: #10b981;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pg-ctx-empty-add:hover { color: #34d399; }

/* ── Result pane ── */
.pg-result-pane {
  flex: 1;
}

.pg-result-tabs {
  display: flex;
  gap: 4px;
}

.pg-result-tab {
  padding: 4px 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 5px;
  background: transparent;
  color: #555;
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pg-result-tab.active {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.25);
}

.pg-result-type {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-family: 'JetBrains Mono', monospace;
  background: rgba(16, 185, 129, 0.08);
  color: #10b981;
}

.pg-result-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  line-height: 1.6;
  color: #e8e4df;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Color-coded result values */
.pg-result-body .r-string { color: #34d399; }
.pg-result-body .r-number { color: #60a5fa; }
.pg-result-body .r-boolean { color: #c084fc; }
.pg-result-body .r-null { color: #555; font-style: italic; }
.pg-result-body .r-key { color: #10b981; }
.pg-result-body .r-bracket { color: #888; }
.pg-result-body .r-punct { color: #444; }

.pg-error {
  display: none;
  padding: 12px 16px;
  margin: 0 16px 16px;
  background: rgba(220, 50, 50, 0.06);
  border: 1px solid rgba(220, 50, 50, 0.2);
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  color: #e06c6c;
  white-space: pre-wrap;
}

/* ── Reuse type badge colors from main styles ── */
.ctx-type-string  { background: rgba(52, 211, 153, 0.1); color: #34d399; }
.ctx-type-number  { background: rgba(96, 165, 250, 0.1); color: #60a5fa; }
.ctx-type-boolean { background: rgba(192, 132, 252, 0.1); color: #c084fc; }
.ctx-type-array   { background: rgba(251, 191, 36, 0.1); color: #fbbf24; }
.ctx-type-object  { background: rgba(244, 114, 182, 0.1); color: #f472b6; }
.ctx-type-null    { background: rgba(255, 255, 255, 0.04); color: #555; }

/* ── Autocomplete dropdown ── */
.pg-autocomplete {
  position: fixed;
  z-index: 1000;
  min-width: 280px;
  max-width: 440px;
  max-height: 320px;
  overflow-y: auto;
  background: #16161e;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  padding: 4px;
  animation: pg-ac-in 0.12s ease;
}

@keyframes pg-ac-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.pg-ac-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.1s ease;
}

.pg-ac-item:hover,
.pg-ac-item.active {
  background: rgba(16, 185, 129, 0.08);
}

.pg-ac-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 500;
  color: #e8e4df;
  flex-shrink: 0;
}

.pg-ac-item.active .pg-ac-name {
  color: #10b981;
}

.pg-ac-name strong {
  color: #10b981;
  font-weight: 700;
}

.pg-ac-module {
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.55rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.04);
  color: #555;
  flex-shrink: 0;
}

.pg-ac-item.active .pg-ac-module {
  background: rgba(96, 165, 250, 0.1);
  color: #60a5fa;
}

.pg-ac-desc {
  font-size: 0.68rem;
  color: #444;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.pg-ac-item.active .pg-ac-desc {
  color: #666;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .pg-sidebar { display: none; }

  .pg-layout {
    margin-top: 50px;
  }

  .pg-editor-grid {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .pg-editor-left {
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }
}

@media (max-width: 640px) {
  .pg-topbar {
    padding: 6px 12px;
    gap: 8px;
  }

  .pg-topbar-btn .pg-btn-label {
    display: none;
  }

  .pg-pane-header {
    padding: 6px 12px;
  }

  .pg-pane-hint {
    display: none;
  }

  #expr-input {
    padding: 12px;
    font-size: 0.82rem;
  }

  .pg-expr-highlight {
    padding: 12px;
    font-size: 0.82rem;
  }

  .pg-result-body {
    padding: 12px;
    font-size: 0.82rem;
  }

  .pg-ctx-vars {
    padding: 6px 10px;
  }

  .pg-ctx-row-name {
    width: 100px;
    font-size: 0.72rem;
  }

  .pg-ctx-row-value {
    font-size: 0.72rem;
  }
}
