/* The post "Universal Test-Time Training" (/blog/uttt/, /en/blog/uttt/).
   The article keeps its own type and figure colours; every rule is scoped under #main.utb, the post's <main>.
   Light and dark follow the site's switch (site.css explains it); the two dark blocks at the end are the same list. */

#main.utb {
  --u-ink: #1f2423; --u-ink-2: #3b4241; --u-muted: #5d6766; --u-paper: #ffffff;
  --u-rule: #dfe3e2; --u-wash: #f5f7f6; --u-accent: #176b65; --u-accent-hover: #104c48;
  --u-note-rule: #b7791f; --u-note-wash: #fbf6ec;
  --u-tile: #ffffff;
  /* chart colours: the paper's own (uTTT-MoE magenta, TTT-MoE green, TTT-Dense purple, uTTT-Dense blue) */
  --c-uttt: #d6006f; --c-tttmoe: #0f9d74; --c-tttdense: #7b52c4; --c-lact: #a78bd6; --c-udense: #1f78d1;
  --c-base: #8f9796; --c-ref: #1f2423; --c-grid: #e9ecec; --c-axis: #8f9796; --c-tick: #5d6766;
  --c-same: #e8b93c; --c-down: #e0662b; --c-up: #f2b38c; --c-resid: #d9dedd; --c-none: #f3f5f4;
  box-sizing: border-box;
  margin: 0 auto;
  color: var(--u-ink);
  background: var(--u-paper);
  font-family: var(--font-sans);
  font-size: 18px;
  line-height: 1.7;
}
#main.utb:lang(zh) { line-height: 1.85; }
#main.utb *, #main.utb *::before, #main.utb *::after { box-sizing: border-box; }

.utb .utb-page { max-width: 1000px; margin: 0 auto; padding: 0 24px 96px; }
.utb article { max-width: 700px; margin: 0 auto; overflow-wrap: anywhere; }

.utb a { color: var(--u-accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--u-accent) 40%, transparent); text-underline-offset: 0.18em; }
.utb a:hover { color: var(--u-accent-hover); text-decoration-color: currentColor; }

/* header */
.utb .utb-head { padding: 56px 0 4px; }
.utb .kicker { margin: 0 0 14px; font-size: 13px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--u-muted); }
.utb .kicker a { color: inherit; text-decoration: none; }
.utb .kicker a:hover { color: var(--u-accent); }
.utb h1 { margin: 0 0 18px; font-size: clamp(32px, 5vw, 46px); line-height: 1.15; font-weight: 650; letter-spacing: -0.02em; text-wrap: balance; }
.utb .standfirst { margin: 0 0 22px; font-size: 20px; line-height: 1.55; color: var(--u-ink-2); }
.utb .byline { margin: 0 0 4px; font-size: 15px; line-height: 1.6; color: var(--u-ink-2); }
.utb .byline.small { font-size: 13.5px; color: var(--u-muted); }
.utb .links { margin: 10px 0 0; font-size: 15px; }
.utb sup { font-size: 0.72em; line-height: 0; position: relative; top: -0.45em; vertical-align: baseline; }
.utb sub { font-size: 0.72em; line-height: 0; position: relative; bottom: -0.2em; vertical-align: baseline; }

/* the site's video tile, under the byline */
.utb .video-tile { margin: 28px 0 8px; }

/* TL;DR and contents */
.utb .label { margin: 0 0 8px; font-size: 12.5px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--u-muted); }
.utb .tldr { margin: 32px 0 0; padding: 20px 22px 6px; background: var(--u-wash); border-radius: 8px; }
.utb .tldr ul { margin: 0; padding-left: 1.1em; }
.utb .tldr li { margin: 0 0 14px; font-size: 16.5px; line-height: 1.6; }
.utb .tldr li::marker { color: var(--u-accent); }
.utb .utb-toc { margin: 28px 0 0; }
.utb .utb-toc ol { margin: 0; padding-left: 1.5em; font-size: 15.5px; line-height: 1.75; }
.utb .utb-toc li::marker { color: var(--u-muted); font-variant-numeric: tabular-nums; }
.utb .utb-toc a { text-decoration: none; }
.utb .utb-toc a:hover { text-decoration: underline; }

/* prose */
.utb h2 { margin: 2.4em 0 0.7em; padding-top: 0.9em; border-top: 1px solid var(--u-rule); font-size: 26px; line-height: 1.3; font-weight: 650; letter-spacing: -0.01em; text-wrap: balance; scroll-margin-top: 24px; }
.utb p { margin: 0 0 1.05em; }
.utb em { font-style: italic; }
.utb strong { font-weight: 650; }
.utb .m { font-style: italic; white-space: nowrap; font-family: "Times New Roman", "STIX Two Text", Georgia, serif; font-size: 1.06em; }
.utb .m sub, .utb .m sup { font-style: normal; }
.utb .m .up { font-style: normal; font-family: var(--font-sans); font-size: 0.92em; }
.utb .utb-note { margin: 1.3em 0 1.5em; padding: 12px 16px; font-size: 15.5px; line-height: 1.6; background: var(--u-note-wash); border-left: 3px solid var(--u-note-rule); border-radius: 0 6px 6px 0; color: var(--u-ink-2); }
.utb .utb-open { padding-left: 1.2em; }
.utb .utb-open li { margin: 0 0 0.75em; }

