/* AI-assisted coding practice: /ai-coding/sandbox/ and /ai-coding/practice/.
 *
 * Both pages are layout:none app shells, so this file carries everything below
 * the site header.
 *
 * EVERY LENGTH HERE COMES FROM A TOKEN IN core.css -- --sp-* for spacing,
 * --r-* for radii, --fs-* for type, --shadow-* for elevation. The first draft
 * of this file hardcoded all of them in rem, which is why it read as a
 * different product bolted onto the site: the cards were a 12px radius beside
 * the site's 14px, the gaps landed between steps of the spacing scale, and the
 * type sat at sizes nothing else used. Matching the scale is most of what
 * "looks like SystemCraft" means.
 *
 * The sandbox is a three-column grid at desktop width and a tabbed single
 * column below 1100px. That breakpoint is not a guess: the panels are a file
 * tree plus brief (272px), an editor that needs ~560px before Monaco starts
 * wrapping signatures, and a chat panel unusable under 280px. Below the sum of
 * those they stop being panels and start being slivers, so they become tabs.
 */

/* ---------- shell ---------- */
.aic-body { margin: 0; }

/* The page measure. Carried by a wrapper the SCRIPT emits rather than by
 * <main>, because the same <main> holds both the padded setup/report screens
 * and the full-bleed three-panel session. */
/* --measure and sp-5 of side padding, exactly as .header-inner in core.css,
 * which is deliberate there: matching both values is what makes the h1 share a
 * left edge with the logo. This was 1180px with sp-4, so /ai-coding/ sat in a
 * narrower column than every other hub on the site and read as a different
 * template -- the cards stopped 260px short of where the sibling hubs' cards
 * end, while the header above them still spanned the window. */
.aic-main { max-width: var(--measure); margin: 0 auto; padding: var(--sp-5) var(--sp-5) var(--sp-7); }
.aic-noscript { padding: var(--sp-6); text-align: center; color: var(--text-muted); }

/* ---------- type ---------- */
.aic-h1 { font-size: var(--fs-2xl); font-weight: 750; letter-spacing: -0.02em; line-height: 1.15; margin: 0 0 var(--sp-2); color: var(--text); }
.aic-lede { font-size: var(--fs-base); color: var(--text-muted); line-height: 1.65; max-width: 68ch; margin: 0; }
.aic-h2 { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -0.01em; margin: 0 0 var(--sp-3); color: var(--text); }
.aic-kicker { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }

/* The page header as a card, the way every other hub on the site opens --
 * mirroring .course-hero and .course-eyebrow in course.css, which /agentic-ai/
 * and /ai-engineer/ use. The values are repeated rather than the classes
 * reused because those are scoped under `.content`, and this page has no
 * layout and therefore no .content wrapper; if the hero is restyled there,
 * restyle it here too.
 *
 * Without this the page opened with a bare kicker and h1 floating above a row
 * of bordered cards, which is why it read as a different template. */
.aic-hero {
  padding: var(--sp-6); margin-bottom: var(--sp-5);
  border: 1px solid var(--border-accent); border-radius: var(--r-xl);
  background: radial-gradient(ellipse 60% 90% at 100% 0%, var(--accent-subtle), transparent 70%), var(--surface);
  box-shadow: var(--shadow-md);
}
.aic-hero .aic-h1 { font-size: var(--fs-3xl); line-height: 1.1; }
.aic-hero .aic-lede { max-width: 64ch; font-size: var(--fs-md); }
/* The kicker becomes a pill inside the hero, as .course-eyebrow is.
 * align-self because .aic-setup-head is a flex column: inline-block does not
 * stop a flex item stretching on the cross axis, so the pill ran the full
 * width of the card. */
.aic-hero .aic-kicker {
  display: inline-block; align-self: flex-start; margin-bottom: var(--sp-2);
  padding: 0.2rem 0.7rem; font-weight: 800;
  background: var(--accent-subtle); border: 1px solid var(--border-accent);
  border-radius: var(--r-full);
}
.aic-hero .aic-back { margin-bottom: var(--sp-3); }
@media (max-width: 760px) {
  .aic-hero { padding: var(--sp-5); }
  .aic-hero .aic-h1 { font-size: var(--fs-2xl); }
}

/* ---------- buttons ---------- */
.aic-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  border: 1px solid var(--glass-border); background: var(--glass); color: var(--text);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; text-decoration: none;
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}
/* text-decoration: none above is load-bearing. Three of these are <a>, and
 * without it they rendered as underlined links sitting beside real buttons. */
.aic-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-subtle); }
.aic-btn:active:not(:disabled) { transform: translateY(1px); }
.aic-btn:disabled { opacity: 0.4; cursor: not-allowed; }
/* --accent-contrast, NOT #fff. The accent flips between themes -- #a5b4fc, a
 * light lavender, in dark mode and #4c55c7, a deep indigo, in light mode -- so
 * a hardcoded white label is white-on-lavender in the theme most readers use.
 * --accent-contrast exists for exactly this and flips with it: dark navy on
 * the light fill, white on the dark one. This was measured on a screenshot,
 * not guessed; the buttons were visibly washed out. */
.aic-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); box-shadow: var(--shadow-sm); }
.aic-btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-contrast); }
.aic-btn-lg { font-size: var(--fs-base); padding: var(--sp-3) var(--sp-5); border-radius: var(--r-md); }

.aic-chip {
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  padding: var(--sp-0) var(--sp-2); border-radius: var(--r-xs); border: 1px solid var(--glass-border);
  color: var(--text-dim); white-space: nowrap;
}
.aic-chip-easy { color: var(--easy); border-color: color-mix(in srgb, var(--easy) 38%, transparent); background: color-mix(in srgb, var(--easy) 8%, transparent); }
.aic-chip-medium { color: var(--medium); border-color: color-mix(in srgb, var(--medium) 38%, transparent); background: color-mix(in srgb, var(--medium) 8%, transparent); }
.aic-chip-hard { color: var(--hard); border-color: color-mix(in srgb, var(--hard) 38%, transparent); background: color-mix(in srgb, var(--hard) 8%, transparent); }

/* ---------- setup ----------
 * One gap value owns the vertical rhythm. The first draft set a flex gap AND a
 * margin under the lede AND a top margin on every h2, so the three compounded
 * into roughly 100px of dead space under the intro. */
.aic-setup { display: flex; flex-direction: column; gap: var(--sp-5); }
.aic-setup-head { display: flex; flex-direction: column; gap: var(--sp-2); }
.aic-section { display: flex; flex-direction: column; gap: var(--sp-3); }

/* 400px, not 290px. There are six problems, and at the full measure a 290px
 * minimum fits four per row, so they landed 4 + 2 with a conspicuous hole.
 * 400px gives three and three. min(100%, ...) keeps a single card from
 * overflowing a narrow viewport. */
.aic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 400px), 1fr)); gap: var(--sp-3); }

/* ---------- the pick bar ----------
 * The difficulty filter and the shuffle, above the problem grid. Added when
 * the bank went from six problems to twenty: six fitted on one screen, twenty
 * are two and a half scrolls of cards that differ mainly in how long they
 * take, which is the chip the filter is on.
 *
 * Not the catalog's filter rig (assets/css/catalog.css). That one carries a
 * search box, four facet dropdowns, sort, density and a progress read-out
 * against a URL-synced state machine, and it is sized for a 390-row list. Two
 * controls over twenty cards want two controls. */
/* --aic-ctl-h is shared by the filter track and the sort select, because each
 * would otherwise derive its own height from its padding and border and the
 * two would sit a few pixels apart -- the ragged-toolbar defect judge.css
 * records and fixes the same way. */
.aic-pickbar { --aic-ctl-h: 34px; display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }

/* One bordered track with the buttons inside it, rather than four separate
 * pills: the group is a single choice, and a row of identical loose pills does
 * not say that the four are alternatives. */
