/* Writing Studio editor, versions and comparison. See WRITING_STUDIO.md. Uses the school.css tokens. */

/* ---------- focus mode: only the writing and its slim toolbar ---------- */
body.ws-focus .site-header,
body.ws-focus #view-writing nav,
body.ws-focus #view-writing .ws-subnav,
body.ws-focus #view-writing [data-ws-subnav],
body.ws-focus .ws-ed-panel,
body.ws-focus .ws-ed-back,
body.ws-focus .toast:empty{display:none!important}
body.ws-focus main{padding-top:10px;padding-bottom:16px}
body.ws-focus .ws-ed-bar{position:sticky;top:0;box-shadow:0 6px 24px rgba(60,35,91,.06)}

/* ---------- the writing page ---------- */
.ws-ed{max-width:1240px;margin:0 auto;padding-top:6px;--ws-ed-fs:max(16px,calc(1.14rem * var(--ws-text-scale,1)));--ws-ed-measure:calc(var(--ws-ed-fs) * 38)}
.ws-ed[data-ws-width="wide"]{--ws-ed-measure:calc(var(--ws-ed-fs) * 56)}
.ws-ed-bar{background:#fff;border:1px solid var(--stroke);border-radius:20px;padding:10px 14px;display:grid;gap:8px;z-index:20}
@media(min-width:900px) and (min-height:640px){.ws-ed-bar{position:sticky;top:var(--ws-ed-bar-top,96px)}}
.ws-ed-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px;min-width:0}
.ws-ed-back{min-height:44px;font-size:.86rem;white-space:nowrap}
.ws-ed-title{flex:1 1 220px;min-width:0;min-height:44px;font:900 1.2rem/1.2 Nunito,'DM Sans',sans-serif;color:var(--deep);border:1px solid transparent;border-radius:12px;background:transparent;padding:6px 10px;text-overflow:ellipsis}
.ws-ed-title:hover{border-color:var(--stroke)}
.ws-ed-title:focus{border-color:#cfbde4;background:#fbf9fe}
.ws-ed-status{font-size:.8rem;font-weight:700;color:var(--muted);white-space:nowrap}
.ws-ed-status[data-state="error"],.ws-ed-status[data-state="stranded"]{color:#8f2f2f;background:#fdeceb;border:1px solid #f3c9c6;border-radius:99px;padding:5px 11px;white-space:normal}
.ws-ed-status[data-state="locked"]{color:#6f4fa0}
.ws-ed-badge{display:inline-flex;align-items:center;gap:6px;font-weight:850;font-size:.74rem;color:#6f4fa0;background:var(--lilac);border-radius:99px;padding:5px 10px;white-space:nowrap}
.ws-ed-badge.ws-kind-revision{background:var(--mint);color:#2f6b55}
.ws-ed-badge.ws-kind-ai-assisted{background:var(--gold);color:#6d5317}
.ws-ed-badge.ws-kind-external-edit{background:var(--blue);color:#2f557c}
.ws-ed-lock{font-weight:800;font-size:.74rem;color:#6b5f78}
.ws-ed-badge .ws-ed-lock{color:inherit;opacity:.85}
.ws-ed-open-tag{font-weight:800;font-size:.74rem;color:#2f6b55}
.ws-ed-count{display:flex;align-items:center;gap:8px;font-weight:800;font-size:.86rem;color:#5d4f6c;font-variant-numeric:tabular-nums;min-height:44px}
.ws-ed-target-bar{display:inline-block;width:92px;height:8px;border-radius:99px;background:#efe7f8;overflow:hidden}
.ws-ed-target-bar span{display:block;height:100%;width:0;border-radius:99px;background:linear-gradient(90deg,#b9a0dd,var(--purple));transition:width .3s ease}
.ws-ed-timer{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.ws-ed-clock{font-weight:850;font-size:.88rem;color:#5d4f6c;font-variant-numeric:tabular-nums;background:#f8f4fd;border:1px solid #eee6f5;border-radius:99px;padding:6px 11px;min-width:58px;text-align:center}
.ws-ed-clock.ws-ed-running{color:var(--purple);border-color:#e2d4f4}
.ws-ed-clock.ws-ed-goal-done{background:var(--mint);border-color:#c9e9d6;color:#2f6b55}
.ws-ed-glow{animation:wsEdGlow 1.3s ease-in-out 3}
@keyframes wsEdGlow{50%{box-shadow:0 0 0 7px rgba(117,83,169,.18)}}
.ws-ed-actions{display:flex;flex-wrap:wrap;gap:6px;margin-left:auto}
.ws-ed-bar .button-small{min-height:44px}
.ws-ed-notice{display:none;margin:10px 0 0;background:#f2fbf6;border:1px solid #cfeedd;color:#2f5f4c;border-radius:14px;padding:10px 14px;font-weight:700;font-size:.88rem}
.ws-ed-notice.show{display:block}
.ws-ed-body{display:flex;flex-direction:column;gap:14px;margin-top:12px}
.ws-ed-page{background:#fff;border:1px solid var(--stroke);border-radius:22px;padding:clamp(14px,3.2vw,44px) clamp(12px,3.2vw,48px);min-width:0;transition:box-shadow .15s ease,border-color .15s ease}
.ws-ed-page:focus-within{border-color:#9b7bcd;box-shadow:0 0 0 3px #e4d8f5}
.ws-ed-text{display:block;box-sizing:border-box;width:100%;max-width:var(--ws-ed-measure);margin:0 auto;height:var(--ws-ed-text-h,65vh);min-height:220px;border:0;outline:none;resize:none;background:transparent;color:var(--ink);
  font-family:var(--ws-font,'DM Sans',-apple-system,BlinkMacSystemFont,sans-serif);font-size:var(--ws-ed-fs);line-height:var(--ws-line-height,1.75);letter-spacing:.005em;padding:0;tab-size:4;overflow-y:auto;-webkit-overflow-scrolling:touch}
.ws-ed-text:focus-visible{outline:none}
.ws-ed-text::placeholder{color:#a497b2}
.ws-ed-text[readonly]{color:#40324f}
.ws-ed-locked{max-width:var(--ws-ed-measure);box-sizing:border-box;margin:0 auto 14px;background:#fdf8ea;border:1px solid #efe0b4;border-radius:16px;padding:12px 14px}
.ws-ed-locked p{margin:0 0 8px;font-weight:700;color:#5b4a26;line-height:1.5}
.ws-ed-locked p.ws-ed-stranded{color:#8f2f2f;background:#fdeceb;border:1px solid #f3c9c6;border-radius:14px;padding:10px 12px}
.ws-ed-locked-actions,.ws-ed-row-actions{display:flex;flex-wrap:wrap;gap:8px}

/* ---------- the More panel: slides down on phones and iPad portrait, sits beside the page on wide screens ---------- */
.ws-ed-panel{order:-1;background:#fff;border:1px solid var(--stroke);border-radius:22px;padding:16px;max-height:min(62dvh,640px);overflow:auto;overscroll-behavior:contain;animation:wsEdSlide .22s ease-out}
.ws-ed-panel[hidden]{display:none}
@keyframes wsEdSlide{from{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:none}}
@media(min-width:1000px){
  .ws-ed-body.panel-open{display:grid;grid-template-columns:minmax(0,1fr) 360px;align-items:start}
  .ws-ed-panel{order:0;position:sticky;top:var(--ws-ed-panel-top,220px);max-height:calc(100dvh - var(--ws-ed-panel-top,220px) - 16px);animation:none}
}
.ws-ed-panel-head{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;margin-bottom:10px}
.ws-ed-panel-head h2{font:900 1.08rem Nunito,'DM Sans',sans-serif;color:var(--deep);margin:0}
.ws-ed-tabs{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:12px}
.ws-ed-tab{min-height:44px;border:1px solid #ded1e7;border-radius:99px;background:#fff;color:#6b5487;font-weight:800;font-size:.8rem;padding:6px 12px;cursor:pointer}
.ws-ed-tab[aria-pressed="true"]{background:var(--purple);border-color:var(--purple);color:#fff}
.ws-ed-tab-n{display:inline-block;min-width:18px;border-radius:99px;background:#f1e9fb;color:#6f4fa0;font-size:.7rem;padding:1px 5px;margin-left:2px}
.ws-ed-tab[aria-pressed="true"] .ws-ed-tab-n{background:rgba(255,255,255,.25);color:#fff}
.ws-ed-section{display:grid;gap:10px}
.ws-ed-section h3{font:900 .98rem Nunito,'DM Sans',sans-serif;color:var(--deep);margin:4px 0 0}
.ws-ed-section h3 small{font:700 .76rem 'DM Sans',sans-serif;color:var(--muted)}
.ws-ed-help{font-size:.84rem;color:var(--muted);line-height:1.5;margin:0}
.ws-ed-field{display:grid;gap:4px}
.ws-ed-field>span{font-weight:850;font-size:.85rem;color:#615370}
.ws-ed-field small{font-weight:600;color:var(--muted)}
.ws-ed-field input,.ws-ed-field select,.ws-ed-field textarea{width:100%;box-sizing:border-box;border:1px solid #ded1e7;border-radius:12px;padding:10px 12px;font:inherit;font-size:1rem;min-height:44px;background:#fff;color:var(--ink)}
.ws-ed-field textarea{line-height:1.55;resize:vertical}
.ws-ed-field select:focus-visible,.ws-ed-tab:focus-visible,.ws-cmp-text:focus-visible{outline:3px solid #9b7bcd;outline-offset:3px}
.ws-ed-check{display:flex;gap:10px;align-items:flex-start;background:#fbf9fe;border:1px solid #eee6f5;border-radius:14px;padding:10px 12px;cursor:pointer}
.ws-ed-check input{width:22px;height:22px;margin-top:2px;flex-shrink:0;accent-color:var(--purple)}
.ws-ed-check span{display:grid;gap:2px}
.ws-ed-check small{color:var(--muted);font-size:.8rem;line-height:1.45}
.ws-ed-check:has(input:disabled){opacity:.6;cursor:default}
.ws-ed-form-status{font-size:.84rem;font-weight:700;color:#6f4fa0;margin:0;min-height:0}
.ws-ed-form-status:empty{display:none}
.ws-ver-list,.ws-fb-list{list-style:none;padding:0;margin:0;display:grid;gap:8px}
.ws-ver{border:1px solid #eee6f5;background:#fbf9fe;border-radius:14px;padding:10px 12px;display:grid;gap:4px}
.ws-ver.here{border-color:#cfbde4;background:#f6f0fd}
.ws-ver-top{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.ws-ver-meta{font-size:.8rem;color:var(--muted);font-weight:700}
.ws-ver-note{font-size:.82rem;color:#5d4f6c;margin:0;line-height:1.45}
.ws-ver-actions{display:flex;gap:8px;align-items:center}
.ws-ver-here{font-size:.8rem;font-weight:800;color:#6f4fa0}
.ws-ed-compare,.ws-ed-fb-form{display:grid;gap:8px;border-top:1px solid #f0e9f5;padding-top:10px}
.ws-ed-compare .button,.ws-ed-fb-form .button,#wsEdExtForm .button{justify-self:start}
.ws-ed-external{background:#fbf9fe;border:1px solid #eee6f5;border-radius:14px;padding:10px 12px}
.ws-ed-external summary{font-weight:850;font-size:.86rem;color:#6b5487;cursor:pointer;min-height:44px;display:flex;align-items:center}
.ws-ed-external form{display:grid;gap:8px;margin-top:6px}
.ws-ed-external fieldset{border:0;padding:0;margin:0;display:flex;flex-wrap:wrap;gap:8px}
.ws-ed-external legend{font-weight:850;font-size:.85rem;color:#615370;margin-bottom:4px}
.ws-ed-radio{display:inline-flex;align-items:center;gap:8px;min-height:44px;border:1px solid #ded1e7;border-radius:99px;background:#fff;padding:4px 14px;font-weight:800;font-size:.84rem;color:#6b5487;cursor:pointer}
.ws-ed-radio input{width:18px;height:18px;accent-color:var(--purple)}
.ws-fb{border:1px solid #eee6f5;border-radius:14px;padding:10px 12px;background:#fff}
.ws-fb-person{border-left:4px solid #b9d7f2}
.ws-fb-teacher{border-left:4px solid #9fd8bd}
.ws-fb-ai{border-left:4px solid #ecd590;background:#fffcf2}
.ws-fb-top{display:flex;flex-wrap:wrap;gap:4px 10px;align-items:baseline;margin-bottom:4px}
.ws-fb-source{font-weight:850;font-size:.84rem;color:var(--deep)}
.ws-fb-meta{font-size:.76rem;color:var(--muted);font-weight:700}
.ws-fb p{margin:0;white-space:pre-wrap;font-size:.9rem;line-height:1.5;color:#4b3f59}
.ws-ed-task{background:#fbf9fe;border:1px solid #eee6f5;border-radius:14px;padding:10px 12px}
.ws-ed-task p{margin:4px 0 0;line-height:1.55;font-size:.9rem;color:#4b3f59}
.ws-ed-task-name{font-size:1.05rem!important;margin:0!important}
.ws-ed-section .eyebrow{margin:6px 0 0}
.ws-ed-steps{margin:6px 0 0;padding-left:1.25em;display:grid;gap:5px;font-size:.88rem;line-height:1.5;color:#4b3f59}
.ws-ed-key{display:inline-block;font-size:.7rem;font-weight:850;color:#6f4fa0;background:#f1e9fb;border-radius:99px;padding:1px 7px;margin-left:2px}
.ws-ed-beats li.weak{font-weight:700}
.ws-ed-missing{max-width:640px}

/* ---------- compare ---------- */
.ws-cmp{max-width:1240px;margin:0 auto}
.ws-cmp-top{padding-top:6px}
.ws-cmp-pagehead{padding:18px 0 14px}
.ws-cmp-pagehead h1{font-size:clamp(2.1rem,4.4vw,3.3rem);letter-spacing:-.03em;line-height:1.04;margin:8px 0 10px;color:var(--deep)}
.ws-cmp-honest{background:#fdf8ea;border:1px solid #efe0b4;border-radius:14px;padding:10px 14px;color:#5b4a26;font-weight:700;margin:0;max-width:640px}
.ws-cmp-controls{display:flex;flex-wrap:wrap;gap:10px 18px;align-items:flex-end;justify-content:space-between;background:#fff;border:1px solid var(--stroke);border-radius:20px;padding:12px 14px}
.ws-cmp-pick{display:flex;flex-wrap:wrap;gap:8px;align-items:flex-end}
.ws-cmp-pick .ws-ed-field{min-width:min(220px,100%)}
.ws-cmp-buttons{display:flex;flex-wrap:wrap;gap:8px}
.ws-cmp-controls .button-small{min-height:44px}
.ws-cmp-stats{font-weight:800;color:#5d4f6c;margin:14px 2px 4px;font-size:.92rem}
.ws-cmp-legend{display:flex;flex-wrap:wrap;gap:6px 18px;font-size:.84rem;color:var(--muted);margin:0 2px 10px}
.ws-cmp-legend[hidden]{display:none}
.ws-cmp-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
.ws-cmp-col{background:#fff;border:1px solid var(--stroke);border-radius:22px;padding:16px clamp(14px,2.4vw,28px) 18px;display:grid;gap:12px;align-content:start;min-width:0}
.ws-cmp-col>.button{justify-self:start}
.ws-cmp-head{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.ws-cmp-meta{font-size:.8rem;color:var(--muted);font-weight:700}
.ws-cmp-text{white-space:pre-wrap;overflow-wrap:anywhere;font-family:var(--ws-font,'DM Sans',sans-serif);font-size:max(16px,calc(1.05rem * var(--ws-text-scale,1)));line-height:var(--ws-line-height,1.75);color:var(--ink);border-radius:8px}
.ws-diff-del{background:#fde6e3;color:#7f2a2a;text-decoration:line-through;text-decoration-thickness:2px;text-decoration-color:#c0504d;border-radius:4px}
.ws-diff-add{background:#def3e7;color:#1f5a41;text-decoration:underline;text-decoration-thickness:2px;text-underline-offset:3px;text-decoration-color:#2f8a63;border-radius:4px}
@media(max-width:760px){.ws-cmp-grid{grid-template-columns:1fr}}

/* ---------- phones ---------- */
@media(max-width:600px){
  .ws-ed-bar{padding:8px 10px;border-radius:16px}
  .ws-ed-title{flex-basis:100%;order:3;font-size:1.08rem}
  .ws-ed-status{margin-left:auto}
  .ws-ed-actions{margin-left:0;width:100%}
  .ws-ed-actions .button{flex:1 1 auto;padding:9px 8px!important}
  .ws-ed-page{border-radius:18px}
  .ws-ed-panel{padding:12px;border-radius:18px}
  .ws-cmp-controls{padding:10px}
  .ws-cmp-pick .ws-ed-field{min-width:100%}
  body.ws-focus main{padding-left:8px;padding-right:8px}
}
@media(prefers-reduced-motion:reduce){.ws-ed-panel,.ws-ed-glow{animation:none}.ws-ed-target-bar span{transition:none}}
/* The game's Calm effects switch also stops the editor's motion. */
body.game-calm .ws-ed-panel,body.game-calm .ws-ed-glow{animation:none}body.game-calm .ws-ed-target-bar span{transition:none}
