/* Text tools (task #460): Readability, Case Converter, Diff Checker, Remove Duplicate Lines,
   grammar-result editor (.gc-app). Loaded only on those tool pages; builds on style.css tokens.
   Every tint uses a light/dark token pair, so the dark theme ([data-theme="dark"]) flips cleanly. */
:root{
  --tt-del-bg:#fdecec; --tt-del-strong:#f9c4c4; --tt-del-ink:#9f1d1d;
  --tt-ins-bg:#e3f7ee; --tt-ins-strong:#b3e9cf; --tt-ins-ink:#065f46;
  --tt-hard-bg:#fdf1d6; --tt-vhard-bg:#fbd9d9;
  --gc-spelling:#dc2626; --gc-grammar:#d97706; --gc-punctuation:#7c3aed; --gc-style:#0f766e;
  --gc-spelling-bg:#fdecec; --gc-grammar-bg:#fef3e2; --gc-punctuation-bg:#f1ebfe; --gc-style-bg:#e2f5f2;
}
[data-theme="dark"]{
  --tt-del-bg:#3f1f27; --tt-del-strong:#7a2c3a; --tt-del-ink:#fecaca;
  --tt-ins-bg:#12382f; --tt-ins-strong:#1f6b52; --tt-ins-ink:#bbf7d0;
  --tt-hard-bg:#4a3a14; --tt-vhard-bg:#5b2430;
  --gc-spelling:#f87171; --gc-grammar:#fbbf24; --gc-punctuation:#c4b5fd; --gc-style:#5eead4;
  --gc-spelling-bg:#3f1f27; --gc-grammar-bg:#3b2e12; --gc-punctuation-bg:#2e2350; --gc-style-bg:#123a37;
}
.tt-hidden{position:absolute;left:-9999px;width:1px;height:1px;opacity:0}
.tt-privacy{font-size:13px;margin-top:6px}
.tt-langnote{font-size:13px;margin-top:10px}
.tt-count{font-size:13px;margin:-6px 0 12px}
.tt-sub{font-size:14.5px;margin:18px 0 10px;color:var(--heading)}

/* score head: ring + band + cards */
.tt-head{align-items:center}
.tt-head-body{flex:1;min-width:240px;display:flex;flex-direction:column;gap:10px}
.tt-band{font-family:var(--head);font-size:22px;font-weight:800;color:var(--heading)}
.tt-band.good{color:var(--link)}.tt-band.warn{color:var(--warn-ink)}.tt-band.bad{color:var(--bad-ink-2)}
.tt-band-sub{color:var(--muted);font-size:14px;margin-top:-6px}
.tt-head .viz-cards{grid-template-columns:repeat(auto-fit,minmax(110px,1fr))}
.tt-head .viz-card-num{font-size:22px}
.viz-card.good .viz-card-num{color:var(--link)}.viz-card.warn .viz-card-num{color:var(--warn-ink)}.viz-card.bad .viz-card-num{color:var(--bad-ink-2)}
.tt-app .viz-card-lbl{display:block;font-size:12px;color:var(--muted);margin-top:3px}

/* formula */
.tt-formula{background:var(--bg-soft);border:1px solid var(--line-2);border-radius:10px;padding:14px 16px;font-size:14px;line-height:1.6;overflow-x:auto}
.tt-formula p+p{margin-top:6px}
.tt-plug{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:13px;color:var(--ink-2)}
.tt-details{margin-top:14px}
.tt-details summary{cursor:pointer;font-weight:600;color:var(--link);font-size:14px;margin-bottom:10px}

