/* ─────────────────────────────────────────────────────────────────
   IELTS Writing — Reverse Engineering stylesheet.

   Three surfaces:
     1. Landing  — hero + stats + two big mode cards
     2. Session  — top bar + progress + Band-9 prompt + stage
                   ↳ Decode  : sentence cards + function chip pool
                   ↳ Rebuild : scrambled cards + number circles
                   Both share the reveal layout (stamps, model panel)
     3. Summary  — hero + per-item breakdown + retry actions

   Visual vocabulary matches the other writing tools (cream paper on
   dark chocolate; --mode-accent flows through eyebrows, chips, and
   stamps). Two modes own their accent:
     · decode  → #B57A2E (honey)
     · rebuild → #5C8A6A (sage)

   Animations are reserved for moments students actually look at:
     · chip-assign pulse (decode)
     · number pop (rebuild)
     · staggered reveal stamps (both)
     · gentle wrong-shake on revealed mistakes
   ───────────────────────────────────────────────────────────── */

.wr-re-page {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.6rem 0 4rem;
  --mode-accent: #B57A2E;
}

/* ── Back link (matches the wr-su / wr-pd convention) ────────── */
.wr-re-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px 7px 10px;
  border-radius: 999px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ielts-ink-soft, #B6A484);
  background: rgba(242, 230, 204, .05);
  border: 1px solid var(--ielts-line, rgba(242, 230, 204, .10));
  text-decoration: none;
  transition: background-color .15s, color .15s, border-color .15s;
  margin-bottom: 1.6rem;
}
.wr-re-back:hover {
  color: var(--ielts-ink, #F2E6CC);
  background: rgba(242, 230, 204, .10);
  border-color: color-mix(in srgb, var(--ielts-honey, #D9A268) 30%, transparent);
}

.wr-re-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ielts-honey, #D9A268);
  margin-bottom: .7rem;
}
.wr-re-eyebrow::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px color-mix(in srgb, currentColor 60%, transparent);
}
.wr-re-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 2.4rem;
  font-weight: 500;
  letter-spacing: -.02em;
  line-height: 1.05;
  color: var(--ielts-ink, #F2E6CC);
  margin: 0 0 .8rem;
}
.wr-re-lede {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 1.02rem;
  line-height: 1.55;
  color: var(--ielts-ink-soft, #B6A484);
  margin: 0 0 1.6rem;
  max-width: 64ch;
}
.wr-re-section-h {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -.01em;
  color: var(--ielts-ink, #F2E6CC);
  margin: 1.6rem 0 .6rem;
}
.wr-re-loading {
  padding: 3rem 1rem;
  text-align: center;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--ielts-ink-soft, #B6A484);
}
.wr-re-error {
  padding: 2rem 1.8rem;
  background: linear-gradient(180deg, rgba(255, 251, 240, 0.97) 0%, rgba(243, 233, 211, 0.95) 100%);
  border: 1px solid rgba(31, 24, 18, 0.10);
  border-left: 3px solid #C24A2B;
  border-radius: 12px;
  color: #1F1812;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}
.wr-re-error h3 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.2rem;
  font-weight: 500;
  margin: 0 0 .4rem;
}
.wr-re-error p {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .94rem;
  line-height: 1.5;
  color: #4A3F33;
  margin: 0 0 1rem;
}

/* ── Stats row (landing) ─────────────────────────────────────── */
.wr-re-stats-row {
  display: flex;
  gap: 1.2rem;
  margin-bottom: 1.8rem;
  flex-wrap: wrap;
}
.wr-re-stats-skeleton {
  height: 76px;
  width: 100%;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(242,230,204,.04), rgba(242,230,204,.07), rgba(242,230,204,.04));
  background-size: 200% 100%;
  animation: wr-re-shimmer 1.8s linear infinite;
}
@keyframes wr-re-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.wr-re-firstrun {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(217, 162, 104, .10);
  border: 1px solid rgba(217, 162, 104, .25);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .9rem;
  color: var(--ielts-ink, #F2E6CC);
  max-width: 64ch;
  line-height: 1.4;
}
.wr-re-firstrun-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ielts-honey, #D9A268);
  box-shadow: 0 0 10px var(--ielts-honey, #D9A268);
  flex: 0 0 auto;
}
.wr-re-stat {
  flex: 1 1 140px;
  padding: 14px 18px;
  background: rgba(242, 230, 204, .04);
  border: 1px solid var(--ielts-line, rgba(242, 230, 204, .10));
  border-radius: 12px;
}
.wr-re-stat-num {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.6rem;
  font-weight: 500;
  color: var(--ielts-ink, #F2E6CC);
  line-height: 1;
}
.wr-re-stat-num.is-text {
  font-size: 1rem;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 600;
}
.wr-re-stat-l {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ielts-ink-soft, #B6A484);
  margin-top: 6px;
}

/* ── Mode grid (landing) ─────────────────────────────────────── */
.wr-re-mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.4rem;
  margin-top: 1rem;
}
.wr-re-mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  padding: 1.6rem 1.5rem 1.2rem;
  background: linear-gradient(180deg, rgba(255, 251, 240, 0.97) 0%, rgba(243, 233, 211, 0.95) 100%);
  border: 1px solid rgba(31, 24, 18, 0.10);
  border-left: 3px solid var(--mode-accent, #B57A2E);
  border-radius: 14px;
  text-decoration: none;
  color: #1F1812;
  box-shadow: 0 1px 0 rgba(255,255,255,.65) inset, 0 18px 30px -22px rgba(31,24,18,.35);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  overflow: hidden;
}
.wr-re-mode-card::after {
  content: '';
  position: absolute;
  inset: -50% -20% auto auto;
  width: 240px; height: 240px;
  background: radial-gradient(circle, color-mix(in srgb, var(--mode-accent) 18%, transparent) 0%, transparent 65%);
  pointer-events: none;
  opacity: .55;
  transition: opacity .25s ease, transform .25s ease;
}
.wr-re-mode-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 1px 0 rgba(255,255,255,.65) inset, 0 24px 36px -22px rgba(31,24,18,.45);
  border-left-color: color-mix(in srgb, var(--mode-accent) 80%, #000);
}
.wr-re-mode-card:hover::after {
  opacity: .85;
  transform: translate(-8px, 6px);
}
.wr-re-mode-card.is-disabled {
  opacity: .55;
  pointer-events: none;
}
.wr-re-mode-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--mode-accent) 14%, transparent);
  color: var(--mode-accent);
  border: 1px solid color-mix(in srgb, var(--mode-accent) 30%, transparent);
}
.wr-re-mode-name {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.4rem;
  font-weight: 500;
  color: #1F1812;
  letter-spacing: -.01em;
}
.wr-re-mode-short {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .85rem;
  font-weight: 600;
  color: var(--mode-accent);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.wr-re-mode-desc {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .94rem;
  line-height: 1.55;
  color: #4A3F33;
  margin: .15rem 0 .8rem;
}
.wr-re-mode-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .78rem;
  color: #6B5E4A;
  margin-top: auto;
}
.wr-re-mode-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.wr-re-mode-count::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--mode-accent);
}
.wr-re-mode-stat {
  font-weight: 600;
  color: var(--mode-accent);
}
.wr-re-mode-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  margin-top: 1.05rem;
  border-radius: 999px;
  background: var(--mode-accent);
  color: #FBF4E2;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .88rem;
  font-weight: 600;
  align-self: flex-start;
  transition: transform .15s ease;
}
.wr-re-mode-card:hover .wr-re-mode-cta {
  transform: translateX(2px);
}

