/* ==========================================================================
   Catalog_View — the eight shared component classes (Requirement 14 AC 3),
   defined once each and serving all seven Content_Collections:

     .cat-card  entry card    .cat-row  entry row     .facet  Facet control
     .seg       segmented     .tag      tag           .badge-*  difficulty
     .prog-dot  Progress_Indicator      .empty-state  empty result

   Still eight. .cat-done (task 28) is the control that wraps .prog-dot, not a
   ninth component — the Progress_Indicator's state and its toggle are one
   affordance. The three progress surfaces beside it (.cat-progress,
   .cat-signin, .cat-save-error) are view chrome for Req 7 AC 2, AC 3 and
   Req 17 AC 8, not entry components, and nothing outside a Catalog_View uses
   them.

   This replaces four competing vocabularies. Absorbed by task 34: listing.css
   (.problem-card, .diff-badge, .diff-dot, .tag, .card-desc, .card-tags,
   .card-companies, .company, .filter-bar, .filter-btn, .card-check),
   dsa-index.css (.pat-card, .list-card, .start-card, .daily-card, .daily-tag,
   .db-row, .practice-item, .diff-chip, .diff-chips, .qb-pill, .prog-ring,
   .list-progress, .list-badge, .pat-count) and the inline block in
   problemset-app.html (.ps-row, .ps-seg, .ps-tag, .ps-diff, .ps-status .dot,
   .ps-empty). Not yet linked from any layout — tasks 26 and 31 wire it in —
   so it has no rendered effect and no live conflict with those three.

   FIVE RULES THIS FILE HOLDS TO
   1. Tokens only (Req 14 AC 2). Every colour, type size, spacing step, radius,
      elevation and duration is a var() into core.css. Two literal classes
      remain and both are forced: the 1px hairline (core.css has no line-weight
      token, and a hairline is neither spacing nor type — where 2px is wanted
      it is written calc(var(--sp-1) * 0.5)), and the media-query breakpoints,
      because CSS does not permit var() in a media query condition.
   2. Both themes (Req 14 AC 6). Nothing resolves a colour itself, so
      [data-theme="light"] reaches every surface with no override block. The
      pairings were picked against the real token values — ratios below.
   3. Targets by rule (Req 15 AC 7, 13 AC 2). Every control carries
      --target-min; Filter_Tray controls are raised to --target-touch.
   4. State beyond colour (Req 15 AC 8). Selected states key off
      [aria-pressed="true"], not a class, so the announced state and the
      painted state are one fact and a colour-only state is not expressible.
      .prog-dot adds a glyph, so its state is a shape change too.
   5. Reduced motion (Req 15 AC 10). Every animated element's at-rest state IS
      its final state and the keyframe animates *from* the transient one with
      `both` fill. That is the trap `card-rise` in core.css shows from the
      wrong side: its .reveal rule parks the element at opacity: 0, so zeroing
      the duration leaves it invisible for the length of its animation-delay.
      Nothing here is parked and no entrance carries a delay; the block at the
      foot then drops the animations outright rather than running them at
      0.01ms.

   MEASURED CONTRAST (dark / light) against the real token values
     text >= 4.5:1  row title --text 16.53/19.29 · desc and facet label and
       count --text-muted 7.11-8.18/6.50-7.09 · facet selected and tag and
       hover title --accent 5.25/5.67 · seg selected --accent 4.85/5.22
     non-text >= 3:1  control boundary --control-border 3.51/3.56 · selected
       boundary --accent 5.80/5.77 · prog-dot ring --control-border 3.75/3.88 ·
       prog-dot done --easy 9.63/3.77 · done glyph --bg on --easy 10.34/3.77 ·
       focus ring, worst of every colour it can abut, 9.51/9.48
     progress chrome (task 28) on --surface-2  save-error heading --hard
       6.25/5.93 · save-error body --text-muted 7.11/6.50 · save-error boundary
       --hard 6.25/5.93 · .cat-progress and .cat-signin sit on --bg and reuse
       the --text-muted and --accent pairings measured above

   --control-border is the control-boundary token, and every boundary figure
   above is measured against it: 3.75:1 dark and 3.88:1 light on --surface,
   which clears the 3:1 non-text floor. It is never a text colour here, and
   nothing here is large text.

   THOSE FIGURES DID NOT MOVE WHEN THE TOKEN WAS RENAMED. This file used to
   read --text-dim for all seven of its boundaries, back when one token carried
   both the text role (295 call sites repo-wide, 4.5:1 floor) and the boundary
   role (18 call sites, 3:1 floor). --text-dim has since been raised to #8695a3
   so it clears 4.5:1 as text on all five surfaces; --control-border was
   created and SEEDED TO THE VALUE --text-dim HELD (#71818f dark, #666c7d
   light), so the rename is a pixel-for-pixel no-op and the numbers above are
   still the numbers this file renders. There are now zero --text-dim reads in
   this file.

   --border is likewise never a control boundary — 1.20:1 dark and 1.26:1 light
   on --surface — so it stays on containers and separators, which are not
   controls. listing.css and the problemset block break both of those; they are
   the failures this consolidation drops.

   DENSITY (Req 2 AC 10) -- MEASURED, NOT BUDGETED

   The budget stated here before task 32 was wrong three ways: it costed the
   Facet_Panel at 56px for a "collapsed single-bar form" nothing had built
   (the panel rendered all 86 of HLD's chips inline, at 555px), it gave one
   72px line to the page title AND the count where the markup has a page
   header plus a separate .cat-controls bar, and it charged nothing for the
   39px early-access banner (Req 17 AC 3, so it stays) or .catalog's row gaps.
   /hld measured 1113px to the first card against its 216px claim and showed
   ZERO entries in both densities. These numbers are off the real page at
   1280x800 instead:

     site header        57   sticky, --header-h plus its 1px rule
     early banner       39   Monetization_Surface, not ours to remove
     .cat-head          55   page header, trimmed from a 362px hero
     row gap            12
     .facet-panel       92   difficulty inline, the rest behind a disclosure;
                             one line of chips, two reserved -- section 3
     row gap            12
     .cat-controls      55
     ----------------------
     first card at     324

     compact      676 / 44                            = 15.4 -> 15 entries
     comfortable  floor((676 + 12) / (168 + 12)) = 3.8 -> 3 rows x 4 cols = 12

   12 comfortable and 15 compact, measured at 1280x800, 1440x900 and
   1920x1080 alike -- the content column is --measure at all three, so there
   is one layout above 1200 and 1280 is not a special case.

   TWELVE IS THE REQUIREMENT AND IT IS NOT A CLIFF EDGE: 12 needs three
   comfortable rows or twelve compact ones, 528px either way, so a first card
   anywhere above 472px shows it. It is at 324px, clearing by 148px -- enough
   to survive the hero returning to its budgeted 72px, a reader expanding a
   facet group, and the no-script panel at 209px.

   WHY FOUR COLUMNS AND NOT THREE. Three needs 708px for 12 cards, leaving
   292px for the header, the banner, the page header and the two bars -- which
   measure 324px at their trimmed sizes. So THREE COLUMNS DOES NOT REACH 12:
   it shows 9. Getting there would take a 23px page header, or giving up the
   facet bar's second reserved line and with it the CLS fix that line is
   (section 3). Four needs 528px for the same 12, turning a 32px deficit into
   a 148px margin, and it also carries the two cases the requirement does not
   measure but a reader meets: an expanded facet group, and no script at all,
   where the panel degrades to scroll strips at 209px and still shows 12
   against three columns' 9. 1160px over four columns is 269px a card, a
   normal catalog card width; three columns of 362px was wide for a two-line
   title over a two-line description.

   Row pitch is exactly --cat-row-h and card pitch exactly --cat-card-h +
   --sp-3, so task 35.5 still has stated values to check.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Shell, controls bar, and the two reservations (Req 16 AC 5, AC 7)
   -------------------------------------------------------------------------- */
/* --sp-3 rather than --sp-4 between the panel, the controls and the list. Two
   gaps sit inside the Req 2 AC 10 budget and the stacked bars already carry
   their own padding, so 16px between them was 8px of the budget bought
   twice. */
.catalog { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); max-width: var(--measure); margin-inline: auto; }

/* Reserved at the tallest control plus its padding, so the search, sort and
   density controls do not grow the bar once script resolves them. The floor
   was --cat-row-h + --sp-3 * 2 = 68px against a 39.44px tallest control (a
   .seg button is --target-min plus --sp-2 padding plus its 1px rule, and
   .cat-search measures the same), so 28.56px of it reserved nothing.
   --target-min + --sp-3 * 2 = 48px is still above the content, and the bar
   renders at 55.44px. */
.cat-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); min-height: calc(var(--target-min) + var(--sp-3) * 2); padding-block: var(--sp-2); }

/* --------------------------------------------------------------------------
   Catalog_View page header -- .cat-head

   55px against the 72px the density budget above assumes. /hld carried
   listing.css's `.hero` here instead: 362px, of which 88px was its own
   --sp-8/--sp-5 padding and 274px a badge, a display-size h1, a 64ch lede and
   three stacked stat blocks. A hero is a landing-page device; a Catalog_View's
   header names the collection and says how big it is, on one line, above the
   controls that filter it.

   Here rather than in listing.css because that file's `.hero` is shared with
   /lld and /dsa, which are not Catalog_Views yet, and because task 21's
   _layouts/catalog.html is where this markup ends up -- so the class is
   already in the stylesheet that layout links.

   `em` is solid --accent, not the hero's --accent-to--accent-hover gradient:
   one definition, at a ratio this file has already measured, 5.25:1 dark and
   5.67:1 light (Req 14 AC 5, Req 15 AC 5).
   -------------------------------------------------------------------------- */
/* A two-row header: title and counts on the first line, one line of lede on
   the second. The lede was below the list, with the editorial blocks, which
   was right when the header was a 362px hero competing with the catalog for
   the Req 2 AC 10 budget and wrong now that the header is 55px -- a reader
   landing on /hld from a search result had no sentence anywhere above the fold
   telling them what the collection is. One line costs ~22px and one entry of
   the fifteen compact shows, against a floor of twelve.

   `grid`, not another `flex` row: the title and the counts share the first
   line and the lede spans the full width beneath them, which a single
   wrapping flex row cannot express without the lede being pulled up beside
   the counts whenever it happens to fit. */
.cat-head { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: var(--sp-1) var(--sp-4); max-width: var(--measure); margin-inline: auto; padding: var(--sp-4) var(--sp-5) var(--sp-3); }

/* ---- Eyebrow, borrowed from .rz-eyebrow on /resume/ ----------------------
   The recipe is the site's shared accent pill (`.badge`, core.css:1455) at
   eyebrow weight and tracking, and it is already re-typed per page as
   .plan-eyebrow, .pk-eyebrow, .mk-eyebrow, .hm-eyebrow and .hero-badge. This
   is the sixth, and it is here rather than in core.css because the density
   budget above constrains its box in a way a site-wide class should not be.

   NO LIVE DOT, unlike .rz-eyebrow and .pk-eyebrow. The dot on those two says
   the tool is running locally and is therefore always ready. A catalog is not
   a tool and has no readiness to report, so a green dot here would be
   decoration carrying an implied claim -- the same reason the stats row
   refuses an engagement figure.

   It costs ~36px of the 148px of slack the density note above measures. */
.cat-head-eyebrow {
    grid-column: 1 / -1;
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    margin: 0 0 var(--sp-1);
    padding: var(--sp-1) var(--sp-3);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    background: var(--accent-subtle);
    border: 1px solid var(--border-accent);
    border-radius: var(--r-full);
}
/* --fs-2xl, not the declared --fs-xl it had and not the --fs-3xl it rendered
   at on three of the five pages. See the specificity note below: this header
   is hand-copied onto /hld-fundamentals, /companies and /problemset, which are
   `layout: default` and so link content.css, whose `.content h1` is 0,1,1
   against this rule's 0,1,0 -- so those three have been rendering at --fs-3xl
   while /hld and /lld rendered at --fs-xl, and the five pages the reader
   experiences as one catalog have never agreed. One size, declared once and
   enforced on both layouts, is the point of this change.

   --fs-2xl is the middle of the two: it reads as a page title rather than a
   bar label, which is most of why these pages looked like a panel inside
   someone else's site, and it costs ~9px against --fs-xl where --fs-3xl would
   cost ~40px and take a two-line title on a narrow column. */
.cat-head-title { min-width: 0; font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.012em; line-height: 1.26; color: var(--text); text-wrap: balance; }
/* Specificity, not duplication: `.content h1` (content.css:325) is 0,1,1 and
   beats the bare class on the three `layout: default` copies of this header.
   `.content` here takes it to 0,2,0 so one declared size reaches all five
   pages. Delete this the moment tasks 32.2/32.4/32.5 move those three onto
   `layout: catalog`, which drops content.css and with it the conflict. */
.content .cat-head-title { font-size: var(--fs-2xl); }
/* Clamped to one line. The sentence is a summary, so a two-line version on a
   narrow column would take back the budget this header exists to protect; the
   collection's full lede still sits below the list for a reader who scrolls. */
.cat-head-lede { grid-column: 1 / -1; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; line-clamp: 1; overflow: hidden; max-width: var(--measure-narrow); font-size: var(--fs-sm); line-height: 1.55; color: var(--text-muted); }
@media (max-width: 640px) {
    /* Counts drop under the title rather than squeezing it. */
    .cat-head { grid-template-columns: 1fr; }
}
.cat-head-title em { font-style: normal; color: var(--accent); }
.cat-head-stats { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-2) var(--sp-4); }
.cat-head-stat { font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; }
/* --fs-md numerals, the .rz-stats b treatment from /resume/: the number is
   what the eye is looking for in a stat, so it is the thing that gets the
   size, and tabular figures stop the row reflowing as counts change. Free
   against the density budget -- these sit on the first line, whose height the
   --fs-2xl title already sets. */
.cat-head-stat strong { font-weight: 700; font-size: var(--fs-md); color: var(--text); font-variant-numeric: tabular-nums; }

