/* Widgets for the compression-is-intelligence post. Data colours are the dataviz
   reference palette, validated on the site's light (#fbfaf7) and dark (#0a0a0a)
   surfaces. Text stays in the site's ink tokens; colour marks identity only. */
:root {
  --cii-s1: #2a78d6; --cii-s2: #eb6834; --cii-s3: #1baf7a; --cii-s4: #eda100; --cii-s5: #e87ba4; --cii-s6: #008300;
  --cii-k1: #ffffff; --cii-k2: #ffffff; --cii-k3: #06231a; --cii-k4: #2a1c00; --cii-k5: #2b0716; --cii-k6: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --cii-s1: #3987e5; --cii-s2: #d95926; --cii-s3: #199e70; --cii-s4: #c98500; --cii-s5: #d55181; --cii-s6: #008300;
    --cii-k3: #031510; --cii-k4: #1a1100; --cii-k5: #ffffff;
  }
}
:root[data-theme="dark"] {
  --cii-s1: #3987e5; --cii-s2: #d95926; --cii-s3: #199e70; --cii-s4: #c98500; --cii-s5: #d55181; --cii-s6: #008300;
  --cii-k3: #031510; --cii-k4: #1a1100; --cii-k5: #ffffff;
}

.cii { position: relative; margin: 28px 0 10px; padding: 16px; border-radius: 8px; background: var(--surface); color: var(--ink); font-family: var(--font-sans); font-size: 15px; line-height: 1.45; }
.cii-cap { font-family: var(--font-sans); font-size: 15px; line-height: 1.5; max-width: 34rem; color: var(--muted); margin-top: 8px !important; }
.cii-title { font-weight: 600; font-size: 15px; margin: 0 0 10px; }
.cii-sub { font-weight: 600; font-size: 14px; margin: 14px 0 4px; }
.cii-note { font-size: 13px; color: var(--muted); }
.cii-mono, .cii-small { font-family: var(--font-mono); font-size: 12px; }
.cii-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.cii .pill { font-family: var(--font-sans); cursor: pointer; border: 0; background: color-mix(in srgb, var(--ink) 9%, var(--bg)); }
.cii .pill:hover { background: color-mix(in srgb, var(--ink) 14%, var(--bg)); }
.cii .pill[aria-pressed="true"] { background: var(--accent); color: var(--bg); }
.cii-inline { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink); }
.cii-inline input[type="range"] { width: min(16rem, 60vw); accent-color: var(--accent); }
.cii-inline input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.cii-input { display: block; width: 100%; box-sizing: border-box; font: 400 14px/1.45 var(--font-mono); color: var(--ink); background: var(--bg); border: 1px solid var(--hairline); border-radius: 6px; padding: 9px 11px; resize: vertical; }
.cii-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.cii-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cii-chart { display: block; width: 100%; min-width: 540px; height: auto; overflow: visible; }
.cii-chart text { font-family: var(--font-sans); }
.cii-grid { stroke: var(--hairline); stroke-width: 1; }
.cii-axis { fill: var(--muted); font-size: 13px; }
.cii-lbl { fill: var(--ink); font-size: 13px; font-weight: 600; }
.cii-lbl-m { fill: var(--ink); font-size: 13px; font-family: var(--font-mono) !important; }
.cii-line { fill: none; stroke-width: 2; }
.cii-guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.cii-dot { stroke: var(--surface); stroke-width: 2; }

.cii-readouts { display: flex; flex-wrap: wrap; gap: 10px 24px; margin-top: 10px; }
.cii-ro { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cii-ro .k { font-size: 12px; color: var(--muted); }
.cii-ro .v { font: 500 16px/1.3 var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink); overflow-wrap: anywhere; }
.cii-wide { flex-basis: 100%; }
.cii-sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
.cii-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.cii-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

.cii-hbars { display: grid; gap: 8px; margin-top: 8px; }
.cii-hbar { display: grid; grid-template-columns: minmax(7rem, 11rem) 1fr 4.6rem; gap: 10px; align-items: center; }
.cii-hbar .name { font-size: 14px; line-height: 1.25; }
.cii-hbar .name span { display: block; color: var(--muted); font-size: 12px; }
.cii-hbar .track { height: 16px; background: var(--bg); border-radius: 0 4px 4px 0; }
.cii-hbar .fill { height: 100%; border-radius: 0 4px 4px 0; }
.cii-hbar .val { font: 500 13px/1 var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .cii-hbar { grid-template-columns: 1fr 4.4rem; } .cii-hbar .track { grid-column: 1 / -1; grid-row: 2; } }