.aic-seg {
  display: flex; gap: var(--sp-0); padding: var(--sp-0);
  border: 1px solid var(--glass-border); border-radius: var(--r-md); background: var(--glass);
}
.aic-seg-btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted);
  padding: var(--sp-1) var(--sp-3); border: 0; border-radius: var(--r-sm);
  background: transparent; cursor: pointer; white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.aic-seg-btn:hover { color: var(--text); background: var(--accent-subtle); }
.aic-seg-btn[aria-pressed="true"] { color: var(--text); background: var(--accent-subtle); box-shadow: inset 0 0 0 1px var(--border-accent); }
.aic-seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* The count. Tabular so the four buttons do not jiggle as they are pressed,
 * and dimmed because it is the second thing read, not the first. */
.aic-seg-n { font-size: var(--fs-xs); font-weight: 700; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.aic-seg-btn[aria-pressed="true"] .aic-seg-n { color: var(--accent); }

/* The sort control and the shuffle form the right-hand cluster, so the auto
 * margin sits on the first of the two rather than on the button. */
.aic-sort { display: inline-flex; align-items: center; gap: var(--sp-2); margin-left: auto; }
.aic-sort-label { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); }
/* box-sizing on both, so the border sits inside the shared height. */
.aic-seg { height: var(--aic-ctl-h); box-sizing: border-box; }
.aic-sort select {
  height: var(--aic-ctl-h); box-sizing: border-box;
  font: inherit; font-size: var(--fs-sm); color: var(--text);
  padding: 0 var(--sp-2); border: 1px solid var(--glass-border);
  border-radius: var(--r-sm); background: var(--glass); cursor: pointer;
  transition: border-color 0.15s;
}
.aic-sort select:hover { border-color: var(--accent); }
.aic-sort select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.aic-ic-shuffle { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.aic-pick-empty { grid-column: 1 / -1; margin: 0; padding: var(--sp-5); text-align: center; font-size: var(--fs-sm); color: var(--text-dim); border: 1px dashed var(--glass-border); border-radius: var(--r-lg); }

/* Below the measure the shuffle stops being a right-hand action and becomes
 * the row under the filter, full width, because `margin-left: auto` on a
 * wrapped flex line puts it alone and right-aligned, which reads as detached
 * from the control it belongs with. */
@media (max-width: 560px) {
  .aic-seg { width: 100%; }
  .aic-seg-btn { flex: 1; justify-content: center; }
  .aic-sort { margin-left: 0; width: 100%; }
  .aic-sort select { flex: 1; min-width: 0; }
  .aic-shuffle { width: 100%; }
}

.aic-card {
  display: flex; flex-direction: column; gap: var(--sp-2); text-align: left;
  padding: var(--sp-4); border: 1px solid var(--glass-border); border-radius: var(--r-lg);
  background: var(--glass); cursor: pointer; font: inherit; color: var(--text);
  transition: border-color 0.16s, transform 0.16s, box-shadow 0.16s;
}
.aic-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.aic-card:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
.aic-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: var(--ring-accent), var(--shadow-md); }
.aic-card-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.aic-card-title { font-size: var(--fs-md); font-weight: 700; letter-spacing: -0.01em; }
.aic-card-desc { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.6; }

/* options */
.aic-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--sp-4); }
.aic-opt { display: flex; flex-direction: column; gap: var(--sp-2); }
/* Scoped to the label class, NOT `.aic-opt > span`. That broader selector also
 * matched .aic-opt-note, so every explanatory sentence under a dropdown
 * rendered bold, tracked-out and in capitals. */
.aic-opt-label { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); }
.aic-opt select {
  font: inherit; font-size: var(--fs-sm); padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm); border: 1px solid var(--glass-border);
  background: var(--glass); color: var(--text); cursor: pointer;
}
.aic-opt-note { font-size: var(--fs-xs); color: var(--text-dim); line-height: 1.55; text-transform: none; letter-spacing: 0; font-weight: 400; }

.aic-start { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; padding-top: var(--sp-1); }

/* ---------- the stepped flow ----------
 * Added because the first version of this screen told nobody what to do: a
 * paragraph, six cards that looked like ordinary content cards, three
 * dropdowns, and a DISABLED primary button as the most prominent element on
 * the page. Numbering the two steps, making the cards look pressable, and
 * pinning the action is the whole fix. */

/* What a session looks like, shown before anyone commits to one. */
.aic-how { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--sp-3); padding: var(--sp-4); border: 1px solid var(--glass-border); border-radius: var(--r-lg); background: var(--glass); }
.aic-how-step { display: flex; gap: var(--sp-3); align-items: flex-start; }
.aic-how-step > div { display: flex; flex-direction: column; gap: var(--sp-0); min-width: 0; }
.aic-how-step strong { font-size: var(--fs-sm); color: var(--text); }
.aic-how-step span { font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.55; }
/* Outlined, not filled. The filled version (accent background, accent-contrast
 * digit) measured as unreadable in a screenshot at this size -- a 12px digit
 * inside a 22px disc reads as a blank dot. The outlined treatment is the same
 * one .aic-stepnum uses on the setup screen, where the numbers are crisp, so
 * this is now one style in two places rather than two styles. */
.aic-how-num {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: var(--r-full);
  display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 800;
  border: 1px solid var(--accent); color: var(--accent); background: var(--accent-subtle);
}

.aic-stephead { display: flex; flex-direction: column; gap: var(--sp-1); }
.aic-stephead-row { display: flex; align-items: center; gap: var(--sp-3); }
.aic-stephead-row .aic-h2 { margin: 0; }
.aic-stepnum {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: var(--r-full);
  display: grid; place-items: center; font-size: var(--fs-sm); font-weight: 800;
  border: 1px solid var(--accent); color: var(--accent); background: var(--accent-subtle);
}
.aic-stephint { font-size: var(--fs-sm); color: var(--text-dim); margin: 0; line-height: 1.55; }
/* The way out. Deliberately quiet — it sits above the page title and must not
 * compete with the pinned primary action, but a screen with no visible exit is
 * what sent people back through the browser's history instead. */
.aic-back {
  align-self: flex-start; display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-2); margin-left: calc(var(--sp-2) * -1);
  border: 0; border-radius: var(--r-sm); background: none; cursor: pointer;
  font-family: inherit; font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted);
  transition: color 0.16s, background 0.16s;
}
.aic-back:hover { color: var(--accent); background: var(--accent-subtle); }
.aic-back:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* A card you press, not a card you read. The footer row is the affordance the
 * original cards lacked entirely. */
.aic-card-pick { position: relative; }
.aic-card-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-top: auto; padding-top: var(--sp-2); font-size: var(--fs-xs); font-weight: 700; color: var(--accent); letter-spacing: 0.02em; }
.aic-card-arrow { transition: transform 0.16s; }
.aic-card-pick:hover .aic-card-arrow { transform: translateX(3px); }
.aic-card-pick.is-chosen { border-color: var(--accent); background: var(--accent-subtle); box-shadow: var(--ring-accent), var(--shadow-md); }
.aic-card-pick:disabled { opacity: 0.5; cursor: not-allowed; }
.aic-card-pick:disabled:hover { border-color: var(--glass-border); transform: none; }

/* Step 2, "where do you want to work". Two cards only, and each carries a
 * short list, so they want to be wider than the six problem cards rather than
 * sharing their auto-fill track. */