/* The collection's lede, below the list with the rest of the editorial blocks
   -- it is prose about the collection, not a control over it, so it is not
   worth any of the 1000px the entries are measured in. */
.cat-lede { font-size: var(--fs-md); line-height: 1.65; color: var(--text-muted); max-width: var(--measure-narrow); text-wrap: pretty; }
/* AND IT NEEDS A GAP ABOVE IT WHERE IT IS BELOW THE LIST.
   A paragraph on this site spaces itself with `margin-bottom`, so `.cat-lede`
   carries no top margin -- and the element before this one is the catalog's
   `<script type="module">`, which has no box at all. Measured at 1440 on all
   four pages that put a lede under the list (/hld-fundamentals,
   /lld-fundamentals, /dsa-fundamentals, /companies): the lede's top edge and
   the catalog section's bottom edge were the SAME pixel, so the first line of
   editorial prose sat directly on the list's bottom border and read as a row
   of the table.
   The sibling combinator is what distinguishes this from the lede on /hld and
   /lld, which is part of the HEADER -- above the list, already spaced by the
   block below it, and which must not gain a second gap.
   SECOND AND LATER LEDES KEEP THEIR OWN RHYTHM. /companies runs two in a row
   (#catalog-lede then #catalog-note); only the one that touches the list needs
   the gap, and the pair already space themselves with margin-bottom. */
#catalog-section ~ .cat-lede { margin-top: var(--sp-5); }
#catalog-section ~ .cat-lede ~ .cat-lede { margin-top: 0; }

/* Starter links — one slim row ABOVE the catalog.
   -------------------------------------------------------------------------
   These were three stacked `.start-here` cards, 83px each, and tasks 31/32.1
   moved them below the list with the editorial blocks. Measured, that put the
   first one at 2226px on /hld -- under all 39 rows. They are the answer to
   "where do I start", so a reader who needs them is exactly the reader who
   will not scroll a catalog they do not yet know how to read to find them.
   Below the list they are not de-prioritised, they are unreachable.

   They are navigation, not prose, which is the distinction the earlier sweep
   missed. The lede above stays below the list: it describes the collection to
   someone already looking at it, and nothing acts on it.

   So: above the catalog, but at a tenth of the cost. Three cards stacked is
   250px of the 1000 the entries are measured in; one row of three is ~45px,
   which drops /hld from 14 entries to 13 and keeps the Req 2 AC 10 floor of 12
   clear. The descriptions go -- they are a sentence each and the titles carry
   the destination -- so this is a link row, not three cards turned sideways.

   `flex-wrap` rather than a three-column grid: at narrow widths these stack to
   full width on their own, and a grid would hold three unreadable columns.
   Below 640px the row is the full width and each link is its own line, which is
   the same shape the cards had. */
.cat-starters { display: flex; flex-wrap: wrap; align-items: stretch; gap: var(--sp-2); max-width: var(--measure); margin-inline: auto; padding-inline: var(--sp-5); }
/* THIS ROW IS THE FIRST THING A NEWCOMER NEEDS AND IT WAS STYLED AS CHROME.
   --surface-2 with a --text-dim boundary is this file's vocabulary for a
   SECONDARY control -- it is what .facet uses at rest, and what
   .cat-row-actions used until the note above. Three links to "New to system
   design?", the 45-minute framework and the cheatsheet were therefore drawn
   with the same weight as a filter chip, in a row of flat outline boxes above
   a 39-entry grid, and read as disabled.
   They are promoted to the accent, which this palette reserves for the thing
   it wants pressed: --accent-subtle fill, --border-accent boundary, the
   --accent arrow that was already there, and --shadow-sm. That makes this the
   only accent-filled row on the page, so it is where the eye lands first
   -- which is the correct answer for a reader who has not chosen a design yet.
   Still flat: a 12% tint of the accent, a 1px border and the palette's
   softest shadow. No gradient fill, no glow, no backdrop filter.
   SIZE IS PART OF THE PRESENCE. --fs-base over --fs-sm and --sp-3/--sp-4
   padding take each link from 24px to about 44px, so the row reads as three
   destinations rather than three labels, and every one clears --target-touch
   without the tap-target floor having to be restated. The cost is ~20px above
   the catalog: measured at 1280x800 that leaves /hld comfortable on 12
   entries (its third card row lands at 913px against the 1000px budget) and
   takes /hld compact from 15 to 14, both clear of the Req 2 AC 10 floor.
   --text, not --accent, for the label. An accent fill with accent text is the
   PRESSED state of .cat-clear and .facet[aria-pressed]; borrowing it here
   would make three resting links look like three active filters. The fill
   carries the emphasis and the text stays the one with 4.5:1 on it. */
.cat-starter {
    display: flex;
    /* `auto` basis, not a length: core.css has no width token narrow enough to
       be a sensible flex-basis here (--measure-narrow is 780px and --rail-w is
       the Section_Sidebar's), and Req 14 AC 2 allows no literal. Content-sized
       with grow 1 distributes the slack evenly, so the three fill the row at
       --measure and wrap to their own lines when they cannot. */
    flex: 1 1 auto;
    min-width: 0;
    align-items: center;
    gap: var(--sp-2);
    min-height: var(--target-min);
    padding: var(--sp-3) var(--sp-4);
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    background: var(--accent-subtle);
    border: 1px solid var(--border-accent);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    transition: color var(--dur) var(--ease), background var(--dur) var(--ease),
                border-color var(--dur) var(--ease);
}
.cat-starter:hover { color: var(--accent); background: var(--accent-subtle-hover); border-color: var(--accent); }
.cat-starter:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-ring-offset); }
/* The arrow is decoration -- the link text is the accessible name -- so it is
   hidden from assistive technology and pushed to the trailing edge. */
.cat-starter-arrow { margin-left: auto; color: var(--accent); }
/* Two lines per starter: what it is, and why open it. The row sits above the
   filter panel, so it gets its own breathing room below. */
.cat-starters { margin-bottom: var(--sp-3); }
.cat-starter-text { display: flex; flex-direction: column; gap: var(--sp-0); min-width: 0; }
.cat-starter-title { font-weight: 650; color: var(--text); }
.cat-starter:hover .cat-starter-title { color: var(--accent); }
.cat-starter-sub { font-size: var(--fs-xs); font-weight: 400; color: var(--text-muted); line-height: 1.4; }
.cat-starter-arrow { flex: 0 0 auto; padding-left: var(--sp-3); }
/* Inside prose (a lesson hub) the row already sits in the content column. */
.cat-starters--inline { padding-inline: 0; margin: var(--sp-4) 0 var(--sp-5); }
/* THREE ON ONE LINE, AND THE ORPHAN THAT HAPPENS WITHOUT THIS.
   The band's default basis is `auto` (see .cat-starter above), so the three are
   sized by their text and wrap when they cannot fit. In the full-width frame
   that is correct and /dsa-fundamentals shows it working: 1392px holds all three
   at 443/471/462. The other two hubs embed the band in the ARTICLE column, and
   at the 992px that column gives it the third link does not fit -- it wraps to a
   line of its own, where `flex-grow: 1` then stretches it to the full 992px.
   Measured on /hld-fundamentals and /lld-fundamentals: two cards of ~530 and
   ~450 over one of 992, so the last of three related-track links became the
   widest element on the page and read as a banner rather than as the third item
   in a row.
   `flex-basis: 0` sizes the three from the container instead of from their text,
   so they take equal thirds of whatever width they are in and the subtitle wraps
   inside the card. `align-items: stretch` on the band already keeps the three
   the same height, so a wrapped subtitle lengthens all three together.
   SCOPED TO THE INLINE BAND AND TO ABOVE 640px. The full-width frame does not
   need it, and below 640px one link per line is the right shape -- that rule
   lives in a `max-width: 640px` block with a single class, so this one is
   confined to a `min-width: 641px` block rather than left to out-specify it. */
@media (min-width: 641px) {
    .cat-starters--inline .cat-starter { flex-basis: 0; }
}

/* --------------------------------------------------------------------------
   Revision strip — one collapsed line above the catalog
   --------------------------------------------------------------------------
   Markup and behaviour: _includes/revise-strip.html, which records why this
   moved above the list and why it is budgeted at one catalog row.

   THE BUDGET IS THE DESIGN. 36px of summary plus --sp-2 beneath it is 44px,
   exactly --cat-row-h, so the strip costs the Req 2 AC 10 count one entry and
   no more: comfortable /hld moves its third card row from 913px to 957px and
   stays on 12, compact goes from 14 to 13. The summary is a click target and
   36px clears --target-min with room, so there is nothing to buy back by
   shrinking it further. The expanded rows are not in the budget -- they do not
   exist until the reader opens the strip.

   IT IS DRAWN AS CHROME, DELIBERATELY, AND THE STARTER ROW ABOVE IT IS NOT.
   --surface-2 on --border is this file's vocabulary for a secondary control,
   which is what .facet uses at rest. The accent-filled .cat-starter row is the
   page's one promoted element and the comment above it explains why; a second
   accent band directly beneath it would split that emphasis in half. This
   strip is for a reader who already knows the site and is being reminded of
   something, not for the newcomer the starters are pitched at.

   NO URGENCY COLOUR, which is the whole visual change. The card this replaced
   drew a 3px left bar in #fbbf24 / #f97316 / #ef4444 by age band. The bands
   saturated -- everything past three weeks was red -- so five rows of red said
   nothing the oldest-first ordering did not already say, in the palette's
   error colour, for a reader who had simply not opened something in a while.
   Each row states its own age in words instead. */
.revise {
    max-width: var(--measure);
    margin-inline: auto;
    margin-bottom: var(--sp-2);
    padding-inline: var(--sp-5);
}
.revise-summary {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    /* Not --target-touch: that is 44px and the whole strip including its margin
       has to be 44px. 36px is the tallest summary that fits the budget and it
       is comfortably over --target-min. */
    min-height: 36px;
    padding: 0 var(--sp-3);
    font-size: var(--fs-sm);
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    cursor: pointer;
    /* The default triangle is replaced by .revise-chevron, which can be
       rotated and placed at the trailing edge. */
    list-style: none;
}
.revise-summary::-webkit-details-marker { display: none; }
.revise-summary:hover { border-color: var(--border-accent); }
.revise-summary:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-ring-offset); }
.revise-icon { color: var(--accent); }
/* The count is the fact, so it gets --text against the summary's --text-muted
   rather than a size of its own -- the line has 36px and no room to grow. */
.revise-count { font-weight: 650; color: var(--text); }
.revise-oldest { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.revise-chevron { margin-left: auto; color: var(--text-muted); transition: transform var(--dur) var(--ease); }
.revise[open] .revise-chevron { transform: rotate(180deg); }
.revise-list { display: flex; flex-direction: column; gap: var(--sp-1); margin: var(--sp-2) 0 0; padding: 0; list-style: none; }
.revise-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2) var(--sp-3);
    min-height: var(--target-touch);
    padding: var(--sp-2) var(--sp-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
}
.revise-item:hover { border-color: var(--border-accent); }
.revise-name { flex: 1 1 auto; min-width: 0; font-size: var(--fs-sm); font-weight: 600; color: var(--text); text-decoration: none; }
.revise-name:hover { color: var(--accent); }
.revise-age { font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.revise-actions { display: flex; gap: var(--sp-2); }
/* --fs-xs is the floor, not 0.68rem, and --target-min is the height. The
   buttons this replaces set font-size: 0.68rem with 0.25rem of padding, which
   computed to roughly 23px tall -- under the site's own 24px target token, in
   text smaller than anything else on the page. */
.revise-btn {
    display: inline-flex;
    align-items: center;
    min-height: var(--target-min);
    padding: var(--sp-1) var(--sp-2);
    font: inherit;
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    white-space: nowrap;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--r-xs);
    cursor: pointer;
    transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.revise-btn:hover { color: var(--accent); border-color: var(--accent); }
.revise-btn:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-ring-offset); }
/* --success, not #4ade80. The literal was tuned for the dark theme and stayed
   put in light, where core.css darkens --success to #059669 to hold contrast
   on a white surface. */
.revise-done { color: var(--success); border-color: var(--border); }
.revise-done:hover { color: var(--success); border-color: var(--success); }
.revise-more { padding: var(--sp-1) var(--sp-3); font-size: var(--fs-xs); color: var(--text-muted); }
/* On a phone the title takes its own line and the age and the buttons share
   the next one. The card this replaces had no media query at all, so a long
   title wrapped to three lines while "78d ago" and two buttons held the right
   edge. */
@media (max-width: 640px) {
    .revise { padding-inline: var(--sp-4); }
    .revise-oldest { display: none; }
    .revise-name { flex-basis: 100%; }
}
/* On a phone, content-sized starters wrapped two-and-one with uneven widths;
   one full-width card per line reads as a list of destinations. */
@media (max-width: 640px) {
    .cat-starter { flex-basis: 100%; }
}
/* --------------------------------------------------------------------------
   .cat-starters--tight — a band of SHORT labels, packed two-up on a phone

   The full-width rule above is right for the bands it was written for: /hld,
   /lld and /hld-fundamentals carry titles like "New to system design? Start with
   Concepts" over a subtitle naming four topics, and half a phone's width cuts
   those mid-sentence.

   /companies carries a name and a count -- "Microsoft", "1,384 questions" --
   and it carries SIX of them rather than three. Full width made that 345px of
   stacked cards on a 430px viewport, which put the search box, both filter
   groups and every one of the 150 entries below the fold: the band stopped
   being a shortcut into the catalog and became a wall in front of it.

   Two-up restores the ~170px the three-card bands cost, which is the budget
   that rule was measured against. `calc(50% - var(--sp-2) / 2)` because the
   row's gap is --sp-2 and two cards plus one gap have to make 100%; `box-sizing`
   is already border-box from core.css's reset, so the padding is inside that.

   A MODIFIER, NOT A COLLECTION NAME. The thing that decides this is label
   length, not which page it is, so a future band of short links gets it by
   adding the class and nothing in this file has to learn about /companies.
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
    .cat-starters--tight .cat-starter { flex-basis: calc(50% - var(--sp-2) / 2); }
}
/* The starter's own mark tile. Bigger than the row's and filled with the
   accent rather than --surface-2, because `.cat-starter` is already the one
   accent-filled row on the page -- a --surface-2 tile inside an
   --accent-subtle card would read as a hole punched in it. This is the same
   shape the homepage uses for its track cards: a rounded tinted square at the
   leading edge, then a title over a one-line subtitle. */
