/* SZUGAR Studio — design system and page styles.
   Tokens and usage are documented in docs/brand.md. Everything is self-hosted:
   no external fonts, scripts or images. */

/* ---------------------------------------------------------------------------
   Fonts (SIL Open Font License 1.1, licences in fonts/)
   Righteous  — display, a free stand-in for the brand's Synthemesc
   Source Code Pro — body, labels and numbers (the brand's own body face)
   Bungee     — sparing accents: step numbers, band letters, tags
   --------------------------------------------------------------------------- */
@font-face { font-family: "Righteous"; src: url("fonts/righteous-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Code Pro"; src: url("fonts/source-code-pro-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Code Pro"; src: url("fonts/source-code-pro-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Source Code Pro"; src: url("fonts/source-code-pro-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Code Pro"; src: url("fonts/source-code-pro-latin-600-normal.woff2") format("woff2"); font-weight: 600 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Bungee"; src: url("fonts/bungee-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }

/* ---------------------------------------------------------------------------
   Tokens
   Contrast on --parchment: ink 10.2, oxblood 10.7, crimson 4.9, ink-2 6.5, ink-3 5.5.
   Gold, caramel, orange, sage and rust fail as small text on parchment: decoration only
   (gold text is fine on oxblood 5.3 and charcoal 5.1).
   --------------------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* brand palette */
  --parchment: #EDE1C8;
  --parchment-2: #E8DCC2;
  --paper: #F7F0E1;        /* panels: pattern paper */
  --paper-2: #FBF7EE;      /* inputs, wells */
  --charcoal: #303030;
  --oxblood: #581213;
  --oxblood-2: #3f0c0d;    /* hover on oxblood */
  --crimson: #BB1735;
  --caramel: #E4BF8E;
  --orange: #E8962E;
  --rust: #8C6447;
  --sage: #A69577;
  --gold: #b49c84;
  --gold-deep: #906c48;

  /* roles */
  --ink: var(--charcoal);
  --ink-2: #5C4A3D;        /* secondary text */
  --ink-3: #6B5340;        /* hints, captions */
  --line: #cdb994;         /* hairlines, decorative */
  --line-strong: var(--rust); /* input borders (4.6:1 on paper) */
  --stitch: rgba(140, 100, 71, .42);
  --accent: var(--crimson);
  --accent-soft: #f3d9c9;
  --ok: #2f5e3a;
  --warn: #7a4a00;
  --bad: #a01530;

  --radius: 6px;
  --radius-lg: 14px;
  --shadow: 0 1px 0 rgba(88, 18, 19, .06), 0 10px 26px -12px rgba(48, 48, 48, .28);

  --display: "Righteous", "Avenir Next", "Futura", "Trebuchet MS", sans-serif;
  --mono: "Source Code Pro", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --accent-font: "Bungee", "Righteous", Impact, sans-serif;
  --serif: var(--display);   /* older rules and app.js output that ask for --serif */
  --sans: var(--mono);

  --glitter:
    radial-gradient(circle at 30% 40%, rgba(255, 244, 214, .95) 0 .7px, transparent 1.2px) 0 0 / 5px 4px,
    radial-gradient(circle at 70% 60%, rgba(80, 52, 24, .55) 0 .7px, transparent 1.2px) 2px 1px / 7px 5px,
    linear-gradient(90deg, #906c48, #b49c84 25%, #d9c4a2 50%, #b49c84 75%, #906c48);

  /* Assistant runtime colours: white text sits on primary (13.9:1) and accent (6.4:1). */
  --ns-primary: #581213;
  --ns-accent: #BB1735;
}

/* ---------------------------------------------------------------------------
   Base
   --------------------------------------------------------------------------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 108px; -webkit-text-size-adjust: 100%; }
/* The masthead wraps to two rows below 860px (about 103px tall at 390px). */
@media (max-width: 860px) { html { scroll-padding-top: 120px; } }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  font: 400 15px/1.65 var(--mono);
  color: var(--ink);
  background-color: var(--parchment);
  /* jigsaw puzzle over a pattern-paper dot grid */
  background-image:
    url("brand/jigsaw-tile.svg"),
    radial-gradient(circle, rgba(140, 100, 71, .2) 1px, transparent 1.4px);
  background-size: 120px 120px, 24px 24px;
  overflow-x: hidden;
}
@media (min-width: 900px) { body { font-size: 16px; } }

img { max-width: 100%; height: auto; }
.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--oxblood); color: var(--parchment); padding: 10px 14px; border-radius: var(--radius); z-index: 20; }
.skip:focus { left: 16px; }

a { color: var(--oxblood); text-decoration-color: var(--crimson); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { color: var(--crimson); }
:focus-visible { outline: 3px solid var(--crimson); outline-offset: 2px; border-radius: 2px; }

::placeholder { color: var(--ink-3); opacity: 1; }

h1, h2, h3 { font-family: var(--display); font-weight: 400; color: var(--oxblood); letter-spacing: .005em; }
h3 { font-size: 1.2rem; line-height: 1.3; margin: 0 0 8px; }
strong, b { font-weight: 600; }

/* The logo's charcoal stroke with its gold-glitter inline, as a rule. */
.inline-rule { height: 9px; background: linear-gradient(var(--charcoal) 0 3px, transparent 3px 6px, var(--charcoal) 6px) , var(--glitter); }

/* ---------------------------------------------------------------------------
   Masthead
   --------------------------------------------------------------------------- */
.masthead { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--parchment) 92%, transparent); backdrop-filter: blur(6px); }
.masthead-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; padding-block: 6px; }
.brand { display: inline-flex; align-items: flex-end; gap: 12px; text-decoration: none; color: var(--ink); min-height: 44px; }
.wordmark { display: block; height: 60px; width: auto; aspect-ratio: 1400 / 509; }
/* "STUDIO" stays lighter than the wordmark: spaced Source Code Pro, charcoal, with a gold rule. */
.brand-sub { font: 500 12px/1 var(--mono); letter-spacing: .32em; text-transform: uppercase; color: var(--charcoal); padding: 0 0 9px 12px; border-left: 2px solid var(--gold); }
.nav-short { display: none; }
.steps-nav { display: flex; gap: 2px; list-style: none; margin: 0; padding: 0; }
.steps-nav a { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 999px; color: var(--ink-2); text-decoration: none; font-size: .86rem; font-weight: 500; white-space: nowrap; }
.steps-nav a:hover { background: var(--parchment-2); color: var(--oxblood); }
@media (max-width: 860px) {
  .masthead-inner { flex-wrap: wrap; row-gap: 0; padding-bottom: 0; }
  .steps-nav-wrap { width: calc(100% + 32px); margin-inline: -16px; overflow-x: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 24px), transparent); }
  .steps-nav-wrap::-webkit-scrollbar { display: none; }
  .steps-nav { padding-inline: 12px; width: max-content; }
  .steps-nav a { padding: 0 10px; font-size: .84rem; }
  .wordmark { height: 46px; }
  .brand-sub { padding-bottom: 7px; font-size: 12px; letter-spacing: .24em; }
}
/* On phones the six steps fit without scrolling: "Assistant" becomes "Ask". */
@media (max-width: 520px) {
  .steps-nav { padding-inline: 6px; width: 100%; min-width: max-content; justify-content: space-between; }
  .steps-nav a { padding: 0 7px; font-size: .8rem; }
  .nav-long { display: none; }
  .nav-short { display: inline; }
  .steps-nav-wrap { -webkit-mask-image: none; mask-image: none; }
}
/* 375px and narrower: tighter links so all six still fit (measured down to 320px). */
@media (max-width: 380px) {
  .steps-nav { padding-inline: 2px; }
  .steps-nav a { padding: 0 4px; font-size: 12px; letter-spacing: -.02em; }
}
@media (max-width: 340px) {
  .steps-nav a { padding: 0 2px; letter-spacing: -.04em; }
}

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 600 .95rem/1.15 var(--mono); padding: 11px 20px; border-radius: 999px; border: 2px solid var(--oxblood); cursor: pointer; background: transparent; color: var(--oxblood); min-height: 44px; text-decoration: none; text-align: center; transition: background-color .15s, color .15s, transform .15s; }
.btn.primary { background: var(--oxblood); color: var(--parchment); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18); }
.btn.primary:hover { background: var(--oxblood-2); color: #fff; }
.btn.ghost { background: color-mix(in srgb, var(--paper-2) 60%, transparent); }
.btn.ghost:hover { background: var(--paper-2); color: var(--crimson); border-color: var(--crimson); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.linklike { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--oxblood); text-decoration: underline; text-decoration-color: var(--crimson); text-underline-offset: 3px; cursor: pointer; min-height: 24px; }

/* ---------------------------------------------------------------------------
   Hero
   --------------------------------------------------------------------------- */
.hero { padding: clamp(28px, 5vw, 64px) 0 12px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr); gap: clamp(24px, 4vw, 56px); align-items: center; }
.eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0 0 18px; font-size: .8rem; font-weight: 500; letter-spacing: .06em; color: var(--ink-2); }
.eyebrow-tag { font: 400 .78rem/1 var(--accent-font); letter-spacing: .1em; color: var(--parchment); background: var(--oxblood); padding: 7px 10px 6px; border-radius: 999px; }
h1 { font-size: clamp(2.35rem, 6.2vw, 4.4rem); line-height: 1.02; margin: 0 0 22px; max-width: 13ch; text-wrap: balance; }
.lede { font-size: 1.02rem; color: var(--ink); max-width: 56ch; margin: 0 0 14px; }
.scope-note { font-size: .86rem; line-height: 1.6; color: var(--ink); max-width: 58ch; margin: 18px 0 0; padding: 10px 14px; background: color-mix(in srgb, var(--paper-2) 75%, transparent); border: 1px dashed var(--rust); border-radius: var(--radius); }
.scope-note b { color: var(--oxblood); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0 22px; }
.privacy-note { font-size: .84rem; line-height: 1.6; color: var(--ink-2); max-width: 60ch; margin: 0; padding: 2px 0 2px 14px; border-left: 3px solid var(--gold); }