.aic-grid-modes { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.aic-mode-points { list-style: none; margin: var(--sp-1) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.aic-mode-points li {
  position: relative; padding-left: var(--sp-4);
  font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.55;
}
.aic-mode-points li::before {
  content: ''; position: absolute; left: 6px; top: 0.52em;
  width: 5px; height: 5px; border-radius: var(--r-full); background: var(--accent);
}
.aic-mode-shape { font-size: var(--fs-xs); color: var(--text-dim); font-style: italic; margin-top: var(--sp-1); }

/* The written material below the app on /ai-coding/. The app page has no
 * layout, so the prose styling the default layout would have supplied has to
 * be declared here. */
/* The site's three floating controls, during a session only. They are
 * fixed-position and sit outside #aic-content, so hiding the written material
 * leaves them over the editor -- and the feedback trigger and SensAI toggle
 * land in the bottom corners, the right one directly on the chat composer. */
.aic-in-session #back-to-top,
.aic-in-session #fb-trigger,
.aic-in-session #sensei-toggle { display: none !important; }

/* Only the spacing that separates the written half of /ai-coding/ from the app
 * above it. The typography used to be redeclared here -- h2, p, ul, li, strong
 * and hr -- which is why that half read as a different template and why the
 * footer inherited prose rules. It carries the site's own `.content` class
 * now, so content.css supplies all of it. */
.aic-longform { padding-top: var(--sp-6); }

.aic-resume { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; border-color: color-mix(in srgb, var(--medium) 40%, transparent); }

/* The pinned action bar. Fixed to the viewport so the one thing you do next is
 * never below the fold, which is exactly what went wrong before. */
.aic-actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--bg); border-top: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg); padding: var(--sp-3) var(--sp-4);
  padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom, 0px));
}
.aic-actionbar-in { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: var(--sp-4); }
.aic-actionbar-sum { display: flex; flex-direction: column; gap: var(--sp-0); min-width: 0; margin-right: auto; }
.aic-actionbar-sum strong { font-size: var(--fs-md); color: var(--text); letter-spacing: -0.01em; }
.aic-actionbar-sum span { font-size: var(--fs-xs); color: var(--text-muted); }
/* Clears the fixed bar so it never covers the last control. */
.aic-main.has-actionbar { padding-bottom: calc(var(--sp-8) + var(--sp-5)); }
@media (max-width: 560px) {
  .aic-actionbar-in { flex-direction: column; align-items: stretch; gap: var(--sp-2); }
  .aic-actionbar-sum { margin-right: 0; }
}

.aic-note {
  font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.65;
  padding: var(--sp-3) var(--sp-4); border: 1px solid var(--glass-border);
  border-radius: var(--r-md); background: var(--glass);
}
.aic-note strong { color: var(--text); }
.aic-note a { color: var(--accent); }
.aic-err { border-color: color-mix(in srgb, var(--hard) 45%, transparent); }

/* ---------- session shell ----------
 * dvh as well as vh, the way simulator.css does it: on mobile Safari and
 * Chrome 100vh is the viewport with the URL bar hidden, so the Run button and
 * the results sat below the fold until you scrolled. vh stays first as the
 * fallback for browsers that do not know dvh. */
.aic-shell {
  display: flex; flex-direction: column; min-height: 520px;
  height: calc(100vh - var(--header-h));
  height: calc(100dvh - var(--header-h));
  height: calc(100dvh - var(--header-h));
}

/* The shell measured its own height by subtracting a hardcoded header, which
 * is wrong whenever anything else sits above it. On the beta site the env
 * banner does, so the shell was sized as though it started at the top of the
 * viewport while actually starting ~87px down: it overflowed by the banner's
 * height, the document scrolled, and the top bar or the run bar ended up cut
 * off depending on where you had scrolled to. Scrolling the page is exactly
 * wrong here, because every panel inside already scrolls on its own.
 *
 * So the shell no longer measures anything. The body is a flex column and the
 * shell takes what is left, whatever is above it -- banner, header, or
 * something added later. :has() scopes this to the sandbox: /ai-coding/
 * practice/ shares .aic-body and wants ordinary document scrolling. */
/* `height`, not `min-height`. A flex container whose height is auto sizes to
 * its content, and min-height only sets a floor -- so `flex: 1` on the main
 * element had no definite space to resolve against and simply took its content
 * height, which meant nothing below it could shrink and a long phase brief
 * pushed the whole document 405px past the viewport. A definite height is what
 * gives the flex distribution something to divide, which is what finally lets
 * the three panels scroll inside themselves.
 *
 * overflow: hidden is the backstop. This is an app shell pinned to the
 * viewport; if some future child does force itself larger, it should be that
 * panel's own scrollbar that appears, never the page's. */
/* Desktop only, matching the 1100px breakpoint below. Under it the layout
 * deliberately stacks into one column and becomes a document you scroll, so
 * pinning the body to the viewport there would make the bottom of the stack
 * unreachable rather than tidy. */
@media (min-width: 1101px) {
  .aic-body:has(.aic-shell) {
    display: flex; flex-direction: column;
    height: 100vh; height: 100dvh;
    overflow: hidden;
  }
  .aic-body:has(.aic-shell) > main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
  .aic-body:has(.aic-shell) > main > #aic-app { flex: 1; display: flex; flex-direction: column; min-height: 0; }
  .aic-body:has(.aic-shell) .aic-shell { flex: 1; height: auto; min-height: 0; }
}

.aic-bar {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-4); border-bottom: 1px solid var(--glass-border);
  background: var(--glass); flex-shrink: 0;
}
.aic-bar-title { font-size: var(--fs-sm); font-weight: 700; letter-spacing: -0.01em; }
/* The phase tabs used to be pushed to the far right by the title's auto
 * margin, so on a wide window they sat next to the timer with a third of the
 * bar empty between them and the problem they belong to. The gap goes before
 * the timer instead, which keeps the clock and Finish button right-aligned and
 * puts "which phase am I on" beside the title. */
.aic-timer { font-variant-numeric: tabular-nums; font-size: var(--fs-sm); font-weight: 700; color: var(--text); font-family: var(--font-mono); margin-left: auto; }
.aic-timer-low { color: var(--hard); }