.cat-starter-logo {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: var(--sp-6);
    height: var(--sp-6);
    color: var(--accent);
    background: var(--accent-subtle);
    border: 1px solid var(--border-accent);
    border-radius: var(--r-sm);
}
.cat-starter-logo > svg { width: 18px; height: 18px; fill: currentColor; }
.cat-starter-logo--initial { font-size: var(--fs-sm); font-weight: 700; letter-spacing: 0; }
.cat-starter:hover .cat-starter-logo { color: var(--accent); background: var(--accent-subtle-hover); border-color: var(--accent); }
.cat-count { margin-left: auto; font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Completed / total for the collection (Req 7 AC 2). The WORDS, and nothing
   else.

   THE TRACK IS GONE. This was a two-child column: the sentence, then a --sp-1
   rule the width of the sentence, with an --accent fill driven by
   --cat-progress-pct. It came up here from the .progress-strip that used to
   sit below the list in pages/hld.html and pages/lld.html, and the
   consolidation it came with stands -- one read, one paint, one element. The
   visual did not.

   It read as a divider, not a gauge. A 4px line sitting under a line of text,
   in a bar that also holds a search box, two segmented controls and a result
   count, has nothing to identify it as progress: it looked like an
   unexplained horizontal rule between two pieces of text. And zero is the
   value that settles it -- the fill is `width: 0` at 0 of 39, which is every
   first visit and every signed-out visit, so the one state it was guaranteed
   to be asked for showed an empty track and no information at all.

   It was already redundant and its own markup said so: aria-hidden, no
   progressbar role, because the sentence beside it is the accessible
   information and an aria-valuenow would be a second place to write one fact.
   A decoration that restates the sentence it sits under earns its place only
   by reading better than the sentence, and it did not. Making it read as
   progress instead -- inline, outlined so 0 looks deliberate, a width token
   for the gauge -- would have spent the bar's last free width on a second
   rendering of a number already in plain words, and .cat-signin now needs
   that width.

   SO THIS IS ONE LINE, and it is cheaper than what it replaced: --fs-sm at the
   body's line-height is 21.44px, where the words plus --sp-1 of gap plus the
   --sp-1 track were 29.44px. .cat-controls reserves --target-min + --sp-3 * 2
   = 48px and renders at 55.44px off a 39.44px tallest control, so both fit in
   the slack and the bar's height moves neither way -- the Req 2 AC 10 count is
   untouched and the first row does not move.

   NO margin-left: auto. It sits in the bar's leading group, ahead of
   .cat-count, so the free space between the two absorbs the one or two
   characters this grows by when the Progress_Store resolves and .cat-count
   stays pinned where the server put it. tabular-nums for the same reason the
   head stats carry it: 7 -> 8 must not re-measure the line.

   --text-muted for the sentence with the number in --text at 700, which is now
   the whole of the contrast story here: 7.11:1 dark and 6.50:1 light for the
   muted half, and the number is body text on --bg. The track's --border-strong
   and the fill's --accent are no longer referenced by this surface. */
/* NO `display: flex` HERE, and that is a correctness rule rather than a
   preference. The content is `<span id=cat-progress-done>0</span> of 39
   completed` -- one element and one text node in ordinary inline flow, and the
   space between them is the space character in the markup. As a flex container
   that text node becomes an ANONYMOUS FLEX ITEM and its leading whitespace is
   discarded, which renders "0of 39 completed". The old two-child column got
   away with `display: flex` only because the sentence was wrapped in a
   .cat-progress-text span, so the span and the text were one item; with the
   track gone that wrapper has nothing left to do and the element is a plain
   block again. It is still a flex ITEM of .cat-controls, which is where
   `align-items: center` lines it up, and that is a separate question from its
   own inner display. */
.cat-progress { font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cat-progress #cat-progress-done { font-weight: 700; color: var(--text); }

/* --------------------------------------------------------------------------
   Signed-out explanation (Req 7 AC 3) and failed-write report (Req 17 AC 8)

   `display: none` by default and revealed by the data-auth attribute
   _includes/site-head.html sets from `authCache` BEFORE FIRST PAINT, which is
   the mechanism design decision 9 names: which of the two states a reader gets
   is settled by the initial response, so resolving the Progress_Store shifts
   nothing (Req 7 AC 5). `html[data-auth="out"]` rather than
   `html:not([data-auth="in"])` on purpose — the attribute is always one of the
   two by the time any stylesheet applies, and the positive form means a
   document that somehow carries no attribute shows nothing rather than
   flashing a sign-in prompt at a signed-in reader.

   IT IS A BAR ITEM NOW, NOT A LINE. _includes/catalog-view.html renders it
   inside .cat-controls beside #cat-progress. As its own full-width block
   between the bar and the list it was 674.56px of text and 20.14px of height
   plus the .catalog grid's --sp-3 gap — roughly 32px of the 1000px the
   Req 2 AC 10 entry count is measured in, and it pushed every row down by
   that much for every signed-out reader, to say something a visitor reads once.

   `flex-shrink: 0` with `white-space: nowrap` is what makes the move free
   rather than a new shift risk. .cat-search is `flex: 1 1 auto; min-width: 0`
   and is holding all of the bar's slack, so this item's 164.38px comes out of
   the search box (483.23px -> ~311px, still showing its placeholder) and the
   bar does not wrap. Nowrap also means it can never become two lines and grow
   the bar past the 39.44px tallest control that settles its 55.44px height:
   --fs-sm at this line-height is 21.44px and sits inside the slack the bar
   already had. Where the viewport really is too narrow the bar's own
   `flex-wrap: wrap` gives it a line, which is correct at that width and not a
   shift at 1280px.

   Still `display: block` on reveal, and the inside stays ordinary inline flow:
   the button is one word in a sentence and the space between it and the next
   word is the space character in the markup. Making this a flex container
   would turn that text into an anonymous flex item and hand the word gap to a
   `gap` declaration, which is machinery for something the line box already
   does. `flex-shrink: 0` governs it as an item OF .cat-controls, which is a
   separate question from its own inner display.
   -------------------------------------------------------------------------- */
.cat-signin { display: none; flex-shrink: 0; font-size: var(--fs-sm); line-height: 1.55; color: var(--text-muted); white-space: nowrap; }
html[data-auth="out"] .cat-signin { display: block; }
/* A real button, in the tab order and operable by Enter and Space (Req 15
   AC 1, AC 2), styled as the inline link it reads as. --target-min is not
   applied: it is a word inside a sentence, and a 24px-tall inline control
   would break the line box it sits in. The surrounding sentence is the
   affordance and the whole line is the hit area in practice. */
.cat-signin-btn { font: inherit; font-weight: 600; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }

.cat-save-error { font-size: var(--fs-sm); line-height: 1.55; color: var(--text-muted); padding: var(--sp-2) var(--sp-3); background: var(--surface-2); border: 1px solid var(--hard); border-radius: var(--r-sm); }
.cat-save-error[hidden] { display: none; }
.cat-save-error b { color: var(--hard); }

.cat-search { flex: 1 1 auto; min-width: 0; min-height: var(--target-min); padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); color: var(--text); background: var(--surface-2); border: 1px solid var(--control-border); border-radius: var(--r-sm); transition: border-color var(--dur-fast) var(--ease); }
.cat-search::placeholder { color: var(--text-muted); opacity: 1; }
.cat-search:hover { border-color: var(--accent); }

/* Result_Set container. The reservation is count x --cat-row-h, as a floor
   rather than a height: 44px is a *lower* bound on an entry's pitch in either
   density (comfortable is 180px over 3 columns, 60px per entry), so one
   formula covers both and never over-reserves into a gap below the last entry.
   In compact the floor equals the real height, which is what keeps hiding rows
   from reflowing the page beneath — the explicit post-filter adjustment in
   catalog.js releases it. --cat-count is the one value the include supplies, a
   unitless integer, so it sets no colour, type size, spacing or radius and
   Req 14 AC 4 still holds; the multiply stays here so --cat-row-h is
   referenced only from CSS, and the 0 default reserves nothing rather than
   breaking the calc. */
.cat-list { --cat-count: 0; min-height: calc(var(--cat-count) * var(--cat-row-h)); margin: 0; padding: 0; list-style: none; }

/* --------------------------------------------------------------------------
   THE DENSITY GATE -- read this before editing any `.cat-list:is(...)`
   selector below.

   Every density rule in this file is gated on one of exactly two selectors:

     compact      .cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *),
                                :where(html[data-cat-density="compact"] *))
     comfortable  .cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *),
                                :where(html[data-cat-density="comfortable"] *))

   TWO SOURCES, BECAUSE NEITHER ONE KNOWS THE WHOLE ANSWER. `is-compact` /
   `is-comfortable` on #cat-list is the collection's `default_density`, which
   is all the server can render. `data-cat-density` on <html> is what
   _includes/site-head.html resolves from `?v=` and the stored `cat-density`
   BEFORE FIRST PAINT, the same mechanism and the same reason as `data-auth`:
   the class alone was swapped after load, and every .cat-row went 44px -> 244px
   under the reader, measuring CLS 0.398 on /hld and 0.400 on /lld against
   Req 16 AC 5's 0.1 -- the worst possible band, since the list is the page.
   With the attribute in the initial response the first paint is already the
   density the reader gets, and catalog.js's later class toggle moves nothing.

   The attribute WINS WHERE PRESENT and is ABSENT WHERE IT HAS NO ANSWER, which
   is what keeps the precedence (query, then stored, then collection default --
   `resolveDensity` in assets/js/catalog/filter-state.js) in one place: the head
   script settles the first two levels or writes nothing at all, and nothing
   writes the third but the class. No script, no storage, nothing stored: the
   attribute never appears and the class governs, so the noscript case is the
   unchanged one.

   THE `:not()` IS VALUE-SPECIFIC ON PURPOSE -- `:not([data-cat-density])` would
   read just as well and is wrong in one case: an attribute holding anything
   outside the two densities would then match NEITHER gate and the list would
   render with no density layout at all. Written this way the attribute can only
   ever redirect the density, never remove it, so an unexpected value degrades
   to the server's class like every other unusable input.

   SPECIFICITY IS DELIBERATELY UNCHANGED. `:where()` scores zero and `:is()`
   scores its most specific argument, so each gate scores 0,2,0 -- exactly what
   the plain `.cat-list.is-compact` it replaced scored. Every specificity
   argument recorded in the comments below therefore still holds literally, the
   `[hidden]` battle in section 1 included. KEEP IT THAT WAY: wrapping the html
   test in `:is()` instead of `:where()`, or hoisting it out of the `:is()` into
   a plain descendant prefix, raises the score and silently hands filtered-out
   cards back their `display: flex`.
   -------------------------------------------------------------------------- */

/* --------------------------------------------------------------------------
   1. Catalog_Entry row — .cat-row  (compact density, and the server-rendered
   form every collection ships: title, difficulty and completion state on one
   line, Req 4 AC 4). The height is exact, not minimum, and the list carries no
   gap, so the reservation is n x --cat-row-h with nothing left over.
   -------------------------------------------------------------------------- */
.cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) { display: flex; flex-direction: column; gap: 0; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }

.cat-row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    height: var(--cat-row-h);
    padding-inline: var(--sp-4);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    transition: background var(--dur-fast) var(--ease);
}
.cat-row:last-child { border-bottom: none; }
.cat-row:hover { background: var(--accent-subtle); }

/* Filtering toggles [hidden]. display: flex above beats the UA's
   [hidden] { display: none }, so it has to be restated — without this every
   hidden entry stays on screen.

   The density selectors are not redundant. `.cat-row[hidden]` scores 0,2,0,
   and the comfortable card block below is the comfortable gate plus `.cat-row`
   at 0,3,0 — so in comfortable density that block's `display: flex` WON and
   every filtered-out card stayed visible while the count said otherwise.
   Selecting Beginner showed "6 results" above a grid of 39. The two density
   forms below score 0,4,0 and 0,4,0, so they outrank their own base rule in
   both densities. Keep the scores above the density blocks if either is ever
   given a deeper selector — which is the whole reason the gate is built out of
   `:is()` and `:where()` rather than a plain descendant prefix. */
.cat-row[hidden],
.cat-card[hidden],
.cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) .cat-row[hidden],
.cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row[hidden] { display: none; }

/* align-self: stretch is a target-size rule, not alignment: under the row's
   align-items: center the link would be only as tall as its --fs-sm text,
   ~20px, under the 24px floor. Stretched, the whole row is one target (15.7). */