.hero-art { position: relative; margin: 0; padding: 18px 18px 14px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  background-image: linear-gradient(rgba(140, 100, 71, .1) 1px, transparent 1px), linear-gradient(90deg, rgba(140, 100, 71, .1) 1px, transparent 1px);
  background-size: 20px 20px; background-position: -1px -1px; }
.hero-art::before { content: ""; position: absolute; inset: 7px; border: 1px dashed var(--stitch); border-radius: 10px; pointer-events: none; }
.outfit { display: block; width: 100%; height: auto; max-height: 520px; overflow: visible; }
.outfit .cut { fill: none; stroke: var(--charcoal); stroke-width: 1.6; stroke-linejoin: round; }
.outfit .lacing { fill: none; stroke: var(--charcoal); stroke-width: 1.4; stroke-linejoin: round; }
.outfit .piece-base { stroke: var(--charcoal); }
.outfit .zips path { fill: none; stroke: var(--gold-deep); stroke-width: 3; stroke-dasharray: 2 3; stroke-linecap: round; }
.outfit .tags text { font: 500 12px var(--mono); fill: var(--ink-2); text-anchor: start; }
.outfit .tags .zip-t { fill: var(--ink-2); font-weight: 600; }   /* gold stays on the dashed line only */
.outfit .leader { stroke: var(--ink-3); stroke-width: .8; stroke-dasharray: 1 2.5; fill: none; }
.outfit .piece { animation: settle .9s cubic-bezier(.2, .7, .2, 1) both; }
.outfit .piece-sleeve-l { --dx: -8px; --dy: 0; animation-delay: .15s; }
.outfit .piece-sleeve-r { --dx: 8px; --dy: 0; animation-delay: .15s; }
.outfit .piece-bodice { --dx: 0; --dy: -8px; }
.outfit .piece-base { --dx: 0; --dy: 6px; animation-delay: .25s; }
.outfit .piece-length { --dx: 0; --dy: 12px; animation-delay: .35s; }
@keyframes settle { from { transform: translate(var(--dx), var(--dy)); opacity: 0; } to { transform: none; opacity: 1; } }
.hero-art figcaption { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 8px; font-size: .8rem; color: var(--ink-2); }
.tag { font: 400 .75rem/1 var(--accent-font); letter-spacing: .08em; padding: 7px 10px 6px; border-radius: 999px; background: var(--crimson); color: #fff; }
.tag-plain { background: var(--paper-2); color: var(--oxblood); box-shadow: inset 0 0 0 1.5px var(--oxblood); }
/* The gold monogram on a paper disc: charcoal strokes and the gold inline read at this size. */
.art-stamp { position: absolute; display: grid; place-items: center; width: 104px; height: 104px; right: -16px; top: -24px; padding: 12px; border-radius: 50%; background: var(--paper-2); box-shadow: 0 0 0 2px var(--charcoal), 0 0 0 5px var(--gold), 0 0 0 7px var(--charcoal), var(--shadow); transform: rotate(8deg); }
.art-stamp img { display: block; width: 100%; height: 100%; }

/* promises + bands */
.promises { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.25fr); gap: 14px; margin-top: clamp(28px, 4vw, 48px); }
.promise { position: relative; padding: 20px 18px 16px 20px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.promise::before { content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 4px; border-radius: 0 4px 4px 0; background: var(--oxblood); }
.promise:nth-child(2)::before { background: var(--crimson); }
.promise:nth-child(3)::before { background: var(--rust); }
.promise-h { font-size: 1.16rem; line-height: 1.2; margin: 0 0 8px; }
.promise p { margin: 0; font-size: .86rem; color: var(--ink-2); }
.bands { padding: 18px; background: var(--charcoal); color: var(--parchment); border-radius: var(--radius); position: relative; overflow: hidden; }
.bands::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--glitter); }
.bands-label { margin: 0 0 10px; font: 400 12px/1 var(--accent-font); letter-spacing: .12em; color: var(--gold); }
.band-list { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; list-style: none; margin: 0 0 12px; padding: 0; }
.band-list li { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 2px 7px; border-radius: 8px; background: rgba(237, 225, 200, .07); box-shadow: inset 0 0 0 1px rgba(180, 156, 132, .45); }
.band-list b { font: 400 1.25rem/1 var(--accent-font); color: var(--caramel); }
.bands-label span { font: 500 12px/1 var(--mono); letter-spacing: .03em; color: var(--parchment); }
.band-list span { font-size: 12px; line-height: 1.2; text-align: center; color: var(--parchment); white-space: nowrap; }
.bands-note { margin: 0; font-size: .8rem; line-height: 1.55; color: var(--parchment); }
.bands-note em { font-style: italic; color: var(--caramel); }