.aic-phases { display: flex; gap: var(--sp-1); }
.aic-phase {
  font: inherit; font-size: var(--fs-xs); font-weight: 600; padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-xs); border: 1px solid transparent; background: transparent;
  color: var(--text-dim); cursor: pointer; white-space: nowrap;
}
.aic-phase:hover { color: var(--text); }
.aic-phase[aria-current="true"] { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.aic-phase-ok { color: var(--easy); }

/* ---------- the walkthrough ---------- */

/* Three fixed layers, replacing the first-run strip that used to sit between
 * the bar and the panels. The strip was readable exactly once and took its
 * height off the editor permanently; these cost the layout nothing, because
 * they are out of flow and removed on exit.
 *
 * z-index sits above the session's own furniture (the highest in here is 40)
 * and deliberately BELOW the site's modals at 9999+ -- the donate dialog must
 * still be able to cover a walkthrough, not the other way round. */

/* Swallows clicks so a step cannot be answered by poking the thing behind it.
 * Transparent: the dimming is the ring's shadow, which is what gives the hole
 * in it crisp edges. */
.aic-tour-veil { position: fixed; inset: 0; z-index: var(--z-modal); background: transparent; }

/* The hole. One element: a giant spread shadow dims the entire viewport
 * except the ring's own box, so there is no four-panel geometry to get wrong
 * and nothing to keep in sync when the target moves. */
.aic-tour-ring {
  position: fixed; z-index: var(--z-coach); pointer-events: none;
  border-radius: var(--r-md);
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 9999px color-mix(in srgb, #000 62%, transparent);
  transition: top 160ms ease, left 160ms ease, width 160ms ease, height 160ms ease;
}

.aic-tour-card {
  position: fixed; z-index: var(--z-coach-fg); width: min(340px, calc(100vw - 16px));
  background: var(--panel); border: 1px solid var(--border-accent);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: var(--sp-4);
}
.aic-tour-title { font-size: var(--fs-sm); font-weight: 700; color: var(--text); margin: 0 0 var(--sp-2); }
.aic-tour-body { font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.6; margin: 0 0 var(--sp-4); }
.aic-tour-foot { display: flex; align-items: center; gap: var(--sp-2); }
/* The counter takes the slack, so Back and Next stay at the right edge and do
 * not shuffle sideways as the step copy changes length. */
.aic-tour-count { font-size: var(--fs-xs); color: var(--text-muted); margin-right: auto; }
.aic-tour-skip { color: var(--text-muted); }

/* Honour a reduced-motion preference: the ring sliding between targets is
 * decoration, and the step change is legible without it. */
@media (prefers-reduced-motion: reduce) { .aic-tour-ring { transition: none; } }

/* The rails grow with the window instead of staying at a fixed pixel width.
 * They were 272px and 340px whatever the screen, so on a 1800px window the
 * editor took 1187px of it -- two thirds of the layout for a file you mostly
 * read -- while the brief, which is the panel that tells you what the task
 * actually is, wrapped into a 239px ribbon. The clamp keeps the old widths as
 * the floor on a laptop and lets both rails widen on a large display, with a
 * cap so the editor never becomes the narrow one. */
/* BOTH INTERNAL EDGES ARE DRAGGABLE, and the clamps below are now the default
 * rather than the only option. Which panel needs the room changes minute to
 * minute inside one session -- the brief and the file tree while you read a
 * codebase you did not write, the editor while you type the fix, the chat
 * while you brief the assistant on a signature and read a long reply back --
 * and none of that could be traded before.
 *
 * A dragged width arrives as a pixel value on --aic-left-w / --aic-right-w,
 * and min() caps each rail at 40% of the grid whatever that value says. That
 * cap is what makes it safe to persist pixels: the JS clamp only runs during a
 * drag, so a layout dragged out on a 27-inch monitor would otherwise squeeze
 * the editor to nothing when the same browser opens on a laptop. */
.aic-cols {
  --aic-left-def: clamp(272px, 19%, 380px);
  --aic-right-def: clamp(340px, 23%, 460px);
  display: grid;
  grid-template-columns:
    min(var(--aic-left-w, var(--aic-left-def)), 40%)
    1px
    minmax(0, 1fr)
    1px
    min(var(--aic-right-w, var(--aic-right-def)), 40%);
  /* minmax(0, 1fr) and not the implicit `auto`. An implicit grid row is sized
   * to max-content, and `min-height: 0` on the items does not change that --
   * it governs the item inside the row, not the row itself. So on a short
   * window the row grew to fit the tallest column's natural height (the chat
   * log plus its composer), the shell grew with it, and the document scrolled
   * again even after the shell stopped measuring its own height. This is what
   * lets the three panels scroll internally, which is what they are built for. */
  grid-template-rows: minmax(0, 1fr);
  flex: 1; min-height: 0;
}
/* No border-right any more: the 1px divider track between the columns draws
 * that line now, and a column border as well put two lines side by side. */
.aic-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* The divider IS the line -- a 1px grid track -- and its hit area is a 9px
 * pseudo-element straddling it, because a 1px pointer target is not one. The
 * same arrangement as .aic-res-grip's negative margins, done with absolute
 * positioning here since a grid track cannot be overflowed by margins. */
.aic-vdiv {
  position: relative; z-index: 3;
  background: var(--glass-border); cursor: col-resize;
}
.aic-vdiv::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: -4px; right: -4px;
}
.aic-vdiv:hover, .aic-vdiv.is-dragging { background: var(--accent); }
/* A visible grab mark on hover, mirroring the results grip's pill so the two
 * resize affordances in the session look like one idea. */
.aic-vdiv::before {
  content: ''; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 3px; height: 26px; border-radius: var(--r-full); background: var(--accent);
  opacity: 0; transition: opacity 0.15s;
}
.aic-vdiv:hover::before, .aic-vdiv.is-dragging::before { opacity: 1; }
.aic-vdiv:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.aic-tabs { display: flex; gap: var(--sp-1); padding: var(--sp-2) var(--sp-2) 0; border-bottom: 1px solid var(--glass-border); flex-shrink: 0; }
.aic-tab {
  font: inherit; font-size: var(--fs-xs); font-weight: 600; padding: var(--sp-2);
  border: 0; border-bottom: 2px solid transparent; background: transparent;
  color: var(--text-dim); cursor: pointer;
}
.aic-tab:hover { color: var(--text); }
.aic-tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.aic-pane { flex: 1; overflow: auto; padding: var(--sp-4); min-height: 0; }
.aic-pane-flush { padding: var(--sp-1) 0; }

/* brief */
.aic-brief { display: flex; flex-direction: column; gap: var(--sp-2); }
.aic-brief h3 { font-size: var(--fs-sm); font-weight: 700; margin: 0; color: var(--text); }
.aic-brief h3 ~ h3 { margin-top: var(--sp-3); }
.aic-brief p { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.65; margin: 0; }
.aic-brief code { font-size: 0.72rem; font-family: var(--font-mono); background: color-mix(in srgb, var(--accent) 12%, transparent); padding: 1px var(--sp-1); border-radius: var(--r-xs); }
/* The stdin/stdout contract. Preformatted because the indentation is what
 * makes the input shape readable; it scrolls sideways rather than wrapping,
 * for the same reason. */
.aic-io {
  margin: 0; padding: var(--sp-2) var(--sp-3);
  font-family: var(--font-mono); font-size: 0.7rem; line-height: 1.6;
  color: var(--text-muted); background: var(--glass);
  border: 1px solid var(--glass-border); border-radius: var(--r-sm);
  /* pre-wrap, not pre: the rail is ~300px and the prose lines ("Input is a box
   * spec followed by the items:") are wider than that, so `pre` cut them off
   * and asked for a sideways scroll to read a sentence. The indented format
   * lines are short and keep their shape. overflow-x stays as the backstop for
   * a long unbroken token. */
  overflow-x: auto; white-space: pre-wrap;
}

/* ---------- file tree ---------- */

/* An explorer, not a list of filenames. The pane used to render a flat row
 * per file with no root and no folder, so a tree that genuinely CAN nest --
 * readTree in the generator recurses and joins with '/' -- would have shown
 * up as names with slashes in them. */
.aic-files { margin: 0; padding: var(--sp-2) var(--sp-2) var(--sp-3); display: flex; flex-direction: column; gap: 1px; }

/* Shared geometry for both row kinds, so a folder and a file sit on the same
 * rhythm and their icons share a left edge. */
.aic-dir,
.aic-file {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%; text-align: left;
  font: inherit; font-size: var(--fs-sm); font-family: var(--font-mono);
  padding: var(--sp-0) var(--sp-2); border-radius: var(--r-xs);
  border: 0; background: transparent; color: var(--text-muted); cursor: pointer;
}
.aic-dir { color: var(--text); font-weight: 600; }
.aic-dir:hover,
.aic-file:hover { background: var(--glass); color: var(--text); }
.aic-file[aria-current="true"] { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--text); }

/* Indentation comes only from nesting, so one constant margin covers every
 * depth. The border is the guide line, and it lands under the parent's
 * folder icon rather than its chevron. */
.aic-tree-group { margin-left: 13px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 1px; }

.aic-chev { width: 10px; height: 10px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0.6; transition: transform 120ms ease; }
.aic-chev-open { transform: rotate(90deg); }
.aic-ic { width: 14px; height: 14px; flex-shrink: 0; }
.aic-ic-dir { fill: currentColor; opacity: 0.55; }
.aic-ic-file { fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linejoin: round; stroke-linecap: round; opacity: 0.85; }

/* Tinted per extension, from the palette the site already has rather than a
 * new one, so both themes are covered without a second set of values. cpp
 * and hpp differ because those two are the pair that share a tree. */