.cii-bits { font: 400 13px/1.6 var(--font-mono); overflow-wrap: anywhere; background: var(--bg); border-radius: 6px; padding: 8px 10px; color: var(--ink); }
.cii-explain { margin: 0 0 6px; font-size: 15px; line-height: 1.5; color: var(--body); max-width: 34rem; }
.cii-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--ink); color: var(--bg); font: 500 13px/1.4 var(--font-sans); padding: 7px 9px; border-radius: 6px; max-width: 260px; }
.cii .pill:disabled { cursor: default; opacity: 0.5; }

.cii-game { border-radius: 6px; padding: 10px; background: var(--bg); }
.cii-game:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cii-lead { margin: 0 0 6px !important; font: 400 14px/1.5 var(--font-mono); color: var(--muted); }
.cii-said { display: flex; flex-wrap: wrap; row-gap: 4px; min-height: 42px; }
.cii-w { display: inline-flex; }
.cii-ch { display: inline-flex; flex-direction: column; align-items: center; min-width: 1.2em; border-radius: 3px; font: 500 17px/1.25 var(--font-mono); }
.cii-ch b { font-weight: 500; }
.cii-ch i { font: 500 11px/1.3 var(--font-mono); font-style: normal; color: var(--muted); min-height: 1.3em; }
.cii-ch.cur b { color: var(--accent); }
.cii-keys { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; margin-top: 10px; }
.cii-key { font: 500 15px/1 var(--font-mono); min-height: 36px; padding: 0; border: 0; border-radius: 5px; cursor: pointer; color: var(--ink); background: color-mix(in srgb, var(--ink) 9%, var(--bg)); }
.cii-key:hover { background: color-mix(in srgb, var(--ink) 15%, var(--bg)); }
.cii-key:disabled { cursor: default; color: var(--muted); text-decoration: line-through; background: transparent; }
/* trained start vs random start (cii-prior) */
.cii-br { display: grid; grid-template-columns: 8.5rem 1fr; column-gap: 12px; row-gap: 5px; align-items: center; margin-top: 4px; }
.cii-br .head { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; margin-top: 10px; font-size: 14px; font-weight: 600; }
.cii-br .head .v { font: 500 13px/1.4 var(--font-mono); font-variant-numeric: tabular-nums; }
.cii-br .k { font: 400 12px/1.2 var(--font-mono); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cii-br .lane { position: relative; height: 14px; background: var(--bg); border-radius: 3px; }
.cii-br .seg { position: absolute; top: 0; bottom: 0; border-radius: 4px; cursor: default; }
.cii-br .seg::after { content: ""; position: absolute; inset: -6px 0; }
.cii-br .ref { position: absolute; top: -3px; bottom: -3px; border-left: 1.5px dashed var(--ink); pointer-events: none; }
.cii-br .reflbl, .cii-br .axis { position: relative; height: 16px; }
.cii-br .reflbl span { position: absolute; bottom: 0; transform: translateX(-100%); padding-right: 6px; white-space: nowrap; font-size: 12px; color: var(--muted); }
.cii-br .axis span { position: absolute; top: 2px; transform: translateX(-50%); font: 400 12px/1 var(--font-mono); color: var(--muted); }
.cii-table { margin-top: 12px; font-size: 13px; color: var(--muted); }
.cii-table summary { cursor: pointer; }
.cii-table table { margin: 8px 0 0; font: 400 12px/1.5 var(--font-mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.cii-table th, .cii-table td { padding: 2px 12px 2px 0; text-align: right; }
.cii-table th:first-child, .cii-table td:first-child { text-align: left; }

/* the three jobs of a compressor (cii-jobs) */
.cii-jobs { display: grid; grid-template-columns: 6.5rem 1fr 14px 1.3fr 14px 0.75fr; gap: 6px; font-size: 14px; line-height: 1.35; }
.cii-jobs .h { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 10px; }
.cii-jobs .h.p { color: var(--ink); }
.cii-jobs .n { font-weight: 600; align-self: center; }
.cii-jobs .c { background: var(--bg); border-radius: 6px; padding: 7px 10px; }
.cii-jobs .c.p { background: color-mix(in srgb, var(--accent) 16%, var(--bg)); }
.cii-jobs .a { align-self: center; text-align: center; color: var(--muted); }
.cii-jobs .c .k { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 560px) {
  .cii-jobs { grid-template-columns: 1fr; gap: 3px; }
  .cii-jobs .h, .cii-jobs .h0, .cii-jobs .a { display: none; }
  .cii-jobs .n { margin-top: 10px; }
  .cii-jobs .c { display: grid; grid-template-columns: 4.8rem 1fr; gap: 8px; padding: 5px 10px; }
  .cii-jobs .c .k { position: static; width: auto; height: auto; overflow: visible; clip-path: none; font-size: 12px; line-height: 1.6; color: var(--muted); }
  /* --muted on the accent tint measures 3.89:1; the label needs 4.5:1 at 12px. */
  .cii-jobs .c.p .k { color: var(--ink); }
}
@media (prefers-reduced-motion: reduce) { .cii * { transition: none !important; animation: none !important; } }