@media (max-width: 1000px) {
  .promises { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bands { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  /* Single column: show the outfit straight after the headline, before the longer copy. */
  .hero-grid { grid-template-columns: 1fr; gap: 0; }
  .hero-copy { display: contents; }
  .hero-copy > * { grid-column: 1; }
  .eyebrow { order: 1; }
  .hero h1 { order: 2; }
  /* Headline, the outfit (capped), then the actions, so "Start" is on the first screen of a phone;
     the longer copy follows. */
  .hero-art { order: 3; max-width: 440px; width: 100%; justify-self: center; margin: 4px 0 18px; }
  .hero-actions { order: 4; margin: 0 0 24px; }
  .hero-copy > .lede, .scope-note, .privacy-note { order: 5; }
  .scope-note { margin: 4px 0 18px; }
  .outfit { max-height: 240px; }
  /* The drawing is shown at about half size here: larger labels keep them at 12px on screen. */
  .outfit .tags text { font-size: 22px; }
  .promises { grid-template-columns: 1fr; }
}
@media (max-width: 460px) {
  .art-stamp { width: 76px; height: 76px; padding: 9px; right: -6px; top: -16px; }
  .band-list { gap: 4px; }
  .band-list span { font-size: 12px; letter-spacing: -.03em; }
  .hero-actions .btn { width: 100%; }
}

/* ---------------------------------------------------------------------------
   Panels: a pattern piece — solid edge, dashed stitching line inside
   --------------------------------------------------------------------------- */
.panel { position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(20px, 3.2vw, 36px); margin-block: 28px; }
.panel::before { content: ""; position: absolute; inset: 7px; border: 1px dashed var(--stitch); border-radius: 3px; pointer-events: none; }
/* two notches on the top edge, like pattern balance marks */
.panel::after { content: ""; position: absolute; top: -1px; left: 50%; width: 22px; height: 8px; transform: translateX(-50%); background: linear-gradient(135deg, transparent 50%, var(--line) 50% calc(50% + 1px), transparent calc(50% + 1px)) 0 0 / 8px 8px no-repeat, linear-gradient(225deg, transparent 50%, var(--line) 50% calc(50% + 1px), transparent calc(50% + 1px)) 14px 0 / 8px 8px no-repeat; pointer-events: none; }
.panel > * { position: relative; }
.panel-head { display: flex; gap: 16px; align-items: center; margin-bottom: 22px; }
.panel-head h2 { font-size: clamp(1.6rem, 3.4vw, 2.1rem); line-height: 1.1; margin: 0 0 4px; }
.panel-head p { margin: 0; color: var(--ink-2); font-size: .92rem; }
@media (max-width: 600px) {
  .panel-head { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 14px; row-gap: 10px; align-items: center; }
  .panel-head > div { display: contents; }
  .panel-head h2 { margin: 0; }
  .panel-head p { grid-column: 1 / -1; }
  .step-no { width: 52px; height: 52px; }
}
.step-no { --piece: var(--oxblood); position: relative; z-index: 0; flex: none; display: grid; place-items: center; width: 60px; height: 60px; padding: 0 7px 2px 0; color: var(--parchment); font: 400 1.25rem/1 var(--accent-font); }
.step-no::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--piece);
  -webkit-mask: url("brand/puzzle-piece.svg") center / contain no-repeat; mask: url("brand/puzzle-piece.svg") center / contain no-repeat; }
.panel:nth-of-type(3n+2) .step-no { --piece: var(--crimson); color: #fff; }
.panel:nth-of-type(3n) .step-no { --piece: var(--charcoal); color: var(--caramel); }
.step-no.step-ask { --piece: var(--charcoal); color: var(--caramel); }

/* ---------------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------------- */
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 18px 20px; align-items: start; }
/* Field title first, then the input, then the hint, so inputs line up however long a hint is. */
.grid-form > label:not(.check) > .hint, .scan-form > label:not(.drop) > .hint { order: 3; margin-top: -2px; line-height: 1.45; }
.grid-form > label.check { align-self: end; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; min-height: 44px; }
label.inline { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.hint { font-weight: 400; font-size: .8rem; color: var(--ink-3); }
.unit-input { display: flex; align-items: center; border: 1.5px solid var(--line-strong); border-radius: var(--radius); background: var(--paper-2); overflow: hidden; min-height: 44px; }
.unit-input:focus-within { outline: 3px solid var(--crimson); outline-offset: 1px; }
.unit-input input { flex: 1; min-width: 0; border: 0; padding: 10px 12px; font: 500 1rem var(--mono); color: var(--ink); background: transparent; outline: none; }
.unit-input > span { padding: 0 12px; color: var(--ink-3); font-weight: 500; font-size: .85rem; }
input[aria-invalid="true"] { background: #fbe4e2; }
select { font: 500 .95rem var(--mono); padding: 10px 12px; min-height: 44px; border: 1.5px solid var(--line-strong); border-radius: var(--radius); background: var(--paper-2); color: var(--ink); max-width: 100%; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--oxblood); width: 20px; height: 20px; flex: none; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-weight: 600; font-size: .9rem; margin-bottom: 8px; padding: 0; }

.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 22px; grid-column: 1 / -1; }
.form-msg { margin: 0; font-size: .88rem; color: var(--ink-2); min-height: 1.4em; }
.form-msg.bad { color: var(--bad); }
.form-msg.ok { color: var(--ok); }

/* Tabs and segmented controls */
.tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--parchment-2); border: 1px solid var(--line); border-radius: 999px; margin-bottom: 22px; max-width: 100%; }
.tabs [role="tab"] { border: 0; background: transparent; padding: 10px 18px; border-radius: 999px; font: 600 .9rem var(--mono); color: var(--ink-2); cursor: pointer; min-height: 44px; }
.tabs [role="tab"]:hover { color: var(--oxblood); }
@media (max-width: 520px) {
  .tabs { display: flex; flex-wrap: nowrap; width: 100%; }
  .tabs [role="tab"] { flex: 1 1 auto; padding: 8px 10px; font-size: .82rem; line-height: 1.2; }
}
.tabs [role="tab"][aria-selected="true"] { background: var(--oxblood); color: var(--parchment); }