.aic-file[data-ext="py"] .aic-ic-file { stroke: var(--info); }
.aic-file[data-ext="js"] .aic-ic-file { stroke: var(--medium); }
.aic-file[data-ext="java"] .aic-ic-file { stroke: var(--hard); }
.aic-file[data-ext="cpp"] .aic-ic-file { stroke: var(--accent); }
.aic-file[data-ext="hpp"] .aic-ic-file { stroke: var(--easy); }

.aic-dir-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aic-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The driver. Said here because this is where the candidate decides what to
 * open, rather than only in brief prose they have scrolled past. */
.aic-file-tag {
  flex-shrink: 0; font-family: var(--font-sans, inherit); font-size: 0.625rem;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: var(--r-full);
  padding: 0 var(--sp-1h); line-height: 1.5;
}
.aic-file-dot { width: 5px; height: 5px; border-radius: var(--r-full); background: var(--accent); flex-shrink: 0; opacity: 0; }
.aic-file-dirty .aic-file-dot { opacity: 1; }
.aic-file-dirty .aic-file-name { color: var(--text); }

/* editor */
.aic-editor-wrap { flex: 1; position: relative; min-height: 0; }
.aic-editor { position: absolute; inset: 0; }
.aic-editor-loading { position: absolute; inset: 0; display: grid; place-items: center; font-size: var(--fs-sm); color: var(--text-dim); }

.aic-run-bar { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-top: 1px solid var(--glass-border); flex-shrink: 0; }
.aic-run-status { font-size: var(--fs-xs); color: var(--text-dim); margin-left: auto; font-variant-numeric: tabular-nums; text-align: right; }

/* "Phase passed, here is the next one". Between the run bar and the results,
 * where the eye already is when the last test turns green — the tick on a tab
 * in the top bar and the counter in the run bar are both too passive and too
 * far away to read as "done".
 *
 * flex-shrink: 0 so it never squeezes the editor, and --easy rather than the
 * accent because this is the one place in the session that means "passed"
 * rather than "primary action". */
.aic-advance {
  display: flex; align-items: center; gap: var(--sp-3); flex-shrink: 0;
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid color-mix(in srgb, var(--easy) 40%, transparent);
  background: color-mix(in srgb, var(--easy) 10%, transparent);
}
.aic-advance-ic { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: var(--easy); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.aic-advance-text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.aic-advance-text strong { font-size: var(--fs-xs); color: var(--text); }
.aic-advance-text span { font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.5; }
.aic-advance-go { flex-shrink: 0; }
@media (max-width: 560px) {
  .aic-advance { flex-wrap: wrap; }
  .aic-advance-go { width: 100%; justify-content: center; }
}

/* ---------- the results pane ----------
 * The results were a bare scrolling box pinned under the editor at a third of
 * the column's height, with no header and nothing to press. The height was
 * permanent: on the narrow breakpoint, where the whole column is 68vh, it took
 * roughly 160px of editor for a box four rows tall, and the one thing a
 * candidate most wants to read -- a failing diff with eight lines of input in
 * it -- had to be scrolled inside it.
 *
 * Height is a custom property, not an inline max-height, for the reason
 * judge.css records: the drag handler and the collapse toggle then write one
 * variable instead of fighting over a property that outranks the stylesheet
 * and cannot be undone. Shrink-wrapped when shut rather than clamped to a
 * fixed height, because the same file records that a fixed 36px clipped the
 * labels it was meant to leave visible.
 *
 * A CAP BY DEFAULT, A HEIGHT ONLY ONCE DRAGGED. The third was always a
 * ceiling, never a floor: at the start of a phase the pane holds one line of
 * "run the tests to see where you stand", and a definite 36% would hand a
 * third of the editor to that line -- the same waste this change exists to
 * undo, just with a header on it. `is-sized` is added by the drag handler, so
 * a candidate who has stated a height gets exactly it and everyone else gets
 * content height. The min() keeps a height dragged out on a tall window from
 * burying the editor on a short one, which is the case the JS clamp cannot
 * see because it only runs during a drag. */
.aic-respane {
  --aic-res-h: 36%;
  display: flex; flex-direction: column; min-height: 0; flex-shrink: 0;
  max-height: min(var(--aic-res-h), 75%);
  border-top: 1px solid var(--glass-border);
  transition: height var(--dur) var(--ease);
}
.aic-respane.is-sized { height: min(var(--aic-res-h), 75%); }
/* After .is-sized, not before: same specificity, so source order is what
 * makes collapsing win over a dragged height. */
.aic-respane.is-collapsed { height: auto; }
.aic-respane.is-collapsed .aic-results { display: none; }
/* No transition mid-drag, or the pane lags a frame behind the pointer. */
.aic-respane:has(.aic-res-grip.is-dragging) { transition: none; }

/* The grip straddles the pane's top border: 10px tall, pulled up by half its
 * height, and the matching negative bottom margin keeps it out of the column's
 * height arithmetic entirely. */
.aic-res-grip {
  position: relative; z-index: 2; flex-shrink: 0;
  height: 10px; margin: -5px 0; cursor: row-resize;
}
.aic-res-grip::after {
  content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 26px; height: 3px; border-radius: var(--r-full); background: var(--accent);
  opacity: 0; transition: opacity 0.15s;
}
.aic-res-grip:hover::after, .aic-res-grip.is-dragging::after { opacity: 1; }
.aic-res-grip:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
/* Held on the body so the cursor and the selection lock apply over the editor
 * and the chat panel too, not only over the 10px strip the pointer left. One
 * selection lock, two cursors: the axis modifier is what the row grip and the
 * column dividers disagree about, and nothing else. */
.aic-resizing, .aic-resizing * { user-select: none !important; }
.aic-resizing-y, .aic-resizing-y * { cursor: row-resize !important; }
.aic-resizing-x, .aic-resizing-x * { cursor: col-resize !important; }

/* The whole strip is the toggle, not a chevron at one end of it: the action is
 * "open the results", and a 10px glyph is a worse target for that than the row
 * it sits in. */
.aic-res-head {
  display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; width: 100%;
  padding: var(--sp-2) var(--sp-3); border: 0; background: var(--bg-subtle);
  font: inherit; text-align: left; color: var(--text-dim); cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.aic-res-head:hover { color: var(--text); background: var(--accent-subtle); }
.aic-res-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.aic-res-title { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
/* Tabular so a streaming run does not shuffle the row as the counts climb. */
.aic-res-tally { margin-left: auto; font-size: var(--fs-xs); color: var(--text-dim); font-variant-numeric: tabular-nums; }
.aic-res-head:hover .aic-res-tally { color: var(--text-muted); }
/* The chevron is drawn open and CSS shuts it, so the toggle handler changes
 * one class on the pane and nothing has to reach into the SVG. */
.aic-respane.is-collapsed .aic-chev-open { transform: none; }

.aic-results { flex: 1; min-height: 0; overflow: auto; }
.aic-result { display: flex; align-items: flex-start; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); border-bottom: 1px solid color-mix(in srgb, var(--glass-border) 50%, transparent); }
.aic-result:last-child { border-bottom: 0; }
.aic-result-mark { flex-shrink: 0; font-weight: 700; width: 1rem; text-align: center; }
.aic-result-pass .aic-result-mark { color: var(--easy); }
.aic-result-fail .aic-result-mark { color: var(--hard); }
.aic-result-name { color: var(--text); }
.aic-result-note { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.aic-result-note .aic-result-name { color: var(--text-dim); }
.aic-result-diff { margin: var(--sp-1) 0 0; font-size: 0.72rem; color: var(--text-dim); white-space: pre-wrap; word-break: break-word; font-family: var(--font-mono); line-height: 1.5; }

/* ---------- chat ----------
 * flex-shrink: 0 on the header, the persona note and the composer, and
 * min-height: 0 on everything between them. The column is one of three in a
 * shell that must not scroll the document (see the note on .aic-cols), so the
 * log is the only part allowed to grow, and it grows by scrolling itself.
 * Giving any of the furniture around it a height in vh, or dropping a
 * min-height: 0, puts the page scrollbar back. */

/* Panel header: the speaker, how many prompts have gone in, and how hobbled
 * the assistant is. The mode used to be readable only by reading the whole
 * paragraph underneath, which is the one thing a candidate re-checks mid
 * session. */
.aic-chat-head {
  display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--glass-border);
  background: linear-gradient(to bottom, var(--accent-subtle), transparent);
}
.aic-chat-av {
  display: grid; place-items: center; flex-shrink: 0; width: 24px; height: 24px;
  border-radius: var(--r-sm); background: var(--accent-subtle);
  border: 1px solid var(--border-accent);
}
.aic-chat-av-ic { width: 13px; height: 13px; fill: var(--accent); }
.aic-chat-who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.aic-chat-who strong { font-size: var(--fs-sm); color: var(--text); line-height: 1.3; }
.aic-chat-tally { font-size: 0.6875rem; color: var(--text-dim); font-variant-numeric: tabular-nums; line-height: 1.3; }
.aic-chat-mode {
  flex-shrink: 0; font-size: 0.625rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: var(--sp-0) var(--sp-2); border-radius: var(--r-full);
  border: 1px solid var(--glass-border); color: var(--text-dim);
}
/* The constrained persona is the one that behaves unlike a normal assistant,
 * so it is the one that gets a colour. --medium is "mind this", which is what
 * it means here; full strength is the unremarkable default and stays neutral. */
.aic-chat-mode-realistic {
  color: var(--medium);
  border-color: color-mix(in srgb, var(--medium) 40%, transparent);
  background: color-mix(in srgb, var(--medium) 12%, transparent);
}

.aic-chat { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.aic-chat-log { flex: 1; overflow: auto; padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-3); min-height: 0; }

/* A message is an avatar in a fixed gutter and a column beside it, so every
 * role label and every line of body text in the thread shares a left edge. */
.aic-msg { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: var(--sp-2); font-size: var(--fs-sm); line-height: 1.65; }
.aic-msg-av {
  display: grid; place-items: center; width: 22px; height: 22px; margin-top: 1px;
  border-radius: var(--r-xs); border: 1px solid var(--glass-border);
  background: var(--glass); flex-shrink: 0;
}
.aic-msg-av-ic { width: 12px; height: 12px; }
.aic-msg-assistant .aic-msg-av { background: var(--accent-subtle); border-color: var(--border-accent); }
.aic-msg-assistant .aic-msg-av-ic { fill: var(--accent); }
.aic-msg-candidate .aic-msg-av-ic { fill: none; stroke: var(--text-dim); stroke-width: 1.4; stroke-linecap: round; }
.aic-msg-main { min-width: 0; }
.aic-msg-role { font-size: 0.625rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-dim); display: block; margin-bottom: 3px; }

/* Both sides get a surface now. The candidate's prompt had an accent wash and
 * the reply had nothing, so a long reply ran into the next prompt with only a
 * small uppercase label between them. Same gutter, different fill: the prompt
 * is tinted because it is the thing being graded, the reply is a plain card. */
.aic-msg-body {
  color: var(--text-muted); white-space: pre-wrap; word-break: break-word;
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm);
  border: 1px solid var(--glass-border); background: var(--glass);
}
.aic-msg-candidate .aic-msg-body {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-color: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--text);
}
/* --bg, not --glass: the card the block sits in is already --glass, and a code
 * fence the same colour as its container has no edges. */