.cat-row-link { display: flex; align-items: center; align-self: stretch; flex: 1 1 auto; min-width: 0; min-height: var(--target-min); overflow: hidden; font-size: var(--fs-sm); font-weight: 500; color: var(--text); text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.cat-row:hover .cat-row-link { color: var(--accent); }

/* THE ELLIPSIS ABOVE HAS NEVER WORKED, and this is what makes it work.

   `text-overflow` applies to a block container's inline content. The rule
   above makes the link a FLEX container, so its text sits in an anonymous
   flex item and the declaration is inert -- an over-long title is cut dead,
   mid-word, with no mark. On /hld that was invisible: the title's box was
   754-813px against 84-264px of glyphs, so nothing had ever overflowed. It
   was not invisible on /problemset, whose titles are long enough to reach the
   end of the box, and revealing the description made it visible on /hld too:
   "Pastebin / Text Shari", "Key-Value Store (Redis / Dynamo", "Nearby Service
   (Yelp / Google Map" -- the exact defect class that `topic_short` exists to
   have fixed for the chips.

   `display: block` with the row's own height as the line-height is the fix.
   It reproduces what the flex container was there for -- one line of text
   vertically centred in a 44px row -- while putting the text back in a block
   container where the ellipsis resolves. `align-self: stretch` and
   `min-height` are untouched, so the whole row is still one 44px target.

   NO WRAPPER ELEMENT, which is the other obvious fix and is not available:
   `paintTitle` in assets/js/catalog.js replaces the children of
   .cat-row-link with text nodes and `<mark>` elements on every keystroke, so
   an inner span would be destroyed by the first search. A `<mark>`'s own
   background box is sized from its font-size rather than from the inherited
   line-height, so the search highlight does not grow to 44px here.

   COMPACT ONLY. Comfortable overrides `display` to `-webkit-box` for its
   two-line clamp, which brings its own overflow marker. */
.cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row-link {
    display: block;
    line-height: var(--cat-row-h);
}

/* Catalog_Search marks its matched substring (Req 3 AC 4). */
.cat-row-link mark { color: var(--accent); background: var(--accent-subtle-hover); border-radius: var(--r-xs); }

/* --------------------------------------------------------------------------
   THE BRAND-MARK TILE -- .cat-row-logo

   WHAT IT IS FOR. /companies is 150 rows whose titles are brands, and a brand
   is the one thing a reader recognises faster as a picture than as a word. The
   rows opened on the title itself, so the eye had no fixed column to track
   down and the page read as prose where every other Catalog_View has a
   leading column -- /hld and /lld open on a step number and a completion dot.

   THE SPRITE IS NOT STYLED HERE. `.ci-sprite` only has to not render; the
   marks are single paths with no fill of their own, so they inherit
   `currentColor` from this tile and the colour lives in one place.

   SQUARE AT --target-min, which is the same 24px the row reserves for its
   other leading controls, so the title's left edge lands where it lands on
   every other collection and these rows stay in register with theirs.
   `flex: 0 0 auto` because the tile must never absorb the row's slack --
   .cat-row-desc is the growing child and the one that yields.

   THE MARK IS INSET INSIDE THE TILE. 24px of tile with a 14px mark leaves a
   5px gutter, which is what stops a dense mark (Amazon's wordmark-and-arrow,
   Samsung's ellipse) touching the tile's border and reading as clipped. The
   SVG is sized rather than the tile padded so the box stays exactly
   --target-min whichever form the tile takes.

   DRAWN AS A SECONDARY SURFACE. --surface-2 behind --text-muted inside a plain
   --border is this file's vocabulary for something present but not actionable,
   the same three tokens `.facet` uses at rest and the depth badge now uses.
   Full-colour marks were the obvious alternative and are wrong here twice: 86
   brand palettes down one column is the loudest thing on a page whose whole
   job is to stay scannable, and the mark would then be the only element on the
   row that ignores the theme. Monochrome also means the tile needs no
   per-brand upkeep when a company rebrands a shade.

   IT TRACKS THE ROW'S HOVER rather than carrying its own, because the whole
   row is one link and a tile that lit independently would read as a second
   control.
   -------------------------------------------------------------------------- */
.ci-sprite { display: none; }
.cat-row-logo { display: none; }
.catalog[data-row-fields~="logo"] .cat-row-logo {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    /* 28px, composed from tokens rather than written as a literal. It started
       at --target-min (24px) with a 14px mark, to line the title's left edge up
       with the step number on /hld. That was the wrong thing to optimise: a
       contact sheet of all 86 marks at both sizes showed the wordmark-shaped
       ones -- intel, ebay, grab, gm, lyft, cisco, amd -- reading as gray mud at
       14px and legibly at 18px. The row is 44px, so 28px costs nothing it was
       using, and 4px of extra indent on one collection is worth less than 86
       marks being identifiable. */
    width: calc(var(--sp-5) + var(--sp-1));
    height: calc(var(--sp-5) + var(--sp-1));
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease);
}
.catalog[data-row-fields~="logo"] .cat-row-logo > svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}
/* The fallback form. --fs-xs at 700 in the same box as a 14px mark: the glyph
   reads at the mark's weight rather than as a letter that happens to be there,
   and `letter-spacing: 0` centres a wide initial (W, M) that the sans's
   default tracking would push off the optical centre. */
.catalog[data-row-fields~="logo"] .cat-row-logo--initial {
    font-size: var(--fs-xs);
    font-weight: 700;
    /* Two letters in a 28px box, so the pair is tracked IN rather than out:
       the sans's default tracking pushes "AC" wider than the optical centre and
       a negative value seats it. */
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}
.catalog[data-row-fields~="logo"] .cat-row:hover .cat-row-logo {
    color: var(--accent);
    background: var(--accent-subtle-hover);
    border-color: var(--border-accent);
}

/* --------------------------------------------------------------------------
   THE WHOLE ROW IS THE TARGET, not just the title

   WHAT WAS WRONG. `.cat-row-link` wraps the title and nothing else, so the
   clickable area was the width of the text: measured on /companies, 64px of a
   1390px row for "Accenture", 86px for "Akuna Capital". Everything else --
   the description, the chips, the badge, the dead space -- did nothing. The
   row already had `.cat-row:hover` repainting its full width in
   --accent-subtle, so the whole row announced itself as one target and then
   ignored a click anywhere except on the name.

   Revealing `.cat-row-desc` is what made this a bug rather than a curiosity.
   An empty row invites a click on the title because that is the only thing in
   it; a row filled edge to edge with a sentence invites a click on the
   sentence, and on /companies that sentence is now the most informative thing
   on the row. The report was "after applying a filter the list items are not
   clickable" -- filtering was a red herring (visibility diffing is correct and
   no hidden row holds space), it is just when a reader starts clicking rows.

   HOW. The standard stretched-link: a pseudo-element on the anchor, absolutely
   positioned to fill the row. Two things make it work here and both are worth
   stating, because each looks like it should break it.

   1. `.cat-row-link` is `overflow: hidden` -- it has to be, that is what makes
      the `text-overflow: ellipsis` above resolve. An absolutely positioned
      descendant escapes an ancestor's overflow clip when its containing block
      is OUTSIDE the clipper, so this works only while the anchor itself stays
      unpositioned and `.cat-row` is the containing block. Giving
      `.cat-row-link` a `position` would silently shrink the hit area back to
      the text.
   2. `.cat-row` is `position: relative` here unconditionally. The comfortable
      card block already sets it, so this only adds the compact row, and it is
      what makes the overlay resolve against the row rather than the viewport.

   WHAT STAYS ABOVE IT. `.cat-done` and `.prog-dot[data-slug]` are the only
   interactive children a row can have -- assets/js/catalog.js listens for
   clicks on both -- and an overlay spanning the row would swallow them, which
   would break completion toggling on /hld, /lld and /problemset. They are
   lifted one layer. Everything else in the row (.tag, .badge, .cat-row-lock,
   .cat-row-time) is a span with no handler and is correctly covered.

   THE COST, accepted deliberately: the description text can no longer be
   selected with a drag, because the overlay is above it. A catalog row is a
   navigation target rather than a passage to quote, and the full sentence is
   the first line of the guide it links to.

   The focus ring is unaffected -- it draws on the anchor's own box, so
   keyboard focus still outlines the title rather than the whole row.
   -------------------------------------------------------------------------- */
.cat-row { position: relative; }
.cat-row-link::after {
    content: '';
    position: absolute;
    inset: 0;
}
.cat-row > .cat-done,
.cat-row > .prog-dot[data-slug] {
    position: relative;
    z-index: 1;
}

/* Description, tags and company chips ride on every row in the initial
   response and are revealed by the density class below, so no node is
   constructed to change density. */
.cat-row-desc, .cat-row-meta { display: none; }

/* --------------------------------------------------------------------------
   THE DESCRIPTION ON THE COMPACT ROW

   A compact row said almost nothing. Measured at 1280 on /hld, the five
   children that render are a 24px completion control, a title, up to two
   topic chips and a 72px badge on 1110px of row -- and the TITLE'S BOX was
   754-813px against 84-264px of actual glyphs. So 500-730px of every row was
   whitespace, on the density that is `default_density` for both collections,
   while the one field that says what the design teaches sat in the markup
   with `display: none` on it.

   It is still in the markup. This reveals it, and it costs NOTHING from the
   Req 2 AC 10 budget: the row is still exactly --cat-row-h, because the
   description takes the title's horizontal slack rather than a second line.
   That is the trade the research framing asks for -- a denser row rather than
   a block above the list -- and it is the only one of the four changes here
   that is free in both axes.

   WHY NOT A SECOND LINE, which is the obvious way to fit a description. The
   row's height is exact and the list's reservation is count x --cat-row-h, so
   a two-line row is a token change. At 56px /hld shows 11 entries in the
   first 1000px against AC 10's floor of 12, and at 60px it shows 10. One
   line of prose is not worth going under the floor for, and at 1110px wide
   there was never a need to.

   GATED ON THE COLLECTION, not on the page. Five other collections share this
   include. /problemset is 390 rows whose `d` is full problem prose rather than
   curated card copy; /hld-fundamentals, /companies, /ai-engineer and /agentic-ai have
   not had their row copy reviewed for this width. `row_fields` in
   _data/collections.yml is where that is declared and `#catalog`'s
   data-row-fields is how it reaches here -- absent, the selector fails and the
   row is unchanged.

   `--text-muted` at --fs-xs against the title's --text at --fs-sm: the two are
   different sizes, weights and colours, so they read as a title and a gloss
   with no separator glyph between them. --text-muted is 7.11:1 dark and 6.50:1
   light on --surface, which the header already measured for this exact use.
   -------------------------------------------------------------------------- */
.catalog[data-row-fields~="desc"] .cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row-desc {
    display: none;
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: var(--fs-xs);
    line-height: 1.4;
    color: var(--text-muted);
    white-space: nowrap;
    text-overflow: ellipsis;
}
/* Shown from the same 900px the topic chips are, and hidden below it for the
   same reason: under 900px the title needs the full width. A 390px row holds a
   title and a badge and that is all it has ever held. */
@media (min-width: 900px) {
    .catalog[data-row-fields~="desc"] .cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row-desc { display: block; }
    /* THE TITLE STOPS GROWING. It was `flex: 1 1 auto` and held all of the
       row's free space; the description is the growing child now, and the
       title sizes to its text and shrinks only under real pressure. Both keep
       an ellipsis, so the order in which they yield is the only thing this
       decides -- and the description is the one that can lose its tail
       harmlessly, which is why it also keeps `flex-shrink: 1`.

       0,5,0 against the 0,3,0 of the rule in the block above that sets
       `flex: 1 1 auto` inside this same media query. Specificity, not source
       order, is what settles it, so this does not depend on staying below. */
    .catalog[data-row-fields~="desc"] .cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row-link { flex: 0 1 auto; }
}

/* --------------------------------------------------------------------------
   THE STEP NUMBER -- .cat-row-order

   `default_sort: order` is what /hld and /lld already ship, so the list
   ARRIVES in the curated study sequence and nothing on it said so. The
   sequence was legible in exactly one place: the seven-step "Recommended
   Study Order" prose, which sits BELOW 39 rows and names 17 of them. The
   `order` front matter that actually drives the sort was derived from that
   prose and then rendered nowhere.

   This is the cheapest honest surface for it -- two glyphs, no height, and
   intrinsic to the entry rather than to the current sort, so it stays correct
   when the reader re-sorts or filters.

   WHAT WAS CONSIDERED AND REJECTED. The `study_group` headings (`cat_groups`
   and `cat_group_counts` in the projection) are the other unrendered half of
   that prose, and for hld and lld they are Beginner / Intermediate /
   Advanced -- the SAME three values as `difficulty_vocab`, which the
   Facet_Panel already renders inline as the only non-disclosed facet group,
   with live counts, as controls that filter. A second surface for those three
   values would be a second place one fact is written down, which is the shape
   design decision 3 exists to remove. So the groups stay unrendered and the
   per-entry position is what gets a surface.

   `min-width` and tabular-nums so the titles line up down the page: #1 and
   #39 are different widths in proportional figures, and a title column that
   jogs left and right under a two-digit step is worse than no step.
   --sp-6 fits "#390" at --fs-xs, which is the widest value any collection in
   _data/collections.yml could produce.

   COMPACT ONLY. A comfortable card is 244px FIXED with a documented overflow
   hazard -- the description's two-line floor is what absorbs the card's slack,
   and the block below notes that an over-full card overflows visibly rather
   than silently. A 4-column grid of cards does not read as a sequence anyway,
   so the step number buys there what it costs.
   -------------------------------------------------------------------------- */
