/* Code panel of the Unisson documentation: the ".code", ".glow", ".copy", ".render" and code colouring rules of the
   model, with its 700 px tier. Colours through the --pack-* tokens only; the font stacks are the model's own. */
:host {
  display: block;
  min-inline-size: 0;
  color: var(--pack-ink);
  font:
    16px / 1.6 Inter,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  letter-spacing: normal;
  font-feature-settings: normal;
  -webkit-font-smoothing: antialiased;
}
:host([hidden]),
:host([collapsed]) {
  display: none;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
:focus-visible {
  outline: 2px solid var(--pack-focus);
  outline-offset: 3px;
  border-radius: 6px;
}

/* .code.glow: panel, hairline border, shadow, and the gradient ring drawn by a masked pseudo-element. */
[part="panel"] {
  position: relative;
  /* The documentation's gap above the panel; an enclosing layout (the playground's grid) may set it to 0. */
  margin-block-start: var(--pack-code-offset, 18px);
  border-radius: 14px;
  overflow: hidden;
  background: var(--pack-panel);
  border: 1px solid var(--pack-line);
  box-shadow: var(--pack-shadow);
}
[part="panel"]::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(140deg, var(--pack-c1), transparent 35%, transparent 65%, var(--pack-c2));
  opacity: 0.55;
  pointer-events: none;
  -webkit-mask:
    linear-gradient(var(--pack-ink) 0 0) content-box,
    linear-gradient(var(--pack-ink) 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(var(--pack-ink) 0 0) content-box exclude,
    linear-gradient(var(--pack-ink) 0 0);
}

[part="bar"] {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-block-end: 1px solid var(--pack-line);
  flex-wrap: wrap;
}
[part="tabs"] {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--pack-panel2);
  box-shadow: 0 0 0 1px var(--pack-line) inset;
}
[part="tab"] {
  min-block-size: 30px;
  min-inline-size: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--pack-mut);
  font:
    600 12.5px ui-monospace,
    "JetBrains Mono",
    Menlo,
    Consolas,
    monospace;
  letter-spacing: normal;
  cursor: pointer;
}
[part="tab"]:hover {
  color: var(--pack-ink);
}
[part="tab"][aria-selected="true"] {
  color: var(--pack-btnink);
  background: linear-gradient(120deg, var(--pack-btn1), var(--pack-btn2));
}
[part="file"] {
  margin-inline-start: auto;
  font:
    600 12px ui-monospace,
    "JetBrains Mono",
    Menlo,
    Consolas,
    monospace;
  color: var(--pack-mut);
  white-space: nowrap;
}
[part="copy"] {
  min-block-size: 36px;
  padding: 0 12px;
  border: 1px solid var(--pack-line2);
  border-radius: 8px;
  background: var(--pack-panel2);
  color: var(--pack-ink);
  font:
    600 12px ui-monospace,
    "JetBrains Mono",
    Menlo,
    Consolas,
    monospace;
  letter-spacing: normal;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
[part="copy"]:hover {
  border-color: var(--pack-c1);
}
[part="copy"][data-done] {
  border-color: var(--pack-c3);
}
[part="copy"] svg {
  display: block;
  flex: none;
}
/* --pack-code-size, --pack-code-max and --pack-code-narrow-padding let a container set the code's size, cap its height
   and keep its padding under 700 px, as the Studio editor's export column does (12.5 px, 300 px, 16 px 18 px); unset,
   the documentation's 14 px, no cap and 14 px. */
[part="code"] {
  margin: 0;
  padding: 16px 18px;
  max-block-size: var(--pack-code-max, none);
  font:
    var(--pack-code-size, 14px) / 1.65 ui-monospace,
    "JetBrains Mono",
    Menlo,
    Consolas,
    monospace;
  color: var(--pack-codeink);
  background: var(--pack-code);
  overflow: auto;
  tab-size: 2;
  /* The playground keeps its code block 180 px high whatever the example: the page below does not jump. */
  min-block-size: var(--pack-code-min-block-size, auto);
}
[part="code"] code {
  font: inherit;
}
/* .code.single: the file name opens the bar. */
[data-single] [part="bar"] {
  padding-inline-start: 16px;
}
[data-single] [part="file"] {
  margin-inline: 0 auto;
}

/* live render below a code panel; the row keeps the model's height (18 px around its 44 px button, plus the rule)
   whatever the slotted control measures, so the page below does not move */
[part="render"] {
  min-block-size: calc(44px + 2 * 18px + 1px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px;
  border-block-start: 1px solid var(--pack-line);
  background: radial-gradient(ellipse at 80% 0%, var(--pack-a2), transparent 60%), var(--pack-panel);
}
[part="render-label"] {
  font:
    600 12px ui-monospace,
    "JetBrains Mono",
    Menlo,
    Consolas,
    monospace;
  color: var(--pack-mut);
}

/* The live region is read, never seen. */
[part="status"] {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Marked passages (marks) and their legend (marks-note): the amber of the model's .chg, from the warning status. */
.chg {
  background: color-mix(in oklch, var(--bythium-status-warning) 16%, transparent);
  box-shadow: inset 0 -2px 0 var(--bythium-status-warning);
  border-radius: 3px;
}
[part="marks-note"] {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
  padding: 8px 14px;
  border-block-start: 1px solid var(--pack-line);
  font-size: 13px;
  color: var(--pack-mut);
}
[part="marks-note"] i {
  display: inline-block;
  inline-size: 22px;
  block-size: 12px;
  border-radius: 3px;
  background: color-mix(in oklch, var(--bythium-status-warning) 16%, transparent);
  box-shadow: inset 0 -2px 0 var(--bythium-status-warning);
}

/* code colouring */
.t {
  color: var(--pack-tok-t);
}
.s {
  color: var(--pack-tok-s);
}
.c {
  color: var(--pack-tok-c);
}
.k {
  color: var(--pack-tok-k);
}
.p {
  color: var(--pack-c3);
}

/* flush: the Studio pages' panel (.code of the agent model), set in a grid or a message, its code a size smaller. */
:host([flush]) [part="panel"] {
  margin-block-start: 0;
}
:host([flush]) [part="code"] {
  padding: 14px 16px;
  font-size: 13px;
}
@media (max-width: 700px) {
  [part="file"] {
    order: -2;
    margin-inline-start: 4px;
    flex: 1;
  }
  [part="copy"] {
    order: -1;
  }
  [part="tabs"] {
    inline-size: 100%;
  }
  [part="tab"] {
    flex: 1;
  }
  [part="code"] {
    font-size: var(--pack-code-size, 13px);
    padding: var(--pack-code-narrow-padding, 14px);
  }
}
/* Forced colours: the glow ring is decoration; the chosen tab keeps a visible mark. */
@media (forced-colors: active) {
  [part="panel"] {
    border-color: CanvasText;
  }
  [part="panel"]::after {
    display: none;
  }
  .chg,
  [part="marks-note"] i {
    forced-color-adjust: none;
    background: Mark;
    color: MarkText;
    box-shadow: none;
  }
  [part="tab"][aria-selected="true"] {
    forced-color-adjust: none;
    color: HighlightText;
    background: Highlight;
  }
  :focus-visible {
    outline-color: Highlight;
  }
}
/* bar-gap: the band of panel the agent model leaves between the bar and the code of its instructions panel. */
:host([bar-gap]) [part="code"] {
  margin-block-start: 14px;
}
/* flush under 700 px: the agent model's 12 px code in a 12 px margin. */
@media (max-width: 700px) {
  :host([flush]) [part="code"] {
    padding: 12px;
    font-size: 12px;
  }
}