/* sentence lists + highlighted text */
.tt-slist{list-style:none;counter-reset:tts;display:flex;flex-direction:column;gap:8px}
.tt-sitem{counter-increment:tts;padding:11px 14px 11px 44px;border:1px solid var(--line-2);border-radius:10px;background:var(--bg-soft);position:relative;font-size:14.5px;line-height:1.55}
.tt-sitem:before{content:counter(tts);position:absolute;left:14px;top:11px;width:20px;height:20px;border-radius:50%;background:var(--bg-soft2);color:var(--muted);font-size:11.5px;font-weight:700;display:grid;place-items:center}
.tt-sitem.hard{border-left:4px solid var(--warn)}
.tt-sitem.vhard{border-left:4px solid var(--bad)}
.tt-stext{display:block;color:var(--ink)}
.tt-smeta{display:flex;flex-wrap:wrap;gap:4px;margin-top:6px}
.tt-smeta .type-chip{margin:0}
.type-chip.tt-chip-bad{background:var(--bad-bg);color:var(--bad-ink-2)}
.tt-fulltext{white-space:pre-wrap;word-break:break-word;font-size:15px;line-height:1.8;background:var(--bg-soft);border:1px solid var(--line-2);border-radius:10px;padding:16px 18px;max-height:520px;overflow:auto}
.tt-hl{color:inherit;border-radius:3px;padding:1px 0}
.tt-hl.tt-hard{background:var(--tt-hard-bg)}
.tt-hl.tt-vhard{background:var(--tt-vhard-bg)}
.tt-legend{display:flex;flex-wrap:wrap;gap:16px;font-size:12.5px;color:var(--muted);margin:0 0 10px}
.tt-legend span{display:inline-flex;align-items:center;gap:6px}
.tt-dot{width:12px;height:12px;border-radius:3px;display:inline-block}
.tt-dot.tt-hard{background:var(--tt-hard-bg);border:1px solid var(--warn)}
.tt-dot.tt-vhard{background:var(--tt-vhard-bg);border:1px solid var(--bad)}
.tt-dot.tt-del{background:var(--tt-del-strong)}
.tt-dot.tt-ins{background:var(--tt-ins-strong)}
.tt-tip-good{border-left:4px solid var(--good)}
.tt-tip-good .issue-tag{background:var(--good-bg);color:var(--link)}
.tt-tip-info{border-left:4px solid var(--info)}
.tt-tip-info .issue-tag{background:var(--info-bg);color:var(--info-ink)}

/* next-step links */
.tt-next{display:flex;flex-wrap:wrap;align-items:center;gap:8px 14px;padding:14px 18px;border:1px dashed var(--line);border-radius:var(--radius);margin:4px 0 10px;font-size:14px}
.tt-next-k{font-weight:700;color:var(--muted);font-size:12px;text-transform:uppercase;letter-spacing:.06em}
.tt-next a{font-weight:600}

/* case converter */
.tt-case-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:12px}
.tt-case-card{background:var(--bg-soft);border:1px solid var(--line-2);border-radius:11px;padding:10px 12px 12px;min-width:0}
.tt-case-head,.tt-out-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px}
.tt-out-head{margin-top:16px}
.tt-btns{display:flex;gap:6px;flex-wrap:wrap}
.tt-case-name{font-weight:700;font-size:13.5px;color:var(--heading);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.tt-copy,.tt-btns .btn{padding:4px 11px;font-size:12.5px}
textarea.form-control.tt-out{min-height:0;resize:vertical;font-size:14px;padding:9px 11px;background:var(--surface);line-height:1.5}
textarea.form-control.tt-out-tall{min-height:120px;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:13.5px}
.tt-case-big textarea.form-control.tt-out{font-size:18px;font-weight:600;font-family:var(--head)}
.tt-case-big{background:var(--emerald-soft);border-color:var(--good-line)}
.tt-style-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:10px}
.tt-style.on .tt-case-card{border-color:var(--emerald);box-shadow:0 0 0 2px rgba(16,185,129,.18)}
.form-group.tt-dim{opacity:.5}

