/* ═══════════════════════════════════════════════════════════════
   CLOTO SCENE EDITOR — CSS
   Classes: .cw-*
   ═══════════════════════════════════════════════════════════════ */

/* ── Scene wrapper: fills workspace, scrolls internally ── */
.cw-scene {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-10);
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Title ── */
.cw-scene-title {
  font-family: var(--cloto-font-brand);
  font-size: var(--cloto-fs-2xl);
  font-weight: 400;
  color: var(--cloto-text-100);
  line-height: 1.3;
  margin: 0;
}

/* ── Synopsis panel (context above editor, not a separate box) ── */
.cw-scene-synopsis {
  border: none;
  margin: 0;
  background: transparent;
  border-radius: 0;
  padding: 0;
  border-left: none;
}

.cw-scene-synopsis > summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-xs);
  font-weight: 500;
  color: var(--cloto-text-70);
  letter-spacing: 0.3px;
  list-style: none;
  user-select: none;
  padding: var(--space-1) 0;
  transition: color 150ms ease;
}

.cw-scene-synopsis > summary:hover {
  color: var(--cloto-text-50);
}

/* Custom arrow */
.cw-scene-synopsis > summary::after {
  content: '\25B8';
  font-size: 10px;
  color: var(--cloto-text-20);
  display: inline-block;
  margin-left: auto;
}

.cw-scene-synopsis[open] > summary::after {
  content: '\25BE';
}

.cw-scene-synopsis > summary::-webkit-details-marker { display: none; }
.cw-scene-synopsis > summary::marker { display: none; content: ''; }

.cw-scene-synopsis-text {
  font-family: var(--cloto-font-system, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  font-size: 1em;
  color: var(--cloto-text-70);
  line-height: 1.7;
  padding: var(--space-4) 0 var(--space-1) 0;
  white-space: pre-wrap;
}

/* ── Textarea (the page) — generous, immersive writing surface ── */
.cw-scene-textarea {
  flex: 1 1 auto;
  min-height: 60vh;
  width: 100%;
  box-sizing: border-box;
  resize: none;
  overflow-y: auto;

  font-family: var(--cloto-font-display, 'Cardo', serif);
  font-size: 1.1em;
  font-weight: 400;
  color: var(--cloto-text-100);
  line-height: 1.8;

  background: transparent;
  border: 1px solid transparent;
  border-radius: 0;
  padding: 16px 24px;

  transition: border-color 200ms ease;
}

.cw-scene-textarea:focus {
  outline: none;
  border-color: transparent;
  box-shadow: none;
}

.cw-scene-textarea::placeholder {
  color: var(--cloto-text-50);
  font-style: italic;
  font-size: 0.95em;
}
body.fd-light .cw-scene-textarea::placeholder {
  color: #888;
}



/* ── Restore original banner ── */
.cw-restore-original {
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-sm);
  color: var(--cloto-teal);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  margin-top: var(--space-3);
  background: var(--cloto-teal-a8);
  border: 1px solid var(--cloto-teal-a12);
  border-radius: var(--radius-md);
  transition: background var(--duration-slow), border-color var(--duration-slow);
}

.cw-restore-original:hover {
  background: var(--cloto-teal-a15);
  border-color: var(--cloto-teal-a25);
}

/* ── Bottom bar ── */
.cw-scene-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-4);
  padding: var(--space-2) 0;
  flex-shrink: 0;
}

.cw-scene-bar .cw-scene-save-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: transparent;
  transition: background var(--duration-normal) var(--ease-spring),
              opacity var(--duration-slow) var(--ease-spring);
  flex-shrink: 0;
}

.cw-scene-bar .cw-scene-save-dot.is-saving {
  background: var(--cloto-gold);
  animation: cloto-save-pulse 0.8s ease-in-out infinite;
}

.cw-scene-bar .cw-scene-save-dot.is-saved {
  background: var(--cloto-success);
  animation: cloto-dot-flash 1.5s forwards;
}

/* Submit button: AI style (gold) */
.cw-scene-submit {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 32px;
  padding: var(--space-3) var(--space-7);
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-sm);
  font-weight: 500;
  color: var(--cloto-gold);
  background: var(--cloto-gold-a8);
  border: 1px solid var(--cloto-gold-a20);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration-normal) var(--ease-spring),
              border-color var(--duration-normal) var(--ease-spring),
              opacity var(--duration-normal) var(--ease-spring);
}

