/* Context Budget Lab (how-an-agent-builds-its-context post). Token-driven only: every colour is a site token, so the
   light and dark themes follow the tokens and no theme-specific rule is needed. Loaded by the post itself. */
.cbl {
  --cbl-target: 2.75rem; /* 44 CSS px touch target (WCAG 2.5.5) */
  margin: var(--space-lg) 0;
  padding: var(--space-md);
  border: thin solid var(--color-border);
  border-radius: 0.5em;
  background: var(--color-bg-alt);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: 1.45;
  max-width: 100%;
  min-width: 0;
}
.cbl[hidden] { display: none; }
.cbl__note { margin: 0 0 var(--space-sm); color: var(--color-text-muted); font-size: var(--text-xs); font-style: italic; }
.cbl__sr { position: absolute; width: 0.0625rem; height: 0.0625rem; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Controls: one column on a phone, two where there is room */
.cbl__controls { display: grid; gap: var(--space-sm) var(--space-md); grid-template-columns: minmax(0, 1fr); margin: 0; }
@media (min-width: 40em) { .cbl__controls { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cbl__field { display: flex; flex-direction: column; gap: 0.25em; min-width: 0; }
.cbl__label { font-weight: 600; font-size: var(--text-ui); }
.cbl__out { font-weight: 400; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.cbl__select {
  font: inherit; font-size: var(--text-ui); max-width: 100%; min-height: var(--cbl-target);
  padding: 0 var(--space-xs); border: thin solid var(--color-border); border-radius: 0.4em;
  background: var(--color-bg); color: var(--color-text);
}
.cbl__range { width: 100%; min-height: var(--cbl-target); margin: 0; accent-color: var(--color-accent); background: transparent; }
.cbl__policy { grid-column: 1 / -1; margin: 0; padding: var(--space-xs) var(--space-sm) var(--space-sm); border: thin solid var(--color-border); border-radius: 0.4em; min-width: 0; }
.cbl__policy legend { padding: 0 0.25em; }
.cbl__radio { display: flex; align-items: center; gap: 0.5em; min-height: var(--cbl-target); cursor: pointer; }
.cbl__radio input { width: 1.1em; height: 1.1em; margin: 0; accent-color: var(--color-accent); flex: none; }
.cbl__select:focus-visible, .cbl__range:focus-visible, .cbl__radio input:focus-visible { outline: 0.2em solid var(--color-accent); outline-offset: 0.1em; }

/* The window as one bar */
.cbl__barwrap { margin: var(--space-md) 0 var(--space-sm); }
.cbl__panel-title {
  margin: 0 0 var(--space-xs); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-text-muted);
}
.cbl__bar {
  display: flex; height: 2.25rem; width: 100%; overflow: hidden;
  border: thin solid var(--color-border); border-radius: 0.4em; background: var(--color-bg);
}
.cbl__seg { display: block; height: 100%; min-width: 0.25rem; flex: none; box-shadow: inset -0.0625rem 0 0 var(--color-bg); transition: width 0.2s ease; }
@media (prefers-reduced-motion: reduce) { .cbl__seg { transition: none; } }
.cbl__seg--system, .cbl__key--system { background: var(--color-pop-violet); }
.cbl__seg--tools, .cbl__key--tools { background: var(--color-pop-gold); }
.cbl__seg--history, .cbl__key--history { background: var(--color-bg-navy); }
.cbl__seg--summary, .cbl__key--summary {
  background: repeating-linear-gradient(45deg, var(--color-bg-navy) 0 0.3em, var(--color-bg) 0.3em 0.6em);
}
.cbl__seg--passages, .cbl__key--passages { background: var(--color-pop-coral); }
.cbl__seg--user, .cbl__key--user { background: var(--color-accent); }
.cbl__seg--reply, .cbl__key--reply {
  background: repeating-linear-gradient(-45deg, var(--color-text-muted) 0 0.15em, transparent 0.15em 0.5em);
}
.cbl__seg--free { flex: 1 1 auto; background: transparent; box-shadow: none; }
.cbl__status { margin: var(--space-xs) 0 0; font-weight: 600; }
.cbl.is-rejected .cbl__status { padding-left: var(--space-xs); border-left: 0.25em solid var(--color-pop-coral); }

/* The table: scrolls inside itself at 320px rather than widening the page */
.cbl__tablewrap { max-width: 100%; overflow-x: auto; margin: var(--space-sm) 0; }
.cbl__table { width: 100%; border-collapse: collapse; font-size: var(--text-xs); }
.cbl__table th, .cbl__table td { padding: 0.35em 0.5em; border-bottom: thin solid var(--color-border); text-align: left; vertical-align: top; }
.cbl__table thead th { color: var(--color-text-muted); font-weight: 600; }
.cbl__table tbody th { font-weight: 600; white-space: nowrap; }
.cbl__num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Phone: each row becomes a small card: the part, then asked and sent side by side, then what happened */
@media (max-width: 34em) {
  .cbl__table thead { position: absolute; width: 0.0625rem; height: 0.0625rem; overflow: hidden; clip-path: inset(50%); }
  .cbl__table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 var(--space-sm); padding: var(--space-xs) 0; border-bottom: thin solid var(--color-border); }
  .cbl__table th, .cbl__table td { border-bottom: 0; padding: 0.15em 0; }
  .cbl__table tbody th { grid-column: 1 / -1; white-space: normal; }
  .cbl__table .cbl__num { text-align: left; }
  .cbl__table .cbl__num::before { content: attr(data-label) " "; color: var(--color-text-muted); }
  .cbl__table .cbl__what { grid-column: 1 / -1; color: var(--color-text-muted); }
}
.cbl__key { display: inline-block; width: 0.8em; height: 0.8em; margin-right: 0.4em; border-radius: 0.15em; vertical-align: -0.05em; border: thin solid var(--color-border); }

.cbl__loss { margin: 0; padding-left: 1.1em; font-family: var(--font-serif); font-size: var(--text-base); }
.cbl__loss li { margin: 0 0 var(--space-xs); }