.cat-row-order { display: none; }
.catalog[data-row-fields~="order"] .cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row-order {
    display: block;
    flex: 0 0 auto;
    min-width: var(--sp-6);
    font-size: var(--fs-xs);
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   THE READING TIME -- .cat-row-time

   The duration signal. The content pages have shown one since long before
   this refactor -- "24 min read" on /hld/Leaderboard/, from
   `content | number_of_words | divided_by: 200 | plus: 1` in
   _layouts/default.html -- and the listing a reader chooses from showed
   nothing, so the only way to find out whether a design was a 10-minute read
   or a 45-minute one was to open it. /lld's pre-refactor cards DID carry one,
   `~15 min read` inside the description paragraph, and the migration to
   `card_desc` dropped it.

   It is `~N min`, banded to five minutes. The `r` note in
   _includes/catalog-data.html has the arithmetic; the reason for the band is
   that this is computed from the markdown source and the page's own figure
   from the rendered body, and they differ by up to one minute. A band is a
   claim both satisfy. The tilde is also what /lld's own cards used.

   IN BOTH DENSITIES, and in the card it costs no flow height. The card is a
   244px column whose only flex-grow child is the description, so a sixth flex
   line would come straight out of the one element that explains the design.
   Out of the flow instead, onto the first line beside the badge and left of
   the completion control -- the same move `.prog-dot` and `.cat-done` already
   make into the opposite corner, and for the same reason.
   -------------------------------------------------------------------------- */
/* The Pro lock. Last child of .cat-row, so it sits against the row's right
   edge after the difficulty badge.

   `flex: 0 0 auto` so it is never what shrinks when a long title competes for
   width — the title carries `text-overflow: ellipsis` and should be what
   truncates. Muted and small: it marks a row, it does not advertise on it.

   Shown in BOTH densities deliberately. Every other right-hand affordance in
   this row is compact-only, but "can I read this one" is not a detail that
   should vanish when a reader changes density. */
/* `.icon-lock` itself is defined in core.css, not here: the same icon is used by
   the section rail on design pages, which load core.css + content.css and never
   load this file. */
.cat-row-lock { display: flex; flex: 0 0 auto; align-items: center; color: var(--text-muted); }
.cat-row:hover .cat-row-lock { color: var(--accent); }
/* The lock is the row's LAST child, after the difficulty badge, so an entry
   without one lets the badge slide into the space it would have occupied.
   Measured at 1440px: a non-PRO badge ended at x=1399 against a PRO badge's
   x=1354, a 45px step -- the 33px tag plus the row's 12px gap. Repeated down
   39 rows that visibly ragged the one column the list is supposed to align, and
   it took the reading-time column with it (1314 against 1247).
   An empty flex item of the lock's width restores the column. The row's own
   `gap` supplies the 12px, so only the tag width is reserved here. */
.cat-row:not(:has(.cat-row-lock))::after {
    content: "";
    flex: 0 0 var(--cat-lock-w);
}

.cat-row-time { display: none; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; color: var(--text-muted); white-space: nowrap; }
/* Compact: its own cell, between the topic chips and the badge. Hidden below
   900px with the description and the chips -- at 390px its 55px is a third of
   what the title has left. */
@media (min-width: 900px) {
    .cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row-time { display: block; flex: 0 0 auto; }
}
/* Comfortable: the card's first line, inset past the completion control.
   --sp-5 + --sp-4 = 40px clears .cat-done, which sits at `right: --sp-3` and
   is --target-min wide, so it occupies the rightmost 36px. --sp-4 of `top`
   matches the bare .prog-dot's inset rather than .cat-done's --sp-3, because
   this is text on the badge's baseline and not a 24px control. */
.cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) .cat-row-time {
    position: absolute;
    top: var(--sp-4);
    right: calc(var(--sp-5) + var(--sp-4));
    display: block;
}

/* Topic chips stay on the compact row, right-aligned after the title.
   A row carrying only a title and a difficulty is too thin to scan: difficulty
   is three values, so it separates 39 designs into three piles and answers
   almost nothing on its own. The topic is what tells a reader whether a row is
   the one they want, and it is the facet they are most likely to be filtering
   by — seeing it on the row is what makes the result set legible rather than a
   list of names. Dropped below 900px, where the title needs the full width. */
.cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row-tags {
    display: none;
    flex: 0 1 auto;
    flex-wrap: nowrap;
    gap: var(--sp-1);
    min-width: 0;
    overflow: hidden;
}
@media (min-width: 900px) {
    .cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row-tags { display: flex; }
    /* The title yields first: it carries an ellipsis, the chips do not, so
       shrinking the chips would cut a word in half instead of hiding a row. */
    .cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row-link { flex: 1 1 auto; }
}
/* THE CAP IS SIZED TO THE LABELS, and the labels were the defect.

   At --sp-8 * 2 = 128px this rule ellipsised every topic chip on every compact
   row of /hld, /lld and /hld-fundamentals -- 99 of 122 chips on the first two, cut
   mid-word: "Ranking and Relevan", "Caching and Invalida", "Rate Limiting and
   Lo". The cap was not the problem. `topic_labels` in _data/collections.yml is
   the Facet_Panel's string, where a chip explains a filter and has a panel
   column to do it in, and the widest of them needs 235px; no cap this row can
   afford fits it. _data/collections.yml now carries a second map,
   `topic_short`, which _includes/catalog-view.html renders on the ROW while
   the panel keeps the long form.

   112px IS THE MEASURED LONGEST OF THOSE SHORT LABELS, rounded up to the token
   scale -- "Object Creation" on /lld at 107.69px as a rendered .tag box at
   --fs-xs, with "Data Structures" at 107.50 and "Async Pipeline" at 102.70
   behind it. Every one of the 39 + 22 + 53 rendered chips across the three
   collections now measures under it, so NOTHING truncates at 1280px and the
   ellipsis below is a backstop rather than the normal case.

   DOWN from 128px, not up, and the direction matters. A label that does not
   fit gets shortened in collections.yml -- raising this cap is not available,
   because the row is 44px with a title, a completion control and a difficulty
   badge on it and the chips are the item with no claim on the slack. The
   per-label widths are recorded beside each map in collections.yml so the next
   label can be checked against this number without re-measuring the set.

   /problemset is the one compact list this rule reaches whose labels are not
   curated -- `dsa` declares `topic_labels: {}` on purpose and its ~60 values
   come from the title-case fallback. Measured: 0 of its 756 chips sit in the
   112-128px band, so lowering the cap changed nothing there, and the 52 that
   were already over 128 ("Sieve of Eratosthenes" at 155px) are unchanged and
   out of scope -- they need the vocabulary consolidating, not a wider chip. */
.cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row-tags > * {
    flex: 0 0 auto;
    /* `inline-block`, overriding .tag's `inline-flex`, FOR THE ELLIPSIS BELOW.
       Same inert-declaration bug as .cat-row-link's: `text-overflow` applies
       to a block container's inline content, and .tag is a flex container, so
       the ellipsis on the next-but-one line has never rendered on a chip that
       exceeded this cap. Measured on /problemset, the one compact list whose
       topic labels are not curated: 4 chips cut mid-word at 1280 and at 1440
       -- "Dynamic Programming", "Sieve of Eratosthenes", "Minimum Spanning
       Tree", "Binary Indexed Tree". Those are the long tail
       _data/collections.yml records as out of scope for a label rewrite,
       which is exactly the case the ellipsis was supposed to cover.

       .tag uses inline-flex only to centre its text with `align-items`; with
       its --sp-1 block padding and line-height 1.5 an inline-block box centres
       the same single line, so nothing moves on the 61 HLD and LLD chips that
       were already inside the cap. */
    display: inline-block;
    max-width: calc(var(--sp-8) + var(--sp-7));
    overflow: hidden;
    font-size: var(--fs-xs);
    white-space: nowrap;
    text-overflow: ellipsis;
}
/* Only the first two. A design with four topics would otherwise push the
   difficulty badge off the row on a 1280px viewport. */
.cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row-tags > *:nth-child(n + 3) { display: none; }

/* ONE CHIP, NOT TWO, ONCE THE ROW CARRIES A DESCRIPTION.

   Two chips plus a description does not fit, and the way it failed is the
   failure mode this file has fixed twice already: `.cat-row-tags` is
   `flex: 0 1 auto` with `overflow: hidden`, so under pressure it shrank and
   clipped its SECOND chip through the glyphs -- "Blob Storag", "Coordinatio",
   "Replicatio", "Transac". The chips' own `text-overflow: ellipsis` cannot
   help with that: it is the container clipping a whole chip, not the chip
   ellipsising its own label.

   Dropping the second chip rather than letting the description shrink is the
   right way round. The description is strictly more specific than the chip --
   "Consistent hashing, replication, quorum reads/writes, LSM trees" says what
   the Replication chip says and then says which design it is -- so the second
   chip was the most redundant thing on the row the moment the description
   arrived. The first chip stays because it is the facet a reader filters by
   and it anchors the row to the panel above it; both values are still on
   `data-p`, so filtering and the panel counts are untouched.

   AND THE CONTAINER STOPS SHRINKING. With one chip under the 112px cap it has
   nothing left to clip, and `flex: 0 0 auto` makes that structural rather than
   lucky -- the description is the growing child and the one that yields. */
.catalog[data-row-fields~="desc"] .cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row-tags { flex: 0 0 auto; }
.catalog[data-row-fields~="desc"] .cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row-tags > *:nth-child(n + 2) { display: none; }

/* .cat-row-state carries the screen-reader wording for the completion state,
   which .prog-dot's aria-hidden hands off to. No rule here: core.css already
   defines .sr-only, so task 26 renders <span class="cat-row-state sr-only">.
   Redefining that clip is the kind of duplicate this file exists to remove. */

/* --------------------------------------------------------------------------
   2. Catalog_Entry card — .cat-card (comfortable density)

   The selector list is how density becomes one switch rather than a rebuild:
   the block defines .cat-card once and simultaneously applies it to rows under
   a comfortable container. The comfortable gate plus `.cat-row` scores 0,3,0
   and so beats the 0,1,0 .cat-row base above, while a bare .cat-card still
   works standalone wherever an entry card is wanted outside a Catalog_View.
   -------------------------------------------------------------------------- */
.cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); }

.cat-card,
.cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) .cat-row {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-1);
    /* A FLOOR, NOT A FIXED HEIGHT, and it used to be fixed on the strength of
       an argument that measurement does not support.

       The old note here said the fixed height "holds unconditionally because
       .cat-row-desc is the only flex-grow child and carries min-height: 0 — it
       absorbs any slack and shrinks under pressure". The description cannot
       absorb anything: it has a two-line FLOOR (see its own rule, which says
       so), so once the badge, title, chips, companies and action row exceed
       what is left, the card breaches its box and `overflow: hidden` eats the
       difference silently.

       Measured on /hld at 1440px: 28 of 39 cards overflowed, and at 1280px 32
       of 39. What they lost was not slack — it was `.cat-row-actions`, the
       Simulate and Draw buttons, clipped on every one of them (by 17px where
       the card was otherwise normal, 34px where the company row pushed too),
       and `.cat-row-meta`, the company chips, on 7. So most of the grid was
       quietly missing two working controls while the eleven cards that
       happened to fit kept theirs, which is what it looked like: a grid where
       some cards have buttons and some do not.

       `min-height` costs nothing that was real. The grid is auto-rowed with
       stretch alignment, so every card in a row still resolves to that row's
       tallest card and the rows stay visually even; only the pitch between
       rows can now vary, and the one thing that depended on a stated pitch --
       `.cat-list`'s CLS reservation -- is `--cat-count * --cat-row-h`, the
       44px COMPACT row, in both densities. assets/js/catalog.js's comment at
       paintDensity records that explicitly. Nothing else reads --cat-card-h.

       It stays as the FLOOR because a sparse collection still wants it:
       /hld-fundamentals/ cards measure 148-191px of content, and letting them
       shrink to that would make one grid hold cards of two visibly different
       classes.

       `height: auto` IS NOT REDUNDANT BESIDE IT. The base `.cat-row` rule sets
       `height: var(--cat-row-h)` for the 44px compact row, and this selector
       used to override that with its own `height`. Swapping only that to
       `min-height` left the inherited 44px `height` in force, so the card
       resolved to exactly max(44, 244) = 244px and content still could not
       grow it: the first attempt at this fix changed nothing at all, and the
       measurement came back with the same 28 of 39. */
    height: auto;
    min-height: var(--cat-card-h);
    padding: var(--sp-4);
    overflow: hidden;
    background: var(--card-glass);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
                transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
/* translateY(-2px), derived rather than written, so the lift tracks the scale. */
.cat-card:hover,
.cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) .cat-row:hover {
    background: var(--card-glass-hover);
    border-color: var(--accent);
    transform: translateY(calc(var(--sp-1) * -0.5));
    box-shadow: var(--shadow-lg), var(--glow-accent);
}

/* The row's own children re-flow into the card; the ones compact hides return.
   Title clamped at two lines so it cannot crowd out the description. */
.cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) .cat-row-link { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; flex: 0 0 auto; order: 2; overflow: hidden; font-size: var(--fs-md); font-weight: 700; line-height: 1.3; white-space: normal; text-overflow: clip; }
/* min-height is two lines, and it is the guard rather than a nicety. With
   `min-height: 0` this was the card's only flex-grow child, so it absorbed the
   whole deficit whenever the chrome above and below it exceeded the card: the
   description measured 11.6px — under one line — and read as missing entirely.
   A floor of two lines means an over-full card overflows visibly, which gets
   noticed and fixed, instead of silently eating the one element on the card
   that explains what the design is. */
.cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) .cat-row-desc {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    order: 3;
    flex: 1 1 auto;
    min-height: calc(var(--fs-sm) * 1.55 * 2);
    /* THE CLAMP AND THE BOX HAVE TO AGREE, and this is the line that makes
       them. THIS IS THE MID-WORD CLIPPING -- not the clamp count, and not
       text-overflow.
       `-webkit-line-clamp` inserts its ellipsis after line N. It does NOT cap
       the element's HEIGHT. This is the card's only `flex: 1 1 auto` child, so
       its box grew to absorb all of the card's slack -- measured at 1280,
       130px on a /hld-fundamentals/ card and 60px on /hld, against the 40px that two
       lines of --fs-sm occupy. The box therefore had room for lines the clamp
       had already decided not to show, and Chrome painted them: the ellipsis
       appeared at line N, mid-word, and the remainder of the sentence carried
       on BELOW it. "Hashing, L4 vs L7, healt..." with "checks" on the next
       line. "distributed limiting with Redis Lua..." then "scripts."
       It is invisible to an overflow test, which is why it survived two
       previous passes: with a box that tall, scrollHeight EQUALS clientHeight,
       so `scrollWidth/scrollHeight > client*` reports nothing wrong on any of
       the 39 cards. The detector has to compare the number of PAINTED LINES
       against the clamp, or the box height against N * line-height.
       Capping the height at exactly the clamp's worth of lines is what puts
       the ellipsis on the last line the reader can see. The min-height floor
       below is unchanged, so under pressure the card still overflows visibly
       rather than silently shrinking its description to nothing; the cap only
       stops the box growing PAST what the clamp will show. */
    max-height: calc(var(--fs-sm) * 1.55 * 2);
    overflow: hidden;
    font-size: var(--fs-sm);
    line-height: 1.55;
    color: var(--text-muted);
}
/* One line each, and nowrap is the fix rather than the style choice. With
   flex-wrap: wrap plus a max-height, a chip row that wrapped to two lines was
   clipped THROUGH the second line's glyphs — chips sliced in half horizontally,
   which reads as a rendering fault rather than as truncation. Capped to a
   single line the overflow runs off the inline edge instead, where a partly
   visible chip reads as "there are more", and the card's fixed 168px holds
   without the description having to absorb a second chip row. */
.cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) .cat-row-tags,
.cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) .cat-row-meta {
    display: flex;
    flex: 0 0 auto;
    /* WHOLE CHIPS OR NONE. nowrap clipped the last chip mid-word ("Realtime
       Pu", "CDN Edg"). Wrapping with a one-chip-tall box and a row gap taller
       than the box sends any chip that does not fit onto a second line that
       starts below the clip, so it disappears entirely instead of being
       sliced. 1.75rem holds a --fs-xs .tag (measured 26px). */
    flex-wrap: wrap;
    column-gap: var(--sp-2);
    row-gap: 2rem;
    height: 1.75rem;
    order: 4;
    min-height: 0;
    overflow: hidden;
}
/* The chips themselves must not shrink into unreadable slivers; they keep
   their intrinsic width and the row clips whatever does not fit. */
.cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) .cat-row-tags > *,
.cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) .cat-row-meta > * { flex: 0 0 auto; white-space: nowrap; }

/* Row-level actions — the Simulate and Draw deep links on an HLD card.
   Their own line, below the company chips, rather than appended into
   .cat-row-meta: a control sitting among three company names on one clipped
   line was the arrangement that made both unreadable. Hidden in compact for
   the same reason the description and the chips are — a 44px row has space
   for a title, a difficulty and a state, and nothing else. */
.cat-row-actions { display: none; }
.cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) .cat-row-actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: var(--sp-2);
    order: 5;
    min-height: 0;
    margin-top: auto;
}
/* THEY HAVE TO READ AS THE TWO INTERACTIVE THINGS ON A STATIC CARD, and at
   --text-muted on --surface-2 they did not: the card's own background is
   --card-glass, which sits between --surface and --surface-2, so the chips
   were a near-invisible step off their own backdrop carrying the same colour
   as the description above them. Three changes, each the smallest one that
   separates a control from prose:
     --text over --text-muted      the label is a control's name, not a gloss.
     --surface-3 over --surface-2  one step ABOVE the card instead of level
                                   with it, so the chip reads as sitting on
                                   the card rather than cut out of it.
     --shadow-sm                   the palette's softest lift. No glow, no
                                   gradient, no backdrop filter.
   What is deliberately NOT done: the accent. --accent on --accent-subtle is
   this file's PRESSED/hover vocabulary and is also what .cat-starter now uses
   for a primary affordance. Spending it here would put these level with the
   card's own title link, and they are secondary to it -- the card links to
   the design, these link to two tools for it. The accent stays as the hover
   and focus response, so the resting state is quiet and the reward for
   reaching one is unambiguous. */
.cat-row-actions > button {
    flex: 0 0 auto;
    min-height: var(--target-min);
    padding: var(--sp-1) var(--sp-2);
    font-size: var(--fs-xs);
    /* A CONTROL'S LABEL IS NOT A PARAGRAPH, and leaving this to inherit cost
       the card 4px it did not have. The body line-height is 1.65, so a --fs-xs
       label resolved to a 19.8px line box and the chip measured 29.8px tall
       (19.8 + --sp-1 twice + two 1px borders) against the --target-min floor
       of 24 that was supposed to be deciding its height. On /hld that put the
       fullest card at 246px inside a 242px content box -- 22 of 39 cards
       overflowing their fixed --cat-card-h by exactly those 4px, clipping the
       bottom of the chip row. At 1 the chip is 22px of content and
       --target-min decides, which is what the floor is for. */
    line-height: 1;
    font-weight: 600;
    white-space: nowrap;
    color: var(--text);
    background: var(--surface-3);
    border: 1px solid var(--control-border);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: color var(--dur) var(--ease), background var(--dur) var(--ease),
                border-color var(--dur) var(--ease);
}
.cat-row-actions > button:hover {
    color: var(--accent);
    background: var(--accent-subtle);
    border-color: var(--accent);
}
.cat-row-actions > button:focus-visible {
    outline: var(--focus-ring);
    outline-offset: var(--focus-ring-offset);
}
/* --------------------------------------------------------------------------
   THE SAME CONTROLS, REACHABLE IN COMPACT
   `display: none` above is the compact default and the note on it is still
   right about the budget: a 44px row has no vertical room for a second line
   and no horizontal room for "Simulate" and "Draw" spelled out beside a
   title, a description, two chips, a reading time and a badge.
   So they are revealed, not added: icon-only, and only while the row is the
   one the reader is on.
   HEIGHT IS UNCHANGED AND SO IS THE PITCH: the chips are --target-min (24px)
   inside a --cat-row-h (44px) row, and the row's height is a fixed token.
   THE WIDTH IS NOT RESERVED, and that was measured rather than assumed. The
   first attempt kept the chips in the flow permanently and only toggled
   `visibility`, so that revealing one could not reflow the row. It costs
   about 64px of the description's 618px -- which took 26 of /hld's 39 compact
   descriptions from fitting to truncating, at rest, on every row, whether or
   not the reader ever went near the actions. Trading 26 descriptions for two
   chips that are only useful on the row you are pointing at is the wrong way
   round, so the reveal is `display` and the cost is confined to the one row
   that is actually hovered or focused. The description keeps a working
   ellipsis (it is `display: block` with `text-overflow: ellipsis` -- see the
   note on the compact title for why that distinction matters), so the row
   that does reflow degrades to a marked truncation rather than a hard cut.
   AND IT IS NOT A HOVER-ONLY CONTROL. `:focus-within` is listed beside
   `:hover` and is the half that makes this usable without a mouse (Req 15):
   Tab reaches .cat-row-link, the row takes focus-within, the chips are laid
   out AND therefore focusable, and the next Tab lands on the first one.
   A `:hover`-only reveal would leave them permanently unreachable from the
   keyboard. `display: none` at rest is also what keeps them out of the tab
   order on the other 38 rows rather than adding 78 stops to the page.
   The accessible name does NOT come from the glyph. Each button carries an
   `aria-label` and a .cat-act-txt span; compact hides the span and keeps the
   label, so the control is named identically in both densities and the
   screen-reader text does not change when the density does. See the chip()
   helpers in pages/hld.html and pages/lld.html.
   -------------------------------------------------------------------------- */
.cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row:hover .cat-row-actions,
.cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row:focus-within .cat-row-actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: var(--sp-1);
}
/* Square targets, so two of them read as a pair of icons rather than as two
   ragged boxes. --target-min on both axes is the floor the rest of the file
   uses for a control with no text. */
.cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row-actions > button {
    min-width: var(--target-min);
    padding: 0;
    justify-content: center;
}
.cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-act-txt { display: none; }
/* The glyph is decoration in comfortable, where the word is present, and the
   whole visible control in compact. Hidden from assistive technology in both
   -- the aria-label is the name either way. */
.cat-act-ico { font-size: var(--fs-xs); line-height: 1; }
.cat-row-actions > button { display: inline-flex; align-items: center; gap: var(--sp-1); }
.cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) .cat-row > .badge { order: 1; align-self: flex-start; }
/* Out of the column flow and into the corner: as a flex line the dot would
   cost the card a whole row of its 168px for a --sp-4 glyph.
   TWO SELECTORS, NOT ONE, and the `>` is load-bearing. Where the collection
   has a writable progress map the dot is wrapped in .cat-done (task 28) and it
   is the BUTTON that has to leave the flow — positioning the dot inside a
   button still in the column flow would float the glyph into the corner and
   leave a 24px empty control sitting in the card's first flex line, eating a
   row of the 168px for nothing and putting the hit area somewhere the reader
   can see no affordance. Where there is no control the dot is a direct child
   and moves itself; `> .prog-dot` is what keeps that rule off the wrapped one.
   --sp-3 for the button against --sp-4 for the bare dot so the two present the
   same optical inset: the button is 8px wider than the dot it contains. */
.cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) .cat-row > .prog-dot { position: absolute; top: var(--sp-4); right: var(--sp-4); }
.cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) .cat-done { position: absolute; top: var(--sp-3); right: var(--sp-3); }
/* AND THE CORNER HAS TO BE RESERVED, which is the other half of taking the
   control out of the flow. The two rules above move it to the top-right of a
   `position: relative` card; nothing below them gave the first flex line an
   inset, so on /hld-fundamentals/ the dot sat INSIDE the title's line box and the
   reader saw "Bloom Filters in (o) System Design".
   WHY /hld NEVER SHOWED IT, AND WHY THAT IS NOT ABOUT TITLE LENGTH. Every
   collection declaring `difficulty_vocab` renders a .badge at `order: 1`, so
   the badge is the card's first flex line and the title starts on the SECOND
   one, clear of a control that is --target-min tall in a --sp-3 inset. The
   badge is the spacer, and it is load-bearing by accident. /hld-fundamentals/ and the
   two courses declare no difficulty, render no badge, and so promote the
   title into the line the control occupies -- on all 53 rows, at every width.
   So the condition is structural and the selector tests exactly it rather
   than naming a collection: `:not(:has(> .badge))` is "this card has nothing
   else holding its first line". It is a direct-child test on an element that
   already exists in the initial response, so it costs nothing per row at
   /problemset's 390 -- and it keeps the inset OFF the collections whose badge
   makes it unnecessary, where it would have cost the title 24px of a 235px
   box for no reason.
   --sp-5 is the smallest token that clears: .cat-done sits at `right: --sp-3`
   and is --target-min wide, so it reaches 36px in from the card's edge, and
   the card's own --sp-4 padding already accounts for 16px of that. 20px has
   to come from the title; --sp-5 is 24px and leaves 4px of optical gap.
   The bare .prog-dot case needs less (--sp-4 inset on a --sp-4 glyph is 32px,
   so 16px) and is covered by the same reservation. */
.cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) .cat-row:not(:has(> .badge)) .cat-row-link { padding-inline-end: var(--sp-5); }
/* A THIRD DESCRIPTION LINE, ON THE CARDS THAT HAVE THE ROOM FOR IT, and the
   test for "has the room" is the same structural one as the inset above.
   A badge-less card is a SPARSE card, and not by coincidence: a collection
   that declares no `difficulty_vocab` also tends to declare no companies and
   no row actions, so /hld-fundamentals/ renders a title, a description and one chip
   row where /hld renders six children. Measured at 1280, a concepts card used
   148px of its 244px box -- 96px, nearly four lines, sitting empty under the
   chips while the description clipped at two.
   SO WHY NOT EVERYWHERE. It was tried at three lines for every collection and
   22 of /hld's 39 cards breached their 244px box -- exactly the overflow the
   note below warns about, because `min-height` is a two-line FLOOR and not a
   two-line ceiling: those cards had already spent their slack on a badge, a
   company row and two action chips, so a third painted line had nowhere to
   come from. /problemset's 385 clipped descriptions did not improve either,
   its cards being 204px wide with descriptions long enough that three lines
   clips as surely as two. Both keep the two-line clamp.
   The gain is real where it applies: three lines of a 167px box is about 78
   characters against 52, which is the difference between a card_desc that
   reaches the end of its first clause and one that stops inside it. The cap
   in _gen/migrate-catalog.mjs is set against this number.
   THE TITLE GETS THE THIRD LINE ON THE SAME TERMS, and for the last two rows
   that needed it. With the derived card_title in place, 51 of /hld-fundamentals/'s 53
   titles fit two lines; "Retry and Exponential Backoff" and "Back-of-Envelope
   Estimation" do not, because the --sp-5 inset above leaves 141px of content
   box and neither "Retry and Exponential" nor "Exponential Backoff" fits on
   one line at --fs-md bold. Both wanted exactly one more line, and a sparse
   card has it: measured after the description's third line, a concepts card
   uses 191px of its 242px content box. Capping the title at two and letting
   the ellipsis take the rest would have been the alternative, and it reads
   worse for no saving -- the room is there and otherwise stays empty. */
/* max-height moves with the clamp -- see the note on it in the block above.
   A three-line clamp inside a two-line cap would show two lines and a wasted
   token; a three-line cap under a two-line clamp brings the painted-past-the-
   ellipsis artifact straight back. The two are one decision. */
.cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) .cat-row:not(:has(> .badge)) .cat-row-desc { -webkit-line-clamp: 3; line-clamp: 3; max-height: calc(var(--fs-sm) * 1.55 * 3); }
.cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) .cat-row:not(:has(> .badge)) .cat-row-link { -webkit-line-clamp: 3; line-clamp: 3; }

/* --------------------------------------------------------------------------
   3. Facet control — .facet
   Boundary is --text-dim, not --border: see the header note on Req 15 AC 6.
   -------------------------------------------------------------------------- */
