/* ==========================================================================
   CareerTech house style - the poster design
   --------------------------------------------------------------------------
   The full design rules are in POSTER-DESIGN-GUIDE.md at the top of the repo.
   In short: pure black and white, four flat section colours, a big serif for
   headings, 2px black borders, square corners and hard black shadows.

   Everything is prefixed ct- so it can never collide with a host page.

     <body class="ct-page">   full-page tool  - styles bare elements too
     <div class="ct-root">    embedded block  - nothing leaks outside the div

   Contrast (WCAG AA needs 4.5:1 for body text) - keep this list up to date:
     white on cobalt  6.7    #E3E8FF on cobalt 5.5
     black on tomato  6.6    #2A0B03 on tomato 5.8
     black on sun    13.6    #4A3500 on sun    7.5
     black on mint   13.9    #11493A on mint   6.8
     black on white  21.0    #4D4D4D on white  8.5
     white on black  21.0    #B3B3B3 on black 10.4   (dark mode)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Fonts. Hosted here rather than loaded from Google, so the tools keep
      working on networks that block it and no visitor data leaves the
      server. All SIL Open Font Licence - see fonts/OFL.txt.
   -------------------------------------------------------------------------- */

@font-face { font-family: 'DM Serif Display'; src: url('fonts/dm-serif-display.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Atkinson Hyperlegible'; src: url('fonts/atkinson-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Atkinson Hyperlegible'; src: url('fonts/atkinson-400-italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Atkinson Hyperlegible'; src: url('fonts/atkinson-700.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'DM Mono'; src: url('fonts/dm-mono-latin.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }

/* --------------------------------------------------------------------------
   2. Colours.

   --ct-ink and --ct-paper are the two poster colours. They swap in dark mode.
   --ct-fg, --ct-soft, --ct-rule and --ct-bg are "whatever I'm sitting on":
   every coloured panel sets its own, so grey text stays readable on every
   colour. Components only read these.
   -------------------------------------------------------------------------- */

:root,
.ct-root {
  --ct-cobalt: #1F3BFF;
  --ct-tomato: #FF5533;
  --ct-sun:    #FFC83D;
  --ct-mint:   #8DE3C0;

  --ct-ink:        #000000;
  --ct-paper:      #FFFFFF;
  --ct-paper-soft: #4D4D4D;   /* muted text on paper, 8.5:1 */
  --ct-hover:      #F2F2F2;

  --ct-fg:   var(--ct-ink);
  --ct-soft: var(--ct-paper-soft);
  --ct-rule: var(--ct-ink);
  --ct-bg:   var(--ct-paper);

  --ct-serif: 'DM Serif Display', Georgia, serif;
  --ct-font:  'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ct-font-mono: 'DM Mono', ui-monospace, 'Cascadia Mono', Menlo, Consolas, monospace;

  --ct-edge:   2px solid var(--ct-ink);
  --ct-shadow: 4px 4px 0 var(--ct-ink);
  --ct-ease:   cubic-bezier(.2, .8, .2, 1);

  --ct-size-xs:  0.8125rem;  /* 13 */
  --ct-size-sm:  0.9375rem;  /* 15 */
  --ct-size-md:  1rem;       /* 16 - body */
  --ct-size-lg:  1.1875rem;  /* 19 */
  --ct-size-xl:  1.75rem;    /* 28 */
  --ct-size-2xl: 2.25rem;    /* 36 */
  --ct-size-3xl: 3rem;       /* 48 */

  --ct-sp-1:   4px;
  --ct-sp-2:   8px;
  --ct-sp-3:  12px;
  --ct-sp-4:  16px;
  --ct-sp-5:  20px;
  --ct-sp-6:  24px;
  --ct-sp-8:  32px;
  --ct-sp-10: 40px;
  --ct-sp-12: 48px;

  --ct-control-h: 44px;

  /* Square everything. These names are kept so older page styles still work. */
  --ct-radius-sm: 0; --ct-radius: 0; --ct-radius-lg: 0; --ct-radius-xl: 0; --ct-radius-full: 0;

  color-scheme: light;
}

/* Dark mode: the page flips to white on black. The coloured panels do not
   change - they are flat colour with black text in both themes - and they
   reset ink and paper, so white boxes sitting on them stay white.

   Dark is opt-in, never automatic: ct.js applies a saved choice before the
   page is painted. */
[data-ct-theme="dark"] {
  --ct-ink:        #FFFFFF;
  --ct-paper:      #000000;
  --ct-paper-soft: #B3B3B3;   /* 10.4:1 on black */
  --ct-hover:      #1F1F1F;
  color-scheme: dark;
}

/* The "sitting on" layer, re-declared wherever ink and paper might have
   changed, because a custom property that points at another one is worked
   out where it is declared, not where it is used. The --ct-text, --ct-line
   and friends are the old names, still read by some pages' own styles. */
:root, .ct-root, [data-ct-theme],
.ct-card, .ct-explain, .ct-modal__box, .ct-dialog, .ct-note--warning, .ct-note--danger, .ct-stage, .ct-tile--plain {
  --ct-fg:   var(--ct-ink);
  --ct-soft: var(--ct-paper-soft);
  --ct-rule: var(--ct-ink);
  --ct-bg:   var(--ct-paper);
}
:root, .ct-root, [data-ct-theme], .ct-panel,
.ct-card, .ct-explain, .ct-modal__box, .ct-dialog, .ct-note--warning, .ct-note--danger, .ct-stage, .ct-tile--plain {
  --ct-edge:   2px solid var(--ct-ink);
  --ct-shadow: 4px 4px 0 var(--ct-ink);

  --ct-page:      var(--ct-paper);
  --ct-surface:   var(--ct-paper);
  --ct-surface-2: var(--ct-hover);
  --ct-sunken:    var(--ct-hover);
  --ct-text:      var(--ct-fg);
  --ct-text-soft: var(--ct-soft);
  --ct-text-faint: var(--ct-soft);
  --ct-text-on-fill: var(--ct-paper);
  --ct-line:        var(--ct-rule);
  --ct-line-strong: var(--ct-ink);
  --ct-accent:      var(--ct-fg);
  --ct-accent-hover: var(--ct-fg);
  --ct-accent-text: var(--ct-fg);
  --ct-accent-tint: transparent;
  --ct-accent-line: var(--ct-rule);
  --ct-danger: var(--ct-fg); --ct-danger-text: var(--ct-fg); --ct-danger-tint: transparent; --ct-danger-line: var(--ct-rule);
  --ct-success: var(--ct-fg);
  --ct-focus: transparent;
  --ct-shadow-sm: none;
  --ct-shadow-md: var(--ct-shadow);
  --ct-shadow-lg: 8px 8px 0 var(--ct-ink);
}

/* The four section colours. Each sets what sits on it, and resets ink and
   paper so buttons, inputs and white boxes on it look the same in dark mode. */
.ct-p-1, .ct-p-2, .ct-p-3, .ct-p-4 { --ct-ink: #000000; --ct-paper: #FFFFFF; --ct-paper-soft: #4D4D4D; --ct-hover: #F2F2F2; }
.ct-p-1 { --ct-bg: var(--ct-cobalt); --ct-fg: #FFFFFF; --ct-soft: #E3E8FF; --ct-rule: rgba(255, 255, 255, .5); }
.ct-p-2 { --ct-bg: var(--ct-tomato); --ct-fg: #000000; --ct-soft: #2A0B03; --ct-rule: rgba(0, 0, 0, .6); }
.ct-p-3 { --ct-bg: var(--ct-sun);    --ct-fg: #000000; --ct-soft: #4A3500; --ct-rule: rgba(0, 0, 0, .45); }
.ct-p-4 { --ct-bg: var(--ct-mint);   --ct-fg: #000000; --ct-soft: #11493A; --ct-rule: rgba(0, 0, 0, .45); }

/* --------------------------------------------------------------------------
   3. Base. Bare elements are only styled inside .ct-page, so an embedded
      .ct-root block can never restyle its host.
   -------------------------------------------------------------------------- */

.ct-page,
.ct-root {
  font-family: var(--ct-font);
  font-size: var(--ct-size-md);
  line-height: 1.5;
  color: var(--ct-fg);
  -webkit-font-smoothing: antialiased;
}

.ct-page { margin: 0; background: var(--ct-paper); min-height: 100vh; }

.ct-page *, .ct-page *::before, .ct-page *::after,
.ct-root *, .ct-root *::before, .ct-root *::after { box-sizing: border-box; }

.ct-page [hidden], .ct-root [hidden] { display: none !important; }

/* :where() keeps this at zero weight, so any component class beats it. */
:where(.ct-page) :where(button, input, select, textarea) { font: inherit; color: inherit; }

.ct-page h1, .ct-page h2, .ct-page h3 {
  margin: 0 0 var(--ct-sp-3);
  font-family: var(--ct-serif);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.01em;
  overflow-wrap: break-word;
}
.ct-page h1 { font-size: clamp(36px, 3.4vw, 52px); line-height: 1; }
.ct-page h2 { font-size: var(--ct-size-xl); }
.ct-page h3 { font-size: 22px; }
.ct-page h4 { margin: 0 0 var(--ct-sp-2); font-size: var(--ct-size-md); font-weight: 700; }

.ct-page .ct-display,
.ct-root .ct-display {
  margin: 0 0 var(--ct-sp-5);
  font-family: var(--ct-serif);
  font-weight: 400;
  font-size: clamp(44px, 4.8vw, 84px);
  line-height: .95;
  letter-spacing: -0.015em;
}

.ct-page p { margin: 0 0 var(--ct-sp-4); }
.ct-page p:last-child { margin-bottom: 0; }

.ct-page a:not(.ct-btn),
.ct-root a:not(.ct-btn) { color: inherit; font-weight: 700; text-decoration-thickness: 2px; text-underline-offset: 3px; }

.ct-page code, .ct-root code,
.ct-page pre,  .ct-root pre { font-family: var(--ct-font-mono); font-size: 0.9em; }

.ct-page :focus-visible,
.ct-root :focus-visible { outline: 3px solid var(--ct-fg); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  .ct-page *, .ct-page *::before, .ct-page *::after,
  .ct-root *, .ct-root *::before, .ct-root *::after { animation: none !important; transition: none !important; }
}

/* --------------------------------------------------------------------------
   4. The frame: a top bar, then either a start screen or the app.
      The page itself never scrolls - only the inside of a panel does.
   -------------------------------------------------------------------------- */

.ct-frame { min-height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.ct-fixed { overflow: hidden; }
.ct-fixed .ct-frame { height: 100dvh; }

.ct-top {
  position: relative; z-index: 30;
  display: flex; align-items: center; gap: var(--ct-sp-4);
  padding: 12px 32px;
  color: var(--ct-ink);
  background: var(--ct-paper);
  border-bottom: var(--ct-edge);
}
.ct-page a.ct-brand, .ct-brand {
  font-family: var(--ct-serif); font-weight: 400; font-size: 26px; line-height: 1;
  color: var(--ct-ink); text-decoration: none; white-space: nowrap;
}
.ct-top__end { margin-left: auto; display: flex; align-items: center; gap: var(--ct-sp-3); }

/* The app: menu rail on the left, sliding panels on the right. */
.ct-app { min-height: 0; display: grid; grid-template-columns: 320px minmax(0, 1fr); }

.ct-rail {
  display: flex; flex-direction: column; gap: var(--ct-sp-6);
  padding: 28px 24px 24px 32px;
  overflow-x: hidden; overflow-y: auto;
  border-right: var(--ct-edge);
}
.ct-page .ct-name {
  margin: 0;
  font-family: var(--ct-serif); font-weight: 400;
  font-size: clamp(36px, 3.2vw, 50px); line-height: .98; letter-spacing: -0.01em;
  overflow-wrap: break-word;
}
.ct-page .ct-name.is-long { font-size: clamp(28px, 2.4vw, 36px); line-height: 1.05; }
.ct-page .ct-rail__lede { margin: 12px 0 0; color: var(--ct-soft); font-size: var(--ct-size-sm); }
.ct-rail__foot { margin-top: auto; display: flex; flex-direction: column; align-items: flex-start; gap: var(--ct-sp-2); font-size: 14px; }

/* The section menu. Each entry: a colour swatch, the name, and one key fact. */
.ct-sections { display: grid; margin: 0; padding: 0; list-style: none; border-top: var(--ct-edge); }
.ct-sections button {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); column-gap: 14px; align-items: center;
  width: 100%; padding: 14px 12px;
  text-align: left; color: var(--ct-ink); background: var(--ct-paper);
  border: 0; border-bottom: var(--ct-edge); cursor: pointer;
  transition: background-color .15s ease;
}
.ct-sections button::before { content: ''; grid-row: span 2; width: 20px; height: 20px; background: var(--sw, var(--ct-paper)); border: var(--ct-edge); }
.ct-sections button:hover { background: var(--ct-hover); }
.ct-sections button[aria-current="true"] { color: var(--ct-paper); background: var(--ct-ink); }
.ct-sections button[aria-current="true"]::before { border-color: var(--ct-paper); }
.ct-sections .ct-sections__name { font-weight: 700; font-size: 17px; }
.ct-sections .ct-sections__val  { font-size: 14px; color: var(--ct-paper-soft); }
.ct-sections button[aria-current="true"] .ct-sections__val { color: var(--ct-paper); opacity: .9; }
.ct-sections .ct-sw-1 { --sw: var(--ct-cobalt); }
.ct-sections .ct-sw-2 { --sw: var(--ct-tomato); }
.ct-sections .ct-sw-3 { --sw: var(--ct-sun); }
.ct-sections .ct-sw-4 { --sw: var(--ct-mint); }
.ct-only-phone { display: none !important; }

/* The deck: panels side by side, one in view, slide left and right. */
.ct-deck {
  --ct-preview-w: 0%;
  position: relative; min-width: 0; min-height: 0;
  display: flex;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.ct-deck::-webkit-scrollbar { display: none; }
.ct-deck--preview { --ct-preview-w: 46%; }

.ct-panel {
  position: relative;
  flex: 0 0 calc(100% - var(--ct-preview-w));
  min-width: 0; min-height: 0;
  padding: 40px 48px 48px;
  overflow-y: auto;
  color: var(--ct-fg);
  background: var(--ct-bg);
  scroll-snap-align: start;
  scroll-snap-stop: always;
}
.ct-panel:focus { outline: none; }

/* The live preview. On a laptop it stays pinned at the right while the
   panels slide beneath it (sticky works sideways too); on a phone it
   becomes the last card in the swipe deck. It is never a snap point. */
.ct-panel--preview {
  flex-basis: var(--ct-preview-w);
  position: sticky; right: 0; z-index: 2;
  scroll-snap-align: none;
  border-left: var(--ct-edge);
  padding: 32px 36px 40px;
}

.ct-page .ct-panel-head { margin-bottom: var(--ct-sp-6); }
.ct-page .ct-panel-head h2 { margin: 0; font-size: clamp(36px, 3.2vw, 50px); line-height: 1; }
.ct-page .ct-panel--preview .ct-panel-head h2 { font-size: clamp(28px, 2.4vw, 36px); }
.ct-page .ct-panel-lede { margin: 12px 0 0; max-width: 64ch; color: var(--ct-soft); font-size: 17px; }

/* A panel's content column, so form lines stay a readable length. */
.ct-measure { max-width: 44rem; }

/* Halftone dots faded in from one corner - the only decoration.
   A wash of the panel's own colour sits over the dots and fades out towards
   the bottom-right corner. */
.ct-halftone {
  background:
    linear-gradient(125deg, var(--ct-bg) 40%, transparent 100%),
    radial-gradient(rgba(0, 0, 0, .16) 1.3px, transparent 1.7px) 0 0 / 11px 11px,
    var(--ct-bg);
}

/* The start screen: a big headline on the left, the sections as tiles on the right. */
.ct-start {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 48px; align-items: center;
  padding: 48px 32px;
  background: radial-gradient(rgba(0, 0, 0, .09) 1.2px, transparent 1.6px) 0 0 / 14px 14px, var(--ct-paper);
}
[data-ct-theme="dark"] .ct-start { background: radial-gradient(rgba(255, 255, 255, .14) 1.2px, transparent 1.6px) 0 0 / 14px 14px, var(--ct-paper); }
.ct-page .ct-start__title span { display: block; }
.ct-page .ct-start__lede { margin: 0 0 28px; max-width: 46ch; font-size: 19px; }
.ct-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 0; padding: 0; list-style: none; }
.ct-tile {
  position: relative; overflow: hidden;
  min-height: 190px; width: 100%; padding: 22px;
  display: flex; flex-direction: column; justify-content: flex-end;
  text-align: left; color: var(--ct-fg);
  border: 2px solid #000; box-shadow: 4px 4px 0 #000;
}
:where(.ct-tile) { background: var(--ct-bg); }
[data-ct-theme="dark"] .ct-tile { box-shadow: 4px 4px 0 #FFF; }
button.ct-tile, a.ct-tile { cursor: pointer; text-decoration: none; transition: transform .12s ease, box-shadow .12s ease; }
button.ct-tile:hover, a.ct-tile:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 #000; }
[data-ct-theme="dark"] button.ct-tile:hover, [data-ct-theme="dark"] a.ct-tile:hover { box-shadow: 6px 6px 0 #FFF; }
.ct-page .ct-tile .ct-tile__name { margin: 0; font-family: var(--ct-serif); font-size: 30px; line-height: 1; }
.ct-page .ct-tile .ct-tile__text { margin: 8px 0 0; font-size: 15px; color: var(--ct-soft); }
.ct-tile .ct-tile__num { position: absolute; top: 10px; right: 16px; font-family: var(--ct-serif); font-size: 64px; line-height: 1; }
.ct-tile > * { position: relative; }

/* --------------------------------------------------------------------------
   5. Layout helpers
   -------------------------------------------------------------------------- */

.ct-shell { max-width: 1400px; margin: 0 auto; padding: var(--ct-sp-8) 32px var(--ct-sp-12); }
.ct-shell--narrow { max-width: 760px; }

.ct-stack   { display: flex; flex-direction: column; gap: var(--ct-sp-5); }
.ct-stack-2 { display: flex; flex-direction: column; gap: var(--ct-sp-2); }
.ct-row     { display: flex; align-items: center; gap: var(--ct-sp-3); flex-wrap: wrap; }
.ct-row--end { justify-content: flex-end; }
.ct-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--ct-sp-4); }
.ct-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--ct-sp-4); }

/* --------------------------------------------------------------------------
   6. Surfaces
   -------------------------------------------------------------------------- */

/* A white box. On a coloured panel it is the one thing that stands out. */
.ct-card {
  color: var(--ct-ink);
  background: var(--ct-paper);
  border: var(--ct-edge);
  box-shadow: var(--ct-shadow);
  padding: var(--ct-sp-5);
}
.ct-card--flush { padding: 0; overflow: hidden; }

.ct-card__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--ct-sp-3);
  margin: 0 0 var(--ct-sp-4); padding-bottom: var(--ct-sp-3);
  border-bottom: var(--ct-edge);
}
.ct-page .ct-card__title { margin: 0; font-family: var(--ct-serif); font-weight: 400; font-size: 24px; line-height: 1.05; }

/* The one concept users must understand. */
.ct-explain { padding: 20px 22px; color: var(--ct-ink); background: var(--ct-paper); border: var(--ct-edge); box-shadow: var(--ct-shadow); }
.ct-page .ct-explain h3 { margin: 0 0 8px; font-size: 28px; }

.ct-section-label { font-size: 14px; font-weight: 700; color: var(--ct-soft); }

.ct-divider { height: 0; border: 0; border-top: 2px solid var(--ct-rule); margin: var(--ct-sp-6) 0; }

/* Rule-separated list: a rule above the list and under each item. */
.ct-rows { margin: 0; padding: 0; list-style: none; border-top: 2px solid var(--ct-rule); }
.ct-rows > li { padding: 16px 0; border-bottom: 2px solid var(--ct-rule); }

/* --------------------------------------------------------------------------
   7. Forms
   -------------------------------------------------------------------------- */

.ct-field { display: flex; flex-direction: column; gap: var(--ct-sp-2); }
.ct-label { font-size: var(--ct-size-sm); font-weight: 700; color: var(--ct-fg); }
.ct-hint  { font-size: 14px; color: var(--ct-soft); }

.ct-input, .ct-select, .ct-textarea {
  width: 100%;
  min-height: var(--ct-control-h);
  padding: 0 var(--ct-sp-3);
  font-family: inherit; font-size: var(--ct-size-md);
  color: #000; background: #FFF;
  border: 2px solid #000; border-radius: 0;
  transition: box-shadow .12s ease;
}
[data-ct-theme="dark"] :not(.ct-panel) > .ct-input,
[data-ct-theme="dark"] .ct-shell .ct-input { border-color: #FFF; }
.ct-textarea { padding: var(--ct-sp-3); min-height: 96px; resize: vertical; line-height: 1.5; }
.ct-input::placeholder, .ct-textarea::placeholder { color: #595959; }
.ct-input:focus, .ct-select:focus, .ct-textarea:focus { outline: none; box-shadow: 4px 4px 0 #000; }
.ct-panel.ct-p-1 .ct-input:focus, .ct-panel.ct-p-1 .ct-select:focus, .ct-panel.ct-p-1 .ct-textarea:focus { box-shadow: 4px 4px 0 #FFF; }
.ct-input:disabled, .ct-select:disabled, .ct-textarea:disabled { background: #E6E6E6; color: #4D4D4D; cursor: not-allowed; }

.ct-select {
  appearance: none;
  padding-right: var(--ct-sp-8);
  background-image: linear-gradient(45deg, transparent 50%, #000 50%), linear-gradient(135deg, #000 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
.ct-input--mono { font-family: var(--ct-font-mono); font-size: 14px; }

.ct-check { display: flex; align-items: flex-start; gap: var(--ct-sp-3); cursor: pointer; }
.ct-check input { width: 20px; height: 20px; flex: none; margin: 1px 0 0; accent-color: #000; cursor: pointer; }
.ct-p-1 .ct-check input { accent-color: #FFF; }
.ct-check--disabled { opacity: .6; cursor: not-allowed; }

.ct-colour {
  display: flex; align-items: center; gap: var(--ct-sp-3);
  padding: 6px;
  color: #000; background: #FFF; border: 2px solid #000;
}
.ct-colour input[type="color"] { width: 44px; height: 32px; flex: none; padding: 0; border: 2px solid #000; background: none; cursor: pointer; }
.ct-colour input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.ct-colour input[type="color"]::-webkit-color-swatch { border: 0; }
.ct-colour__label { font-size: 14px; color: #4D4D4D; }
.ct-colour--off { opacity: .5; pointer-events: none; }

.ct-range { width: 100%; accent-color: var(--ct-fg); }

/* --------------------------------------------------------------------------
   8. Buttons: a black edge and a hard shadow that lifts on hover and presses
      flat when chosen. Never a flat coloured block.
   -------------------------------------------------------------------------- */

.ct-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--ct-sp-2);
  min-height: var(--ct-control-h);
  padding: 9px 16px;
  font-family: inherit; font-size: 15px; font-weight: 700; line-height: 1.2;
  color: var(--ct-ink); background: var(--ct-paper);
  border: var(--ct-edge); border-radius: 0;
  box-shadow: var(--ct-shadow);
  cursor: pointer; text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
}
.ct-btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ct-ink); }
.ct-btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ct-ink); }
.ct-btn[aria-pressed="true"], .ct-btn[aria-selected="true"], .ct-btn.is-active {
  color: var(--ct-paper); background: var(--ct-ink);
  transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ct-ink);
}
.ct-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: var(--ct-shadow); }

/* The main action on a screen: filled in ink. */
.ct-btn--primary { color: var(--ct-paper); background: var(--ct-ink); }
.ct-btn--primary:hover { background: var(--ct-ink); }

/* Kept for older markup: no red for danger, no second style of outline. */
.ct-btn--outline, .ct-btn--danger { color: var(--ct-ink); background: var(--ct-paper); }

/* Words, not a box - for actions inside sentences. */
.ct-btn--quiet, .ct-link-btn {
  min-height: 0; padding: 0;
  color: inherit; background: none; border: 0; box-shadow: none;
  font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px;
  cursor: pointer;
}
.ct-btn--quiet:hover, .ct-link-btn:hover, .ct-btn--quiet:active { transform: none; box-shadow: none; }

.ct-btn--block { width: 100%; }
.ct-btn--sm { min-height: 38px; padding: 6px 12px; font-size: 14px; }
.ct-btn--lg { min-height: 52px; padding: 12px 22px; font-size: 17px; }

/* Square icon-only button, for the top bar. */
.ct-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; flex: none; padding: 0;
  color: var(--ct-ink); background: var(--ct-paper);
  border: var(--ct-edge); box-shadow: 3px 3px 0 var(--ct-ink);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.ct-icon-btn:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ct-ink); }
.ct-icon-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ct-ink); }
.ct-icon-btn svg { width: 20px; height: 20px; }

/* Moon in light mode (press for dark), sun in dark mode. */
.ct-themetoggle .ct-icon-sun { display: none; }
[data-ct-theme="dark"] .ct-themetoggle .ct-icon-sun { display: block; }
[data-ct-theme="dark"] .ct-themetoggle .ct-icon-moon { display: none; }

/* --------------------------------------------------------------------------
   9. Notes. Never red: a shortfall gets a plain explanation, not an alarm.
   -------------------------------------------------------------------------- */

.ct-note {
  display: flex; gap: var(--ct-sp-3);
  padding: var(--ct-sp-3) var(--ct-sp-4);
  color: var(--ct-fg);
  border: 2px solid var(--ct-fg);
  font-size: var(--ct-size-sm); line-height: 1.5;
}
.ct-note__icon { flex: none; width: 18px; height: 18px; margin-top: 2px; }
.ct-note b { font-weight: 700; }
.ct-note--warning, .ct-note--danger { color: var(--ct-ink); background: var(--ct-paper); border-color: var(--ct-ink); box-shadow: var(--ct-shadow); }
.ct-note--success { border-style: solid; }

/* --------------------------------------------------------------------------
   10. Chips. Square, 2px edge, small bold text.
   -------------------------------------------------------------------------- */

.ct-badge, .ct-tag {
  display: inline-flex; align-items: center; gap: var(--ct-sp-1);
  padding: 2px 9px;
  font-size: 13px; font-weight: 700;
  color: inherit; background: transparent;
  border: 2px solid currentColor;
}
.ct-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.ct-chips li { padding: 2px 9px; border: 2px solid currentColor; font-size: 13px; font-weight: 700; }

/* --------------------------------------------------------------------------
   11. Figures - a big serif number over a small label
   -------------------------------------------------------------------------- */

.ct-stats { display: flex; flex-wrap: wrap; gap: var(--ct-sp-8); }
.ct-stat__value { display: block; font-family: var(--ct-serif); font-size: clamp(40px, 4vw, 68px); line-height: .95; font-variant-numeric: lining-nums; }
.ct-stat__label { display: block; margin-top: 6px; font-size: 14px; font-weight: 700; color: var(--ct-soft); }

/* --------------------------------------------------------------------------
   12. Table
   -------------------------------------------------------------------------- */

.ct-table-wrap { overflow-x: auto; border: var(--ct-edge); }
.ct-table { width: 100%; border-collapse: collapse; font-size: var(--ct-size-sm); }
.ct-table th, .ct-table td { padding: var(--ct-sp-3) var(--ct-sp-4); text-align: left; }
.ct-table th { font-weight: 700; border-bottom: 2px solid var(--ct-rule); white-space: nowrap; }
.ct-table tbody tr + tr td { border-top: 2px solid var(--ct-rule); }

/* --------------------------------------------------------------------------
   13. Builder parts - the preview stage and the generated-code box
   -------------------------------------------------------------------------- */

/* Always white: widgets are shown on the white page they will live on. */
.ct-stage {
  --ct-ink: #000; --ct-paper: #FFF; --ct-paper-soft: #4D4D4D; --ct-hover: #F2F2F2;
  display: flex; align-items: center; justify-content: center;
  min-height: 200px;
  padding: var(--ct-sp-6);
  color: #000; background: #FFF;
  border: 2px solid #000;
  overflow: auto;
}
[data-ct-theme="dark"] .ct-stage { border-color: #FFF; }

/* Black in both themes: it holds code. */
.ct-codebox {
  display: block; width: 100%; min-height: 220px;
  padding: var(--ct-sp-3) var(--ct-sp-4);
  font-family: var(--ct-font-mono); font-size: 13px; line-height: 1.6;
  color: #FFF; background: #000;
  border: 2px solid #000; border-radius: 0;
  resize: vertical; white-space: pre;
}
[data-ct-theme="dark"] .ct-codebox { border-color: #FFF; }
.ct-codebox:focus { outline: none; box-shadow: 4px 4px 0 var(--ct-fg); }

/* --------------------------------------------------------------------------
   14. Dialogs - "how to use this" and "about"
   -------------------------------------------------------------------------- */

.ct-modal {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  padding: var(--ct-sp-5);
  background: rgba(0, 0, 0, .45);
}
.ct-modal.is-open { display: flex; }

.ct-modal__box, .ct-dialog {
  position: relative;
  width: 100%; max-width: min(640px, calc(100vw - 32px)); max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
  color: var(--ct-ink); background: var(--ct-paper);
  border: var(--ct-edge); box-shadow: 8px 8px 0 var(--ct-ink);
}
.ct-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.ct-page .ct-modal__box h2, .ct-page .ct-dialog h2 { font-size: 32px; }
.ct-modal__close { position: absolute; top: 14px; right: 14px; }
.ct-modal__figure { display: block; max-width: 100%; margin: var(--ct-sp-3) 0 var(--ct-sp-5); border: var(--ct-edge); }

/* --------------------------------------------------------------------------
   15. Toast - the "copied" confirmation
   -------------------------------------------------------------------------- */

.ct-toast {
  position: fixed; left: 50%; bottom: var(--ct-sp-6); z-index: 60;
  transform: translate(-50%, 12px);
  display: flex; align-items: center; gap: var(--ct-sp-2);
  padding: var(--ct-sp-3) var(--ct-sp-5);
  color: var(--ct-paper); background: var(--ct-ink);
  border: 2px solid var(--ct-ink); box-shadow: 4px 4px 0 var(--ct-paper-soft);
  font-size: var(--ct-size-sm); font-weight: 700;
  opacity: 0; pointer-events: none;
  transition: opacity .2s var(--ct-ease), transform .2s var(--ct-ease);
}
.ct-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------------------------
   16. Bits and pieces
   -------------------------------------------------------------------------- */

.ct-muted { color: var(--ct-soft); }
.ct-small { font-size: var(--ct-size-sm); }
.ct-mono  { font-family: var(--ct-font-mono); }
.ct-empty { text-align: center; padding: var(--ct-sp-10) var(--ct-sp-5); color: var(--ct-soft); font-size: var(--ct-size-sm); }
.ct-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Show the working: a details box whose summary is a bold underlined line. */
.ct-working > summary { cursor: pointer; font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.ct-working[open] > summary { margin-bottom: var(--ct-sp-3); }

/* Checkerboard, for previewing anything with transparency */
.ct-checkerboard {
  background-color: #FFF;
  background-image:
    linear-gradient(45deg, #D9D9D9 25%, transparent 25%),
    linear-gradient(-45deg, #D9D9D9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #D9D9D9 75%),
    linear-gradient(-45deg, transparent 75%, #D9D9D9 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

/* --------------------------------------------------------------------------
   17. The one moment of motion, when a tool opens. Nothing else moves by
       itself; only buttons answer hover and press.
   -------------------------------------------------------------------------- */

.ct-play .ct-reveal { animation: ct-rise .6s var(--ct-ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
.ct-play .ct-deck > .ct-panel:first-child { animation: ct-wipe .75s cubic-bezier(.7, 0, .2, 1) both; animation-delay: .12s; }
/* The preview's contents wipe, not the panel: the panel must stay solid,
   or the section sliding underneath it shows through mid-wipe. */
.ct-play .ct-panel--preview > * { animation: ct-rise .6s var(--ct-ease) both; animation-delay: .35s; }
.ct-play-start .ct-start__title span,
.ct-play-start .ct-start__lede,
.ct-play-start .ct-start__more { animation: ct-rise .7s var(--ct-ease) both; }
.ct-play-start .ct-start__title span:nth-child(2) { animation-delay: .1s; }
.ct-play-start .ct-start__lede { animation-delay: .26s; }
.ct-play-start .ct-start__more { animation-delay: .38s; }
.ct-play-start .ct-tile { animation: ct-wipe .7s cubic-bezier(.7, 0, .2, 1) both; animation-delay: calc(var(--t, 0) * 110ms + .3s); }

@keyframes ct-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes ct-wipe { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }

/* --------------------------------------------------------------------------
   18. Phones: the menu becomes tabs, the panels become cards you swipe,
       with the next card's edge showing - that is what says "swipe".
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .ct-top { gap: var(--ct-sp-3); padding: 10px 16px; }
  .ct-brand, .ct-page a.ct-brand { font-size: 20px; }
  .ct-top .ct-btn--sm { padding: 6px 10px; }

  .ct-start { grid-template-columns: minmax(0, 1fr); gap: 32px; padding: 28px 16px 40px; }
  .ct-tile { min-height: 120px; padding: 14px; }
  .ct-page .ct-tile .ct-tile__name { font-size: 22px; }
  .ct-page .ct-tile .ct-tile__text { display: none; }
  .ct-tile .ct-tile__num { font-size: 40px; }

  .ct-app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); }
  .ct-rail { display: contents; }
  .ct-rail__who { padding: 14px 16px 10px; }
  .ct-page .ct-name { font-size: 30px; }
  .ct-page .ct-name.is-long { font-size: 22px; }
  .ct-page .ct-rail__lede { display: none; }
  .ct-rail__foot { display: none; }
  .ct-sections { display: flex; gap: 8px; padding: 4px 16px 14px; overflow-x: auto; scrollbar-width: none; border-top: 0; }
  .ct-sections::-webkit-scrollbar { display: none; }
  .ct-sections li { flex: none; }
  .ct-sections button { grid-template-columns: 14px auto; column-gap: 8px; padding: 8px 12px; border: var(--ct-edge); box-shadow: 3px 3px 0 var(--ct-ink); }
  .ct-sections button::before { width: 14px; height: 14px; grid-row: auto; }
  .ct-sections .ct-sections__val { display: none; }
  .ct-sections .ct-sections__name { font-size: 14px; white-space: nowrap; }
  .ct-only-phone { display: revert !important; }

  .ct-deck, .ct-deck--preview { --ct-preview-w: 0%; gap: 10px; padding: 0 16px 16px; scroll-padding-left: 16px; }
  .ct-panel, .ct-panel--preview {
    flex-basis: calc(100% - 22px);
    position: relative; right: auto;
    padding: 24px 18px 32px;
    border: 2px solid #000;
    scroll-snap-align: start;
  }
  [data-ct-theme="dark"] .ct-panel--preview { border-color: #FFF; }
  .ct-page .ct-panel-head h2 { font-size: 32px; }
  .ct-two { grid-template-columns: minmax(0, 1fr); }
}