.aic-msg-body pre { background: var(--bg); border: 1px solid var(--glass-border); border-radius: var(--r-sm); padding: var(--sp-2) var(--sp-3); overflow-x: auto; font-size: 0.72rem; font-family: var(--font-mono); margin: var(--sp-2) 0; white-space: pre; line-height: 1.55; }
.aic-msg-body pre:first-child { margin-top: 0; }
.aic-msg-body pre:last-child { margin-bottom: 0; }
/* assets/js/md-render.js turns every newline into <br>, then collapses the
 * breaks between CONSECUTIVE list items and around headings -- but not the
 * ones where a block meets a paragraph. So a fenced block arrived wrapped in
 * <br><br> on each side and added its own margin on top, and a bullet list
 * arrived with two blank lines between it and the sentence introducing it.
 * Both blocks already carry their own spacing, so the breaks beside them are
 * pure dead height: roughly four blank lines around every code block the
 * assistant sent, in the narrowest column on the page.
 *
 * Dropped here rather than in the renderer because four other surfaces share
 * it and the blank-line-between-paragraphs convention is theirs to keep.
 *
 * :has() is the only way to reach a break that PRECEDES an element -- there is
 * no previous-sibling combinator. Where it is unsupported none of these rules
 * applies and the spacing is exactly what it was before, so the fallback is
 * today's behaviour rather than a broken layout. */
.aic-msg-body br:has(+ pre),
.aic-msg-body br:has(+ br + pre),
.aic-msg-body br:has(+ .aic-li),
.aic-msg-body br:has(+ br + .aic-li) { display: none; }
.aic-msg-body pre + br,
.aic-msg-body pre + br + br,
.aic-msg-body .aic-li + br,
.aic-msg-body .aic-li + br + br { display: none; }
.aic-msg-body code { font-size: 0.74rem; font-family: var(--font-mono); }
.aic-msg-body > :first-child { margin-top: 0; }
/* The waiting bubble holds three dots and nothing else, so it should be the
 * size of the dots rather than a full-width empty card. */
.aic-msg-waiting .aic-msg-body { width: fit-content; padding: var(--sp-2) var(--sp-3); }

/* Reply on its way. The send button also says "Thinking", but that is at the
 * bottom of the panel and the eye is at the end of the thread. */
.aic-typing { display: inline-flex; align-items: center; gap: var(--sp-1); }
.aic-typing span {
  width: 5px; height: 5px; border-radius: var(--r-full); background: var(--accent);
  animation: aic-typing 1.1s ease-in-out infinite;
}
.aic-typing span:nth-child(2) { animation-delay: 0.16s; }
.aic-typing span:nth-child(3) { animation-delay: 0.32s; }
@keyframes aic-typing {
  0%, 70%, 100% { opacity: 0.25; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-3px); }
}

/* Empty state. It was a single gray paragraph telling the candidate to write a
 * better prompt without showing one, in the panel where they are least sure
 * what to type. The chips are shapes to edit, not prompts to send. */
.aic-chat-empty { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-2); padding: var(--sp-2) 0; }
.aic-chat-empty-ic { width: 20px; height: 20px; fill: var(--accent); opacity: 0.8; }
.aic-chat-empty-h { font-size: var(--fs-sm); color: var(--text); font-weight: 700; }
.aic-chat-empty-p { font-size: var(--fs-sm); color: var(--text-dim); line-height: 1.65; margin: 0; }
.aic-chat-empty-lbl {
  font-size: 0.625rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-dim); margin-top: var(--sp-2);
}
.aic-starters { display: flex; flex-direction: column; gap: var(--sp-2); width: 100%; }
.aic-starter {
  font: inherit; font-size: var(--fs-xs); line-height: 1.5; text-align: left; cursor: pointer;
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm);
  border: 1px dashed var(--glass-border); background: transparent; color: var(--text-muted);
  transition: border-color var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
}
.aic-starter:hover { border-style: solid; border-color: var(--accent); background: var(--accent-subtle); color: var(--text); }

/* Composer. Textarea and actions sit inside one bordered shell so it reads as
 * a single control, and the shell takes the focus ring on behalf of the
 * textarea, which has none of its own. */