/* THE COLLAPSED SINGLE BAR this file used to claim its floor covered, and
   which nothing had built.

   The panel was `flex-direction: column`, a group per declared facet, so it
   rendered at whatever its longest vocabulary needed -- on /hld difficulty 3,
   topic 24, company 56, status 3, measuring 555px. Two failures in one: it
   put the first Catalog_Entry below 1000px of scroll (Req 2 AC 10), and 86
   chips is not something a reader scans even where that budget is irrelevant.

   Now a ROW: every group on one line, and any group longer than a glance
   behind a disclosure (section 3b). Server-rendered collapsed with its real
   counts, so nothing here arrives late and the bar's height is settled by the
   initial response rather than by script (Req 16 AC 5, AC 7) -- reservation 1
   of design decision 10's four.

   TWO LINES ARE RESERVED, NOT ONE, and that is a CLS fix with a price. The
   empty bar needs one line: 49px, four groups inside 908px of the 1086px
   available at 1280. But the server cannot know the Filter_State, so on a
   deep link -- `/hld?d=beginner&sort=order`, which this page's own
   Recommended Study Order block links to -- the first render presses chips
   that were rendered unpressed, the collapsed groups reveal them, and
   `Clear all filters` appears beside them: ~280px against 178px of free
   space, so the bar wraps and everything below drops 40px. Measured at
   1280x800, worst of five loads each:

                                   one-line floor      two lines reserved
     /hld                          CLS 0.016  16 ent   CLS 0.014  12 ent
     /hld?d=beginner&sort=order    CLS 0.034   6 ent   CLS 0.015   6 ent
     /hld?d=advanced&t=geospatial  CLS 0.446  FAIL     CLS 0.063  PASS

   One line shows four more entries unfiltered and blows Req 16 AC 5's 0.1
   budget on every URL arriving with a facet selected. Req 2 AC 10 asks for
   twelve, not sixteen, and twelve clears by 148px, so the four entries are
   the cheaper thing to give up.

   --cat-row-h * 2 + --sp-1 = 92px against a natural two-line height of 89.

   AND IT IS A CAP, NOT ONLY A FLOOR -- min-height and max-height are the same
   value, so the bar is 92px in every state the server can render and every
   state a Filter_State can put it in. A floor alone covers a one or two value
   selection and nothing more: `?t=caching,fan-out,geospatial` shows three
   chips, needs a third line, and measured 128px and CLS 0.438. Selections are
   unbounded, so no reservation can cover them by being generous; the bar has
   to stop growing instead, and the overflow scrolls. Every chip stays
   reachable -- tabbing into one scrolls it into view, which is Req 15 AC 4 --
   and the selection stays legible because selected chips are the only thing
   a collapsed group shows.

   The cap is lifted for the one height change that is NOT a layout shift: a
   reader expanding a group, which is their own action and gets the group's
   own bounded scroll (see section 3b). `:has()` is how the panel sees that
   without a class for the script to maintain. Where `:has()` is not
   supported the rule is dropped and the panel keeps its 92px cap, so an
   expanded group scrolls inside the bar rather than beside it -- narrower,
   still every chip reachable, and not a dead end. */
/* ONE line reserved, not two, and `nowrap` is what makes one line safe.
   -------------------------------------------------------------------------
   Two lines were reserved so that a deep link arriving with facets selected
   could reveal its selected chips and its Clear control without the panel
   wrapping and shifting the page. The guarantee was right and the result was
   not: measured at 1280x800 the panel held 31.4px of content inside 92px, with
   30.3px of dead space ABOVE and BELOW the single row of chips. Two thirds of
   the box was empty, which reads as a rendering fault rather than as a
   reservation, and it spent 43px of the 1000px the entries are measured in to
   look that way.

   `flex-wrap: nowrap` plus `overflow-x: auto` gets the same guarantee at half
   the height: the row CANNOT wrap, so no selection can grow it, so there is
   nothing to reserve a second line for. What a long selection does instead is
   scroll, and that is strictly better than a second line -- a second line
   covers two or three selected values and then shifts anyway on the fourth,
   whereas scrolling is bounded for any number of them.

   Nothing becomes unreachable. A collapsed group shows its selected chips and
   hides the rest (the rules further down), tabbing to a chip scrolls it into
   view (Req 15 AC 4), and the toggle's own label carries the count -- "2 of 24
   topics" -- so the selection is legible even while scrolled off.

   The `:has()` rule below still lifts the cap when a reader expands a group,
   which is their own action rather than a layout shift. */
.facet-panel { display: flex; flex-wrap: nowrap; align-items: center; gap: var(--sp-2) var(--sp-4); min-height: calc(var(--cat-row-h) + var(--sp-1)); max-height: calc(var(--cat-row-h) + var(--sp-1)); overflow-x: auto; overflow-y: hidden; padding: var(--sp-2) var(--sp-3); background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--r-md); }
/* The groups keep their intrinsic width so the row scrolls rather than
   squeezing a label into a sliver. */
.facet-panel > * { flex: 0 0 auto; }
/* The containing block for the .sr-only status spans inside the bar. Without it
   they are positioned against an ancestor outside this scroll box, so the ones
   scrolled past the right edge escaped its clip and widened the whole page:
   /hld and /lld scrolled sideways by ~150px at 768px. The tray below 640px is
   `position: fixed` at a higher specificity and is unaffected. */
.facet-panel { position: relative; }
/* Expanding a group is the reader's own action, so the growth is not a layout
   shift and the cap lifts. `flex-wrap` returns with it: an expanded group is 24
   or 56 chips and has to use the full width rather than scroll sideways
   through all of them. */
.facet-panel:has(.facet-toggle[aria-expanded="true"]) { flex-wrap: wrap; max-height: none; overflow-x: visible; overflow-y: visible; }
/* The expanded group takes a full line of the panel, and without this its
   chips do not wrap at all.
   `.facet-panel > *` above is `flex: 0 0 auto` so the collapsed bar scrolls
   sideways rather than squeezing a group label into a sliver. But `0 0 auto`
   sizes a flex item to max-content, so an expanded group became as wide as all
   its chips laid end to end -- measured on /problemset's 60-value topic
   vocabulary: a 7552px values box inside an 852px panel, one line, 54 chips
   past the right edge and unreachable. The inner `flex-wrap: wrap` was never
   the problem; it had 7552px to work with and nothing to wrap against.
   `1 1 100%` gives the expanded group the panel's width as its basis, so its
   values wrap inside it. The other groups keep `0 0 auto` and share the
   remaining lines. */
.facet-panel:has(.facet-toggle[aria-expanded="true"]) > .facet-group:has(.facet-toggle[aria-expanded="true"]) { flex: 1 1 100%; min-width: 0; }
.facet-group { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); border: none; }
.facet-group-title { display: flex; align-items: center; min-height: var(--target-min); font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }

/* The values of one group. A flex container of its own rather than
   `display: contents`, because the noscript fallback in pages/hld.html needs
   a real box to bound, and because aria-controls has to point at something
   that exists in the accessibility tree. */
.facet-group-values { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); min-width: 0; }

.facet {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    min-height: var(--target-min);
    min-width: var(--target-min);
    padding: var(--sp-1) var(--sp-3);
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid var(--control-border);
    border-radius: var(--r-full);
    transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease);
}
.facet:hover { color: var(--text); border-color: var(--accent); }
.facet[aria-pressed="true"] { color: var(--accent); background: var(--accent-subtle); border-color: var(--accent); font-weight: 600; }
.facet[aria-pressed="true"]:hover { background: var(--accent-subtle-hover); }
/* The completion-status facet before the Progress_Store resolves: dimmed *and*
   disabled, so the state is in the DOM and not only in the paint. */
.facet[disabled] { opacity: 0.55; cursor: not-allowed; }
.facet[disabled]:hover { color: var(--text-muted); border-color: var(--control-border); }

/* Facet counts (Req 2 AC 4). --text-muted, not --text-dim — header note. */
.facet-count { font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.facet[aria-pressed="true"] .facet-count { color: var(--accent); }

/* --------------------------------------------------------------------------
   3b. Facet disclosure — .facet-toggle

   A real `button` carrying aria-expanded and aria-controls, so it is in the
   tab order, operable by Enter AND Space, and announced (Req 15 AC 1, AC 2,
   AC 8). Not a `:hover` reveal, which no keyboard or touch reader can use,
   and not a label over a checkbox, which announces itself as a checkbox.

   A SELECTED VALUE IS NEVER HIDDEN. The collapsed rule hides the group's
   chips and exempts [aria-pressed="true"], so a reader with three topics
   selected sees those three chips in the bar with their counts and can clear
   them one at a time without expanding anything. A collapsed group hiding an
   active selection turns a filter into state the reader can neither see nor
   clear. aria-pressed is the hook rather than a class because
   assets/js/catalog.js already writes it on every update, so the painted and
   announced states stay one fact (rule 4 above) with no second source of
   selection truth here.

   The caret is a border triangle with an empty `content`: no generated text
   for a screen reader to meet, and the rotation says nothing aria-expanded
   has not already said.
   -------------------------------------------------------------------------- */
.facet-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    min-height: var(--target-min);
    min-width: var(--target-min);
    padding: var(--sp-1) var(--sp-3);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid var(--control-border);
    border-radius: var(--r-full);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease);
}
.facet-toggle:hover { color: var(--text); border-color: var(--accent); }
.facet-toggle[aria-expanded="true"] { color: var(--accent); background: var(--accent-subtle); border-color: var(--accent); }
.facet-toggle::after {
    content: '';
    width: 0;
    height: 0;
    /* Derived from the spacing scale; core.css carries no line weight or glyph
       size. 5px of border gives a 10x5 triangle. */
    border-inline: calc(var(--sp-1) * 1.25) solid transparent;
    border-top: calc(var(--sp-1) * 1.25) solid currentColor;
    transition: transform var(--dur-fast) var(--ease);
}
.facet-toggle[aria-expanded="true"]::after { transform: rotate(180deg); }

/* Collapsed: the long tail is out, the selection stays.
   Specificity is deliberate -- the hide rule scores (0,4,0) so it beats
   `.facet`'s own (0,1,0) display, and both exemptions outscore it. */
.facet-group.is-collapsible > .facet-group-values > .facet { display: none; }
.facet-group.is-collapsible > .facet-group-values > .facet[aria-pressed="true"] { display: inline-flex; }
.facet-group.is-collapsible > .facet-toggle[aria-expanded="true"] ~ .facet-group-values > .facet { display: inline-flex; }

/* Expanded, a 56-value group would otherwise push the controls bar and the
   list down the page by several hundred pixels. Bounded and scrolled instead,
   so expanding costs a known amount of the viewport and the list stays in
   sight. --cat-card-h is the one height token at roughly the right size; the
   group scrolls inside it. */
.facet-group.is-collapsible > .facet-toggle[aria-expanded="true"] ~ .facet-group-values {
    flex: 1 1 100%;
    align-items: flex-start;
    align-content: flex-start;
    max-height: var(--cat-card-h);
    overflow-y: auto;
    padding-block: var(--sp-1);
}

/* --------------------------------------------------------------------------
   4. Segmented control — .seg (sort order and density)
   -------------------------------------------------------------------------- */
.seg { display: inline-flex; align-items: stretch; gap: 0; background: var(--surface-2); border: 1px solid var(--control-border); border-radius: var(--r-sm); overflow: hidden; }
.seg > button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--target-min);
    min-width: var(--target-min);
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-muted);
    transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.seg > button + button { border-left: 1px solid var(--control-border); }
.seg > button:hover { color: var(--text); }
.seg > button[aria-pressed="true"] { color: var(--accent); background: var(--accent-subtle); }
/* The selected segment also gains a 2px rule along its inner edge, so the
   state survives a monochrome rendering as well as the aria-pressed
   announcement. Derived from the spacing scale; core.css has no line weight. */
.seg > button[aria-pressed="true"]::after { content: ''; position: absolute; inset-inline: 0; bottom: 0; height: calc(var(--sp-1) * 0.5); background: var(--accent); }

/* --------------------------------------------------------------------------
   5. Tag — .tag, with .tag-muted for the company chips
   Not interactive: a tag labels, a .facet selects. So the 3:1 boundary rule
   does not reach it and --border-accent is free to stay a hairline.
   -------------------------------------------------------------------------- */
.tag { display: inline-flex; align-items: center; padding: var(--sp-1) var(--sp-2); font-size: var(--fs-xs); font-weight: 500; line-height: 1.5; color: var(--accent); background: var(--accent-subtle); border: 1px solid var(--border-accent); border-radius: var(--r-xs); white-space: nowrap; }
.tag-muted { color: var(--text-muted); background: var(--surface-2); border-color: var(--border); }

/* --------------------------------------------------------------------------
   6. Difficulty badge — .badge, .badge-easy, .badge-medium, .badge-hard

   Defined ONCE, in core.css, already reading --easy / --medium / --hard, which
   already carry light-theme values. Redefining them is exactly what this
   consolidation removes, so this section adds no colour, no type size and no
   radius — only the two layout facts a catalog entry needs.

   HLD's and LLD's beginner / intermediate / advanced reach the same three
   classes through difficulty_tokens in _data/collections.yml
   (beginner: easy, intermediate: medium, advanced: hard), so one colour change
   reaches both vocabularies (Req 14 AC 5).
   -------------------------------------------------------------------------- */
/* Uniform width, so the column to its LEFT lines up too. The badge is the
   row's right-hand anchor and the reading-time cell butts against it, so a
   variable-width badge drags that cell around: measured at 1440px the labels
   are "Beginner" 72.5px, "Advanced" 78.1px and "Intermediate" 95.1px, which
   left `~30 min` landing anywhere across a 23px band down 39 rows. Pinned to
   the widest label and centred, which costs nothing — the row has slack here —
   and buys both columns.
   Reserving the lock's width above fixed the badge column; this fixes the one
   behind it. */
.cat-row > .badge {
    flex: 0 0 auto;
    min-width: var(--cat-badge-w);
    justify-content: center;
    text-transform: capitalize;
}
/* THE UNCOLOURED BADGE IS SECONDARY, and it has to say so.

   A collection whose `difficulty_tokens` map is empty gets no `badge-*` class
   -- catalog-view.html only adds one when the token resolves -- so the badge
   falls back to the base `.badge` in core.css, which is --accent-subtle fill
   on a --border-accent boundary. That is byte-for-byte the vocabulary of
   `.tag`, which is already on the same row three pixels to the left: on
   /companies every one of the 150 rows came out with two accent pills of
   near-identical weight at its trailing edge, distinguishable only by
   `.badge`'s --r-full against `.tag`'s --r-xs. The right-hand edge of the list
   read as one busy accent column and neither pill was legible at a glance.

   The two are not equal and the fill should not imply it. The chip is the
   sector, which is what the entry IS; the badge is a depth band, which is
   metadata about how well covered it is. So the badge drops to this file's
   established secondary language -- --surface-2 behind --text-muted inside a
   plain --border, the same three tokens `.facet` uses at rest -- and the row
   has a primary and a secondary again.

   NOT A RULE ABOUT /companies. It is a rule about a badge with no colour
   token, which is the only state that has this collision; the three coloured
   variants are more specific and are untouched, so /hld, /lld and /problemset
   render exactly what they rendered. The `:not()` chain names them rather than
   using an attribute substring match so that a fourth colour variant added to
   core.css fails loudly here instead of silently losing its fill.

   --text-muted on --surface-2 is about 6.5:1 dark and 7:1 light, both clear of
   the 4.5:1 floor; --text-muted's ratios are measured against --surface in the
   header note and --surface-2 is one step lighter. */
