.qcw{
  --qcw-pad: clamp(1.1rem, 4vw, 2.4rem);
  /* The shadow a cut-out sheet of paper actually casts: warm, hard-edged,
     low alpha. This is ink-900 with an alpha channel, not a new colour —
     tokens carry no alpha variants, so the one place it is spelled out is
     here and everything else references it. NEVER a glow. */
  --qcw-cast: rgba(28,19,10,.16);
  --qcw-cast-soft: rgba(28,19,10,.10);
  max-width: 60rem;
  margin: 0 auto;
  padding: clamp(2.5rem, 7vw, 4.5rem) clamp(1rem, 4vw, 2rem);
  color: var(--ink-700);
  font-family: var(--font-body);
}
.qcw *{ box-sizing: border-box; }

/* ── Heading ───────────────────────────────────────────── */
.qcw-head{ max-width: 46ch; margin-bottom: clamp(1.6rem, 4vw, 2.4rem); }
.qcw-eyebrow{
  /* .78rem — under the --font-display floor, so body at 700 + tracking. */
  font-family: var(--font-body);
  font-size: .78rem; font-weight: 700; letter-spacing: .42em; text-transform: uppercase;
  color: var(--rubric-deep); margin: 0 0 .7rem;
}
.qcw-head h2{
  font-family: var(--font-display);
  font-weight: 600; line-height: 1.12;
  font-size: clamp(1.7rem, 5vw, 2.65rem);
  margin: 0 0 .75rem; color: var(--ink-900);
  letter-spacing: .01em;
}
/* .62em of the h2 drops well under the display floor at small viewports. */
.qcw-head h2 span{ display: block; font-family: var(--font-body); color: var(--ink-soft); font-size: .62em; font-style: italic; font-weight: 400; }
.qcw-lede{ margin: 0; color: var(--ink-700); font-size: clamp(1rem, 2.4vw, 1.12rem); line-height: 1.6; max-width: 52ch; }

/* ── Frame fallback (renders correctly with tokens alone) ─ */
/* One sheet of page-ground paper, one hard ink rule, one offset cast.
   The result card below deliberately carries MORE edge than this. */
.qcw-frame{ position: relative; padding: var(--qcw-pad); }
.qcw-frame:where(:not(.qc-frame)){
  background: var(--paper-300);
  border: 1px solid var(--ink-500);
  border-radius: 2px;
  box-shadow: 10px 10px 0 -1px var(--qcw-cast);
}
.qcw-corner{ position: absolute; width: 24px; height: 24px; color: var(--ink-500); pointer-events: none; }
.qcw-corner.tl{ top: -1px; left: -1px; }
.qcw-corner.tr{ top: -1px; right: -1px; transform: scaleX(-1); }
.qcw-corner.bl{ bottom: -1px; left: -1px; transform: scaleY(-1); }
.qcw-corner.br{ bottom: -1px; right: -1px; transform: scale(-1,-1); }

/* ── Tabs ──────────────────────────────────────────────── */
.qcw-tabs{
  display: flex; flex-wrap: wrap; gap: .35rem;
  border-bottom: 1px solid var(--ink-500);
  margin-bottom: 1.3rem; padding-bottom: .1rem;
}
.qcw-tab{
  appearance: none; background: none; border: 0; cursor: pointer;
  /* .82rem — body at 700, never the condensed display face. */
  font-family: var(--font-body); font-size: .82rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft); padding: .55rem .85rem .65rem; position: relative;
  display: inline-flex; align-items: center; gap: .45rem;
  transition: color .2s ease, background-color .2s ease;
}
.qcw-tab-glyph{ font-size: .5em; color: var(--ink-soft); opacity: 0; transition: opacity .2s ease; }
.qcw-tab:hover{ color: var(--ink-900); }
/* The selected tab is a cut chip of the lightest paper, pinned by a rubric rule. */
.qcw-tab[aria-selected="true"]{ color: var(--ink-900); background: var(--paper-100); }
.qcw-tab[aria-selected="true"] .qcw-tab-glyph{ opacity: 1; color: var(--rubric); }
.qcw-tab[aria-selected="true"]::after{
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 3px;
  /* this 3px rule is the only non-text carrier of "which tab is selected" and it
     straddles paper-100/paper-300, where --rubric is 2.82:1 — under the 3:1 floor
     for meaningful non-text. --rubric-deep is 5.18:1, and matches the focus ring
     on the next line, so the component now speaks one red. */
  background: var(--rubric-deep);
}
.qcw-tab:focus-visible{ outline: 2px solid var(--rubric-deep); outline-offset: 3px; border-radius: 2px; }

