/* Syntax token colors + optional editable overlay (docs try-it console).
 * Colors come from --bp-code-* (defined in bp-system) so palette packs apply. */

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: var(--bp-code-token-comment, #64748b);
}

.token.punctuation {
  color: var(--bp-code-token-punctuation, #94a3b8);
}

.token.namespace {
  opacity: .85;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
  color: var(--bp-code-token-tag, #f472b6);
}

/*
 * Prism marks HTML tags as class="token tag". Never inherit chip/pill chrome
 * from design-system `.tag` (or any future chip rule that targets `.tag`).
 */
.token.tag {
  display: inline !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  gap: 0 !important;
  font-size: inherit !important;
  font-weight: inherit !important;
  font-family: inherit !important;
  line-height: inherit !important;
  letter-spacing: inherit !important;
  vertical-align: baseline !important;
  white-space: inherit !important;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: var(--bp-code-token-string, #86efac);
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  color: var(--bp-code-token-operator, #7dd3fc);
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: var(--bp-code-token-keyword, #c4b5fd);
}

.token.function,
.token.class-name {
  color: var(--bp-code-token-function, #fcd34d);
}

.token.regex,
.token.important,
.token.variable {
  color: var(--bp-code-token-variable, #fdba74);
}

.token.important,
.token.bold {
  font-weight: 700;
}

.token.italic {
  font-style: italic;
}

/*
 * Kill remaining design-system collisions inside Prism overlays
 * (padding / display on bare `.token`, not just `.tag`).
 */
.bp-code-hl .token,
.bp-code-hl .tag,
.dev-code .token,
.dev-code .tag,
[data-bp-highlight] .token,
[data-bp-highlight] .tag,
.bp-el-code-console .token,
.bp-el-code-console .tag {
  display: inline !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: inherit !important;
  font-weight: inherit !important;
  font-family: inherit !important;
  line-height: inherit !important;
  letter-spacing: inherit !important;
  vertical-align: baseline !important;
  white-space: inherit !important;
  gap: 0 !important;
}

.bp-code-hl .token.tag,
.dev-code .token.tag,
[data-bp-highlight] .token.tag,
.bp-el-code-console .token.tag {
  color: var(--bp-code-token-tag, #f472b6) !important;
}

.bp-code-hl .token.attr-name,
.dev-code .token.attr-name,
[data-bp-highlight] .token.attr-name,
.bp-el-code-console .token.attr-name {
  color: var(--bp-code-token-string, #86efac) !important;
}

.bp-code-hl .token.attr-value,
.dev-code .token.attr-value,
[data-bp-highlight] .token.attr-value,
.bp-el-code-console .token.attr-value {
  color: var(--bp-code-token-keyword, #c4b5fd) !important;
}

.bp-code-hl .token.punctuation,
.dev-code .token.punctuation,
[data-bp-highlight] .token.punctuation,
.bp-el-code-console .token.punctuation {
  color: var(--bp-code-token-punctuation, #94a3b8) !important;
}

.bp-code-hl .token.comment,
.dev-code .token.comment,
[data-bp-highlight] .token.comment,
.bp-el-code-console .token.comment {
  color: var(--bp-code-token-comment, #64748b) !important;
}

.bp-code-hl .token.string,
.dev-code .token.string,
[data-bp-highlight] .token.string,
.bp-el-code-console .token.string {
  color: var(--bp-code-token-string, #86efac) !important;
}

.bp-code-hl .token.keyword,
.dev-code .token.keyword,
[data-bp-highlight] .token.keyword,
.bp-el-code-console .token.keyword {
  color: var(--bp-code-token-keyword, #c4b5fd) !important;
}

.bp-code-hl .token.function,
.dev-code .token.function,
[data-bp-highlight] .token.function,
.bp-el-code-console .token.function {
  color: var(--bp-code-token-function, #fcd34d) !important;
}

.bp-code-hl .token.number,
.dev-code .token.number,
[data-bp-highlight] .token.number,
.bp-el-code-console .token.number {
  color: var(--bp-code-token-tag, #f472b6) !important;
}

.bp-code-hl .token.operator,
.dev-code .token.operator,
[data-bp-highlight] .token.operator {
  color: var(--bp-code-token-operator, #7dd3fc) !important;
}

/* Docs samples: base text color; token colors use the shared .token rules above */
.dev-code code,
.dev-section .dev-code code {
  color: var(--bp-code-fg) !important;
}

/* Editable try-it / page HTML: surface grid + optional lint status */
.bp-code-hl {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.bp-code-hl-row {
  display: flex;
  flex: 1 1 auto;
  flex-direction: row;
  align-items: stretch;
  min-width: 0;
  min-height: 0;
  width: 100%;
}

.bp-code-hl-gutter {
  flex: 0 0 auto;
  box-sizing: border-box;
  width: calc(var(--bp-code-gutter-digits, 2) * 1ch + 1.35rem);
  margin: 0;
  padding: var(--space-12) var(--space-7) var(--space-12) var(--space-9);
  overflow: hidden;
  border-right: 1px solid var(--bp-code-border, color-mix(in srgb, #94a3b8 18%, transparent));
  background: var(--bp-code-gutter-bg, color-mix(in srgb, #0f172a 78%, #1e293b));
  color: var(--bp-code-muted, #64748b);
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
  font-size: var(--bp-text-sm);
  font-variant-numeric: tabular-nums;
  line-height: 1.55;
  text-align: right;
  user-select: none;
  pointer-events: none;
  scrollbar-width: none;
}

.bp-code-hl-gutter::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.bp-code-hl-gutter[hidden] {
  display: none !important;
}

.bp-code-hl-gutter-inner {
  display: block;
  min-height: 100%;
}

.bp-code-hl-ln {
  display: block;
  box-sizing: border-box;
  height: 1.55em;
  line-height: 1.55;
  white-space: nowrap;
  overflow: hidden;
}

/* Soft-wrap: JS sets per-line height so #N stays aligned with logical line N (VS Code style). */
.bp-code-hl.is-wrap .bp-code-hl-ln {
  height: auto;
  min-height: 1.55em;
}

.bp-code-hl-surface {
  position: relative;
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  width: 100%;
}

.bp-code-hl-surface > .bp-code-hl-pre,
.bp-code-hl-surface > .bp-code-lint,
.bp-code-hl-surface > textarea {
  grid-area: 1 / 1;
  margin: 0;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 0;
  /* Lock identical metrics on mirror + textarea or caret/selection drift. */
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace);
  font-size: var(--bp-text-sm);
  font-weight: 400;
  font-style: normal;
  font-variant-ligatures: none;
  font-feature-settings: normal;
  font-kerning: none;
  line-height: 1.55;
  letter-spacing: 0;
  word-spacing: 0;
  tab-size: 2;
  -moz-tab-size: 2;
  white-space: pre;
  overflow: auto;
  padding: var(--space-12) var(--space-13) var(--space-13);
}

.bp-code-hl.is-wrap .bp-code-hl-surface > .bp-code-hl-pre,
.bp-code-hl.is-wrap .bp-code-hl-surface > .bp-code-lint,
.bp-code-hl.is-wrap .bp-code-hl-surface > textarea {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  overflow-x: hidden;
}

.bp-code-hl-surface > .bp-code-hl-pre {
  z-index: 0;
  pointer-events: none;
  background: transparent;
  color: var(--bp-code-fg, #e2e8f0);
}

.bp-code-hl-surface > .bp-code-hl-pre code {
  display: block;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  font-variant-ligatures: none;
  line-height: inherit;
  letter-spacing: inherit;
  word-spacing: inherit;
  background: transparent !important;
  color: inherit;
  padding: 0 !important;
  margin: 0;
  border-radius: 0;
  box-shadow: none !important;
  white-space: inherit;
  tab-size: inherit;
}

.bp-code-hl-surface > .bp-code-lint {
  z-index: 1;
  position: relative;
  pointer-events: none;
  overflow: auto;
  color: transparent;
  background: transparent;
  scrollbar-width: none;
}

.bp-code-hl-surface > .bp-code-lint::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.bp-code-lint-inner {
  position: relative;
  width: 100%;
  min-width: 100%;
  pointer-events: none;
}

.bp-code-lint-mark {
  position: absolute;
  height: 3px;
  border-radius: 1px;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      -60deg,
      transparent 0 2px,
      var(--bp-code-lint-mark, #f87171) 2px 4px
    );
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--bp-code-lint-mark, #f87171) 35%, transparent);
}

.bp-code-lint-status {
  flex: 0 0 auto;
  margin: 0;
  padding: var(--space-5) var(--space-11);
  border-top: 1px solid color-mix(in srgb, var(--bp-code-lint-mark, #f87171) 45%, transparent);
  background: var(--bp-code-lint-bg, color-mix(in srgb, #7f1d1d 88%, #0f172a));
  color: var(--bp-code-lint-fg, #fecaca);
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
  font-size: var(--bp-text-xs);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bp-code-hl-surface > textarea,
.bp-code-hl-surface > textarea.bp-code-hl-ta,
.bp-code-hl-surface > textarea.dev-tryit-code,
.bp-code-hl-surface > textarea.pb-code-editor-code {
  z-index: 2;
  resize: vertical;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--bp-code-caret, #e2e8f0);
  outline: none;
  font-variant-ligatures: none;
  /* Beat any later textarea { font: inherit } rules. */
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace) !important;
  font-size: var(--bp-text-sm) !important;
  font-weight: 400 !important;
  line-height: 1.55 !important;
  letter-spacing: 0 !important;
  word-spacing: 0 !important;
}

.bp-code-hl-surface > textarea::placeholder {
  color: var(--bp-code-muted, #64748b);
  -webkit-text-fill-color: var(--bp-code-muted, #64748b);
}

.bp-code-hl-surface > textarea::selection {
  background: color-mix(in srgb, var(--c-primary, #3b82f6) 45%, transparent);
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.dev-tryit-editor .bp-code-hl {
  min-height: 14rem;
}

.dev-tryit-editor .bp-code-hl-row,
.dev-tryit-editor .bp-code-hl-surface > .bp-code-hl-pre,
.dev-tryit-editor .bp-code-hl-surface > .bp-code-lint,
.dev-tryit-editor .bp-code-hl-surface > .dev-tryit-code {
  min-height: 14rem;
}

.dev-tryit-editor .bp-code-hl-surface > .dev-tryit-code:focus {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--dev-primary) 45%, transparent);
}

/* ── Universal fenced / editor chrome (site-wide) ─────────────────────── */
/* Themed fenced snippets (same chrome as developers docs) */
.dev-code {
  position: relative;
  margin: var(--space-11) 0 var(--space-13b);
  border-radius: var(--bp-card-radius);
  background: var(--bp-code-bg);
  color: var(--bp-code-fg);
  box-shadow: var(--bp-shadow);
  border: 1px solid var(--bp-code-border);
  overflow: hidden
}

.dev-code-toolbar,
.dev-code-toolbar.analytics-tabs {
  display: flex;
  width: 100%;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-6);
  margin: 0;
  min-height: 0;
  padding: var(--space-9) var(--space-8a);
  border-radius: 0;
  border-bottom: 1px solid var(--bp-code-border);
  background: var(--bp-code-toolbar-bg);
  box-shadow: none
}

.dev-code-toolbar .analytics-tab {
  color: var(--bp-code-muted);
  background: transparent;
  box-shadow: none;
  border: 0;
  min-height: calc(var(--btn-min-height) - 8px);
  cursor: pointer
}

.dev-code-toolbar span.analytics-tab {
  cursor: default
}

.dev-code-toolbar .analytics-tab:hover:not(.is-active):not(:disabled) {
  color: var(--bp-code-fg);
  background: var(--bp-code-tab-hover);
  box-shadow: none
}

.dev-code-toolbar .analytics-tab.is-active {
  color: var(--bp-code-fg);
  background: var(--bp-code-tab-active);
  box-shadow: none
}

.dev-code-toolbar .dev-code-copy {
  margin-left: auto;
  cursor: pointer;
  font-family: inherit
}

.dev-code pre {
  margin: 0;
  padding: var(--space-12) var(--space-13) var(--space-13);
  overflow-x: auto;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
  font-size: var(--bp-text-sm);
  line-height: 1.55;
  background: transparent;
  color: inherit
}

.dev-code code {
  font-family: inherit;
  font-size: inherit;
  background: transparent !important;
  color: inherit !important;
  padding: 0 !important;
  border-radius: 0;
  box-shadow: none !important
}

.pb-code-editor {
  margin: 0;
  border-radius: var(--bp-card-radius);
  background: var(--bp-code-bg);
  color: var(--bp-code-fg);
  box-shadow: var(--bp-shadow);
  border: 1px solid var(--bp-code-border);
  overflow: hidden
}

/* Header bar for every code section (editor, docs, embeds).
 * Do not require `.analytics-tabs` - that class is only for language mode chips. */
.pb-code-editor-toolbar,
.pb-code-editor-toolbar.analytics-tabs {
  display: flex;
  width: 100%;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-8);
  margin: 0;
  min-height: 0;
  padding: var(--space-6) var(--space-9) var(--space-6) var(--space-12);
  border-radius: 0;
  border-bottom: 1px solid var(--bp-code-border);
  background: var(--bp-code-toolbar-bg);
  box-shadow: none;
  box-sizing: border-box;
}

.pb-code-editor-lang {
  font-size: var(--bp-text-sm);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--bp-code-muted)
}

.pb-code-editor-modes {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  min-width: 0
}

.pb-code-editor-toolbar .analytics-tab {
  color: var(--bp-code-muted);
  background: transparent;
  box-shadow: none;
  border: 0;
  min-height: calc(var(--btn-min-height) - 8px);
  cursor: pointer;
  font-family: inherit
}

.pb-code-editor-toolbar .analytics-tab:hover:not(.is-active):not(:disabled) {
  color: var(--bp-code-fg);
  background: var(--bp-code-tab-hover);
  box-shadow: none
}

.pb-code-editor-toolbar .analytics-tab.is-active,
.pb-code-editor-toolbar.analytics-tabs.bp-slide-select--live .analytics-tab.is-active,
.pb-code-editor-toolbar.analytics-tabs.bp-slide-select--live .analytics-tab.is-active:hover,
.pb-code-editor-toolbar.analytics-tabs.bp-slide-select--live.bp-slide-select--no-clip .analytics-tab.is-active,
.pb-code-editor-toolbar.analytics-tabs.bp-slide-select--live.bp-slide-select--no-clip .analytics-tab.is-active:hover {
  color: var(--bp-code-fg) !important;
  background: var(--bp-code-tab-active) !important;
  box-shadow: none !important
}

.pb-code-editor-toolbar.bp-slide-select--live > .bp-slide-select__pill,
.pb-code-editor-toolbar.bp-slide-select--live > .bp-slide-select__clip {
  display: none !important
}

.pb-code-editor-toolbar .pb-code-editor-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-5);
}

.pb-code-editor-toolbar .pb-code-editor-copy,
.pb-code-editor-toolbar .pb-console-copy,
.pb-code-editor-toolbar .pb-code-editor-wrap,
.pb-code-editor-toolbar .pb-code-theme-toggle {
  margin-left: 0
}

.pb-console-copy,
.pb-code-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  min-width: 2.15rem;
  padding: var(--space-6a) var(--space-10);
}

.pb-console-copy .pb-icon-mask,
.pb-code-theme-toggle .pb-icon-mask,
.pb-code-theme-toggle .bp-icon-mask {
  width: .95rem;
  height: .95rem;
  background-color: currentColor
}

.pb-console-copy.is-copied {
  color: var(--bp-code-token-string) !important
}

/*
 * Independent code chrome theme (persisted as data-bp-code-theme).
 * Fixed tokens so light UI + dark code (or the reverse) stay readable.
 * Selectors beat palette packs: [data-palette][data-theme="dark"] is (0,2,0).
 */
html[data-bp-code-theme="dark"],
html[data-palette][data-bp-code-theme="dark"],
html[data-theme="dark"][data-bp-code-theme="dark"],
html[data-palette][data-theme="dark"][data-bp-code-theme="dark"] {
  --bp-code-bg: #0f172a;
  --bp-code-fg: #e2e8f0;
  --bp-code-muted: #94a3b8;
  --bp-code-border: color-mix(in srgb, #94a3b8 22%, transparent);
  --bp-code-toolbar-bg: #0f172a;
  --bp-code-gutter-bg: color-mix(in srgb, #0f172a 78%, #1e293b);
  --bp-code-tab-hover: color-mix(in srgb, #94a3b8 18%, transparent);
  --bp-code-tab-active: color-mix(in srgb, #94a3b8 28%, transparent);
  --bp-code-caret: #e2e8f0;
  --bp-code-token-comment: #64748b;
  --bp-code-token-punctuation: #94a3b8;
  --bp-code-token-tag: #f472b6;
  --bp-code-token-string: #86efac;
  --bp-code-token-keyword: #c4b5fd;
  --bp-code-token-function: #fcd34d;
  --bp-code-token-operator: #7dd3fc;
  --bp-code-token-variable: #fdba74;
  --bp-code-lint-mark: #f87171;
  --bp-code-lint-bg: color-mix(in srgb, #7f1d1d 88%, #0f172a);
  --bp-code-lint-fg: #fecaca;
}

html[data-bp-code-theme="light"],
html[data-palette][data-bp-code-theme="light"],
html[data-theme="dark"][data-bp-code-theme="light"],
html[data-palette][data-theme="dark"][data-bp-code-theme="light"] {
  --bp-code-bg: #f1f5f9;
  --bp-code-fg: #0f172a;
  --bp-code-muted: #64748b;
  --bp-code-border: #e2e8f0;
  --bp-code-toolbar-bg: #f1f5f9;
  --bp-code-gutter-bg: #e2e8f0;
  --bp-code-tab-hover: color-mix(in srgb, #64748b 14%, transparent);
  --bp-code-tab-active: color-mix(in srgb, #64748b 22%, transparent);
  --bp-code-caret: #0f172a;
  --bp-code-token-comment: #64748b;
  --bp-code-token-punctuation: #475569;
  --bp-code-token-tag: #be185d;
  --bp-code-token-string: #15803d;
  --bp-code-token-keyword: #6d28d9;
  --bp-code-token-function: #b45309;
  --bp-code-token-operator: #0369a1;
  --bp-code-token-variable: #c2410c;
  --bp-code-lint-mark: #dc2626;
  --bp-code-lint-bg: color-mix(in srgb, #dc2626 12%, #f1f5f9);
  --bp-code-lint-fg: #991b1b;
}

.pb-code-editor-code {
  display: block;
  width: 100%;
  min-height: 14rem;
  max-height: min(48vh, 28rem);
  margin: 0;
  padding: var(--space-12) var(--space-13) var(--space-13);
  border: 0;
  resize: vertical;
  background: transparent;
  color: var(--bp-code-fg);
  caret-color: var(--bp-code-caret);
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace);
  font-size: var(--bp-text-sm);
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: 0;
  word-spacing: 0;
  box-sizing: border-box;
  outline: none;
  white-space: pre;
  overflow-x: auto;
  tab-size: 2;
  -moz-tab-size: 2;
}

.pb-code-editor .bp-code-hl {
  min-height: 14rem;
  max-height: min(48vh, 28rem);
  background: transparent
}

.pb-code-editor .bp-code-hl-surface > .bp-code-hl-pre,
.pb-code-editor .bp-code-hl-surface > .bp-code-lint,
.pb-code-editor .bp-code-hl-surface > textarea.pb-code-editor-code {
  min-height: 14rem;
  max-height: min(48vh, 28rem);
  padding: var(--space-12) var(--space-13) var(--space-13);
  font-size: var(--bp-text-sm);
  line-height: 1.55;
  tab-size: 2
}

.pb-code-editor .bp-code-hl-surface > textarea.pb-code-editor-code,
.pb-code-editor .bp-code-hl-surface > textarea.bp-code-hl-ta {
  background: transparent !important;
  color: transparent !important;
  -webkit-text-fill-color: transparent !important;
  caret-color: var(--bp-code-caret)
}

.pb-code-editor .bp-code-hl.is-wrap textarea.pb-code-editor-code,
.pb-code-editor .bp-code-hl.is-wrap .bp-code-hl-surface > .bp-code-hl-pre,
.pb-code-editor .bp-code-hl.is-wrap .bp-code-hl-surface > .bp-code-lint,
.pb-code-editor .bp-code-hl.is-wrap .bp-code-hl-surface > textarea.pb-code-editor-code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  overflow-x: hidden
}

.pb-code-editor-code:focus,
.pb-code-editor .bp-code-hl-surface > textarea.pb-code-editor-code:focus {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c-primary) 45%, transparent)
}

.pb-code-editor-code::placeholder {
  color: var(--bp-code-muted);
  -webkit-text-fill-color: var(--bp-code-muted)
}

.pb-code-editor .bp-code-hl-surface > textarea::selection {
  background: color-mix(in srgb, var(--c-primary, #3b82f6) 45%, transparent);
  color: transparent;
  -webkit-text-fill-color: transparent
}