.cat-row > .badge:not(.badge-easy):not(.badge-medium):not(.badge-hard) {
    color: var(--text-muted);
    background: var(--surface-2);
    border-color: var(--border);
}

/* --------------------------------------------------------------------------
   7. Progress_Indicator — .prog-dot

   MOVED TO assets/css/core.css (task 19.2). The Section_Sidebar renders a dot
   per entry on the 258 content pages served by _layouts/default.html, which
   links core.css and content.css and not this file, so the one definition had
   to move somewhere both page shells see. It is still defined exactly once
   (Req 14 AC 3); the reduced-motion block at the foot of this file still
   names it, which is harmless and kept so the Catalog_View's motion list
   stays a complete inventory of what it animates.

   The controls that WRAP the dot stay here, because only a Catalog_View
   renders them.
   -------------------------------------------------------------------------- */

/* The completion control that wraps the dot (task 28), rendered only where the
   collection names a writable progress map. The dot is its visual and keeps
   aria-hidden; this carries the name, the state and the target size, so there
   is ONE affordance for one bit of state rather than an indicator with a
   control beside it repeating the same fact.

   --target-min is a floor on the box, not on the dot: the dot stays --sp-4 so
   the resolved state is the same class toggle on the same geometry it always
   was (Req 7 AC 5). The 8px the box adds over the dot is in the initial
   response, not added when the store resolves, so it costs no shift.

   `disabled` changes opacity and cursor and NOTHING that measures, for the
   same reason — enabling it after the auth hint resolves must not re-lay-out
   the row. */
.cat-done { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; min-width: var(--target-min); min-height: var(--target-min); padding: 0; background: none; border: 0; border-radius: var(--r-full); cursor: pointer; }
.cat-done[disabled] { cursor: default; opacity: 0.45; }
.cat-done:not([disabled]):hover .prog-dot { border-color: var(--accent); }

/* Save control (Req 8 AC 1). Its glyph is the affordance at rest, so the
   boundary rule does not bind; --target-min still does. */
.cat-save { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; min-height: var(--target-min); min-width: var(--target-min); border-radius: var(--r-sm); color: var(--text-muted); transition: color var(--dur-fast) var(--ease); }
.cat-save:hover, .cat-save[aria-pressed="true"] { color: var(--accent); }

/* --------------------------------------------------------------------------
   8. Empty-result message — .empty-state (Req 2 AC 8)
   At-rest state IS the final state; the keyframe animates from the transient
   one. See rule 5 in the header.
   -------------------------------------------------------------------------- */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); padding: var(--sp-7) var(--sp-4); text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); animation: cat-fade-in var(--dur) var(--ease-out) both; }
.empty-state[hidden] { display: none; }
.empty-state-title { font-size: var(--fs-md); font-weight: 700; color: var(--text); }
.empty-state-body { font-size: var(--fs-sm); color: var(--text-muted); max-width: var(--measure-narrow); }
/* The active Filter_State, named back to the reader. */
.empty-state-body .tag { margin-inline: var(--sp-1); }
@keyframes cat-fade-in { from { opacity: 0; transform: translateY(var(--sp-3)); } to { opacity: 1; transform: translateY(0); } }

/* Clear control, shown while any Facet value is selected (Req 2 AC 7). */
.cat-clear { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--target-min); padding: var(--sp-1) var(--sp-3); font-size: var(--fs-sm); font-weight: 600; color: var(--accent); background: var(--accent-subtle); border: 1px solid var(--accent); border-radius: var(--r-full); transition: background var(--dur-fast) var(--ease); }
.cat-clear:hover { background: var(--accent-subtle-hover); }
.cat-clear[hidden] { display: none; }

/* --------------------------------------------------------------------------
   Focus indicator (Req 15 AC 3) and focus placement (Req 15 AC 4)
   One ring, from the audited token set, rather than one per surface. The
   offset is load-bearing where the ring would otherwise abut a solid --accent
   fill — see the --focus-ring comment in core.css. Worst case across every
   colour these controls can put behind it is 9.51:1 dark, 9.48:1 light.
   -------------------------------------------------------------------------- */
.cat-row-link:focus-visible,
.cat-card:focus-visible,
.cat-search:focus-visible,
.facet:focus-visible,
.facet-toggle:focus-visible,
.seg > button:focus-visible,
.cat-save:focus-visible,
.cat-done:focus-visible,
.cat-signin-btn:focus-visible,
.cat-clear:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-ring-offset); border-radius: var(--r-xs); }

.cat-row, .cat-card { scroll-margin-top: calc(var(--header-h) + var(--sp-4)); scroll-margin-bottom: calc(var(--nav-mobile-h) + var(--sp-4)); }

/* --------------------------------------------------------------------------
   Responsive. Breakpoint literals are forced: CSS does not allow var() in a
   media query condition. 640px is Req 13's Mobile_Nav and Filter_Tray
   threshold; 1200px is where the content column is wide enough for the
   three-column card grid the density budget assumes, and the budget is
   measured at 1280.
   -------------------------------------------------------------------------- */
/* THE COLUMN COUNT IS A FUNCTION OF THE LIST'S OWN WIDTH, NOT THE VIEWPORT'S.
   This was two viewport media queries, and the 1200px one is where the
   concepts cards broke. "At --measure that is 281px a card" is true only of a
   Catalog_View that HAS --measure to spend, which is /hld and /lld on
   `layout: catalog`. Three of the seven collections do not:
     /hld, /lld      layout: catalog, no reading column   #cat-list 1112px
     /problemset     "                                    #cat-list  852px
     /hld-fundamentals/      layout: default -- the catalog sits   #cat-list  700px
                     INSIDE .content, beside a 232px
                     Page_Outline rail
   All three were handed `repeat(4, ...)` the moment the WINDOW passed 1200px,
   so /hld-fundamentals/ rendered four 160px cards holding 126px of text. At --fs-md
   bold that is about 14 characters a line, so a two-line clamped title lost
   the back half of every concept name -- "Dead Letter Queue (DLQ) i" -- and a
   two-line description could not reach the end of its first clause. The dot
   overlap in the same report is a second, separate bug (see .cat-row-link's
   padding-inline-end below), but this is what made the cards unreadable.
   A container query asks the question the layout actually depends on. The
   breakpoints are chosen against the three measured widths above, not round
   numbers: 820px keeps /problemset's 852px on four columns, which is what
   holds its Req 2 AC 10 floor at 12 entries, and 620px takes /hld-fundamentals/'s
   700px to three 225px cards without dropping it to two.
   Literals, not tokens: a container or media query condition cannot contain
   var() -- the same forcing the responsive block below already notes.
   WHY `container-type` IS SCOPED ABOVE 640px. `container-type: inline-size`
   computes to `contain: layout inline-size`, and `contain: layout` makes the
   element a containing block for fixed-position descendants. The Filter_Tray
   is `position: fixed` inside this same .catalog at 640px and below, so an
   unscoped container would anchor the bottom sheet to the catalog box instead
   of the viewport. Above 640px nothing inside .catalog is fixed, and below it
   the grid is a single column anyway, so the containment is only ever
   established where it is both needed and harmless. */
@media (min-width: 641px) { .catalog { container-type: inline-size; } }
@container (min-width: 420px) { .cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (min-width: 620px) { .cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@container (min-width: 820px) { .cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
/* The page frame grew to 1440px (core.css, --measure), so a full-width catalog
   is ~1390px inside. Four cards there are 340px each; five keeps them near the
   ~270px they were at the old 1160px frame. */
@container (min-width: 1180px) { .cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* TWO-COLUMN COMPACT LIST, for a catalog whose rows carry no description.
   A /problemset or /companies row is a title and two or three chips. At the
   1390px the wider frame gives it, one row per line left ~900px of empty row
   between the title and its chips, and the 400 problems ran to ~18,700px.
   Two columns halve that and keep a row readable as one unit. /hld and /lld
   rows show a description in that space, so `desc` opts a catalog out; the
   hubs that embed a catalog in the article column (/hld-fundamentals/,
   /lld-fundamentals/) are narrower than the 1040px threshold.

   ROW-MAJOR, NOT CSS COLUMNS. A column-major split would put problem 201 beside
   problem 1 at the top of a Recommended list; a grid keeps the first entries at
   the top, which is the order the comfortable grid already reads in.

   BORDERS FOLLOW THE VISIBLE ROWS. Filtering hides rows with [hidden], which
   plain :nth-child still counts, so the left-column divider and the last-line
   rule use `of :not([hidden])`. The left column is every odd visible row; the
   last line is the last visible row, plus the one before it when that one is
   in the left column (an even visible count). Those lose their own bottom
   border so it does not double the list's.

   THE RESERVATION HALVES. --cat-count x --cat-row-h is a floor on the list
   (section above); at two per line the floor is half of it. For an odd count it
   is half a row short, which a floor is allowed to be. */
@container (min-width: 1040px) {
    .catalog:not([data-row-fields~="desc"]) .cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        min-height: calc(var(--cat-count) * var(--cat-row-h) / 2);
    }
    .catalog:not([data-row-fields~="desc"]) .cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row:nth-child(odd of :not([hidden])) { border-right: 1px solid var(--border); }
    .catalog:not([data-row-fields~="desc"]) .cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row:nth-last-child(1 of :not([hidden])),
    .catalog:not([data-row-fields~="desc"]) .cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row:nth-last-child(2 of :not([hidden])):nth-child(odd of :not([hidden])) { border-bottom: none; }
    /* AND THE DIVIDER STOPS AT THE LAST ROW WHEN IT IS ALONE ON ITS LINE.
       An odd visible count leaves the final row in the left column with nothing
       beside it. The divider rule above still gives that row a `border-right`,
       which draws a full-height rule down the middle of the last line and
       closes a box around the empty half -- so /dsa-fundamentals, 19 rows, ended
       its list with what read as an empty table cell rather than a list that had
       run out of entries.
       Dropping the divider on that one row lets the last line read as one row
       with content on the left, which is what it is. It is the same
       `of :not([hidden])` bookkeeping as the rules above, so filtering to an
       even count puts the last row in the right column and this stops applying
       on its own. */
    .catalog:not([data-row-fields~="desc"]) .cat-list:is(.is-compact:where(html:not([data-cat-density="comfortable"]) *), :where(html[data-cat-density="compact"] *)) .cat-row:nth-last-child(1 of :not([hidden])):nth-child(odd of :not([hidden])) { border-right: none; }
}

/* Filter_Tray — the Facet_Panel as a bottom sheet at 640px and below
   (Req 13 AC 5, AC 6). Every control inside is raised to --target-touch. */
@media (max-width: 640px) {
    .facet-panel.is-tray {
        position: fixed;
        inset-inline: 0;
        bottom: 0;
        z-index: var(--z-sheet);
        max-height: 80vh;
        overflow-y: auto;
        padding: var(--sp-4) var(--sp-4) calc(var(--nav-mobile-h) + var(--sp-4));
        background: var(--surface);
        border-radius: var(--r-lg) var(--r-lg) 0 0;
        box-shadow: var(--shadow-lg);
        animation: cat-sheet-in var(--dur) var(--ease-out) both;
    }
    .facet-panel.is-tray[hidden] { display: none; }
    .facet-panel.is-tray .facet,
    .facet-panel.is-tray .seg > button,
    .facet-panel.is-tray .facet-toggle,
    .facet-panel.is-tray .cat-clear { min-height: var(--target-touch); }

    /* In the sheet the panel has 80vh and its own scroll, so the groups go
       back to a stack and a group gets a full line. The disclosures stay --
       56 chips is still 56 chips on a phone, and the sheet would be nothing
       but company chips without them. The desktop bar's 92px cap goes: it is
       there to stop a wrapping ROW moving the list, and this is a column. */
    .facet-panel { flex-direction: column; align-items: stretch; gap: var(--sp-3); max-height: none; overflow-y: visible; }
    .facet-group { align-items: flex-start; }
    .facet-group.is-collapsible > .facet-toggle[aria-expanded="true"] ~ .facet-group-values { max-height: none; overflow-y: visible; }

    .cat-tray-trigger {
        position: fixed;
        right: var(--sp-5);
        bottom: calc(var(--nav-mobile-h) + var(--sp-3));
        z-index: var(--z-nav);
        display: inline-flex;
        align-items: center;
        gap: var(--sp-2);
        min-height: var(--target-touch);
        min-width: var(--target-touch);
        padding: var(--sp-2) var(--sp-4);
        font-size: var(--fs-sm);
        font-weight: 600;
        color: var(--accent);
        background: var(--surface);
        border: 1px solid var(--accent);
        border-radius: var(--r-full);
        box-shadow: var(--shadow-md);
    }
    .cat-tray-trigger:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-ring-offset); }

    .cat-row-tags { display: none; }
}
@keyframes cat-sheet-in { from { opacity: 0; transform: translateY(var(--sp-6)); } to { opacity: 1; transform: translateY(0); } }

/* --------------------------------------------------------------------------
   Reduced motion (Req 15 AC 10). core.css already collapses every duration to
   0.01ms; this removes the animations and transitions outright instead, so
   nothing runs at all and every element presents its final state — which is
   its at-rest state here, by rule 5 in the header.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .cat-row,
    .cat-card,
    .cat-search,
    .facet,
    .facet-toggle,
    .facet-toggle::after,
    .seg > button,
    .prog-dot,
    .cat-save,
    .cat-done .prog-dot,
    .cat-clear,
    .empty-state,
    .facet-panel.is-tray { transition: none; animation: none; }
    .cat-card:hover,
    .cat-list:is(.is-comfortable:where(html:not([data-cat-density="compact"]) *), :where(html[data-cat-density="comfortable"] *)) .cat-row:hover { transform: none; }
}