/* ── Controls ──────────────────────────────────────────── */
.qcw-controls{ display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem 1.4rem; }
.qcw-controls[hidden]{ display: none; }
.qcw-field{ display: flex; flex-direction: column; gap: .4rem; }
.qcw-field--count{ max-width: 6.5rem; }
.qcw-label{
  /* .7rem — body at 700 with tracking, printed-form label. */
  font-family: var(--font-body); font-size: .7rem; font-weight: 700; letter-spacing: .2em;
  text-transform: uppercase; color: var(--ink-500);
}
/* Ruled blanks on a printed form: uninked paper, hard ink rule, no gloss. */
.qcw-select, .qcw-count, .qcw-email{
  font-family: var(--font-body); font-size: .98rem; color: var(--ink-700);
  background: var(--paper-100); border: 1px solid var(--ink-500);
  border-radius: 2px; padding: .6rem .8rem; min-height: 44px;
  transition: border-color .18s ease, background-color .18s ease;
}
.qcw-select{ min-width: 13rem; appearance: none;
  /* Two half-gradients cut a solid ink triangle; the third layer is the
     printed rule that fences off the arrow gutter. Flat shapes only. */
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-500) 50%),
    linear-gradient(135deg, var(--ink-500) 50%, transparent 50%),
    linear-gradient(var(--ink-500), var(--ink-500));
  background-position: calc(100% - 18px) center, calc(100% - 13px) center, calc(100% - 2.1rem) 0;
  background-size: 5px 5px, 5px 5px, 1px 100%;
  background-repeat: no-repeat; padding-right: 2.2rem;
}
.qcw-count{ width: 100%; text-align: center; font-variant-numeric: tabular-nums; }
.qcw-select:hover, .qcw-count:hover, .qcw-email:hover{ border-color: var(--ink-900); }
.qcw-select:focus-visible, .qcw-count:focus-visible, .qcw-email:focus-visible{
  outline: 2px solid var(--rubric-deep); outline-offset: 2px;
  border-color: var(--ink-900);
}
.qcw-hint{ flex-basis: 100%; margin: .1rem 0 0; color: var(--ink-soft); font-size: .88rem; font-style: italic; }
.qcw-hint--solo{ flex-basis: auto; max-width: 44ch; }

/* ── Conjure button ────────────────────────────────────── */
/* Flat cut-paper CTA: a solid ink field, a paper label, a hard edge and a
   real offset cast that shortens when pressed. No gradient, no specular,
   no glow. The gilt glyph is the one gold moment in the whole panel. */
.qcw-action{ margin-top: 1.5rem; }
.qcw-conjure{
  appearance: none; cursor: pointer; display: inline-flex; align-items: center; gap: .6rem;
  font-family: var(--font-body); font-size: 1rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--paper-100);
  padding: .85rem 1.9rem; min-height: 48px; border: 1px solid var(--ink-900); border-radius: 2px;
  background: var(--ink-900);
  box-shadow: 5px 5px 0 var(--qcw-cast);
  transition: transform .14s var(--snap), box-shadow .14s var(--snap), background-color .18s ease, border-color .18s ease;
}
.qcw-conjure:hover{ background: var(--rubric-deep); border-color: var(--rubric-deep); box-shadow: 7px 7px 0 var(--qcw-cast); }
.qcw-conjure:active{ transform: translate(2px, 2px); box-shadow: 3px 3px 0 var(--qcw-cast); }
.qcw-conjure:focus-visible{ outline: 2px solid var(--rubric-deep); outline-offset: 3px; }
.qcw-conjure[disabled]{ background: var(--ink-soft); border-color: var(--ink-soft); cursor: progress; box-shadow: none; transform: translate(2px, 2px); }
.qcw-conjure-glyph{ font-size: 1.15em; color: var(--gold); }
.qcw-conjure.is-casting .qcw-conjure-glyph{ animation: qcw-spin .7s linear infinite; }

