/* Worksheet maker: question cards on the left, "Your worksheet" (summary and download) on the right. */
.ws-wrap { max-width: 1120px; margin: auto; }
.ws-intro { margin-bottom: 18px; }
.ws-intro h1 { font-size: clamp(22px, 3vw, 28px); line-height: 1.25; margin: 0 0 6px; }
.ws-intro p { max-width: 640px; margin: 0; }

.ws-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.ws-builder { min-width: 0; }
.ws-list { display: grid; gap: 12px; }
.ws-list:not(:empty) { margin-bottom: 12px; }

.ws-step {
  flex: none; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: var(--text-on-primary, #fff); font-size: 13px; font-weight: 700;
}

/* ── A question card ── */
.ws-q { padding: 14px 16px 16px; min-width: 0; scroll-margin-top: 90px; }
.ws-q-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.ws-q-kind { display: inline-flex; align-items: center; gap: 6px; margin-inline-end: auto; padding-inline-start: 4px; font-size: 13px; font-weight: 700; color: var(--text-muted); }
.ws-marks { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); margin-inline-end: 4px; }
.ws-marks .input { width: 58px; height: 32px; padding: 0 8px; text-align: center; }
.ws-q-text { display: block; width: 100%; min-height: 44px; line-height: 1.6; font-size: 16px; resize: none; overflow: hidden; }
.ws-q [aria-invalid="true"] { border-color: var(--bad-ink, #b42318); }
.ws-q .hint-text { margin: 8px 0 0; }
.ws-q .field { margin: 12px 0 0; }
.ws-q-note { margin: 10px 0 0; font-size: 13px; font-weight: 600; color: var(--warning-strong, #9a5b00); }
.ws-q-note::before { content: "→ "; }

/* Fill in the blank: the sentence again, as words to tap, then as students see it. */
.ws-tapbox { margin-top: 10px; padding: 10px 12px; background: var(--surface-subtle, rgba(0,0,0,.03)); border: 1px solid var(--border); border-radius: 10px; }
.ws-tapbox.is-waiting { border: 1.5px dashed var(--primary); }
.ws-tap-caption { margin: 0 0 4px; font-size: 13px; font-weight: 600; line-height: 1.45; color: var(--text-muted); }
.ws-tapbox.is-waiting .ws-tap-caption { color: var(--text); }
.ws-tap { line-height: 2.5; font-size: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ws-tap-seen { margin: 6px 0 0; padding-top: 8px; border-top: 1px solid var(--border); font-size: 14px; line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere; }
.ws-tap-seen b { font-size: 12px; color: var(--text-muted); }
.ws-gap { display: inline-block; min-width: 70px; border-bottom: 1.5px solid currentColor; margin: 0 4px; }
.ws-word {
  font: inherit; color: inherit; background: var(--surface); cursor: pointer;
  padding: 3px 7px; margin: 0 1px; border: 1px solid var(--border-strong, var(--border)); border-radius: 7px;
  transition: background var(--dur-fast, .12s), border-color var(--dur-fast, .12s);
}
.ws-word:hover { background: var(--primary-softer, rgba(15,118,110,.08)); border-color: var(--primary); }
.ws-word:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.ws-word.is-blank { background: var(--primary-soft, rgba(15,118,110,.14)); border: 1px solid var(--primary); font-weight: 700; padding: 3px 9px; margin: 0 2px; }
.ws-word.is-blank::after { content: "×"; margin-inline-start: 6px; font-weight: 400; opacity: .6; }
.ws-tap-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 6px; }
.ws-tap-tools:empty { display: none; }
.ws-tap-tip { font-size: 12.5px; color: var(--text-muted); }

/* Options and ordering items. */
.ws-rows { display: grid; gap: 8px; margin-top: 10px; }
.ws-row { display: flex; align-items: center; gap: 8px; }
.ws-row .input { flex: 1; min-width: 0; }
.ws-row-add { justify-self: start; }
.ws-mark {
  flex: none; display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  background: var(--surface); border: 2px solid var(--border-strong, var(--border)); color: transparent;
}
.ws-mark:hover { border-color: var(--success, #0f9d6b); }
.ws-mark[aria-pressed="true"] { background: var(--success, #0f9d6b); border-color: var(--success, #0f9d6b); color: #fff; }
.ws-mark:focus-visible, .ws-tf:focus-visible, .ws-kind:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.ws-order-n { flex: none; width: 30px; text-align: center; font-weight: 700; color: var(--text-muted); }
.ws-tf-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--text-muted); }
.ws-tf {
  font: inherit; font-weight: 700; cursor: pointer; min-width: 84px; height: 38px; padding: 0 16px; border-radius: 10px;
  background: var(--surface); color: var(--text); border: 1.5px solid var(--border-strong, var(--border));
}
.ws-tf[aria-pressed="true"] { background: var(--success, #0f9d6b); border-color: var(--success, #0f9d6b); color: #fff; }

/* Drag to reorder: the grip, the row or card being carried, and the line that shows where it lands. */
.ws-grip {
  flex: none; display: inline-grid; place-items: center; width: 24px; height: 32px; padding: 0; border: 0; border-radius: 6px;
  background: none; color: var(--text-faint, var(--text-muted)); cursor: grab; touch-action: none;
}
.ws-grip:hover { color: var(--text); background: var(--surface-hover, rgba(0,0,0,.05)); }
.ws-grip:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.ws-grip:active { cursor: grabbing; }
.ws-q-head .ws-grip { margin-inline-start: -6px; }
.ws-row, .ws-q { position: relative; }
.is-dragging { z-index: 5; opacity: .92; box-shadow: var(--shadow-raised, 0 8px 24px rgba(0,0,0,.18)); background: var(--surface); border-radius: 10px; }
.drop-before::before, .drop-after::after { content: ""; position: absolute; left: 0; right: 0; height: 3px; border-radius: 2px; background: var(--primary); }
.drop-before::before { top: -6px; }
.drop-after::after { bottom: -6px; }
.ws-q.drop-before::before { top: -8px; }
.ws-q.drop-after::after { bottom: -8px; }

/* ── Add a question ── */
.ws-adder { padding: 16px; border: 1.5px dashed var(--border-strong, var(--border)); border-radius: var(--r-lg, 16px); }
.ws-adder h2 { font-size: 15px; margin: 0 0 10px; }
.ws-adder > .muted { margin: -4px 0 12px; font-size: 13px; }
.ws-adder.is-empty { padding: 22px; background: var(--surface); border-style: solid; border-width: 1px; border-color: var(--border); }
.ws-adder.is-empty h2 { font-size: 18px; }
.ws-kinds { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ws-adder.is-empty .ws-kinds { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.ws-kind {
  display: flex; align-items: center; gap: 10px; text-align: start; cursor: pointer; font: inherit; color: var(--text);
  padding: 10px 12px; min-height: 44px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  transition: border-color var(--dur-fast, .12s), background var(--dur-fast, .12s);
}
.ws-kind:hover { border-color: var(--primary); background: var(--primary-softer, rgba(15,118,110,.06)); }
.ws-kind .icon { flex: none; color: var(--primary); }
.ws-kind b { display: block; font-size: 13.5px; }
.ws-kind small { display: none; font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }
.ws-adder.is-empty .ws-kind { padding: 14px; }
.ws-adder.is-empty .ws-kind small { display: block; }
.ws-adder-foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ws-adder > .btn { margin-top: 10px; }

/* ── Your worksheet ── */
.ws-side { position: sticky; top: calc(var(--topbar-h, 64px) + 16px); padding: 20px; min-width: 0; }
.ws-side h2 { font-size: 17px; margin: 0 0 14px; }
.ws-side .field { margin-bottom: 10px; }
.ws-side-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; }
.ws-summary { margin: 0; font-weight: 700; }
.ws-undo { display: inline-flex; align-items: center; gap: 2px; }
.ws-option { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; margin-top: 8px; border-top: 1px solid var(--border); cursor: pointer; }
.ws-option b { display: block; font-size: 14px; }
.ws-option small { display: block; font-size: 12.5px; color: var(--text-muted); line-height: 1.45; margin-top: 2px; }
.ws-status-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; margin-bottom: 12px; border-top: 1px solid var(--border); }
.ws-status { font-size: 13.5px; font-weight: 600; line-height: 1.45; }
.ws-status.ws-ready { color: var(--success-strong, #0f7a4d); }
.ws-status.ws-ready::before { content: "✓ "; }
.ws-status.ws-error { color: var(--bad-ink, #b42318); }
.ws-status-row .btn { flex: none; }
.ws-actions { display: grid; gap: 8px; }
.ws-next { margin-top: 16px; padding: 12px 14px; border-radius: 12px; background: var(--surface-subtle, rgba(0,0,0,.03)); font-size: 12.5px; line-height: 1.5; }
.ws-next ul { margin: 6px 0 0; padding-inline-start: 18px; color: var(--text-muted); }
.ws-notice { font-size: 12.5px; color: var(--text-muted); margin: 12px 0 0; line-height: 1.55; }
.ws-mobile-dock { display: none; }

@media (max-width: 900px) {
  .ws-wrap { padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
  .ws-intro { margin-bottom: 14px; }
  .ws-grid { grid-template-columns: 1fr; gap: 14px; }
  .ws-side { position: static; padding: 16px; }
  .ws-q { padding: 12px; }
  .ws-adder, .ws-adder.is-empty { padding: 14px; }
  .ws-adder.is-empty .ws-kinds { grid-template-columns: 1fr; }
  /* Bigger targets for a finger. */
  .ws-tap { line-height: 2.9; }
  .ws-word { padding: 6px 8px; }
  .ws-word.is-blank { padding: 6px 10px; }
  .ws-mark { width: 36px; height: 36px; }
  .ws-grip { height: 40px; }
  .ws-row { gap: 6px; }
  .ws-tf { height: 44px; }
  .ws-mobile-dock {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -5px 24px rgba(0,0,0,.06);
  }
  .ws-mobile-status { font-size: 12px; max-width: 44%; line-height: 1.5; }
  .ws-mobile-dock .btn { min-height: 44px; flex-shrink: 0; }
}
@media (max-width: 420px) {
  .ws-marks span { display: none; }
  /* The grip already moves a question (drag, or arrow keys), so a narrow phone drops the two arrow buttons. */
  .ws-up, .ws-down { display: none; }
}
@media (max-width: 360px) {
  .ws-mobile-dock { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .ws-mobile-dock .btn { font-size: 12px; padding-inline: 12px; }
}
@media (max-height: 480px) {
  .ws-mobile-dock { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ws-word, .ws-kind { transition: none; }
}

/* Worksheet maker: its intro is the page header now (the duplicate top bar is hidden), in the same header card as every page. */
.ws-intro { position: relative; isolation: isolate; overflow: hidden; padding: 22px 24px; border: 1px solid color-mix(in srgb, var(--primary) 16%, var(--border)); border-radius: 20px;
  background:
    radial-gradient(120% 160% at 100% 0%, color-mix(in srgb, var(--primary) 12%, transparent) 0%, transparent 46%),
    linear-gradient(180deg, color-mix(in srgb, var(--primary) 5%, var(--surface)) 0%, var(--surface) 100%);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 18px 40px -28px color-mix(in srgb, var(--primary) 55%, transparent); }
.ws-intro::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 40%, var(--surface))); }
.ws-intro::after { content: ""; position: absolute; top: 0; right: 0; width: 44%; height: 150px; z-index: -1; pointer-events: none;
  background-image: radial-gradient(color-mix(in srgb, var(--primary) 26%, transparent) 1.2px, transparent 1.5px); background-size: 16px 16px;
  -webkit-mask-image: linear-gradient(215deg, #000 0%, transparent 62%); mask-image: linear-gradient(215deg, #000 0%, transparent 62%); }
.ws-intro h1 { letter-spacing: -.015em; }
@media (max-width: 600px) { .ws-intro { padding: 18px 16px; border-radius: 16px; } }