/* Scan */
.scan-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; }
@media (max-width: 760px) { .scan-grid { grid-template-columns: 1fr; } }
.tips { margin: 8px 0 0; padding-left: 20px; color: var(--ink-2); font-size: .9rem; }
.tips li { margin: 4px 0; }
.tips li::marker { color: var(--crimson); }
.scan-form { display: flex; flex-direction: column; gap: 16px; }
.scan-form .form-actions { margin-top: 0; }
.drop { position: relative; align-items: center; justify-content: center; text-align: center; gap: 4px; padding: 30px 16px; border: 2px dashed var(--rust); border-radius: var(--radius-lg); background: var(--paper-2); cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--crimson); background: var(--accent-soft); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop:focus-within { outline: 3px solid var(--crimson); outline-offset: 2px; }
.drop-title { font: 400 1.15rem var(--display); color: var(--oxblood); }
.scan-result { margin-top: 24px; padding-top: 20px; border-top: 1px dashed var(--stitch); }
.confidence { font-weight: 600; }
.confidence.good { color: var(--ok); }
.confidence.check { color: var(--warn); }
.confidence.poor { color: var(--bad); }
.figures { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 12px 0; }
.figures div { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.figures dt { font-size: .78rem; color: var(--ink-3); }
.figures dd { margin: 0; font: 600 1.2rem var(--mono); color: var(--oxblood); }

/* Style */
.silhouettes { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 22px; }
.sil { position: relative; }
.sil input { position: absolute; opacity: 0; }
.sil-card { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 112px; padding: 12px 8px 10px; border: 1.5px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--paper-2); font-weight: 600; font-size: .88rem; cursor: pointer; }
.sil-card:hover { border-color: var(--crimson); }
.sil-card svg { width: 54px; height: 62px; fill: var(--parchment-2); stroke: var(--ink-2); stroke-width: 1.6; stroke-linejoin: round; }
.sil input:checked + .sil-card { border-color: var(--oxblood); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--oxblood); }
.sil input:checked + .sil-card svg { fill: var(--crimson); stroke: var(--oxblood); }
.sil input:focus-visible + .sil-card { outline: 3px solid var(--crimson); outline-offset: 2px; }