.cw-scene-submit:hover:not(:disabled) {
  background: var(--cloto-gold-a12);
  border-color: var(--cloto-gold-a25);
}

.cw-scene-submit:disabled {
  opacity: var(--opacity-disabled);
  cursor: not-allowed;
  pointer-events: none;
}

/* Submit spinner — golden spiral logo rotating */
.cw-scene-submit-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 180 180' fill='none'%3E%3Ccircle cx='90' cy='90' r='75.6' stroke='%23c9a84c' stroke-width='21.6' fill='none' opacity='0.8' stroke-dasharray='342 648' transform='rotate(0 90 90)'/%3E%3Ccircle cx='90' cy='90' r='46.8' stroke='%23c9a84c' stroke-width='21.6' fill='none' opacity='0.45' stroke-dasharray='216 648' transform='rotate(55 90 90)'/%3E%3Ccircle cx='90' cy='90' r='16.2' fill='%23c9a84c'/%3E%3C/svg%3E") no-repeat center / contain;
  animation: cw-spin 3s linear infinite;
}

@keyframes cw-spin {
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════
   TESSILA — Tessuto view + infusion highlights + tooltips
   ═══════════════════════════════════════════════════════════════ */

/* ── Tessuto view: shows the woven text with highlights ── */
/* Must mirror .cw-scene-textarea exactly for visual continuity */
.cw-tessuto-view {
  flex: 1 1 auto;
  min-height: 200px;
  overflow-y: auto;

  /* Identical to .cw-scene-textarea */
  font-family: var(--cloto-font-display, 'Cardo', serif);
  font-size: 1.1em;
  font-weight: 400;
  color: var(--cloto-text-100);
  line-height: 1.8;
  white-space: pre-wrap;

  background: transparent;
  border: 1px solid transparent;
  border-radius: 0;
  padding: 16px 24px;
}

/* ── Infusion highlight: teal underline ── */
.cw-infusion {
  border-bottom: 2px solid rgba(45, 212, 191, 0.5);
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.cw-infusion:hover {
  border-bottom-color: var(--cloto-teal);
}

/* ── Correction highlight: gold dotted underline ── */
.cw-correction {
  border-bottom: 2px dotted rgba(154, 126, 48, 0.5);
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.cw-correction:hover {
  border-bottom-color: var(--cloto-gold);
}

/* ── Infusion tooltip (popover) ── */
.cw-infusion-tooltip {
  position: fixed;
  max-width: 320px;
  padding: 10px 14px;
  background: var(--cloto-elevated-bg, #1a1a2e);
  border: 1px solid rgba(45, 212, 191, 0.3);
  border-radius: var(--radius-md, 8px);
  font-family: var(--cloto-font-ui);
  font-size: 0.82rem;
  line-height: 1.55;
  color: #f0eeea;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.cw-infusion-tooltip .cw-fonte {
  font-style: italic;
  margin-top: 4px;
  color: #a8adb5;
}
.cw-correction-reason {
  font-size: 12px;
  color: var(--cloto-gold, #c9a84c);
  font-style: italic;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* ── Editorial note highlight: blue underline ── */
.cw-note {
  border-bottom: 2px solid rgba(94, 198, 198, 0.5);
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.cw-note:hover {
  border-bottom-color: var(--cloto-teal);
}
.cw-note.cw-el-accepted {
  background: rgba(94, 198, 198, 0.08);
  border-bottom-color: var(--cloto-teal);
}
.cw-note.cw-el-rejected {
  border-bottom: none;
  opacity: 0.6;
}
.cw-note.cw-el-editing {
  outline: 1px dashed var(--cloto-teal);
  border-radius: 2px;
  padding: 1px 2px;
}

/* ── Tooltip proposal text ── */
.cw-tip-proposal {
  font-style: italic;
  color: var(--cloto-teal);
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
body.fd-light .cw-tip-proposal {
  color: var(--cloto-teal-deep, #0e5454);
  border-bottom-color: rgba(0,0,0,0.06);
}

/* ── Action buttons bar (centered) ── */
.cw-tessila-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  justify-content: center;
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: var(--cloto-surface);
  border-top: 1px solid var(--cloto-glass-border);
  margin: 0 calc(-1 * var(--space-10));
  padding: var(--space-4) var(--space-10);
}

.cw-tessila-btn {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: var(--space-3) var(--space-6);
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-spring),
              border-color var(--duration-fast) var(--ease-spring);
}

/* "Originale" — outline */
.cw-tessila-btn--revert {
  color: var(--cloto-text-60);
  background: transparent;
  border-color: var(--cloto-text-25);
}

.cw-tessila-btn--revert:hover {
  background: var(--cloto-glass-border);
  border-color: var(--cloto-text-25);
}

/* "Modifica" — outline */
.cw-tessila-btn--edit {
  color: var(--cloto-text-60);
  background: transparent;
  border-color: var(--cloto-text-25);
}

.cw-tessila-btn--edit:hover {
  background: var(--cloto-glass-border);
  border-color: var(--cloto-text-25);
}

/* ── First-tessila hint banner ── */
.cw-tessila-hint {
  font-family: var(--cloto-font-ui);
  font-size: 0.78rem;
  color: var(--cloto-text-50);
  background: var(--cloto-teal-a6);
  border: 1px solid var(--cloto-teal-a25);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-6);
  margin: 0 0 var(--space-3);
  text-align: center;
}
.cw-tessila-hint__icon {
  margin-right: 4px;
  opacity: 0.7;
}

/* ── Pending indicator on tessila button ── */
.has-pending {
  border-color: var(--cloto-teal-a25);
  animation: cw-nota-pulse 2s infinite;
}

/* ── Stats line (centered, below actions) ── */
.cw-tessila-stats {
  font-family: var(--cloto-font-ui);
  font-size: 0.75rem;
  color: var(--cloto-text-40);
  text-align: center;
  padding: var(--space-2) 0;
}

/* ── Granular review: element states ── */

/* Accepted: underline fades */
.cw-el-accepted {
  border-bottom-color: transparent;
  transition: border-color 0.4s ease-out;
}

/* Rejected: strikethrough + fade */
.cw-el-rejected {
  text-decoration: line-through;
  text-decoration-color: rgba(220, 80, 80, 0.6);
  opacity: 0.4;
  transition: opacity 0.4s ease-out;
}

/* Modified: dashed teal */
.cw-el-modified {
  border-bottom: 2px dashed var(--cloto-teal);
  background: var(--cloto-teal-a6);
}


/* ── Popover action buttons ── */
.cw-tip-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--cloto-glass-border);
}

.cw-tip-btn {
  padding: 8px 16px;
  font-family: var(--cloto-font-ui);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}

/* Accept: teal pill */
.cw-tip-btn--accept { background: #5ec6c6; color: #0b0e15; }
.cw-tip-btn--accept:hover { background: #6fd0d0; }
/* Edit/Rewrite: outline grey */
.cw-tip-btn--edit   { color: #ccc; border: 1px solid rgba(255,255,255,0.2); background: transparent; }
.cw-tip-btn--edit:hover   { background: rgba(255,255,255,0.06); }
.cw-tip-btn--ok     { color: #ccc; border: 1px solid rgba(255,255,255,0.2); background: transparent; }
.cw-tip-btn--ok:hover     { background: rgba(255,255,255,0.06); }
/* Reject: text-only red */
.cw-tip-btn--reject { color: #E06060; background: transparent; border: none; }
.cw-tip-btn--reject:hover { color: #f07070; }

.cw-tip-divider { border: none; border-top: 1px solid var(--cloto-glass-border); margin: 6px 0; }


/* ── Confirm button (enabled/disabled) ── */
.cw-tessila-btn--confirm {
  color: #0b0e15;
  background: var(--cloto-teal);
  border-color: var(--cloto-teal);
}
.cw-tessila-btn--confirm:hover:not(:disabled) {
  background: var(--cloto-teal-bright);
}

/* ── Discard button ── */
.cw-tessila-btn--discard {
  color: #dc5050;
  background: transparent;
  border-color: rgba(220,80,80,0.3);
}
.cw-tessila-btn--discard:hover {
  background: rgba(220,80,80,0.08);
}

/* ── Inline edit (contenteditable) ── */
.cw-inline-editing {
  outline: 1px dashed var(--cloto-teal);
  outline-offset: 2px;
  border-bottom: none;
  background: var(--cloto-teal-a6);
  min-width: 40px;
}
.cw-inline-edit-actions {
  display: inline-flex;
  gap: 4px;
  margin-left: 4px;
  vertical-align: middle;
}
.cw-inline-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 0.65rem;
  border-radius: 3px;
  border: 1px solid var(--cloto-text-25);
  background: var(--cloto-bg-20, #1a1a2e);
  color: var(--cloto-text-60);
  cursor: pointer;
  line-height: 1;
}
.cw-inline-edit-btn--ok { color: var(--cloto-teal); }
.cw-inline-edit-btn--cancel { color: #dc5050; }

/* ── Popover: decided state info ── */
.cw-tip-decided {
  font-size: 0.72rem;
  color: var(--cloto-text-40);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cw-tip-decided-label {
  font-style: italic;
}
.cw-tip-undo {
  color: var(--cloto-teal);
  cursor: pointer;
  text-decoration: underline;
  font-size: 0.72rem;
  background: none;
  border: none;
  padding: 0;
  font-family: var(--cloto-font-ui);
}

/* ── Workspace basic card (non-scene) ── */
.cw-ws-basic {
  padding: var(--space-6) var(--space-10);
}

.cw-ws-basic-title {
  font-family: var(--cloto-font-brand);
  font-size: var(--cloto-fs-2xl);
  font-weight: 400;
  color: var(--cloto-text-100);
  line-height: 1.3;
  margin: 0 0 var(--space-4);
}

.cw-ws-basic-body {
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-base);
  color: var(--cloto-text-70);
  line-height: 1.8;
  white-space: pre-wrap;
  max-height: 45vh;
  overflow-y: auto;
}

.cw-ws-basic-empty {
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-base);
  font-style: italic;
  color: var(--cloto-text-25);
  padding: var(--space-16) 0;
  text-align: center;
}

/* ── Reveal footer ── */
.cw-reveal-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-6) 0;
  opacity: 0;
  transition: opacity 0.4s ease-out;
}

.cw-reveal-footer.is-visible {
  opacity: 1;
}

.cw-reveal-celebration {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-family: var(--cloto-font-brand);
  font-size: var(--cloto-fs-md);
  font-style: italic;
  color: var(--cloto-text-40);
}

/* ── Light Theme ── */
body.fd-light .cw-scene-textarea {
  border-color: var(--cloto-surface-a8);
}

body.fd-light .cw-scene-textarea:focus {
  border-color: var(--cloto-teal-a25);
}

body.fd-light .cw-scene-submit {
  color: #7a6220;
  background: rgba(154, 126, 48, 0.08);
  border-color: rgba(154, 126, 48, 0.20);
}

body.fd-light .cw-scene-submit:hover:not(:disabled) {
  background: rgba(154, 126, 48, 0.12);
  border-color: rgba(154, 126, 48, 0.25);
}

body.fd-light .cw-infusion-tooltip {
  background: #f8f7f4;
  border-color: rgba(45, 212, 191, 0.25);
  color: #222;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body.fd-light .cw-tessila-actions {
  background: rgba(255, 255, 255, 0.85);
  border-top-color: var(--cloto-surface-a8);
}

body.fd-light .cw-tip-btn--accept { background: #0F6E56; color: #fff; }
body.fd-light .cw-tip-btn--accept:hover { background: #0a5a46; }
body.fd-light .cw-tip-btn--edit { color: #555; border-color: #ccc; }
body.fd-light .cw-tip-btn--edit:hover { background: rgba(0,0,0,0.04); }
body.fd-light .cw-tip-btn--ok { color: #555; border-color: #ccc; }
body.fd-light .cw-tip-btn--ok:hover { background: rgba(0,0,0,0.04); }
body.fd-light .cw-tip-btn--reject { color: #CC4444; }
body.fd-light .cw-tip-btn--reject:hover { color: #aa3333; }
body.fd-light .cw-inline-edit-btn { background: #f8f7f4; }
body.fd-light .cw-tessila-btn--confirm { color: #fff; }
body.fd-light .cw-tessila-btn--confirm:hover:not(:disabled) { color: #fff; background: #0a8a7a; }

/* ── Nota Scena button + modal ── */
.cw-tessila-btn--nota {
  position: relative;
  color: var(--cloto-teal);
  border-color: var(--cloto-teal-a30);
  background: var(--cloto-teal-a6);
}
.cw-tessila-btn--nota:hover {
  background: var(--cloto-teal-a12);
}
.cw-nota-icon { opacity: 0.8; }
.cw-nota-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 6px; height: 6px;
  background: var(--cloto-teal);
  border-radius: 50%;
  animation: cw-nota-pulse 2s infinite;
}
@keyframes cw-nota-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.cw-nota-modal-bg {
  position: fixed; inset: 0; z-index: 10000;
  background: var(--cloto-void-a60);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.2s;
}
.cw-nota-modal-bg.is-visible { opacity: 1; }
.cw-nota-modal {
  background: var(--cloto-elevated-bg);
  border: 1px solid var(--cloto-teal-a20);
  border-radius: 12px;
  max-width: 480px; width: 90%;
  padding: 24px;
  transform: translateY(10px);
  transition: transform 0.2s;
}
.cw-nota-modal-bg.is-visible .cw-nota-modal {
  transform: translateY(0);
}
.cw-nota-modal__header {
  font-size: 15px; font-weight: 600;
  color: var(--cloto-teal); margin-bottom: 16px;
}
.cw-nota-modal__icon { opacity: 0.7; margin-right: 6px; }
.cw-nota-modal__body {
  font-size: 14px; color: var(--cloto-text-100);
  line-height: 1.6; margin-bottom: 16px;
}
/* Persistent nota button in scene bar */
.cw-scene-nota-btn {
  background: none; border: none; cursor: pointer;
  color: var(--cloto-teal); font-size: 14px; opacity: 0.5;
  padding: 0 4px; line-height: 1;
  transition: opacity 0.15s;
}
.cw-scene-nota-btn:hover { opacity: 1; }

.cw-nota-modal__footer { text-align: right; }
.cw-nota-modal__close {
  background: var(--cloto-teal-a10);
  border: 1px solid var(--cloto-teal-a30);
  color: var(--cloto-teal); border-radius: 6px;
  padding: 6px 20px; font-size: 13px; cursor: pointer;
}
.cw-nota-modal__close:hover { background: var(--cloto-teal-a20); }
body.fd-light .cw-nota-modal { background: var(--cloto-elevated-bg); border-color: var(--cloto-teal-a30); }
body.fd-light .cw-nota-modal__body { color: var(--cloto-text-70); }
body.fd-light .cw-nota-modal-bg { background: var(--cloto-void-a60); }

/* ── Promise context in bible ── */
.bible-promise__context {
  font-size: 12px; color: var(--cloto-text-50);
  line-height: 1.4; margin-top: 2px;
}
.bible-promise__meta--advanced { color: var(--cloto-teal); }
.bible-promise__meta--age { color: var(--cloto-warning); font-size: 11px; }
.bible-promise--resolved .bible-promise__icon { color: var(--cloto-success); }

/* ── Scene brief (arc segments + promise opportunities) ── */
.cw-scene-brief {
  border-top: 1px solid var(--cloto-glass-border, rgba(255,255,255,0.06));
  margin-top: var(--space-4, 16px);
  padding-top: var(--space-3, 12px);
}
.cw-brief-arc {
  font-size: var(--cloto-fs-xs, 12px);
  color: var(--cloto-text-40);
  padding: 2px 0;
  line-height: 1.5;
}
.cw-brief-char {
  color: var(--cloto-teal);
  font-weight: 500;
}
.cw-brief-promise {
  font-size: var(--cloto-fs-xs, 12px);
  color: var(--cloto-text-30);
  padding: 2px 0;
}

/* ── Acknowledged state: soberer than accepted — read but no text change ── */
/* Pattern: cw-el-accepted but with lower opacity border fade instead of bg */
.cw-el-acknowledged {
  border-bottom-color: transparent;
  opacity: 0.7;
  transition: border-color 0.4s ease-out, opacity 0.4s ease-out;
}

/* ── Direction text in tooltip (diagnostic notes — no diff, just prose) ── */
/* Pattern: cw-tip-proposal but without italic — direction is prescriptive, not a quote */
.cw-tip-direction {
  color: var(--cloto-teal);
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  line-height: 1.5;
}
body.fd-light .cw-tip-direction {
  color: var(--cloto-teal-deep, #0e5454);
  border-bottom-color: rgba(0,0,0,0.06);
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .cw-el-accepted,
  .cw-el-rejected,
  .cw-el-modified,
  .cw-el-acknowledged,
  .cw-infusion,
  .cw-correction,
  .cw-tip-btn {
    transition: none;
  }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .cw-scene {
    padding: var(--space-6);
  }

  .cw-scene-textarea {
    padding: var(--space-6);
    min-height: 160px;
  }

  .cw-scene-title {
    font-size: var(--cloto-fs-xl);
  }

  .cw-tessila-actions {
    flex-wrap: wrap;
    margin: 0 calc(-1 * var(--space-6));
    padding: var(--space-4) var(--space-6);
  }

  .cw-tessuto-view {
    padding: var(--space-6);
    font-size: 16px;
  }

  .cw-infusion-tooltip {
    max-width: calc(100vw - 32px);
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .cw-scene-bar .cw-scene-save-dot.is-saving {
    animation: none;
  }

  .cw-scene-submit-spinner {
    animation: none;
  }

  .cw-infusion,
  .cw-correction {
    transition: none;
  }
}

/* ═══════════════════════════════════════════════════════════════
   WOVEN SCENE — readonly prose with clickable source phrases
   ═══════════════════════════════════════════════════════════════ */

.cw-scene--woven {
  padding: var(--space-10);
  max-width: 680px;
  margin: 0 auto;
}

.cw-woven-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--cloto-text-40, #5c5f68);
  font-size: 13px;
  font-family: var(--cloto-font-ui, system-ui, sans-serif);
  cursor: pointer;
  padding: 6px 0;
  margin-bottom: 12px;
  transition: color 0.15s;
}
.cw-woven-back:hover { color: var(--cloto-text-80, rgba(255,255,255,0.7)); }
body.fd-light .cw-woven-back { color: #888; }
body.fd-light .cw-woven-back:hover { color: #333; }

.cw-woven-title {
  font-family: var(--cloto-font-brand, 'Cardo', serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--cloto-gold, #c9a84c);
  margin: 0 0 1.2rem;
  line-height: 1.3;
}
body.fd-light .cw-woven-title { color: #8a6d2b; }

.cw-woven-prose {
  font-family: var(--cloto-font-brand, 'Cardo', serif);
  font-size: 17px;
  line-height: 1.85;
  color: var(--cloto-editor-text, rgba(224,220,214,0.92));
}
body.fd-light .cw-woven-prose { color: #333; }

.cw-woven-paragraph {
  margin: 0 0 1.2em 0;
}
.cw-woven-paragraph:last-child { margin-bottom: 0; }

.cw-woven-sentence {
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.15s;
  padding: 1px 2px;
}
.cw-woven-sentence:hover {
  background: rgba(94, 198, 198, 0.18);
}
body.fd-light .cw-woven-sentence:hover {
  background: rgba(29, 158, 117, 0.14);
}
.cw-woven-sentence--active {
  background: rgba(94, 198, 198, 0.22);
}
body.fd-light .cw-woven-sentence--active {
  background: rgba(29, 158, 117, 0.18);
}

/* Source tooltip */
.cw-source-tooltip {
  position: absolute;
  z-index: 10000;
  background: var(--cloto-bg-200, #1e2030);
  border: 1px solid var(--cloto-border, #333);
  border-radius: 8px;
  padding: 10px 14px;
  max-width: 340px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  font-family: var(--cloto-font-ui);
  font-size: 12px;
  line-height: 1.5;
}
body.fd-light .cw-source-tooltip {
  background: #fff;
  border-color: #ddd;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.cw-source-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
}
.cw-source-item + .cw-source-item {
  border-top: 1px solid var(--cloto-border, #333);
  margin-top: 4px;
  padding-top: 6px;
}

.cw-source-label {
  color: #5ec6c6;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
body.fd-light .cw-source-label { color: #1D9E75; }

.cw-source-detail {
  color: var(--cloto-text-200, #999);
  font-style: italic;
}

.cw-source-qa {
  margin-top: 3px;
  line-height: 1.45;
}
.cw-source-qa-label {
  color: #5ec6c6;
  font-weight: 600;
  font-size: 11px;
}
body.fd-light .cw-source-qa-label { color: #1D9E75; }
.cw-source-qa-text {
  color: var(--cloto-text-200, #999);
}