/* diff */
.tt-diff-tools{display:flex;flex-wrap:wrap;gap:8px}
.tt-diff-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;border:1px solid var(--line);border-radius:10px}
.tt-diff{width:100%;border-collapse:collapse;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:13px;line-height:1.55;table-layout:fixed;min-width:560px}
.tt-diff td{padding:2px 8px;vertical-align:top;white-space:pre-wrap;word-break:break-word}
.tt-diff .tt-ln{width:46px;text-align:right;color:var(--muted-2);background:var(--bg-soft);user-select:none;font-size:12px;border-right:1px solid var(--line-2)}
.tt-diff-unified .tt-sign{width:22px;text-align:center;color:var(--muted);user-select:none}
.tt-diff-split .tt-ln+.tt-code{border-right:1px solid var(--line)}
.tt-diff .tt-c-del,.tt-diff-unified .tt-r-del td{background:var(--tt-del-bg)}
.tt-diff .tt-c-ins,.tt-diff-unified .tt-r-ins td{background:var(--tt-ins-bg)}
.tt-diff .tt-c-empty{background:repeating-linear-gradient(-45deg,var(--bg-soft),var(--bg-soft) 6px,var(--surface) 6px,var(--surface) 12px)}
.tt-diff-unified .tt-r-del .tt-sign{color:var(--tt-del-ink);font-weight:700}
.tt-diff-unified .tt-r-ins .tt-sign{color:var(--tt-ins-ink);font-weight:700}
del.tt-x{background:var(--tt-del-strong);color:var(--tt-del-ink);text-decoration:line-through;text-decoration-thickness:1px;border-radius:3px}
ins.tt-x{background:var(--tt-ins-strong);color:var(--tt-ins-ink);text-decoration:none;border-radius:3px}
.tt-fold td{background:var(--bg-soft2);text-align:center;padding:4px}
.tt-fold-btn{background:none;border:0;color:var(--link);font-weight:600;font-size:12.5px;cursor:pointer;font-family:var(--font)}
.tt-split{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.tt-pane{border:1px solid var(--line);border-radius:10px;overflow:hidden;min-width:0}
.tt-pane-h{background:var(--bg-soft);border-bottom:1px solid var(--line);padding:7px 12px;font-weight:700;font-size:13px;color:var(--heading)}
.tt-lines{margin:0;padding:8px 0;list-style:none;counter-reset:ttl;font-size:14px;line-height:1.65;max-height:560px;overflow:auto}
.tt-lines li{counter-increment:ttl;padding:0 12px 0 52px;position:relative;white-space:pre-wrap;word-break:break-word}
.tt-lines li:before{content:counter(ttl);position:absolute;left:0;width:38px;text-align:right;color:var(--muted-2);font-size:12px;font-family:ui-monospace,Consolas,monospace;user-select:none}

/* language mismatch notice under the text field */
.tt-lang-note{display:flex;align-items:center;flex-wrap:wrap;gap:8px 10px;margin:-6px 0 14px;padding:9px 12px;border-radius:var(--radius-sm);background:var(--info-bg);border:1px solid var(--info-line);color:var(--info-ink);font-size:13.5px}
.tt-lang-note[hidden]{display:none}
.tt-lang-note span{flex:1;min-width:180px}
.tt-lang-note .btn{padding:4px 12px;font-size:12.5px}
.tt-lang-x{background:none;border:0;color:inherit;font-size:18px;line-height:1;cursor:pointer;padding:2px 4px;opacity:.7}
.tt-lang-x:hover{opacity:1}

/* grammar editor */
.gc-app{position:relative;margin-top:6px}
.gc-bar{display:flex;flex-wrap:wrap;justify-content:space-between;gap:10px;margin-bottom:10px}
.gc-chips,.gc-acts{display:flex;flex-wrap:wrap;gap:6px;align-items:center}
.gc-chip{display:inline-flex;align-items:center;gap:6px;border:1.5px solid var(--line);background:var(--surface);color:var(--muted);border-radius:999px;padding:5px 12px;font-size:13px;font-weight:600;cursor:pointer;font-family:var(--font);transition:.15s}
.gc-chip b{font-weight:800}
.gc-chip.on{color:var(--heading);border-color:currentColor}
.gc-chip.on.gc-chip-spelling{color:var(--gc-spelling);background:var(--gc-spelling-bg)}
.gc-chip.on.gc-chip-grammar{color:var(--gc-grammar);background:var(--gc-grammar-bg)}
.gc-chip.on.gc-chip-punctuation{color:var(--gc-punctuation);background:var(--gc-punctuation-bg)}
.gc-chip.on.gc-chip-style{color:var(--gc-style);background:var(--gc-style-bg)}
.gc-chip:not(.on){text-decoration:line-through;text-decoration-color:var(--muted-2)}
.gc-sw{width:10px;height:10px;border-radius:50%;display:inline-block;background:var(--muted-2)}
.gc-chip-spelling .gc-sw,.gc-t-spelling .gc-sw{background:var(--gc-spelling)}
.gc-chip-grammar .gc-sw,.gc-t-grammar .gc-sw{background:var(--gc-grammar)}
.gc-chip-punctuation .gc-sw,.gc-t-punctuation .gc-sw{background:var(--gc-punctuation)}
.gc-chip-style .gc-sw,.gc-t-style .gc-sw{background:var(--gc-style)}
.gc-acts .btn{padding:6px 13px;font-size:13px}
.gc-acts .btn[disabled]{opacity:.45;cursor:not-allowed}
.gc-status{margin-bottom:10px}
.gc-hint{font-size:13px}
.gc-editor{white-space:pre-wrap;word-break:break-word;font-size:16px;line-height:1.9;background:var(--surface);border:1.5px solid var(--line);border-radius:var(--radius-sm);padding:16px 18px;min-height:120px;color:var(--ink)}
.gc-m{cursor:pointer;border-radius:3px;text-decoration-line:underline;text-decoration-style:wavy;text-decoration-thickness:1.5px;text-underline-offset:4px;text-decoration-skip-ink:none;outline-offset:2px}
.gc-m.gc-spelling{text-decoration-color:var(--gc-spelling)}
.gc-m.gc-grammar{text-decoration-color:var(--gc-grammar)}
.gc-m.gc-punctuation{text-decoration-color:var(--gc-punctuation);text-decoration-style:solid;text-decoration-thickness:2.5px}
.gc-m.gc-style{text-decoration-color:var(--gc-style);text-decoration-style:dotted;text-decoration-thickness:2.5px}
.gc-m.gc-spelling:hover,.gc-m.gc-spelling:focus{background:var(--gc-spelling-bg)}
.gc-m.gc-grammar:hover,.gc-m.gc-grammar:focus{background:var(--gc-grammar-bg)}
.gc-m.gc-punctuation:hover,.gc-m.gc-punctuation:focus{background:var(--gc-punctuation-bg)}
.gc-m.gc-style:hover,.gc-m.gc-style:focus{background:var(--gc-style-bg)}
.gc-pop{position:absolute;z-index:40;width:300px;max-width:calc(100% - 8px);background:var(--surface);border:1px solid var(--line);border-radius:12px;box-shadow:var(--shadow-lg);padding:12px 14px}
.gc-pop[hidden]{display:none}
.gc-pop-type{display:flex;align-items:center;gap:7px;font-size:12px;font-weight:800;text-transform:uppercase;letter-spacing:.05em;color:var(--muted)}
.gc-pop-msg{font-size:14px;color:var(--ink);margin:6px 0 10px;line-height:1.5}
.gc-reps{display:flex;flex-wrap:wrap;gap:6px}
.gc-rep{border:0;background:var(--emerald);color:#fff;font-weight:700;font-size:14px;border-radius:8px;padding:6px 12px;cursor:pointer;font-family:var(--font)}
.gc-rep:hover,.gc-rep:focus{background:var(--emerald-d)}
.gc-rep em{font-style:normal;opacity:.9}
.gc-pop-none{font-size:13px}
.gc-pop-foot{display:flex;justify-content:space-between;align-items:center;margin-top:10px;padding-top:8px;border-top:1px solid var(--line-2)}
.gc-ignore,.gc-close{background:none;border:0;color:var(--muted);font-weight:600;font-size:13px;cursor:pointer;font-family:var(--font);padding:4px 6px;border-radius:6px}
.gc-ignore:hover,.gc-close:hover{color:var(--heading);background:var(--bg-soft)}
.gc-close{font-size:18px;line-height:1}

@media (max-width:640px){
  .tt-split{grid-template-columns:1fr}
  .tt-head{gap:16px}
  .tt-head .viz-ring{margin:0 auto}
  .tt-case-grid{grid-template-columns:1fr}
  .gc-bar{flex-direction:column}
  .tt-sitem{padding-left:40px}
}
@media print{
  .tt-diff-tools,.tt-copy,.tt-btns,.gc-bar,.gc-pop,.tt-next,.tt-fold{display:none !important}
  .tt-fulltext,.tt-lines{max-height:none;overflow:visible}
}
.tt-diffapp .viz-ring-num{font-size:28px}
.tt-top th.num{text-align:right}

/* AI Content Detector result (task #460) */
.ai-head{display:flex;gap:22px;align-items:center;flex-wrap:wrap}.ai-head .viz-ring{flex:0 0 auto}.ai-head-body{flex:1 1 320px;min-width:0}
.ai-verdict{font-size:18px;font-weight:700;margin:0 0 10px}.ai-verdict.good{color:var(--good)}.ai-verdict.warn{color:var(--warn-ink,var(--warn))}.ai-verdict.bad{color:var(--bad-ink,var(--bad))}
.ai-legend{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:12px;font-size:13px}
.ai-text{line-height:1.85;font-size:15px;white-space:normal;word-wrap:break-word}
.ai-s{border-radius:4px;padding:1px 2px;box-decoration-break:clone;-webkit-box-decoration-break:clone}
.ai-s.lo{background:var(--good-bg);box-shadow:inset 0 -2px 0 var(--good-line)}.ai-s.mid{background:var(--warn-bg);box-shadow:inset 0 -2px 0 var(--warn-line)}.ai-s.hi{background:var(--bad-bg);box-shadow:inset 0 -2px 0 var(--bad-line)}
.ai-legend .ai-s{padding:2px 8px}
.ai-disclaimer{margin-bottom:14px}