/* Preview */
.preview-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; }
@media (max-width: 820px) { .preview-grid { grid-template-columns: 1fr; } }
.stage { position: relative; aspect-ratio: 4 / 5; max-height: 640px; width: 100%; border-radius: var(--radius-lg); overflow: hidden; background: radial-gradient(120% 90% at 50% 10%, #fbf5e8, #e3d4b6); border: 1px solid var(--line); }
.stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.stage .stage-msg { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--ink-2); }
.preview-controls { display: flex; flex-direction: column; gap: 20px; }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--parchment-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.seg label { position: relative; font-weight: 600; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; cursor: pointer; font-size: .88rem; }
.seg input:checked + span { background: var(--oxblood); color: var(--parchment); }
.seg input:focus-visible + span { outline: 3px solid var(--crimson); outline-offset: 1px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.swatch { position: relative; width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--paper-2); box-shadow: 0 0 0 1.5px var(--line-strong); cursor: pointer; padding: 0; }
.swatch:hover { box-shadow: 0 0 0 2px var(--crimson); }
/* Selected: an offset oxblood ring and a check on a parchment dot, readable on any swatch colour. */
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--paper-2), 0 0 0 5px var(--oxblood); }
.swatch[aria-pressed="true"]::after { content: ""; position: absolute; inset: 0; margin: auto; width: 20px; height: 20px; border-radius: 50%;
  background: var(--paper-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 10.5l3 3 6-7' fill='none' stroke='%23581213' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
  box-shadow: 0 0 0 1px rgba(48, 48, 48, .35); }
.swatches { padding: 4px; }
.body-source { font-size: .84rem; color: var(--ink-3); margin: 0; }

/* Pattern */
.pattern-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: .84rem; }
.chip b { font-family: var(--mono); font-weight: 600; color: var(--oxblood); }
.pattern-view, .layout-view { background: #fffdf8; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; overflow: auto; }
.pattern-view svg, .layout-view svg { display: block; width: 100%; height: auto; max-height: 560px; }
.layout-view:empty, .pattern-view:empty { display: none; }
/* On-screen drawings in the brand's type and colours. drafting.js writes print-ready black on
   white (presentation attributes); CSS overrides them here only, so downloads and print tiles
   stay black and white. */
.pattern-view svg text, .layout-view svg text { font-family: var(--mono); fill: var(--charcoal); }
.pattern-view svg > rect:first-of-type, .layout-view svg > rect:first-of-type { fill: #fffdf8; }
.pattern-view svg [stroke="#111"], .pattern-view svg [stroke="#000"] { stroke: var(--charcoal); }
.pattern-view svg [fill="#111"] { fill: var(--charcoal); }
.pattern-view svg polygon[stroke-dasharray] { fill: var(--paper); stroke: var(--rust); }
/* Labels drawn at 4-5 mm are unreadable at screen scale: keep piece names only, larger. */
.pattern-view svg text[font-size="0.4"], .pattern-view svg text[font-size="0.42"], .pattern-view svg text[font-size="0.45"], .pattern-view svg text[font-size="0.5"] { display: none; }
.pattern-view svg text[font-weight="bold"] { font-size: 2.4px; font-weight: 600; fill: var(--oxblood); letter-spacing: -.02em; }
.pattern-view svg text[font-size="0.6"] { display: none; }
.layout-view svg rect[fill="#f7f4ee"] { fill: var(--parchment-2); stroke: var(--rust); }
.layout-view svg polygon[fill="#cfe3f5"] { fill: #F1D9B4; }   /* caramel tint */
.layout-view svg polygon[fill="#f6d6c8"] { fill: #E2D9C4; }   /* sage tint */
.layout-view svg polygon[fill="#d9ecd0"] { fill: #E3C9B3; }   /* rust tint */
.layout-view svg polygon[fill="#e5e5e5"] { fill: #EFD3CF; }   /* crimson tint, other pieces */
.layout-view svg [stroke="#333"], .layout-view svg [stroke="#555"] { stroke: var(--charcoal); }
.layout-view svg polygon[fill="#333"] { fill: var(--charcoal); }
.layout-view svg line[stroke="#000"] { stroke: var(--oxblood); }
.layout-view svg text { font-weight: 500; letter-spacing: -.03em; }
.notes { margin: 14px 0 0; padding-left: 20px; color: var(--ink-2); font-size: .88rem; }
.notes li { margin: 4px 0; }
.notes li::marker { color: var(--rust); }
.notes li.warn { color: var(--warn); }

/* Fabric */
.fabric-result { margin: 20px 0 12px; font-size: 1rem; }
.fabric-result .big { font: 400 2.4rem/1 var(--display); color: var(--oxblood); display: block; margin-bottom: 6px; }
.shop-link { margin-top: 16px; }

/* ---------------------------------------------------------------------------
   Puzzleware builder: measure + fit card, outfit, collective, preview, patterns, fabric
   --------------------------------------------------------------------------- */
.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; }
.btn.small { min-height: 44px; padding: 8px 14px; font-size: .84rem; }
.note { margin: 8px 0 0; font-size: .84rem; color: var(--ink-2); }
.note.warn, li.warn { color: var(--warn); }
h4 { font-family: var(--display); font-weight: 400; color: var(--oxblood); margin: 0; font-size: 1.05rem; line-height: 1.25; }

/* Measure */
.measure-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: clamp(20px, 3vw, 36px); align-items: start; }
@media (max-width: 900px) { .measure-grid { grid-template-columns: 1fr; } }
.measure-form .units { margin-bottom: 16px; }
.seg-small span { min-height: 36px; padding: 0 14px; font-size: .82rem; }
.more-measures { margin-top: 18px; border-top: 1px dashed var(--stitch); padding-top: 4px; }
.more-measures > summary { cursor: pointer; padding: 12px 0; font-weight: 600; font-size: .9rem; color: var(--oxblood); min-height: 44px; }
.more-measures > summary .hint { font-weight: 400; margin-left: 6px; }
.more-measures .grid-form { margin-top: 6px; }

.fit-card { position: relative; padding: 22px 20px 18px; background: var(--charcoal); color: var(--parchment); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
/* (no overflow:hidden on the card: with larger text spacing its controls grow, never get cut off) */
.fit-card::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--glitter); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.fit-card h3 { color: var(--gold); font: 400 12px/1 var(--accent-font); letter-spacing: .14em; text-transform: uppercase; margin: 0 0 10px; }
.fit-headline { margin: 0 0 14px; display: flex; flex-direction: column; gap: 4px; min-height: 3.2em; }
.fit-big { font: 400 2rem/1.05 var(--display); color: var(--parchment); }
.fit-big b { font: 400 2.2rem/1 var(--accent-font); color: var(--caramel); font-weight: 400; letter-spacing: .04em; }
.fit-sub { font-size: .82rem; color: #d9ccb2; }
.band-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; list-style: none; margin: 0 0 16px; padding: 0; }
.band-strip li { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px 6px; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(180, 156, 132, .45); background: rgba(237, 225, 200, .05); }
.band-strip b { font: 400 1.1rem/1 var(--accent-font); color: var(--caramel); }
.band-strip span { font-size: 11px; line-height: 1.2; color: #d9ccb2; letter-spacing: -.02em; text-align: center; overflow-wrap: anywhere; }
.band-strip li.on { background: var(--caramel); box-shadow: 0 0 0 2px var(--gold); }
.band-strip li.on b, .band-strip li.on span { color: var(--charcoal); }
.fit-form { display: grid; gap: 12px; margin-bottom: 14px; }
.fit-form legend, .fit-form label { color: var(--parchment); }
.fit-card .seg { display: flex; flex-wrap: wrap; width: 100%; background: rgba(237, 225, 200, .08); border-color: rgba(180, 156, 132, .5); }
.fit-card .seg label { flex: 1 1 0; } /* basis 0: side by side, each label wrapping its own words; a row of its own only when a word cannot fit */
.fit-card .seg span { color: var(--parchment); justify-content: center; text-align: center; padding: 0 10px; line-height: 1.2; }
.fit-card .seg input:checked + span { background: var(--caramel); color: var(--charcoal); }
.fit-card .seg input:focus-visible + span, .fit-card select:focus-visible { outline-color: var(--caramel); }
.fit-card select { background: #3d3c3b; color: var(--parchment); border-color: var(--gold); }
.fit-card select:disabled { opacity: .55; }
/* messages on the charcoal card: parchment 11.3:1, green 8.9:1, pink 9.0:1 */
.fit-card .form-msg { color: var(--parchment); }
.fit-card .form-msg.ok { color: #a9dcb0; }
.fit-card .form-msg.bad { color: #ffb4a8; }
.fit-groups { display: grid; gap: 10px; }
.fit-group { padding: 12px 14px; border-radius: var(--radius); background: #3d3c3b; }
.fit-group h4 { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; color: var(--parchment); font-size: 1rem; margin-bottom: 6px; }
.fit-group-band { font: 400 .78rem/1 var(--accent-font); letter-spacing: .08em; color: var(--caramel); white-space: nowrap; }
.girths { list-style: none; margin: 0; padding: 0; font-size: .8rem; line-height: 1.5; color: #e9dfca; }
.girths li { padding: 3px 0; }
.girths li + li { border-top: 1px dashed rgba(180, 156, 132, .35); }
.girths b { color: var(--parchment); font-weight: 600; }
.girths li.warn, .fit-group .note.warn { color: #ffcf8a; }
.fit-explain { margin: 14px 0 0; font-size: .78rem; line-height: 1.55; color: #d9ccb2; }

/* Outfit builder */
.presets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: -4px 0 24px; }
.presets-label { font: 400 .74rem/1 var(--accent-font); letter-spacing: .1em; color: var(--ink-2); margin-right: 4px; }
.outfit-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: clamp(20px, 3vw, 36px); align-items: start; }
@media (max-width: 900px) { .outfit-grid { grid-template-columns: 1fr; } }
.outfit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.outfit-list .empty { padding: 18px; border: 1.5px dashed var(--rust); border-radius: var(--radius); color: var(--ink-2); }
.module-card { position: relative; padding: 14px 16px 14px 20px; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); }
.module-card::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 4px; border-radius: 0 4px 4px 0; background: var(--oxblood); }
.module-card.extension { margin-left: 22px; }
.module-card.extension::before { background: var(--crimson); }
.module-card.extension::after { content: ""; position: absolute; left: -16px; top: -12px; width: 12px; height: 34px; border-left: 2px dashed var(--gold-deep); border-bottom: 2px dashed var(--gold-deep); border-bottom-left-radius: 6px; }
/* Kept to swap in: a dashed edge and a tag, never lower opacity (the text keeps AA contrast). */
.module-card.not-worn { border-style: dashed; border-color: var(--line-strong); background: color-mix(in srgb, var(--paper-2) 60%, var(--parchment)); }
.tag-kept { font: 400 .7rem/1.5 var(--accent-font); letter-spacing: .06em; color: var(--ink); border: 1px dashed var(--ink-2); border-radius: 999px; padding: 0 8px; }
.module-head { display: flex; gap: 12px; align-items: flex-start; }
.module-title { flex: 1; min-width: 0; }
.module-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 4px 0 0; font-size: .78rem; color: var(--ink-2); }
.tag-band { font: 400 .7rem/1.5 var(--accent-font); letter-spacing: .06em; color: var(--parchment); background: var(--oxblood); border-radius: 999px; padding: 1px 8px 0; }
.icon-btn { flex: none; min-height: 44px; min-width: 44px; padding: 0 12px; border: 1.5px solid var(--line-strong); border-radius: 999px; background: transparent; color: var(--ink-2); font: 600 .8rem var(--mono); cursor: pointer; }
.icon-btn:hover { color: var(--crimson); border-color: var(--crimson); }
.face-dots { flex: none; position: relative; display: inline-block; width: 44px; height: 44px; }
.face-dots .dot { position: absolute; width: 30px; height: 30px; border-radius: 50%; box-shadow: 0 0 0 2px var(--paper-2), 0 0 0 3px rgba(48, 48, 48, .35); }
.face-dots .dot:first-child { left: 0; top: 0; z-index: 1; }
.face-dots .dot:last-child { right: 0; bottom: 0; }
.module-opts { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; }
.module-opts label.inline { font-size: .84rem; }
.module-opts select { min-height: 40px; padding: 6px 10px; font-size: .88rem; }
.fit-line { margin: 10px 0 0; font-size: .84rem; color: var(--ink-2); }
.status { display: inline-block; font: 400 .68rem/1.6 var(--accent-font); letter-spacing: .06em; padding: 1px 8px 0; border-radius: 999px; vertical-align: 1px; }
.status.fits { background: #dfe6cf; color: #2f4a26; }
.status.loose { background: #f5e1b8; color: #6b4300; }
.status.tight, .status.wontfit { background: #f6d2cf; color: var(--bad); }
.cloth { margin-top: 10px; font-size: .84rem; }
.cloth > summary { cursor: pointer; color: var(--oxblood); font-weight: 600; min-height: 32px; padding: 4px 0; }
.cloth-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding-top: 6px; }
.cloth-row select { min-height: 40px; padding: 6px 10px; font-size: .86rem; }
.joins-h { margin-top: 26px; }
.join-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: .88rem; }
.join-list li { display: grid; grid-template-columns: 26px minmax(0, 1fr); align-items: baseline; gap: 6px; color: var(--ink-2); }
.join-list .mark { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--parchment-2); color: var(--ink-2); font-weight: 700; font-size: .8rem; }
.join-list li.ok { color: var(--ink); }
.join-list li.ok .mark { background: #dfe6cf; color: #2f4a26; }
.join-list li.bad { color: var(--bad); }
.join-list li.bad .mark { background: #f6d2cf; color: var(--bad); }
.outfit-side { display: grid; gap: 18px; }
.add-form, .cloth-form { padding: 18px; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); display: grid; gap: 12px; }
.add-form .form-actions { margin-top: 4px; }
.add-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 130px), 1fr)); gap: 12px; }
.add-options .hint { margin: 0; grid-column: 1 / -1; }
.cloth-form h3 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cloth-form .hint { margin: -4px 0 0; }
.cloth-form .swatches { margin-bottom: 0; }

.collective { margin-top: 32px; padding-top: 24px; border-top: 1px dashed var(--stitch); }
.collective-lede { margin: 0 0 16px; color: var(--ink-2); font-size: .9rem; max-width: 72ch; }
.collective-filter { margin-bottom: 14px; }
.collective-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 18px; }
.designer { padding: 16px 16px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: #fffdf8; }
.designer-head { margin-bottom: 10px; }
.designer-head h3 { margin: 0; font-size: 1.15rem; }
.designer-head h3 a { text-decoration-thickness: 1px; }
.designer-head .hint { margin: 2px 0 0; }
.piece-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.piece { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px dashed var(--stitch); }
.piece:first-child { border-top: 0; }
.piece h4 { font-size: .98rem; }
.piece-text p { margin: 2px 0 0; font-size: .78rem; color: var(--ink-2); line-height: 1.4; }
.piece-offer { color: var(--oxblood) !important; font-weight: 600; }
.piece-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.small-link { font-size: .76rem; min-height: 32px; display: inline-flex; align-items: center; text-align: right; }
.offline p { margin: 0 0 10px; font-size: .86rem; color: var(--ink-2); }
@media (max-width: 520px) {
  .piece { grid-template-columns: 44px minmax(0, 1fr); }
  .piece-actions { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; }
  .module-card.extension { margin-left: 12px; }
  .module-card.extension::after { left: -10px; width: 6px; }
}

/* See it on you */
.change input[type="range"] { width: 100%; accent-color: var(--oxblood); min-height: 32px; }
.range-scale { display: flex; justify-content: space-between; font-size: .72rem; color: var(--ink-3); margin-top: -2px; }
.range-out { margin: 6px 0 8px; font-size: .86rem; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.range-out output { font-weight: 600; color: var(--oxblood); }
.fit-statuses { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: .8rem; line-height: 1.45; color: var(--ink-2); }
.fit-statuses li { padding: 8px 10px; border-radius: var(--radius); background: var(--paper-2); border: 1px solid var(--line); }
.fit-statuses li.tight, .fit-statuses li.wontfit { border-color: #e2a9a2; }
.fit-statuses li.loose { border-color: #e0c48c; }
.fit-statuses b { color: var(--ink); font-weight: 600; }
.view-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.view-btns .btn[aria-pressed="true"] { background: var(--oxblood); color: var(--parchment); }
.preview-grid { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
@media (min-width: 821px) { .preview-grid .stage { position: sticky; top: 96px; } }
@media (max-width: 820px) { .preview-grid { grid-template-columns: 1fr; } }

/* Patterns */
.pattern-bar { margin-bottom: 14px; max-width: 100%; }
/* A select sizes to its longest option: let it shrink and wrap under its label on phones. */
.pattern-bar label.inline { flex-wrap: wrap; max-width: 100%; }
#pattern-pick { max-width: 100%; min-width: 0; }
select { max-width: 100%; }
.outfit-main, .outfit-side, .module-card, .module-title, .add-form, .cloth-form { min-width: 0; }
.outfit-side { grid-template-columns: minmax(0, 1fr); }
.add-form, .cloth-form { grid-template-columns: minmax(0, 1fr); }
.fit-statuses-h { margin: 14px 0 6px; font-size: .9rem; }
.kit { margin-top: 26px; padding: 18px 20px; background: var(--paper-2); border: 1.5px dashed var(--rust); border-radius: var(--radius); }
.kit h3 { margin-bottom: 4px; }
.kit > p { margin: 0 0 8px; font-size: .9rem; color: var(--ink-2); }
.kit-list { margin: 0; padding-left: 20px; font-size: .88rem; display: grid; gap: 4px; }
.kit-list li::marker { color: var(--crimson); }
.kit-list b { color: var(--oxblood); }

/* Fabric */
.fabric-faces { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 12px; margin: 22px 0 14px; }
.face-card { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 14px; align-items: center; align-content: center; padding: 14px 16px; border-radius: var(--radius); background: var(--paper-2); border: 1px solid var(--line); }
.face-card p { margin: 0; }
.face-side { font: 400 .7rem/1.4 var(--accent-font); letter-spacing: .08em; color: var(--ink-2); }
.face-name { font: 400 1.1rem/1.2 var(--display); color: var(--oxblood); }
.face-card .big { font: 400 2rem/1 var(--display); color: var(--oxblood); white-space: nowrap; }
.fabric-total, .fabric-faces > .hint { grid-column: 1 / -1; margin: 0; }
.leftovers { margin-top: 18px; padding: 16px 18px; border-radius: var(--radius); background: color-mix(in srgb, var(--sage) 22%, var(--paper-2)); border: 1px solid var(--line); }
.leftovers:empty { display: none; }
.leftovers h3 { margin-bottom: 4px; }
.leftovers p { margin: 0; font-size: .9rem; }
.figures .fig-check dd, .figures .fig-poor dd { color: var(--warn); }
.fig-flag { font-size: .7rem; color: var(--warn); }

/* ---------------------------------------------------------------------------
   Assistant (from the agentify-website skill's assistant.css, in the SZUGAR palette).
   The runtime reads these variables for its chat, settings and agent panels. White text
   sits on --ns-primary (oxblood, 13.9:1) and --ns-accent (crimson, 6.4:1). Keep
   --ns-msgbg different from --ns-bg, or bot replies lose their bubble.
   --------------------------------------------------------------------------- */
.assistant-note { font-size: .86rem; color: var(--ink-2); max-width: 72ch; margin: 0 0 8px; }
#assistant-status { margin-bottom: 4px; }

#agent-app {
  --ns-font: var(--mono);
  --ns-bg: #FBF7EE;
  --ns-fg: #303030;
  --ns-primary: #581213;
  --ns-accent: #BB1735;
  --ns-border: #cdb994;
  --ns-panelbg: #FBF7EE;
  --ns-msgbg: #EDE1C8;
  --ns-muted: #5C4A3D;
}

.assistant-panels {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 16px;
  margin-top: 16px;
}

/* Set the height once the runtime has mounted the chat, so a failed load leaves no
   empty box. */
#agent-app.ns-composed-app [data-ns-slot="chat"] { height: 640px; }
#agent-app .ns-chat { background: var(--ns-bg); }

/* The studio's form rules (labels as bold columns, 20px boxes, select padding) would
   reach the runtime's own controls. Undo them here. */
#agent-app input[type="checkbox"],
#agent-app input[type="radio"] { width: auto; height: auto; }
#agent-app label { display: block; gap: 0; font-size: inherit; }
#agent-app label.check { min-height: 0; }
#agent-app select { min-height: 0; }
#agent-app .ns-header { flex-wrap: wrap; }
#agent-app .ns-settings-body label { margin: 4px 0; font-weight: 400; }
#agent-app legend { font-size: inherit; margin-bottom: 4px; }
#agent-app .ns-w-label { font-family: inherit; }
#agent-app .ns-widget label { margin: 0; }
#agent-app .ns-w-radio label,
#agent-app .ns-w-multi label,
#agent-app .ns-w-toggle { font-weight: 400; }
#agent-app .ns-w-toggle { font-size: 13px; }
#agent-app button { margin: 0; }
#agent-app .ns-w-choice { color: var(--ns-fg); }
#agent-app .ns-devtoggle:not(.on):hover,
#agent-app .ns-modal-close:hover { background: transparent; }
#agent-app .ns-w-choice:disabled:hover { background: #f4ecdc; }
/* The runtime's message rule hides the partner consent card's own background, and its
   Decline label then has too little contrast. */
#agent-app .ns-consent { background: #FBF3DF; }
/* While a consent card waits, the status line above it already says "Contacting", though
   nothing has been sent. Hide it until the visitor answers. */
#agent-app .ns-msgs:has(.ns-consent-actions) > .ns-turn-status { display: none; }
#agent-app .ns-msg { overflow-wrap: break-word; }
/* The runtime's amber hint is 4.4:1 on paper; darken it. */
#agent-app .ns-hint.warn { color: #8a3d06; }
#agent-app .ns-consent-actions { flex-wrap: wrap; }
#agent-app .ns-consent-actions button { white-space: nowrap; }

/* Assistant controls in the studio's type and target sizes. Buttons and inputs do not inherit
   fonts, so the runtime's controls fell back to Arial 12-13px at 24-34px tall. */
#agent-app button, #agent-app input:not([type="checkbox"]):not([type="radio"]), #agent-app select, #agent-app textarea { font-family: var(--mono); }
#agent-app button { min-height: 44px; font-size: .9rem; font-weight: 600; line-height: 1.2; }
#agent-app input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), #agent-app select { min-height: 44px; font-size: .95rem; color: var(--ink); background: var(--paper-2); border: 1.5px solid var(--line-strong); border-radius: var(--radius); padding: 9px 12px; }
#agent-app textarea { font-size: .95rem; border: 1.5px solid var(--line-strong); border-radius: var(--radius); }
#agent-app input:focus-visible, #agent-app select:focus-visible, #agent-app textarea:focus-visible { outline: 3px solid var(--crimson); outline-offset: 1px; }
/* Primary actions: the studio's pill buttons. */
#agent-app .ns-send, #agent-app .ns-inputbar button:not(#ns-newchat), #agent-app .ns-settings-body button:not(.ghost), #agent-app .ns-consent-actions button:not(.ghost), #agent-app .ns-linker-form button:not(.ghost), #agent-app .ns-w-btn:not(.ghost) {
  padding: 10px 20px; border: 2px solid var(--oxblood); border-radius: 999px; background: var(--oxblood); color: var(--parchment); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18); }
#agent-app .ns-send:hover:not(:disabled), #agent-app .ns-settings-body button:not(.ghost):hover, #agent-app .ns-consent-actions button:not(.ghost):hover, #agent-app .ns-w-btn:not(.ghost):hover { background: var(--oxblood-2); color: #fff; }
#agent-app .ns-send.ns-send-steering { background: var(--crimson); border-color: var(--crimson); color: #fff; }
/* Secondary actions: outlined pills. */
#agent-app .ns-settings-body button.ghost, #agent-app .ns-consent-actions button.ghost, #agent-app .ns-linker-form button.ghost, #agent-app .ns-w-btn.ghost, #agent-app .ns-devtoggle, #agent-app .ns-chat button:not([class]) {
  padding: 10px 18px; border: 2px solid var(--oxblood); border-radius: 999px; background: transparent; color: var(--oxblood); box-shadow: none; }
#agent-app .ns-settings-body button.ghost:hover, #agent-app .ns-consent-actions button.ghost:hover, #agent-app .ns-w-btn.ghost:hover, #agent-app .ns-chat button:not([class]):hover, #agent-app .ns-devtoggle:not(.on):hover { background: var(--paper-2); color: var(--crimson); border-color: var(--crimson); }
/* "New chat" carries inline colours from the runtime. */
#agent-app #ns-newchat { padding: 10px 18px; border-radius: 999px; background: transparent !important; color: var(--oxblood) !important; border: 2px solid var(--oxblood) !important; }
#agent-app #ns-newchat:hover { color: var(--crimson) !important; border-color: var(--crimson) !important; }
#agent-app .ns-devtoggle { padding: 8px 14px; font-size: .82rem; font-weight: 500; }
#agent-app .ns-devtoggle.on { background: var(--charcoal); border-color: var(--charcoal); color: var(--parchment); }
#agent-app .ns-w-choice { min-height: 44px; border: 1.5px solid var(--line-strong); background: var(--paper-2); }
#agent-app .ns-modal-close { min-height: 44px; min-width: 44px; }
/* Header and agent list: the brand name in the display face, never cut off. */
#agent-app .ns-title { font: 400 1.4rem/1.2 var(--display); color: var(--oxblood); min-width: 0; overflow-wrap: anywhere; }
#agent-app .ns-anode .ns-aname { white-space: normal; overflow: visible; font-size: .86rem; line-height: 1.3; }
#agent-app .ns-agents h3 { font: 400 .8rem/1.2 var(--accent-font); letter-spacing: .1em; color: var(--oxblood); }
/* Settings: readable sizes (the runtime uses 10-12px). */
#agent-app .ns-settings { font-size: .88rem; }
#agent-app summary { padding-block: 12px; line-height: 20px; cursor: pointer; }
#agent-app .ns-settings summary { padding-block: 12px; line-height: 20px; color: var(--ink-2); font-weight: 600; }
#agent-app .ns-settings-advanced > summary { padding-block: 12px; }
#agent-app .ns-hint, #agent-app .ns-arole, #agent-app .ns-aaddr { font-size: .8rem; line-height: 1.5; }
#agent-app .ns-key-providers a { display: inline-block; min-height: 44px; padding: 7px 12px; border: 1.5px solid var(--oxblood); border-radius: var(--radius); background: var(--paper-2); color: var(--oxblood); }
#agent-app .ns-key-providers small { font-size: .78rem; color: var(--ink-2); }
/* Status badge in the palette (the runtime's own is Tailwind red/green/blue). */
#agent-app .ns-llmbadge { font: 600 12px/1.3 var(--mono); letter-spacing: .02em; padding: 5px 12px; border-radius: 999px; }
#agent-app .ns-llmbadge.error { background: var(--accent-soft); color: var(--oxblood); border: 1.5px solid var(--crimson); }
#agent-app .ns-llmbadge.pending { background: var(--paper-2); color: var(--ink-2); border: 1.5px solid var(--rust); }
#agent-app .ns-llmbadge.real { background: #e4e8d6; color: var(--ok); border: 1.5px solid #6f7d55; }
#agent-app .ns-llmbadge.mock { background: var(--caramel); color: var(--charcoal); border: 1.5px solid var(--rust); }
/* Agent list icons: the monogram for this studio, puzzle pieces for partner networks (not emoji). */
#agent-app .ns-anode .ns-aicon { flex: none; width: 22px; height: 22px; font-size: 0; color: transparent; overflow: hidden;
  background: var(--crimson); -webkit-mask: url("brand/puzzle-piece.svg") center / contain no-repeat; mask: url("brand/puzzle-piece.svg") center / contain no-repeat; }
#agent-app .ns-anode:nth-child(3n) .ns-aicon { background: var(--rust); }
#agent-app .ns-anode:nth-child(3n+1) .ns-aicon { background: var(--charcoal); }
#agent-app .ns-anode:first-child .ns-aicon { width: 26px; height: 26px; background: url("brand/szugar-mark.svg") center / contain no-repeat; -webkit-mask: none; mask: none; }
/* Once the runtime has mounted, its badge and first chat message say what to do next, so the
   page's own status line would only repeat it. It still shows while loading or if the load fails. */
#assistant:has(#agent-app .ns-header .ns-llmbadge) #assistant-status { display: none; }
#agent-app .ns-in-use { font-size: .88rem; }
#agent-app .ns-settings-body input:not([type="checkbox"]):not([type="radio"]) { width: min(100%, 26rem); }

/* site.js and the runtime add their confirmation dialogs to <body>, outside #agent-app.
   The studio has no dialogs of its own. */
body > dialog { color: var(--ink); background: var(--paper); }
body > dialog::backdrop { background: rgba(48, 48, 48, .45); }
body > dialog h2 { margin: 0 0 12px; font: 400 1.4em var(--display); color: var(--oxblood); }
body > dialog button { margin-right: 8px; }
.assistant-review { max-width: 640px; width: 85%; max-height: 85vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; font: 15px var(--mono); }
.assistant-review dl { display: grid; grid-template-columns: fit-content(40%) 1fr; gap: 4px 16px; margin: 12px 0; }
.assistant-review dt { font-weight: 600; }
.assistant-review dd { margin: 0; overflow-wrap: anywhere; }
.assistant-review details { margin: 12px 0; }
.assistant-review pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.assistant-review .assistant-decline { background: transparent; color: inherit; border: 1px solid currentColor; }

@media (max-width: 760px) {
  .assistant-panels { grid-template-columns: 1fr; }
  .assistant-review dl { grid-template-columns: 1fr; gap: 0; }
  .assistant-review dd { margin-bottom: 8px; }
}

/* ---------------------------------------------------------------------------
   Footer
   --------------------------------------------------------------------------- */
/* Sign-off: the wordmark large, where its gold-glitter inline can be seen. */
.signoff { margin-top: 56px; padding: clamp(28px, 5vw, 56px) 0 clamp(24px, 4vw, 40px); }
.signoff-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
.signoff-wordmark { display: block; width: min(760px, 100%); height: auto; aspect-ratio: 1400 / 509; }
.signoff-line { margin: 0; max-width: 46ch; font: 400 clamp(1.05rem, 2.2vw, 1.3rem)/1.4 var(--display); color: var(--oxblood); }
.signoff-line em { font-style: normal; color: var(--crimson); }
.footer { margin-top: 0; background: var(--charcoal); color: var(--parchment); font-size: .86rem; }
.footer-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; padding: 36px 0 48px; }
.footer-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.footer-stamp { display: grid; place-items: center; width: 152px; height: 152px; padding: 12px; border-radius: 50%; background: var(--oxblood); box-shadow: 0 0 0 3px var(--gold), 0 0 0 5px var(--charcoal), 0 0 0 6px rgba(180, 156, 132, .6); }
/* The print-filled monogram has pale print in its strokes: it holds together on oxblood, not on parchment or charcoal,
   and only from about 140px; smaller, it breaks into confetti. */
.footer-mark { display: block; width: 100%; height: 100%; }
.footer-motto { margin: 0; font: 400 1.25rem/1.2 var(--display); color: var(--caramel); }
.footer-text p { margin: 0 0 10px; max-width: 72ch; }
.footer-small { color: #d9ccb2; font-size: .8rem; }
.footer a { color: var(--caramel); text-decoration-color: var(--gold); }
.footer a:hover { color: #fff; }
.footer :focus-visible { outline-color: var(--caramel); }
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr; gap: 18px; } .footer-brand { flex-direction: row; align-items: center; gap: 20px; } .footer-stamp { width: 140px; height: 140px; padding: 11px; flex: none; } }

/* ---------------------------------------------------------------------------
   Print-at-home view
   --------------------------------------------------------------------------- */
.print-sheet { display: none; }
@media print {
  @page { margin: 0; }
  body { background: #fff; }
  body.printing > *:not(.print-sheet) { display: none !important; }
  body.printing .print-sheet { display: block; }
  .print-sheet .page { break-after: page; page-break-after: always; }
  .print-sheet .page:last-child { break-after: auto; }
  .print-sheet svg { display: block; }
}

/* The runtime's small controls (the actions summary, the API-key help link): give them
   at least 24 px targets (WCAG 2.2 target size). */
#agent-app summary { min-height: 24px; padding-block: 3px; }
#agent-app .ns-key-help a { display: inline-block; min-height: 24px; padding-block: 3px; }

/* The collective is loaded only when the visitor asks. */
.collective-start { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; padding: 16px; border-radius: var(--radius); border: 1px dashed var(--line); background: #fffdf8; }
.collective-start p { margin: 0; flex: 1 1 260px; font-size: .9rem; }
.keep-note { margin-top: 4px; }
#agent-app .ns-anode:focus-visible { outline: 3px solid var(--crimson); outline-offset: 2px; }