.aic-chat-form { display: flex; flex-direction: column; padding: var(--sp-3); border-top: 1px solid var(--glass-border); flex-shrink: 0; }
.aic-chat-box {
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-2); border-radius: var(--r-md);
  border: 1px solid var(--glass-border); background: var(--glass);
  transition: border-color var(--dur-fast);
}
.aic-chat-box:focus-within { border-color: var(--accent); }
.aic-chat-form textarea {
  font: inherit; font-size: var(--fs-sm); resize: none; min-height: 2.6rem; max-height: 11rem;
  padding: var(--sp-0) var(--sp-1); border: 0; border-radius: 0;
  background: transparent; color: var(--text); line-height: 1.55; overflow-y: auto;
}
.aic-chat-form textarea:focus { outline: none; }
.aic-chat-form textarea::placeholder { color: var(--text-dim); }
.aic-chat-actions { display: flex; align-items: center; gap: var(--sp-2); }
.aic-chat-hint { font-size: 0.6875rem; color: var(--text-dim); font-family: var(--font-mono); }
.aic-send { margin-left: auto; padding: var(--sp-1) var(--sp-3); }
/* The label is the only thing swapped for "Thinking", so the button has to
 * hold a steady width or the composer twitches on every send. */
.aic-send-label { min-width: 4.1rem; text-align: center; }
.aic-send:disabled { opacity: 0.55; }

.aic-persona-note {
  font-size: var(--fs-xs); color: var(--text-dim); line-height: 1.55;
  padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--glass-border); flex-shrink: 0;
}

/* ---------- report ---------- */
.aic-report { display: flex; flex-direction: column; gap: var(--sp-5); }
/* A heading and the list under it are one section, so the heading has to sit
 * closer to its own list than to the section above. The flex gap applies
 * equally to both sides, which left every heading floating midway between the
 * two and grouped with neither; the negative margin spends part of the gap
 * below it to buy that back. */
.aic-report .aic-h2 { margin: 0 0 calc(var(--sp-4) - var(--sp-5)); }

/* The base banner. Shared: the open-ended session screen in
 * aicode-practice.js uses a bare .aic-verdict to show the running clock beside
 * the problem title. Anything that assumes a dial, a badge or a score out of
 * 100 belongs on .aic-verdict-hero below, not here. */
.aic-verdict {
  display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap;
  padding: var(--sp-4) var(--sp-5); border-radius: var(--r-lg); background: var(--glass);
  border: 1px solid var(--glass-border); border-left-width: 3px; box-shadow: var(--shadow-sm);
}
/* The verdict is the first thing read, so it carries the colour rather than
 * leaving the reader to infer it from a number. Reuses the difficulty tokens,
 * which are the site's existing good/middling/bad triple and are already
 * redefined for the light theme, so this needs no second palette. */
.aic-verdict-strong, .aic-verdict-hire { border-left-color: var(--easy); }
.aic-verdict-lean { border-left-color: var(--medium); }
.aic-verdict-no { border-left-color: var(--hard); }
.aic-verdict-strong .aic-score, .aic-verdict-hire .aic-score { color: var(--easy); }
.aic-verdict-lean .aic-score { color: var(--medium); }
.aic-verdict-no .aic-score { color: var(--hard); }
.aic-score { font-size: var(--fs-3xl); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.aic-verdict-label { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -0.01em; }
.aic-verdict-sub { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.55; }

/* ---- the report hero ----
 * --band is set once per verdict and every tinted surface in the hero reads
 * it, so the four bands need one declaration each rather than one per part. */
.aic-verdict-hero {
  --band: var(--accent);
  gap: var(--sp-5); padding: var(--sp-5);
  border-left-width: 1px;
  /* The wash fades out across the card so the colour lands behind the dial,
     where the verdict is, and not behind the sentence explaining it. */
  background:
    linear-gradient(105deg, color-mix(in srgb, var(--band) 13%, transparent), transparent 62%),
    var(--glass);
  border-color: color-mix(in srgb, var(--band) 28%, var(--glass-border));
}
.aic-verdict-hero.aic-verdict-strong, .aic-verdict-hero.aic-verdict-hire { --band: var(--easy); }
.aic-verdict-hero.aic-verdict-lean { --band: var(--medium); }
.aic-verdict-hero.aic-verdict-no { --band: var(--hard); }

/* The score as a ring: a conic-gradient swept to the --pct custom property
 * renderReport sets on the element.
 *
 * The gradient is on ::before and not on .aic-dial itself, because the hole
 * is cut with a mask and a mask applies to an element's descendants too -- so
 * masking .aic-dial would have cut the score out of the middle along with the
 * disc. On the pseudo-element it cuts only the ring, the card's own tinted
 * wash shows through the hole, and nothing has to guess what colour the
 * surface behind it is. */
.aic-dial { position: relative; flex-shrink: 0; width: 104px; height: 104px; display: grid; place-items: center; }
.aic-dial::before {
  content: ''; position: absolute; inset: 0; border-radius: var(--r-full);
  background: conic-gradient(
    var(--band) calc(var(--pct, 0) * 1%),
    color-mix(in srgb, var(--band) 18%, var(--border)) 0
  );
  -webkit-mask: radial-gradient(farthest-side, transparent 70%, #000 72%);
  mask: radial-gradient(farthest-side, transparent 70%, #000 72%);
}
.aic-dial-in {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
}
.aic-verdict-hero .aic-score { font-size: var(--fs-2xl); color: var(--band); letter-spacing: -0.03em; }
.aic-score-of { font-size: 0.625rem; font-weight: 700; letter-spacing: 0.06em; color: var(--text-dim); }

.aic-verdict-text { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; flex: 1; }
.aic-verdict-hero .aic-verdict-label { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xl); }
/* The dot repeats the band colour next to the words. The ring says the same
 * thing, but it is 104px away and the label is what gets read aloud. */
.aic-verdict-dot { width: 9px; height: 9px; border-radius: var(--r-full); background: var(--band); flex-shrink: 0; }
.aic-verdict-meta { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.aic-vmeta {
  font-size: var(--fs-xs); color: var(--text-muted);
  padding: var(--sp-0) var(--sp-2); border-radius: var(--r-full);
  border: 1px solid var(--glass-border); background: var(--bg-subtle);
  font-variant-numeric: tabular-nums;
}
/* Balanced is the one being aimed for; low and high are both "look at this",
 * not failures, so they take --medium rather than --hard. */
.aic-vmeta-balanced { color: var(--easy); border-color: color-mix(in srgb, var(--easy) 35%, transparent); background: color-mix(in srgb, var(--easy) 10%, transparent); }
.aic-vmeta-low, .aic-vmeta-high { color: var(--medium); border-color: color-mix(in srgb, var(--medium) 35%, transparent); background: color-mix(in srgb, var(--medium) 10%, transparent); }
@media (max-width: 560px) {
  .aic-verdict-hero { padding: var(--sp-4); gap: var(--sp-4); }
  .aic-dial { width: 84px; height: 84px; }
  .aic-dial-in { width: 66px; height: 66px; }
}

/* A count beside the heading, so "What to fix" says how much there is to fix
 * before the list is scrolled. */
.aic-h2-n {
  display: inline-block; margin-left: var(--sp-2); vertical-align: 2px;
  font-size: var(--fs-xs); font-weight: 700; color: var(--text-dim);
  padding: 1px var(--sp-2); border-radius: var(--r-full);
  border: 1px solid var(--glass-border); background: var(--bg-subtle);
  font-variant-numeric: tabular-nums;
}

.aic-dims { display: flex; flex-direction: column; gap: var(--sp-2); }
.aic-dim {
  padding: var(--sp-3) var(--sp-4); border: 1px solid var(--glass-border);
  border-radius: var(--r-md); background: var(--glass);
}
.aic-dim-unscored { opacity: 0.72; }
.aic-dim-unscored .aic-dim-score { color: var(--text-dim); }
.aic-dim-head { display: flex; align-items: center; gap: var(--sp-3); }
.aic-dim-name { font-size: var(--fs-sm); font-weight: 700; margin-right: auto; }
.aic-dim-score { font-size: var(--fs-xs); font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text-muted); flex-shrink: 0; min-width: 2rem; text-align: right; }

/* Four pips rather than a proportional bar. The bar drew (score - 1) / 3 of
 * its width, so a 1 out of 4 drew nothing and was indistinguishable from an
 * unscored dimension -- the two readings furthest apart in the whole report.
 * Four steps for a four-step rubric also lets the reader count instead of
 * estimating a length. */
.aic-pips { display: flex; gap: var(--sp-0); flex-shrink: 0; }
.aic-pip { width: 15px; height: 5px; border-radius: var(--r-full); background: var(--border); }
.aic-pip-on { background: var(--accent); }
.aic-pip-low { background: var(--hard); }
.aic-pip-mid { background: var(--medium); }
.aic-pip-ok { background: var(--easy); }

/* The quoted transcript line, separated from the grader's note directly
 * underneath it by a rule rather than by italics alone.
 *
 * No decorative quote glyph. A 1.5rem '\201C' absolutely positioned here had
 * nowhere to sit: the 2px rule is at the left edge and the text starts 16px
 * in, so the glyph landed in the gap between them and half a line high, which
 * read as a smudge rather than as punctuation. The rule and the italics
 * already say "quotation", and renderReport emits a <blockquote>, so a screen
 * reader is told too. */
.aic-dim-ev {
  margin: var(--sp-3) 0 var(--sp-2); padding: 0 0 0 var(--sp-3);
  font-size: var(--fs-sm); color: var(--text); font-style: italic; line-height: 1.6;
  border-left: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
}
.aic-dim-note { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.6; margin: 0; }

/* All three pair groups used the same accent rule, so a screen of feedback
 * gave no clue which half was praise and which was the fix list. The rule
 * carries the kind now; the headings still say it in words. */
.aic-pairs { display: flex; flex-direction: column; gap: var(--sp-2); }
.aic-pair {
  --kind: var(--accent);
  padding: var(--sp-3) var(--sp-4); border-left: 3px solid var(--kind);
  background: linear-gradient(to right, color-mix(in srgb, var(--kind) 7%, transparent), transparent 55%), var(--glass);
  border-radius: 0 var(--r-md) var(--r-md) 0;
}
.aic-pair-good { --kind: var(--easy); }
.aic-pair-fix { --kind: var(--medium); }
.aic-pair-prompt { --kind: var(--accent); }
.aic-pair strong { display: block; font-size: var(--fs-sm); margin-bottom: 2px; color: var(--text); }
.aic-pair span { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.6; }

.aic-tags { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.aic-tag { font-size: var(--fs-xs); padding: var(--sp-1) var(--sp-2); border-radius: var(--r-xs); background: var(--glass); border: 1px solid var(--glass-border); color: var(--text-muted); }

/* separate, not collapse. The table is the only part of the report that was
 * not on a card, and giving it one needs a radius -- but a collapsed table
 * does not clip its cells to the table's border-radius, and overflow: hidden
 * does not reliably clip a table either, so the tinted header squared off the
 * top corners. With border-spacing: 0 the cells still sit flush, the table's
 * own border takes the radius, and the two header cells round their outer
 * corners to match. */
.aic-phase-table {
  width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm);
  border: 1px solid var(--glass-border); border-radius: var(--r-md); background: var(--glass);
}
.aic-phase-table th, .aic-phase-table td { text-align: left; padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--glass-border); }
.aic-phase-table th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); font-weight: 700; background: var(--bg-subtle); }
.aic-phase-table th:first-child { border-top-left-radius: var(--r-md); }
.aic-phase-table th:last-child { border-top-right-radius: var(--r-md); }
.aic-phase-table tr:last-child td { border-bottom: 0; }
.aic-phase-table td:nth-child(2), .aic-phase-table td:nth-child(3) { font-variant-numeric: tabular-nums; }
/* Same green and amber as the pips, so a column of "4 of 4" and "1 of 4" is
 * not one undifferentiated column of numbers. */