.wr-re-last-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 1.6rem;
  padding: 8px 14px;
  border-radius: 999px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .86rem;
  color: var(--ielts-ink-soft, #B6A484);
  background: rgba(242, 230, 204, .04);
  border: 1px solid var(--ielts-line, rgba(242, 230, 204, .10));
  text-decoration: none;
  transition: color .15s, border-color .15s;
}
.wr-re-last-link:hover {
  color: var(--ielts-ink, #F2E6CC);
  border-color: color-mix(in srgb, var(--ielts-honey, #D9A268) 30%, transparent);
}

/* ── Session top bar ─────────────────────────────────────────── */
.wr-re-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: .8rem;
}
.wr-re-item-top .wr-re-back { margin-bottom: 0; }
.wr-re-item-meta {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .78rem;
  color: var(--ielts-ink-soft, #B6A484);
}
.wr-re-item-mode {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  color: var(--mode-accent);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: .72rem;
}
.wr-re-item-mode::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--mode-accent);
  box-shadow: 0 0 8px color-mix(in srgb, var(--mode-accent) 70%, transparent);
}
.wr-re-item-progress {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.wr-re-progress-track {
  height: 4px;
  width: 100%;
  background: rgba(242, 230, 204, .08);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1.6rem;
}
.wr-re-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--mode-accent) 0%, color-mix(in srgb, var(--mode-accent) 60%, #FFD7A0) 100%);
  border-radius: 999px;
  transition: width .35s cubic-bezier(.4, 0, .2, 1);
}

/* ── Prompt card (Band 9 source context) ─────────────────────── */
.wr-re-prompt {
  padding: 1.05rem 1.3rem 1.15rem;
  background: rgba(242, 230, 204, .04);
  border: 1px solid var(--ielts-line, rgba(242, 230, 204, .10));
  border-radius: 12px;
  margin-bottom: 1.4rem;
}
.wr-re-prompt-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: .6rem;
}
.wr-re-prompt-task,
.wr-re-prompt-kind,
.wr-re-prompt-band {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  border-radius: 999px;
}
.wr-re-prompt-task {
  background: color-mix(in srgb, var(--mode-accent) 18%, transparent);
  color: var(--mode-accent);
  border: 1px solid color-mix(in srgb, var(--mode-accent) 35%, transparent);
}
.wr-re-prompt-kind {
  background: rgba(242, 230, 204, .04);
  color: var(--ielts-ink-soft, #B6A484);
  border: 1px solid var(--ielts-line, rgba(242, 230, 204, .12));
}
.wr-re-prompt-band {
  background: rgba(217, 162, 104, .14);
  color: var(--ielts-honey, #D9A268);
  border: 1px solid rgba(217, 162, 104, .35);
}
.wr-re-prompt-text {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--ielts-ink, #F2E6CC);
  font-style: italic;
}

.wr-re-q {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -.005em;
  color: var(--ielts-ink, #F2E6CC);
  margin: 0 0 1rem;
}

/* ── DECODE: two-column layout (sentences left, chips right) ───
   The whole page widens for the decode session so both columns
   have room without breaking the 880px ceiling on the rest of the
   tool. :has() lets us scope the widening to decode-only without
   adding a body class. */
.wr-re-page:has(.wr-re-decode-grid) {
  max-width: 1180px;
}
.wr-re-decode-grid {
  display: grid;
  grid-template-columns: 1fr minmax(240px, 300px);
  gap: 1.6rem;
  align-items: start;
  margin-bottom: 1.4rem;
}

/* ── DECODE: sentence cards (cream paper inside dark shell) ──── */
.wr-re-sentences {
  display: flex;
  flex-direction: column;
  gap: .9rem;
  /* When inside the two-column grid the wrapper handles bottom
     margin; remove the standalone one. */
  margin-bottom: 0;
}
.wr-re-sent-card {
  position: relative;
  padding: 1.05rem 1.2rem;
  background: linear-gradient(180deg, rgba(255, 251, 240, 0.97) 0%, rgba(247, 238, 218, 0.95) 100%);
  border: 1px solid rgba(31, 24, 18, 0.08);
  border-left: 3px solid rgba(31, 24, 18, .12);
  border-radius: 12px;
  cursor: pointer;
  transition: border-left-color .18s ease, transform .18s ease, box-shadow .18s ease;
  box-shadow: 0 1px 0 rgba(255,255,255,.65) inset;
}
.wr-re-sent-card:hover {
  border-left-color: color-mix(in srgb, var(--mode-accent) 60%, transparent);
}
/* When the body is in an armed state (chip selected), tease the
   sentences so the user knows where to click next. */
body.is-wr-re-armed .wr-re-sent-card {
  border-left-color: color-mix(in srgb, var(--mode-accent) 50%, transparent);
  box-shadow: 0 1px 0 rgba(255,255,255,.65) inset, 0 0 0 1px color-mix(in srgb, var(--mode-accent) 20%, transparent);
}
body.is-wr-re-armed .wr-re-sent-card:hover {
  transform: translateX(3px);
  border-left-color: var(--mode-accent);
}
.wr-re-sent-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.wr-re-sent-num {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: .95rem;
  font-weight: 500;
  background: rgba(31, 24, 18, .06);
  color: #4A3F33;
  border: 1px solid rgba(31, 24, 18, .10);
  margin-top: 1px;
}
.wr-re-sent-text {
  flex: 1 1 auto;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.6;
  color: #1F1812;
}
.wr-re-sent-slot {
  margin-top: .75rem;
  padding-left: 42px; /* aligns with sentence text */
}
.wr-re-slot-empty {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 8px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .76rem;
  color: #8A7D67;
  background: rgba(31, 24, 18, .03);
  border: 1px dashed rgba(31, 24, 18, .14);
}
.wr-re-slot-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--mode-accent) 15%, white);
  border: 1px solid color-mix(in srgb, var(--mode-accent) 40%, transparent);
  color: var(--mode-accent);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .01em;
}
.wr-re-slot-chip.is-fresh {
  animation: wr-re-pop .35s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes wr-re-pop {
  0%   { transform: scale(.6); opacity: 0; }
  60%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}
.wr-re-slot-chip-x {
  width: 20px; height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  background: color-mix(in srgb, var(--mode-accent) 25%, white);
  color: var(--mode-accent);
  transition: background-color .15s;
}
.wr-re-slot-chip-x:hover {
  background: color-mix(in srgb, var(--mode-accent) 40%, white);
}

/* ── DECODE: chip pool (right-side sticky sidebar) ───────────── */
.wr-re-pool-wrap {
  padding: 1rem 1.1rem 1.15rem;
  background: rgba(242, 230, 204, .04);
  border: 1px solid var(--ielts-line, rgba(242, 230, 204, .10));
  border-radius: 12px;
  /* Sticky so the chips stay alongside the sentences as the
     student scrolls through them. 16px of breathing room from
     the top of the viewport. */
  position: sticky;
  top: 16px;
  z-index: 3;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.wr-re-pool-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-bottom: .8rem;
}
.wr-re-pool-label {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ielts-honey, #D9A268);
}
.wr-re-pool-hint {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .74rem;
  color: var(--ielts-ink-soft, #B6A484);
  font-style: italic;
}
.wr-re-pool {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wr-re-pool .wr-re-chip {
  width: 100%;
}
.wr-re-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(242, 230, 204, .05);
  border: 1px solid var(--ielts-line, rgba(242, 230, 204, .14));
  color: var(--ielts-ink, #F2E6CC);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: transform .15s ease, background-color .15s, border-color .15s, color .15s;
}
.wr-re-chip:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--mode-accent) 50%, transparent);
  background: rgba(242, 230, 204, .08);
  transform: translateY(-1px);
}
.wr-re-chip.is-armed {
  background: color-mix(in srgb, var(--mode-accent) 22%, transparent);
  border-color: var(--mode-accent);
  color: var(--ielts-ink, #F2E6CC);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mode-accent) 20%, transparent);
}
.wr-re-chip.is-spent {
  opacity: .38;
  cursor: default;
  transform: none;
}
.wr-re-chip:disabled { cursor: default; }
.wr-re-chip-name {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .88rem;
  font-weight: 600;
}
.wr-re-chip-tag {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .72rem;
  color: var(--ielts-ink-soft, #B6A484);
  font-weight: 500;
}

/* ── REBUILD: cards ──────────────────────────────────────────── */
.wr-re-rb-hint-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.wr-re-rb-hint {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .82rem;
  color: var(--ielts-ink-soft, #B6A484);
  line-height: 1.45;
}
.wr-re-rb-clear {
  padding: 6px 12px;
  border-radius: 999px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .78rem;
  font-weight: 600;
  color: var(--ielts-ink-soft, #B6A484);
  background: rgba(242, 230, 204, .03);
  border: 1px solid var(--ielts-line, rgba(242, 230, 204, .10));
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.wr-re-rb-clear:hover {
  color: var(--ielts-ink, #F2E6CC);
  border-color: color-mix(in srgb, var(--ielts-honey, #D9A268) 35%, transparent);
}

.wr-re-rb-stack {
  display: flex;
  flex-direction: column;
  gap: .85rem;
  margin-bottom: 1.4rem;
}
.wr-re-rb-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 1rem 1.2rem;
  background: linear-gradient(180deg, rgba(255, 251, 240, 0.97) 0%, rgba(247, 238, 218, 0.95) 100%);
  border: 1px solid rgba(31, 24, 18, 0.08);
  border-left: 3px solid rgba(31, 24, 18, .12);
  border-radius: 12px;
  cursor: pointer;
  transition: border-left-color .18s ease, transform .18s ease, box-shadow .18s ease;
  box-shadow: 0 1px 0 rgba(255,255,255,.65) inset;
}
.wr-re-rb-card:hover {
  transform: translateY(-1px);
  border-left-color: color-mix(in srgb, var(--mode-accent) 60%, transparent);
}
.wr-re-rb-card.is-picked {
  border-left-color: var(--mode-accent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--mode-accent) 6%, rgba(255,251,240,.97)) 0%, color-mix(in srgb, var(--mode-accent) 4%, rgba(247,238,218,.95)) 100%);
}
.wr-re-rb-num {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 500;
  background: rgba(31, 24, 18, .04);
  color: #4A3F33;
  border: 1px solid rgba(31, 24, 18, .14);
  margin-top: 1px;
  transition: background-color .2s, color .2s, border-color .2s;
}
.wr-re-rb-card.is-picked .wr-re-rb-num {
  background: var(--mode-accent);
  color: #FBF4E2;
  border-color: var(--mode-accent);
}
.wr-re-rb-num.is-pop {
  animation: wr-re-num-pop .42s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes wr-re-num-pop {
  0%   { transform: scale(.4); }
  55%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.wr-re-rb-text {
  flex: 1 1 auto;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.55;
  color: #1F1812;
}

/* ── Reveal layout (shared) ──────────────────────────────────── */
.wr-re-rev-score {
  padding: 1.2rem 1.4rem;
  margin: .2rem 0 1.4rem;
  background: linear-gradient(135deg, color-mix(in srgb, var(--mode-accent) 10%, transparent) 0%, transparent 100%);
  border: 1px solid color-mix(in srgb, var(--mode-accent) 25%, transparent);
  border-left: 3px solid var(--mode-accent);
  border-radius: 12px;
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}
.wr-re-rev-score-num {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 2.2rem;
  font-weight: 500;
  color: var(--ielts-ink, #F2E6CC);
  line-height: 1;
}
.wr-re-rev-score-of {
  font-size: 1.05rem;
  color: var(--ielts-ink-soft, #B6A484);
  margin-left: 6px;
}
.wr-re-rev-score-l {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .9rem;
  color: var(--ielts-ink-soft, #B6A484);
}

.wr-re-sentences.is-revealed,
.wr-re-rb-stack.is-revealed {
  margin-bottom: 1.6rem;
}
.wr-re-sent-card.is-revealed,
.wr-re-rb-card.is-revealed {
  cursor: default;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  animation: wr-re-reveal-in .42s cubic-bezier(.4, 0, .2, 1) forwards;
  animation-delay: var(--reveal-delay, 0ms);
}
@keyframes wr-re-reveal-in {
  to { opacity: 1; transform: translateY(0); }
}
.wr-re-sent-card.is-revealed.is-correct,
.wr-re-rb-card.is-revealed.is-correct {
  border-left-color: #2E7D5B;
  background: linear-gradient(180deg, rgba(238, 247, 240, 0.97) 0%, rgba(228, 240, 232, 0.95) 100%);
}
.wr-re-sent-card.is-revealed.is-wrong,
.wr-re-rb-card.is-revealed.is-wrong {
  border-left-color: #C24A2B;
  background: linear-gradient(180deg, rgba(252, 240, 234, 0.97) 0%, rgba(245, 226, 215, 0.95) 100%);
  animation: wr-re-reveal-in .42s cubic-bezier(.4, 0, .2, 1) forwards, wr-re-wrong-shake .42s ease;
  animation-delay: var(--reveal-delay, 0ms), calc(var(--reveal-delay, 0ms) + .42s);
}
@keyframes wr-re-wrong-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

.wr-re-stamp {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  border-radius: 999px;
  flex: 0 0 auto;
  margin-left: 12px;
  margin-top: 1px;
}
.wr-re-stamp.is-correct {
  background: #2E7D5B;
  color: #F4FCF7;
}
.wr-re-stamp.is-wrong {
  background: #C24A2B;
  color: #FCEFE9;
}

.wr-re-rev-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-left: 42px;
  margin-top: .65rem;
}
.wr-re-rev-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .82rem;
  font-weight: 600;
}
.wr-re-rev-chip.is-correct {
  background: rgba(46, 125, 91, .14);
  color: #1E5A40;
  border: 1px solid rgba(46, 125, 91, .35);
}
.wr-re-rev-chip.is-wrong {
  background: rgba(194, 74, 43, .10);
  color: #8C3520;
  border: 1px solid rgba(194, 74, 43, .35);
}
.wr-re-rev-chip-strike {
  text-decoration: line-through;
  text-decoration-color: rgba(140, 53, 32, .55);
  text-decoration-thickness: 2px;
}
.wr-re-rev-arrow {
  color: #6B5E4A;
  font-weight: 700;
  font-size: .95rem;
}
.wr-re-rev-why {
  padding-left: 42px;
  margin-top: .55rem;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .92rem;
  line-height: 1.55;
  color: #4A3F33;
  font-style: italic;
}

/* New: paired explanation blocks (mistake-context + why-correct). */
.wr-re-rev-explain {
  margin: .65rem 0 0 42px;
  padding: .7rem .95rem .8rem;
  border-radius: 10px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .92rem;
  line-height: 1.55;
}
.wr-re-rev-explain.is-mistake {
  background: rgba(194, 74, 43, .07);
  border: 1px solid rgba(194, 74, 43, .22);
  border-left: 3px solid #C24A2B;
  color: #4A2A1F;
}
.wr-re-rev-explain.is-why {
  background: rgba(31, 24, 18, .04);
  border: 1px solid rgba(31, 24, 18, .10);
  border-left: 3px solid color-mix(in srgb, var(--mode-accent) 70%, #000);
  color: #2A2118;
}
.wr-re-rev-explain-h {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 4px;
  color: inherit;
  opacity: .75;
}
.wr-re-rev-explain.is-mistake .wr-re-rev-explain-h { color: #8C3520; opacity: 1; }
.wr-re-rev-explain.is-why     .wr-re-rev-explain-h { color: color-mix(in srgb, var(--mode-accent) 75%, #000); opacity: 1; }
.wr-re-rev-explain-h em {
  font-style: normal;
  font-weight: 700;
}
.wr-re-rev-explain-b {
  color: inherit;
  line-height: 1.55;
}

/* ── Rebuild reveal extras ───────────────────────────────────── */
.wr-re-rb-num.is-locked {
  background: rgba(31, 24, 18, .08);
  color: #4A3F33;
  border-color: rgba(31, 24, 18, .14);
}
.wr-re-rb-card.is-revealed.is-correct .wr-re-rb-num.is-locked {
  background: #2E7D5B;
  color: #F4FCF7;
  border-color: #2E7D5B;
}
.wr-re-rb-card.is-revealed.is-wrong .wr-re-rb-num.is-locked {
  background: #C24A2B;
  color: #FCEFE9;
  border-color: #C24A2B;
}
.wr-re-rb-slot-note {
  padding-left: 52px;
  margin-top: .5rem;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .85rem;
  color: #8C3520;
}
.wr-re-rb-slot-note strong {
  font-weight: 700;
}

.wr-re-rb-sec-h {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--ielts-ink, #F2E6CC);
  margin: 1.4rem 0 .25rem;
}
.wr-re-rb-sec-sub {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .9rem;
  color: var(--ielts-ink-soft, #B6A484);
  margin: 0 0 .8rem;
  line-height: 1.45;
}
.wr-re-rb-model {
  list-style: none;
  padding: 0;
  margin: 0 0 1.2rem;
  display: flex;
  flex-direction: column;
  gap: .8rem;
}
.wr-re-rb-model-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 1rem 1.2rem;
  background: linear-gradient(180deg, rgba(255, 251, 240, 0.97) 0%, rgba(247, 238, 218, 0.95) 100%);
  border: 1px solid rgba(31, 24, 18, 0.08);
  border-left: 3px solid var(--mode-accent);
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(255,255,255,.65) inset;
}
.wr-re-rb-model-num {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: .95rem;
  font-weight: 500;
  background: var(--mode-accent);
  color: #FBF4E2;
  margin-top: 1px;
}
.wr-re-rb-model-body { flex: 1 1 auto; min-width: 0; }
.wr-re-rb-model-text {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.02rem;
  line-height: 1.55;
  color: #1F1812;
}
.wr-re-rb-model-why {
  margin-top: .5rem;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .88rem;
  line-height: 1.5;
  color: #4A3F33;
  font-style: italic;
}

/* ── Actions / CTAs ──────────────────────────────────────────── */
.wr-re-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 1.6rem 0 0;
}
.wr-re-cta {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: 999px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .92rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform .15s, background-color .15s, color .15s, border-color .15s, box-shadow .15s;
}
.wr-re-cta.is-primary {
  background: var(--ielts-honey, #D9A268);
  color: #1F1812;
  border-color: var(--ielts-honey, #D9A268);
}
.wr-re-cta.is-primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ielts-honey, #D9A268) 88%, white);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px -10px rgba(217, 162, 104, .65);
}
.wr-re-cta.is-primary:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.wr-re-cta.is-ghost {
  background: rgba(242, 230, 204, .04);
  color: var(--ielts-ink, #F2E6CC);
  border-color: var(--ielts-line, rgba(242, 230, 204, .14));
}
.wr-re-cta.is-ghost:hover {
  border-color: color-mix(in srgb, var(--ielts-honey, #D9A268) 35%, transparent);
  background: rgba(242, 230, 204, .08);
}

/* ── Summary page ────────────────────────────────────────────── */
.wr-re-summary-page .wr-re-hero {
  margin: 1.2rem 0 1.6rem;
  padding: 1.6rem 1.8rem;
  background: linear-gradient(135deg, color-mix(in srgb, var(--mode-accent) 16%, transparent) 0%, transparent 60%);
  border: 1px solid color-mix(in srgb, var(--mode-accent) 30%, transparent);
  border-left: 3px solid var(--mode-accent);
  border-radius: 14px;
  display: flex;
  gap: 1.8rem;
  align-items: center;
  flex-wrap: wrap;
}
.wr-re-summary-page .wr-re-hero.is-elite { --mode-accent: #4F8F70; }
.wr-re-summary-page .wr-re-hero.is-good  { --mode-accent: #B57A2E; }
.wr-re-summary-page .wr-re-hero.is-mid   { --mode-accent: #C9942F; }
.wr-re-summary-page .wr-re-hero.is-weak  { --mode-accent: #C24A2B; }

.wr-re-hero-score { display: flex; align-items: baseline; gap: 14px; }
.wr-re-hero-num {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 3rem;
  font-weight: 500;
  color: var(--ielts-ink, #F2E6CC);
  line-height: 1;
}
.wr-re-hero-of {
  font-size: 1.3rem;
  color: var(--ielts-ink-soft, #B6A484);
  margin-left: 4px;
}
.wr-re-hero-pct {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.6rem;
  font-weight: 500;
  color: var(--mode-accent);
}
.wr-re-hero-msg {
  flex: 1 1 320px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ielts-ink, #F2E6CC);
}

.wr-re-summary-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.6rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.wr-re-summary-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1.1rem;
  background: linear-gradient(180deg, rgba(255, 251, 240, 0.97) 0%, rgba(247, 238, 218, 0.95) 100%);
  border: 1px solid rgba(31, 24, 18, 0.08);
  border-left: 3px solid var(--mode-accent);
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(255,255,255,.65) inset;
}
.wr-re-summary-item-l {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.wr-re-summary-item-meta {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--mode-accent);
}
.wr-re-summary-item-prompt {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: .95rem;
  color: #1F1812;
  line-height: 1.4;
  font-style: italic;
}
.wr-re-summary-item-r {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.wr-re-summary-item-pct {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.3rem;
  font-weight: 500;
  color: #1F1812;
  line-height: 1;
}
.wr-re-summary-item-frac {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .76rem;
  color: #6B5E4A;
}

.wr-re-summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 1.4rem;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 960px) {
  /* Below 960 the two-column decode layout collapses — sentences
     stack first, then the chip pool below (and the pool reverts to
     its old wrapped-row layout, sticky to the bottom of the
     viewport). */
  .wr-re-decode-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .wr-re-decode-grid .wr-re-pool-wrap {
    position: sticky;
    top: auto;
    bottom: 12px;
    max-height: 45vh;
    backdrop-filter: blur(10px);
    background-color: rgba(38, 30, 22, .85);
  }
  .wr-re-decode-grid .wr-re-pool {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .wr-re-decode-grid .wr-re-chip {
    width: auto;
  }
  .wr-re-decode-grid .wr-re-pool-head {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
  }
}
@media (max-width: 720px) {
  .wr-re-mode-grid { grid-template-columns: 1fr; }
  .wr-re-title { font-size: 2rem; }
  .wr-re-rev-row,
  .wr-re-rev-why { padding-left: 0; }
  .wr-re-rev-explain { margin-left: 0; }
  .wr-re-rb-slot-note { padding-left: 0; }
  .wr-re-sent-slot { padding-left: 0; }
  .wr-re-stamp { margin-left: 0; margin-top: 8px; }
  .wr-re-sent-row { flex-wrap: wrap; }
  .wr-re-hero-num { font-size: 2.4rem; }
}

/* When armed, hint the body cursor as a "carrying chip" affordance */
body.is-wr-re-armed { cursor: crosshair; }
body.is-wr-re-armed .wr-re-sent-card { cursor: cell; }