/* ── Divider ───────────────────────────────────────────── */
.qcw-divider{ border: 0; height: 1px; margin: 1.8rem 0; }
.qcw-divider:where(:not(.qc-divider)){
  background: linear-gradient(90deg, transparent, var(--ink-500) 22%, var(--ink-500) 78%, transparent);
}

/* ── Result card ───────────────────────────────────────── */
/* Now that the whole page is parchment this card can no longer be "the light
   one". It earns its own weight instead: the LIGHTEST paper, a double printed
   rule (paper margin band + inner ink line), a heavier ink-900 outer edge and
   a deeper cast than the panel around it. Defined on the base class so it does
   not depend on any other framing class being present. */
.qcw-result,
.qc-frame--parchment{
  position: relative; padding: clamp(1.2rem, 4vw, 2rem); min-height: 9rem;
  color: var(--ink-700);
  background:
    radial-gradient(ellipse 80% 60% at 50% 30%, var(--paper-100), var(--paper-300) 82%);
  border: 1px solid var(--ink-900); border-radius: 2px;
  box-shadow:
    inset 0 0 0 5px var(--paper-100),
    inset 0 0 0 6px var(--ink-500),
    7px 7px 0 var(--qcw-cast);
}
.qcw-result .qcw-corner,
.qc-frame--parchment .qcw-corner{ color: var(--ink-900); }

.qcw-empty{ text-align: center; padding: 1rem .5rem; color: var(--ink-soft); }
.qcw-empty-glyph{ display: block; font-size: 2rem; color: var(--ink-500); margin-bottom: .4rem; opacity: .5; }
.qcw-empty-title{ font-family: var(--font-body); font-weight: 700; font-size: 1.15rem; margin: 0 0 .3rem; color: var(--ink-900); }
.qcw-empty-sub{ margin: 0 auto; max-width: 38ch; font-size: .95rem; line-height: 1.5; }
.qcw-empty-sub strong{ color: var(--ember-text); }

.qcw-out[hidden], .qcw-empty[hidden]{ display: none; }
.qcw-out{ animation: qcw-rise .35s var(--calm) both; }
.qcw-kicker{
  font-family: var(--font-body); font-size: .68rem; font-weight: 700; letter-spacing: .26em;
  text-transform: uppercase; color: var(--rubric-deep); margin: 0 0 .7rem;
}
.qcw-headline{
  /* Floor-safe: the display face never renders below 1.6rem here. */
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.65rem, 5vw, 2.15rem); line-height: 1.1; margin: 0 0 .9rem; color: var(--ink-900);
}
.qcw-prose{ margin: 0; font-size: 1.04rem; line-height: 1.62; color: var(--ink-700); }
.qcw-rows{ list-style: none; margin: .2rem 0 0; padding: 0; display: grid; gap: .55rem; }
.qcw-row{ display: grid; grid-template-columns: minmax(5.5rem, 8rem) 1fr; gap: .2rem .9rem; align-items: baseline; }
.qcw-row-key{
  font-family: var(--font-body); font-size: .68rem; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-500); padding-top: .12rem;
}
.qcw-row-val{ font-size: 1.02rem; line-height: 1.5; color: var(--ink-700); }
.qcw-row--secret .qcw-row-key{ color: var(--rubric-deep); }
.qcw-row--secret .qcw-row-val{ font-style: italic; }
.qcw-loot-list{ list-style: none; margin: .3rem 0 0; padding: 0; display: grid; gap: .45rem; }
.qcw-loot-item{ display: flex; gap: .6rem; align-items: baseline; font-size: 1.02rem; color: var(--ink-700); }
.qcw-loot-bullet{ color: var(--rubric-deep); flex: none; }