.aic-phase-ok { color: var(--easy); font-weight: 700; }
.aic-phase-part { color: var(--medium); font-weight: 700; }
.aic-phase-skip td { color: var(--text-dim); }

/* ---------- open-ended submit ---------- */
.aic-submit { display: flex; flex-direction: column; gap: var(--sp-4); }
.aic-field { display: flex; flex-direction: column; gap: var(--sp-2); }
.aic-field > label { font-size: var(--fs-sm); font-weight: 700; color: var(--text); }
.aic-field-note { font-size: var(--fs-xs); color: var(--text-dim); line-height: 1.55; }
.aic-field textarea {
  font-family: var(--font-mono); font-size: var(--fs-xs); line-height: 1.6;
  min-height: 11rem; padding: var(--sp-3); border-radius: var(--r-md);
  border: 1px solid var(--glass-border); background: var(--glass); color: var(--text); resize: vertical;
}
.aic-count { font-size: var(--fs-xs); color: var(--text-dim); text-align: right; font-variant-numeric: tabular-nums; }
/* Footer of a field that has a dictate button (assets/js/voice-input.js): the
   mic on the left, the character count keeping its right edge. */
.aic-field-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.aic-field-foot .aic-count { margin-left: auto; }

.aic-steps { margin: 0; padding-left: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-2); }
.aic-steps li { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.65; }

.aic-spin { width: 13px; height: 13px; border: 2px solid var(--glass-border); border-top-color: var(--accent); border-radius: var(--r-full); animation: sc-spin 0.7s linear infinite; display: inline-block; vertical-align: -2px; }

@media (prefers-reduced-motion: reduce) {
  .aic-spin { animation-duration: 2s; }
  .aic-card:hover { transform: none; }
  .aic-btn:active:not(:disabled) { transform: none; }
  /* The dots stop bouncing but must stay visible: they are the only thing in
     the bubble, so animation: none on the element would leave it reading as an
     empty reply. Hold them at full opacity instead. */
  .aic-typing span { animation: none; opacity: 1; transform: none; }
}

/* ---------- narrow ---------- */
.aic-mobile-tabs { display: none; }
@media (max-width: 1100px) {
  .aic-shell { height: auto; }
  .aic-cols { grid-template-columns: 1fr; }
  .aic-col { border-bottom: 1px solid var(--glass-border); }
  /* One panel at a time below this width, so there is no edge between two of
   * them to drag. display: none takes the dividers out of the grid entirely
   * rather than leaving two 1px rows in the stack. */
  .aic-vdiv { display: none; }
  .aic-mobile-tabs { display: flex; gap: var(--sp-1); padding: var(--sp-2) var(--sp-3) 0; border-bottom: 1px solid var(--glass-border); }
  .aic-cols[data-mobile="brief"] .aic-col-editor,
  .aic-cols[data-mobile="brief"] .aic-col-chat,
  .aic-cols[data-mobile="editor"] .aic-col-brief,
  .aic-cols[data-mobile="editor"] .aic-col-chat,
  .aic-cols[data-mobile="chat"] .aic-col-brief,
  .aic-cols[data-mobile="chat"] .aic-col-editor { display: none; }
  .aic-col-editor { height: 68vh; }
  .aic-col-chat, .aic-col-brief { max-height: 68vh; }
}
@media (max-width: 560px) {
  .aic-main { padding: var(--sp-4) var(--sp-3) var(--sp-6); }
  .aic-grid { grid-template-columns: 1fr; }
  .aic-start .aic-btn { flex: 1 1 auto; }
}

/* Markdown emitted by model answers, rendered by assets/js/md-render.js.
   This surface previously rendered only bold and code, so a model's bullets
   and headings reached the page as raw "*" and "##" characters. */
.aic-li { display: block; padding-left: 0.9rem; text-indent: -0.7rem; margin: 0.15rem 0; }
.aic-li::before { content: "\2022\00a0"; color: var(--accent); }
.aic-h { display: block; margin: 0.45rem 0 0.15rem; color: var(--text); }
