/* Versed Study — student tools, second sheet: writing checker (/tools/write/), read aloud (/tools/listen/),
   formula and unit reference (/tools/formulas/). Loaded after study.css and tools.css; tools.css is untouched. */

/* ---------- writing checker ---------- */
.wr-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.wr-status { font-size: .74rem; color: var(--muted); display: inline-flex; align-items: center; gap: .4rem; min-height: 1.4em; }
.wr-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.wr-status.ok .dot { background: var(--lime); }
.wr-status.busy .dot { background: var(--amber); animation: wr-pulse 1s infinite; }
.wr-status.err .dot { background: var(--red); }
@keyframes wr-pulse { 50% { opacity: .3; } }
.wr-editor { position: relative; margin-top: .6rem; border: 2px solid var(--line); border-radius: 14px; background: var(--bg2); transition: border-color .15s, box-shadow .15s; }
.wr-editor:focus-within { border-color: var(--lime); box-shadow: 0 0 0 4px rgba(198,255,61,.15); }
.wr-editor .wr-back, .wr-editor textarea {
  font-family: var(--wf, var(--body)); font-size: var(--wfs, 1.02rem); line-height: var(--wlh, 1.65); letter-spacing: var(--wls, 0); word-spacing: var(--wws, 0);
  padding: .9rem 1rem; margin: 0; border: 0; width: 100%; min-height: 220px; white-space: pre-wrap; overflow-wrap: break-word; word-wrap: break-word; -webkit-hyphens: none; hyphens: none; tab-size: 4;
}
.wr-editor.browser-font .wr-back, .wr-editor.browser-font textarea { font-family: initial; }   /* the reader chose "my browser's default" */
.wr-editor .wr-back { position: absolute; inset: 0; color: transparent; pointer-events: none; overflow: hidden; border-radius: 12px; user-select: none; }
.wr-editor textarea { position: relative; display: block; background: transparent; color: var(--text); resize: none; outline: none; overflow: hidden; caret-color: var(--lime); }
.wr-editor textarea::placeholder { color: var(--dim); }
.wr-back mark { color: transparent; background: rgba(255,79,163,.16); border-bottom: 2px solid var(--pink); border-radius: 3px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.wr-back mark.k-grammar, .wr-back mark.k-agreement, .wr-back mark.k-wordorder, .wr-back mark.k-boundaryerror, .wr-back mark.k-typo { background: rgba(255,176,32,.16); border-bottom-color: var(--amber); }
.wr-back mark.k-style, .wr-back mark.k-readability, .wr-back mark.k-enhancement, .wr-back mark.k-redundancy, .wr-back mark.k-repetition, .wr-back mark.k-miscellaneous, .wr-back mark.k-formatting { background: rgba(139,123,255,.16); border-bottom: 2px dotted var(--violet); }
.wr-back mark.k-punctuation, .wr-back mark.k-capitalization { background: rgba(61,242,255,.14); border-bottom-color: var(--cyan); }
.wr-back mark.is-active { outline: 2px solid var(--text); outline-offset: 1px; }
/* dyslexia-friendly view: paper look with the easy reader's spacing and tint */
.wr-editor.paper-view { background: var(--wpaper, #FBF6E9); border-color: var(--wpaper-line, #d9d2bf); }
.wr-editor.paper-view textarea { color: var(--wink, #1a1a1f); caret-color: var(--wink, #1a1a1f); }
.wr-editor.paper-view textarea::placeholder { color: #8a8570; }
.wr-editor.paper-view.dark { --wpaper: #15142a; --wpaper-line: var(--line); --wink: #ECEAF8; }
.wr-editor .wr-tint { position: absolute; inset: 0; pointer-events: none; border-radius: 12px; mix-blend-mode: multiply; display: none; }
.wr-editor.paper-view .wr-tint { display: block; }
.wr-editor.paper-view.dark .wr-tint { mix-blend-mode: screen; opacity: .18; }
.wr-pop { position: absolute; z-index: 5; background: var(--card2); border: 2px solid var(--line); border-radius: 12px; padding: .6rem .7rem; max-width: min(320px, calc(100% - 12px)); box-shadow: var(--shadow); font-size: .82rem; }
.wr-pop .k { font-size: .66rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: .2rem; }
.wr-pop .m { color: var(--text); line-height: 1.4; }
.wr-pop .fixes { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.wr-pop .fixes button, .wr-issue .fixes button { padding: .35rem .65rem; border-radius: 8px; background: var(--lime); color: var(--ink); font-weight: 700; font-size: .8rem; max-width: 100%; overflow-wrap: anywhere; }
.wr-pop .fixes button.gh, .wr-issue .fixes button.gh { background: var(--card); color: var(--muted); border: 1px solid var(--line); }
.wr-pop .fixes button.rm, .wr-issue .fixes button.rm { background: var(--card); color: var(--red); border: 1px solid var(--line); }
.wr-tools { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .6rem; }
.wr-tools .grow { flex: 1; }
.wr-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: .5rem; margin-top: .8rem; }
.wr-stat { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: .55rem .7rem; }
.wr-stat b { display: block; font-family: var(--display); font-size: 1.05rem; color: var(--lime); line-height: 1.2; }
.wr-stat span { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.wr-issues { list-style: none; margin: .6rem 0 0; padding: 0; display: grid; gap: .45rem; }
.wr-issue { display: grid; grid-template-columns: 8px 1fr; gap: .6rem; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: .6rem .7rem; font-size: .82rem; cursor: pointer; }
.wr-issue:hover, .wr-issue.is-active { border-color: var(--violet); }
.wr-issue .bar { border-radius: 4px; background: var(--pink); }
.wr-issue.k-grammar .bar, .wr-issue.k-agreement .bar, .wr-issue.k-wordorder .bar, .wr-issue.k-boundaryerror .bar, .wr-issue.k-typo .bar { background: var(--amber); }
.wr-issue.k-style .bar, .wr-issue.k-readability .bar, .wr-issue.k-enhancement .bar, .wr-issue.k-redundancy .bar, .wr-issue.k-repetition .bar, .wr-issue.k-miscellaneous .bar, .wr-issue.k-formatting .bar { background: var(--violet); }
.wr-issue.k-punctuation .bar, .wr-issue.k-capitalization .bar { background: var(--cyan); }
.wr-issue .q { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--card); padding: 0 .3rem; border-radius: 4px; color: var(--text); overflow-wrap: anywhere; }
.wr-issue .k { font-size: .64rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.wr-issue .m { color: var(--muted); margin-top: .15rem; line-height: 1.4; }
.wr-issue .fixes { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
.wr-legend { display: flex; flex-wrap: wrap; gap: .6rem; font-size: .7rem; color: var(--muted); margin-top: .5rem; }
.wr-legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: .3rem; }
.wr-rewrite { display: flex; flex-wrap: wrap; gap: .4rem; }
.wr-rewrite button { padding: .45rem .8rem; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); font-size: .8rem; font-weight: 700; color: var(--muted); display: inline-flex; align-items: center; gap: .35rem; }
.wr-rewrite button svg { width: 15px; height: 15px; }
.wr-rewrite button:hover { border-color: var(--violet); color: var(--text); }
.wr-rewrite button[aria-pressed="true"] { background: var(--lime); border-color: var(--lime); color: var(--ink); }
.wr-dialects { display: flex; flex-wrap: wrap; }
.wr-dialects button { padding: .4rem .6rem; font-size: .76rem; }
.wr-hidden-warn { font-size: .74rem; color: var(--amber); }
.wr-opens { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .7rem; }
.wr-opens .btn { padding: .7rem .8rem; font-size: .9rem; }
.wr-opens .btn svg { width: 16px; height: 16px; }
.wr-opens .btn.is-off { opacity: .45; cursor: not-allowed; box-shadow: none; }
@media (max-width: 560px) { .wr-two { grid-template-columns: 1fr; } .wr-opens { grid-template-columns: 1fr 1fr; } .wr-opens #rw-copy { grid-column: 1 / -1; } }
@media (max-width: 480px) { .wr-editor .wr-back, .wr-editor textarea { padding: .8rem .8rem; } .wr-stats { grid-template-columns: 1fr 1fr 1fr; } }

/* ---------- read aloud ---------- */
.ls-transport { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .6rem; }
.ls-transport .btn-icon { width: 44px; height: 44px; }
.ls-transport .btn-icon.main { width: 56px; height: 56px; background: var(--lime); color: var(--ink); border-radius: 16px; box-shadow: var(--pop); }
.ls-transport .btn-icon.main:active { box-shadow: 1px 1px 0 var(--pink); transform: translate(2px, 2px); }
.ls-transport .btn-icon.main svg { width: 24px; height: 24px; }
.ls-transport .ls-pos { font-size: .74rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-left: auto; }
.ls-controls { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem .9rem; margin-top: .8rem; }
@media (max-width: 480px) { .ls-controls { grid-template-columns: 1fr; } }
.ls-controls .ctl label { display: flex; justify-content: space-between; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .3rem; }
.ls-controls .ctl label output { color: var(--lime); font-family: var(--display); text-transform: none; letter-spacing: 0; }
.ls-controls input[type=range] { width: 100%; accent-color: var(--lime); }
.ls-voice-note { font-size: .74rem; color: var(--muted); margin-top: .35rem; line-height: 1.45; }
.ls-voice-note b { color: var(--text); }
.ls-paper { position: relative; margin-top: 1rem; border-radius: 14px; padding: 1.3rem 1.2rem; background: var(--paper, #FBF6E9); color: var(--ink-paper, #1a1a1f); min-height: 160px; border: 2px solid var(--line); font-size: var(--lfs, 1.15rem); line-height: 1.85; font-family: var(--lf, system-ui, sans-serif); letter-spacing: .01em; word-spacing: .06em; }
.ls-paper.dark { --paper: #15142a; --ink-paper: #ECEAF8; }
.ls-paper p { margin: 0 0 1em; }
.ls-paper p:last-child { margin-bottom: 0; }
.ls-paper .sent { border-radius: 6px; transition: background .15s; padding: .05em 0; }
.ls-paper .sent.now { background: rgba(198,255,61,.35); box-shadow: 0 0 0 3px rgba(198,255,61,.35); }
.ls-paper.dark .sent.now { background: rgba(198,255,61,.18); box-shadow: 0 0 0 3px rgba(198,255,61,.18); }
.ls-paper .w { cursor: pointer; border-radius: 4px; }
.ls-paper .w:hover { background: rgba(255,79,163,.18); }
.ls-paper .w.now { background: var(--pink); color: #fff; }
.ls-paper .ph { color: #8a8570; }
.ls-paper.dark .ph { color: var(--muted); }
.ls-keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .3rem .8rem; font-size: .76rem; color: var(--muted); margin-top: .6rem; }
.ls-keys kbd { font-family: ui-monospace, Menlo, monospace; font-size: .7rem; background: var(--bg2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 .35rem; color: var(--text); }
.ls-tag { font-size: .62rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--amber); }

/* ---------- formula and unit reference ---------- */
.fm-search { position: relative; }
.fm-search svg { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--dim); pointer-events: none; }
.fm-search .input { padding-left: 2.5rem; }
.fm-subjects { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .7rem; }
.fm-subjects button { padding: .45rem .8rem; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: .8rem; font-weight: 700; color: var(--muted); }
.fm-subjects button:hover { border-color: var(--violet); color: var(--text); }
.fm-subjects button[aria-pressed="true"] { background: var(--lime); color: var(--ink); border-color: var(--lime); }
.fm-levels { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .5rem; align-items: center; }
.fm-levels .lbl { font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); margin-right: .2rem; }
.fm-levels button { padding: .3rem .6rem; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); font-size: .72rem; font-weight: 700; color: var(--muted); }
.fm-levels button[aria-pressed="true"] { border-color: var(--lime); color: var(--lime); }
.fm-count { font-size: .74rem; color: var(--muted); margin-top: .5rem; display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; align-items: center; }
.fm-topic { margin-top: 1rem; }
.fm-topic h2 { font-size: 1rem; display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.fm-topic h2 small { font-family: var(--body); font-size: .7rem; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.fm-list { display: grid; gap: .45rem; }
.fm-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem .8rem; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .6rem .8rem; align-items: start; }
.fm-item .n { font-weight: 700; font-size: .84rem; color: var(--text); }
.fm-item .f { grid-column: 1 / -1; font-family: 'Cambria', 'Georgia', 'Times New Roman', 'STIX Two Math', serif; font-size: 1.12rem; color: var(--lime); line-height: 1.55; overflow-x: auto; overflow-y: hidden; padding-bottom: .05rem; }
.fm-item .f i { font-style: italic; }
.fm-item .f sup, .fm-item .f sub { font-size: .68em; line-height: 0; }
.fm-item .f .frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 .15em; line-height: 1.15; }
.fm-item .f .frac > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 .2em; }
.fm-item .f .frac > span:last-child { padding: 0 .2em; }
.fm-item .f .big { font-size: 1.5em; vertical-align: -.15em; line-height: 0; }
.fm-item .w { grid-column: 1 / -1; font-size: .76rem; color: var(--muted); line-height: 1.45; }
.fm-item .w i { font-style: italic; color: var(--text); }
.fm-item .lv { font-size: .6rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); white-space: nowrap; padding-top: .2rem; }
.fm-item mark { background: rgba(198,255,61,.25); color: inherit; border-radius: 3px; }
.fm-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.fm-table th, .fm-table td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.fm-table th { color: var(--dim); font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; }
.fm-table td.v { font-family: 'Cambria', 'Georgia', 'Times New Roman', serif; color: var(--lime); white-space: nowrap; }
.fm-table td.s { font-family: 'Cambria', 'Georgia', 'Times New Roman', serif; font-size: 1rem; color: var(--text); white-space: nowrap; }
.fm-table sup, .fm-table sub { font-size: .7em; line-height: 0; }
.fm-conv { display: grid; grid-template-columns: 1fr auto 1fr; gap: .5rem; align-items: end; margin-top: .6rem; }
.fm-conv .swap { width: 40px; height: 40px; margin-bottom: 2px; }
.fm-conv .input { min-width: 0; }
.fm-conv-out { font-family: var(--display); font-size: 1.15rem; color: var(--lime); margin-top: .6rem; overflow-wrap: anywhere; }
.fm-conv-out small { display: block; font-family: var(--body); font-size: .74rem; color: var(--muted); margin-top: .2rem; }
@media (max-width: 420px) { .fm-conv { grid-template-columns: 1fr; } .fm-conv .swap { width: 100%; height: 34px; margin: 0; } }
.fm-empty { text-align: center; color: var(--muted); font-size: .85rem; padding: 1.2rem .5rem; }
.fm-print-note { display: none; }

@media print {
  @page { margin: 9mm; }
  body, body.has-ad { background: #fff; color: #000; padding: 0; font-size: 8.5pt; }
  .top, .toolbar, .hero p, .hero .deco, .fm-controls, .fm-count, .foot, .ad-slot, .toast, .shelf, .divider, details, .fm-noprint, .fm-item .lv { display: none !important; }
  .wrap, .wrap.wide { max-width: none; padding: 0; min-height: 0; }
  .hero h1 { font-size: 13pt; margin: 0 0 2pt; color: #000; }
  .hero h1 span { color: #000; }
  .hero p.fm-print-note { display: block; font-size: 7pt; color: #444; margin-bottom: 4pt; }
  .fm-topic { margin-top: 5pt; }
  .fm-topic h2 { font-size: 9.5pt; margin-bottom: 2pt; color: #000; border-bottom: 1px solid #000; padding-bottom: 1pt; break-after: avoid; }
  .fm-topic h2 small { color: #444; }
  .fm-list { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1pt 8pt; }
  .fm-item { border: 0; border-bottom: 1px dotted #aaa; border-radius: 0; padding: 1.5pt 0 2pt; background: none; break-inside: avoid; gap: 0 4pt; }
  .fm-item .n { color: #000; font-size: 7.5pt; line-height: 1.2; }
  .fm-item .f { color: #000; font-size: 8.5pt; line-height: 1.35; overflow: visible; }
  .fm-item .f .frac { line-height: 1.05; }
  .fm-item .w { color: #333; font-size: 6.5pt; line-height: 1.25; }
  .fm-item .w i { color: #000; }
  .fm-item mark { background: none; }
  .fm-table { font-size: 7.5pt; }
  .fm-table th { color: #444; }
  .fm-table td, .fm-table th { border-bottom-color: #bbb; padding: 1.5pt 3pt; }
  .fm-table td.s { font-size: 8.5pt; }
  .fm-table td.v, .fm-table td.s { color: #000; }
  .card { border: 0; padding: 0; background: none; }
  a { text-decoration: none; color: inherit; }
}