/* ── Result actions ────────────────────────────────────── */
.qcw-result-actions{ display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1rem; }
.qcw-result-actions[hidden]{ display: none; }
.qcw-result-actions button{
  appearance: none; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem;
  font-family: var(--font-body); font-size: .82rem; font-weight: 700; letter-spacing: .06em;
  color: var(--ink-700); background: var(--paper-100);
  border: 1px solid var(--ink-500); border-radius: 2px; padding: .55rem 1rem; min-height: 40px;
  box-shadow: 3px 3px 0 var(--qcw-cast-soft);
  transition: color .18s, border-color .18s, background-color .18s, box-shadow .12s var(--snap), transform .12s var(--snap);
}
.qcw-result-actions button:hover{ color: var(--ink-900); border-color: var(--ink-900); background: var(--paper-500); }
.qcw-result-actions button:active{ transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--qcw-cast-soft); }
.qcw-result-actions button:focus-visible{ outline: 2px solid var(--rubric-deep); outline-offset: 2px; }
.qcw-save{ margin-left: auto; }
.qcw-save[aria-expanded="true"]{ color: var(--rubric-deep); border-color: var(--rubric-deep); background: var(--paper-100); }

/* ── Vault soft-gate ───────────────────────────────────── */
/* A slip of clean paper with a rubric marginal bar down its left edge —
   the manuscript way of flagging "this bit matters". */
.qcw-vault{ margin-top: 1rem; padding: 1.1rem 1.2rem; border: 1px solid var(--ink-500);
  border-radius: 2px; background: var(--paper-100);
  box-shadow: inset 4px 0 0 var(--rubric); animation: qcw-rise .3s var(--calm) both; }
.qcw-vault[hidden]{ display: none; }
.qcw-vault-copy{ margin: 0 0 .8rem; color: var(--ink-700); font-size: 1rem; line-height: 1.5; }
.qcw-vault-row{ display: flex; flex-wrap: wrap; gap: .55rem; }
.qcw-vault-field{ flex: 1 1 14rem; min-width: 0; }
.qcw-email{ width: 100%; }
.qcw-vault-submit{
  appearance: none; cursor: pointer; flex: none; font-family: var(--font-body);
  font-size: .85rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--paper-100);
  background: var(--ink-900);
  border: 1px solid var(--ink-900); border-radius: 2px; padding: 0 1.3rem; min-height: 44px;
  box-shadow: 4px 4px 0 var(--qcw-cast);
  transition: background-color .18s ease, border-color .18s ease, box-shadow .12s var(--snap), transform .12s var(--snap);
}
.qcw-vault-submit:hover{ background: var(--rubric-deep); border-color: var(--rubric-deep); box-shadow: 6px 6px 0 var(--qcw-cast); }
.qcw-vault-submit:active{ transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--qcw-cast); }
.qcw-vault-submit:focus-visible, .qcw-email:focus-visible{ outline: 2px solid var(--rubric-deep); outline-offset: 2px; }
.qcw-vault-fine{ margin: .7rem 0 0; color: var(--ink-soft); font-size: .82rem; font-style: italic; }
.qcw-vault-done{ margin: .7rem 0 0; color: var(--ember-text); font-size: .92rem; }
.qcw-vault-done[hidden]{ display: none; }

/* ── Toast ─────────────────────────────────────────────── */
/* An inked slip stamped over the page — solid ink field, paper lettering. */
.qcw-toast{
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%) translateY(8px);
  background: var(--ink-900); color: var(--paper-100);
  border: 1px solid var(--ink-900); border-radius: 2px; padding: .65rem 1.2rem;
  font-family: var(--font-body); font-size: .9rem; font-weight: 700; letter-spacing: .04em;
  box-shadow: 5px 5px 0 var(--qcw-cast); z-index: 60; opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
}
.qcw-toast[hidden]{ display: none; }
.qcw-toast.is-on{ opacity: 1; transform: translateX(-50%) translateY(0); }

.qcw-vis-hidden{
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@keyframes qcw-rise{ from{ opacity: 0; transform: translateY(6px); } to{ opacity: 1; transform: none; } }
@keyframes qcw-spin{ to{ transform: rotate(360deg); } }

@media (max-width: 520px){
  .qcw-save{ margin-left: 0; }
  .qcw-result-actions button{ flex: 1 1 auto; justify-content: center; }
  .qcw-row{ grid-template-columns: 1fr; gap: .05rem; }
}

@media (prefers-reduced-motion: reduce){
  .qcw *{ animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .qcw-toast{ transition: opacity .12s linear; }
}
