/*
 * The shared demo of the product's panel: its structure and a neutral skin.
 *
 * Every colour, radius, typeface and shadow comes from the --coreness-* properties a page sets; each use
 * carries a fallback, so the demo stands on its own with nothing set. The panel draws no outer frame: the
 * page frames it, and the demo fills what it is given.
 */

/* The mount is the query container: the demo answers the width it was given, not the window's. */
[data-coreness-demo] {
  container-type: inline-size;
}

.coreness-demo,
.coreness-demo *,
.coreness-demo *::before,
.coreness-demo *::after {
  box-sizing: border-box;
}

.coreness-demo {
  --demo-bg: var(--coreness-bg, #ffffff);
  --demo-surface: var(--coreness-surface, #ffffff);
  --demo-surface-2: var(--coreness-surface-2, #f2f4f7);
  --demo-line: var(--coreness-line, #d8dce3);
  /* The boundary of a control — the off switch's ring, an input's or a checkbox's border. It is not the
     card line: a card edge may be faint, a control's outline may not, and the fallback clears the 3:1 floor
     against the fallback surface. */
  --demo-control-line: var(--coreness-control-line, #6b7280);
  --demo-text: var(--coreness-text, #15181e);
  --demo-muted: var(--coreness-muted, #586273);
  --demo-accent: var(--coreness-accent, #2455ff);
  --demo-font: var(--coreness-font, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);
  --demo-mono: var(--coreness-mono, ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace);
  --demo-shadow: var(--coreness-shadow, 0 1px 2px rgba(17, 22, 35, 0.08));
  --demo-radius-card: calc(var(--coreness-radius, 12px) * 0.78);
  --demo-radius-small: calc(var(--coreness-radius, 12px) * 0.5);

  display: flex;
  align-items: stretch;
  background: var(--demo-bg);
  color: var(--demo-text);
  font-family: var(--demo-font);
  font-size: 14px;
  line-height: 22px;
  text-align: left;
}

/* The rail */

.coreness-rail {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 18px;
  width: 188px;
  padding: 22px 12px 24px;
}

.coreness-brand {
  padding: 0 12px;
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
}

.coreness-rail-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.coreness-rail-item {
  appearance: none;
  margin: 0;
  padding: 9px 16px 9px 12px;
  border: 0;
  border-radius: var(--demo-radius-small);
  background: transparent;
  color: var(--demo-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.coreness-rail-item:hover {
  background: var(--demo-surface-2);
}

.coreness-rail-item[aria-current="true"] {
  background: var(--demo-surface-2);
}

/* The pane and a section */

/* The pane is a grid of one cell: the sections stand on top of one another, so the open one decides what
   is seen while the tallest one decides the height. A window that changes its size at every press moves the
   page under the reader, and the panel would read as a widget rather than as the application's frame. */
.coreness-pane {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  flex: 1 1 auto;
  align-items: start;
  justify-items: center;
  min-width: 0;
  padding: 26px 30px 32px;
}

.coreness-section {
  display: flex;
  grid-area: 1 / 1;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 960px;
}

/* A closed section keeps its box for the pane's height and is drawn by nothing: `visibility` takes it out of
   the picture, the pointer and the tab order while `hidden` keeps the state the tree is read by. */
.coreness-section[hidden] {
  display: flex;
  visibility: hidden;
}

.coreness-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
}

.coreness-section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
}

.coreness-count {
  color: var(--demo-muted);
  font-size: 12px;
  line-height: 18px;
  font-variant-numeric: tabular-nums;
}

.coreness-intro {
  margin: 0;
  max-width: 76ch;
  color: var(--demo-muted);
  font-size: 14px;
  line-height: 22px;
}

.coreness-hint {
  margin: 0;
  max-width: 86ch;
  color: var(--demo-muted);
  font-size: 12px;
  line-height: 18px;
}

/* A surface: the product's card, its radius and its lift. */

.coreness-panel {
  background: var(--demo-surface);
  border: 1px solid var(--demo-line);
  border-radius: var(--demo-radius-card);
  box-shadow: var(--demo-shadow);
}

/* The MCP roster */

.coreness-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.coreness-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 16px;
  row-gap: 6px;
  padding: 13px 16px;
}

.coreness-card-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.coreness-card-name {
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
}

.coreness-card-sub {
  color: var(--demo-muted);
  font-size: 12px;
  line-height: 18px;
  overflow-wrap: anywhere;
}

.coreness-card-sub code {
  font-family: var(--demo-mono);
  font-size: 12px;
}

.coreness-card-tools {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--demo-muted);
  font-size: 12px;
  line-height: 18px;
  overflow-wrap: anywhere;
}

.coreness-card-tools-label {
  font-weight: 500;
}

/* The switch: the product's track and thumb, mirrored for the off state. */

/* The boundary is a border, not an inset shadow: a border survives Windows High Contrast mode and is the
   edge an instrument can read. The box stays 36 by 20 — the border stands inside it — and the thumb keeps
   2 px of air at the track's edge (1 px border + 1 px place). */
.coreness-switch {
  position: relative;
  flex: none;
  width: 36px;
  height: 20px;
  margin: 2px 0 0;
  padding: 1px;
  border: 1px solid var(--demo-control-line);
  border-radius: 999px;
  background: var(--demo-surface-2);
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.coreness-switch[aria-checked="true"] {
  background: var(--demo-accent);
  border-color: var(--demo-accent);
}

.coreness-switch-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 16px;
  height: 16px;
  border: 1px solid var(--demo-control-line);
  border-radius: 50%;
  background: var(--demo-bg);
  transition: transform 0.12s ease, border-color 0.12s ease;
}

/* On, the thumb stands on the accent and its own fill is the boundary: its edge takes the ground colour. */
.coreness-switch[aria-checked="true"] .coreness-switch-thumb {
  transform: translateX(16px);
  border-color: var(--demo-bg);
}

/* The General card */

.coreness-team {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
}

.coreness-team-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.coreness-status {
  margin-left: auto;
  min-width: 48px;
  color: var(--demo-muted);
  font-size: 12px;
  line-height: 18px;
  text-align: right;
}

.coreness-status[data-tone="done"] {
  color: var(--demo-accent);
}

.coreness-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.coreness-field-label {
  color: var(--demo-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
}

.coreness-field-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.coreness-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--demo-control-line);
  border-radius: var(--demo-radius-small);
  background: var(--demo-surface);
  color: var(--demo-text);
  font: inherit;
  font-size: 14px;
  line-height: 22px;
}

.coreness-input:focus {
  border-color: var(--demo-accent);
}

.coreness-button {
  flex: none;
  appearance: none;
  margin: 0;
  padding: 6px 14px;
  border: 1px solid var(--demo-text);
  border-radius: var(--demo-radius-small);
  background: var(--demo-text);
  color: var(--demo-bg);
  font: inherit;
  font-size: 14px;
  line-height: 22px;
  cursor: pointer;
}

.coreness-button:hover:not(:disabled) {
  filter: brightness(1.12);
}

.coreness-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.coreness-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  line-height: 22px;
  cursor: pointer;
}

/* The check is drawn here rather than left to the platform so its off border is the control line: a native
   box takes the browser's own colour, which no theme property reaches. */
.coreness-check input {
  appearance: none;
  position: relative;
  flex: none;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1px solid var(--demo-control-line);
  border-radius: 3px;
  background: var(--demo-surface);
  cursor: pointer;
}

.coreness-check input:checked {
  border-color: var(--demo-accent);
  background: var(--demo-accent);
}

.coreness-check input:checked::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 4px;
  width: 4px;
  height: 8px;
  border: solid var(--demo-bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Rows: the Qoder models and the limiter's ceilings */

.coreness-rows {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 4px 16px;
  list-style: none;
}

.coreness-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 18px;
  padding: 9px 0;
}

.coreness-row + .coreness-row {
  border-top: 1px solid var(--demo-line);
}

.coreness-row-name {
  font-size: 14px;
  font-weight: 500;
  line-height: 22px;
  overflow-wrap: anywhere;
}

.coreness-row-meta {
  color: var(--demo-muted);
  font-size: 12px;
  line-height: 18px;
  font-variant-numeric: tabular-nums;
}

/* The limit card */

.coreness-limit {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
}

.coreness-limit-cells {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 32px;
}

.coreness-limit-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 112px;
}

.coreness-limit-value {
  font-size: 14px;
  line-height: 22px;
  font-variant-numeric: tabular-nums;
}

.coreness-unit {
  color: var(--demo-muted);
  font-size: 12px;
}

/* Focus: one ring for every control the demo owns, visible on both grounds. */

.coreness-demo :focus-visible {
  outline: 2px solid var(--demo-accent);
  outline-offset: 2px;
}

.coreness-input:focus-visible {
  outline-width: 1.5px;
  outline-offset: 1px;
}

/* In a narrow frame the rail lies above the pane as a row of sections. */

@container (max-width: 760px) {
  .coreness-demo {
    flex-direction: column;
  }

  .coreness-rail {
    width: 100%;
    gap: 10px;
    padding: 16px 16px 12px;
  }

  .coreness-brand {
    padding: 0 2px;
  }

  .coreness-rail-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }

  .coreness-rail-item {
    padding: 7px 10px;
  }

  .coreness-pane {
    padding: 18px 16px 22px;
  }
}

/* The demo keeps no motion of its own where the reader asked it to keep still. */

@media (prefers-reduced-motion: reduce) {
  .coreness-demo *,
  .coreness-demo *::before,
  .coreness-demo *::after {
    transition: none !important;
    animation: none !important;
  }
}