/* figures */
.utb .fig { margin: 2em 0 2.2em; }
.utb .fig.wide { margin-left: calc(50% - min(470px, 50vw - 24px)); margin-right: calc(50% - min(470px, 50vw - 24px)); }
.utb .fig-title { margin: 0 0 2px; font-size: 17px; font-weight: 650; line-height: 1.4; }
.utb .fig-sub { margin: 0 0 12px; font-size: 14.5px; line-height: 1.5; color: var(--u-muted); }
.utb figcaption { margin-top: 10px; font-size: 14px; line-height: 1.6; color: var(--u-muted); }
.utb figcaption em { font-style: normal; font-weight: 650; color: var(--u-ink-2); }
.utb img.tile, .utb video.demo { display: block; width: 100%; height: auto; background: var(--u-tile); border-radius: 6px; }
.utb video.demo { aspect-ratio: 2048 / 564; }
/* the three-panel figure stays legible on phones: it scrolls sideways instead of shrinking */
.utb .scrollx { overflow-x: auto; }
@media (max-width: 640px) { .utb .scrollx img { width: 680px; max-width: none; } }

.utb .controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 10px; font-size: 14px; }
.utb .ctl { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.utb .ctl-label { color: var(--u-muted); }
.utb .seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--u-rule); border-radius: 7px; overflow: hidden; }
.utb .seg button { font: inherit; font-size: 14px; line-height: 1.3; color: var(--u-ink-2); background: transparent; border: 0; border-left: 1px solid var(--u-rule); padding: 6px 12px; cursor: pointer; min-height: 32px; }
.utb .seg button:first-child { border-left: 0; }
.utb .seg button:hover { background: var(--u-wash); }
.utb .seg button[aria-pressed="true"] { background: var(--u-ink); color: var(--u-paper); }
.utb .seg button:focus-visible { outline: 2px solid var(--u-accent); outline-offset: -2px; }
.utb .chart { width: 100%; min-height: 120px; }
.utb .chart svg { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font-sans); }
.utb .readout { min-height: 1.6em; margin: 6px 0 0; font-size: 14.5px; line-height: 1.55; color: var(--u-ink-2); font-variant-numeric: tabular-nums; }
.utb .legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0 0; padding: 0; list-style: none; font-size: 13.5px; color: var(--u-ink-2); }
.utb .legend li { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.utb .legend .sw { display: inline-block; width: 13px; height: 13px; border-radius: 3px; }
html:not(.utb-js) .utb .controls, html:not(.utb-js) .utb .readout { display: none; }

/* chart marks (SVG, coloured from the variables above) */
.utb svg text { fill: var(--c-tick); font-size: 12.5px; }
.utb svg .grid { stroke: var(--c-grid); stroke-width: 1; }
.utb svg .axis { stroke: var(--c-axis); stroke-width: 1; }
.utb svg .axis-title { fill: var(--u-muted); font-size: 12.5px; }
.utb svg .lbl { font-size: 12.5px; fill: var(--u-ink-2); }
.utb svg .lbl.strong { font-weight: 650; }
.utb svg .val { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.utb svg [tabindex] { outline: none; cursor: pointer; }
.utb svg [tabindex]:focus-visible .hit, .utb svg .on .hit { stroke: var(--u-ink); stroke-width: 1.5; }
.utb svg .k-uttt { fill: var(--c-uttt); stroke: var(--c-uttt); }
.utb svg .k-tttmoe { fill: var(--c-tttmoe); stroke: var(--c-tttmoe); }
.utb svg .k-tttdense { fill: var(--c-tttdense); stroke: var(--c-tttdense); }
.utb svg .k-lact { fill: var(--c-lact); stroke: var(--c-lact); }
.utb svg .k-udense { fill: var(--c-udense); stroke: var(--c-udense); }
.utb svg .k-base { fill: var(--c-base); stroke: var(--c-base); }
.utb svg .k-ref { fill: var(--c-ref); stroke: var(--c-ref); }
.utb svg .hollow { fill: var(--u-paper); stroke-width: 2; }
.utb svg path.line { fill: none; stroke-width: 2.2; }
.utb svg path.line.thin { stroke-width: 1.2; opacity: 0.55; }
.utb svg .dim { opacity: 0.18; }
.utb svg .arrow { fill: none; stroke: var(--u-muted); stroke-width: 1.4; }
.utb svg .arrowhead { fill: var(--u-muted); stroke: none; }
.utb svg .ci { stroke-width: 1.6; fill: none; }
.utb svg .refline { stroke-width: 1.4; stroke-dasharray: 5 4; fill: none; }
.utb svg .cell { stroke: var(--u-paper); stroke-width: 2; }
.utb svg .c-same { fill: var(--c-same); }
.utb svg .c-down { fill: var(--c-down); }
.utb svg .c-up { fill: var(--c-up); }
.utb svg .c-resid { fill: var(--c-resid); }
.utb svg .c-none { fill: var(--c-none); }
.utb svg .reader { fill: var(--u-paper); stroke: #1f5fbf; stroke-width: 2.6; }
.utb svg .bar-lbl { font-size: 12px; font-weight: 600; fill: var(--u-ink-2); font-variant-numeric: tabular-nums; }
.utb svg .bar-lbl.k-uttt { fill: var(--c-uttt); stroke: none; }

/* table */
.utb .tablewrap { overflow-x: auto; margin: 1.6em 0; }
.utb table.utb-table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.45; font-variant-numeric: tabular-nums; }
.utb .utb-table caption { caption-side: top; text-align: left; padding: 0 0 8px; font-size: 14px; color: var(--u-muted); }
.utb .utb-table th, .utb .utb-table td { padding: 8px 10px; border-bottom: 1px solid var(--u-rule); text-align: left; vertical-align: top; }
.utb .utb-table thead th { font-weight: 650; border-bottom: 1.5px solid var(--u-ink-2); }
.utb .utb-table tbody th { font-weight: 400; color: var(--u-ink-2); }
.utb .utb-table td:last-child { font-weight: 600; }

/* references and citation */
.utb ol.refs { padding-left: 1.6em; font-size: 15px; line-height: 1.6; }
.utb ol.refs li { margin: 0 0 0.55em; }
.utb ol.refs li:target { background: var(--u-note-wash); }
.utb a.ref { text-decoration-style: dotted; }
.utb pre.bibtex { margin: 0 0 1em; padding: 14px 16px; overflow-x: auto; background: var(--u-wash); border-radius: 6px; font-family: var(--font-mono); font-size: 13px; line-height: 1.55; overflow-wrap: normal; }

@media (max-width: 640px) {
  #main.utb { font-size: 17px; }
  .utb .utb-page { padding: 0 18px 72px; }
  .utb .utb-head { padding-top: 36px; }
  .utb .standfirst { font-size: 18px; }
  .utb h2 { font-size: 22px; }
  .utb .tldr { padding: 16px 16px 4px; }
  .utb .fig.wide { margin-left: 0; margin-right: 0; }
  .utb .seg button { padding: 6px 10px; }
}

@media print {
  #main.utb { font-size: 11pt; }
  .utb .controls, .utb .video-tile { display: none; }
}

/* Dark theme. Figures from the paper keep a near-white tile, since they are drawn for white. */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #main.utb {
    --u-ink: #e8eceb; --u-ink-2: #c2cac8; --u-muted: #97a2a0; --u-paper: #151817;
    --u-rule: #343b39; --u-wash: #1c201f; --u-accent: #5ec4b9; --u-accent-hover: #8ddbd2;
    --u-note-rule: #c9963f; --u-note-wash: #241f16;
    --u-tile: #f3f5f4;
    --c-uttt: #ff5fa8; --c-tttmoe: #3fcf9f; --c-tttdense: #a98ae8; --c-lact: #c3b0ea; --c-udense: #5aa7f0;
    --c-base: #7d8786; --c-ref: #e8eceb; --c-grid: #262b2a; --c-axis: #5d6766; --c-tick: #97a2a0;
    --c-same: #d9a92f; --c-down: #ef7a43; --c-up: #9c6a4d; --c-resid: #3f4746; --c-none: #1f2423;
  }
}
@media screen {
  :root[data-theme="dark"] #main.utb {
    --u-ink: #e8eceb; --u-ink-2: #c2cac8; --u-muted: #97a2a0; --u-paper: #151817;
    --u-rule: #343b39; --u-wash: #1c201f; --u-accent: #5ec4b9; --u-accent-hover: #8ddbd2;
    --u-note-rule: #c9963f; --u-note-wash: #241f16;
    --u-tile: #f3f5f4;
    --c-uttt: #ff5fa8; --c-tttmoe: #3fcf9f; --c-tttdense: #a98ae8; --c-lact: #c3b0ea; --c-udense: #5aa7f0;
    --c-base: #7d8786; --c-ref: #e8eceb; --c-grid: #262b2a; --c-axis: #5d6766; --c-tick: #97a2a0;
    --c-same: #d9a92f; --c-down: #ef7a43; --c-up: #9c6a4d; --c-resid: #3f4746; --c-none: #1f2423;
  }
}
