/* text-editor.css — ИИ-редактор текста (/perefrazirovat-tekst, /ispravit-oshibki-v-tekste).
   Оболочка — как у ИИ-страниц сайта (lesson-plan.css: подшапка, тарифы, частые вопросы). Две колонки: слева текст и действие,
   справа результат с кнопками под ним. Один акцент — синий сайта, градиент ИИ — только на кнопке запуска;
   зелёный и красный — только у подсветки правок (добавлено / убрано). */
.te-app{--te-ac:var(--primary,#4f46e5);--te-soft:rgba(79,70,229,.08);--te-line:rgba(79,70,229,.38);
  --te-ins:#047857;--te-ins-bg:rgba(16,185,129,.16);--te-del:#b91c1c;--te-del-bg:rgba(239,68,68,.11)}
[data-theme="dark"] .te-app{--te-soft:rgba(129,140,248,.14);--te-line:rgba(165,180,252,.45);--te-ins:#6ee7b7;--te-ins-bg:rgba(16,185,129,.2);--te-del:#fca5a5;--te-del-bg:rgba(239,68,68,.18)}
.te-app :where(button){font:inherit;color:inherit}
.te-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin:4px 0 18px}
.te-head h1{font-size:1.65rem;line-height:1.2;font-weight:850;letter-spacing:-.015em;margin:0}
.te-head p{margin:6px 0 0;max-width:640px;color:var(--text-muted);font-size:.95rem;line-height:1.5}
.te-guide{flex:none;display:inline-flex;align-items:center;gap:7px;height:38px;padding:0 14px;border-radius:999px;border:1px solid var(--border-strong);background:var(--surface);cursor:pointer;font-size:13.5px;font-weight:650}
.te-guide:hover{border-color:var(--te-ac);color:var(--te-ac)}
.te-guide svg{width:16px;height:16px}
.te-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:20px;align-items:start}
.te-col{display:flex;flex-direction:column;gap:12px;min-width:0}
.te-out{position:sticky;top:calc(var(--top-offset,116px) + 14px)}
.te-card{background:var(--surface);border:1px solid var(--border);border-radius:18px;padding:16px}
[data-theme="dark"] .te-card{background:var(--white)}
.te-ct{font-size:14.5px;font-weight:750;color:var(--text)}

/* текст */
.te-ch{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:0 0 10px}
.te-tools{display:flex;gap:4px}
.te-tb{display:inline-flex;align-items:center;gap:6px;height:32px;padding:0 10px;border-radius:9px;border:0;background:transparent;color:var(--text-muted);font-size:13px;font-weight:650;cursor:pointer}
.te-tb:hover{background:var(--surface-2);color:var(--text)}
.te-tb svg{width:15px;height:15px;flex:none}
.te-ta{display:block;width:100%;min-height:240px;max-height:620px;padding:14px 15px;border-radius:13px;border:1px solid transparent;background:var(--surface-2);color:var(--text);
  font:inherit;font-size:15.5px;line-height:1.6;resize:vertical;outline:0;transition:border-color .15s,box-shadow .15s,background-color .15s}
[data-theme="dark"] .te-ta{background:var(--surface)}
.te-ta:hover{border-color:var(--border)}
.te-ta:focus{background:var(--surface);border-color:var(--te-line);box-shadow:0 0 0 3px var(--te-soft)}
[data-theme="dark"] .te-ta:focus{background:var(--bg)}
.te-ta.bad{border-color:var(--danger)}
.te-ta::placeholder{color:var(--text-faint)}
.te-cf{display:flex;justify-content:space-between;gap:10px;margin:8px 2px 0;font-size:12.5px;color:var(--text-faint);font-variant-numeric:tabular-nums}
.te-cnt.over{color:var(--danger);font-weight:700}

/* действие и сила */
.te-acts .te-ct{margin:0 0 10px}
.te-chips{display:flex;flex-wrap:wrap;gap:6px}
.te-chip{display:inline-flex;align-items:center;gap:7px;height:38px;padding:0 13px 0 11px;border-radius:999px;border:1px solid var(--border);background:var(--surface);
  cursor:pointer;font-size:13.5px;font-weight:650;line-height:1;white-space:nowrap;color:var(--text-muted);transition:border-color .15s,background-color .15s,color .15s}
[data-theme="dark"] .te-chip{background:var(--surface)}
.te-chip svg{width:17px;height:17px;flex:none}
.te-chip:hover{border-color:var(--border-strong);color:var(--text)}
.te-chip.on{border-color:var(--te-line);background:var(--te-soft);color:var(--te-ac)}
[data-theme="dark"] .te-chip.on{color:#c7d2fe}
.te-chip:focus-visible{outline:2px solid var(--te-line);outline-offset:2px}
.te-ah{margin:10px 2px 0;font-size:13px;line-height:1.45;color:var(--text-muted)}
.te-lv{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:12px;padding-top:12px;border-top:1px solid var(--border)}
.te-lt{font-size:13.5px;font-weight:700}
.te-seg{display:grid;grid-template-columns:repeat(3,auto);gap:3px;padding:3px;border-radius:11px;background:var(--surface-2)}
[data-theme="dark"] .te-seg{background:var(--surface)}
.te-seg button{height:32px;padding:0 11px;border:0;border-radius:8px;background:transparent;color:var(--text-muted);font-size:13px;font-weight:700;cursor:pointer;white-space:nowrap}
.te-seg button:hover{color:var(--text)}
.te-seg button[aria-checked="true"]{background:var(--surface);color:var(--text);box-shadow:0 1px 2px rgba(15,23,42,.14)}
[data-theme="dark"] .te-seg button[aria-checked="true"]{background:var(--border-strong)}

/* дополнительно */
.te-adv{padding:0}
.te-advh{display:flex;align-items:center;gap:10px;width:100%;min-height:52px;padding:12px 16px;border:0;border-radius:18px;background:transparent;cursor:pointer;text-align:left}
.te-advh>span{font-size:14.5px;font-weight:750}
.te-advh small{flex:1;min-width:0;text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12.5px;font-weight:650;color:var(--te-ac)}
.te-advh:focus-visible{outline:2px solid var(--te-line);outline-offset:-2px}
.te-chev{width:16px;height:16px;flex:none;color:var(--text-faint);transition:transform .2s}
.te-advh[aria-expanded="true"] .te-chev{transform:rotate(90deg)}
.te-advb{padding:0 16px 14px}
.te-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 0;border-top:1px solid var(--border)}
.te-row>span{display:flex;flex-direction:column;min-width:0;font-size:14px;font-weight:650}
.te-row small{font-size:12px;font-weight:500;color:var(--text-muted)}
.te-sw{position:relative;flex:none;width:44px;height:26px;border:0;border-radius:999px;background:var(--border-strong);cursor:pointer;transition:background .2s}
.te-sw::after{content:"";position:absolute;top:3px;left:3px;width:20px;height:20px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.25);transition:transform .2s}
.te-sw[aria-checked="true"]{background:var(--te-ac)}
.te-sw[aria-checked="true"]::after{transform:translateX(18px)}
.te-sw:focus-visible{outline:2px solid var(--te-line);outline-offset:2px}
.te-wl{display:block;margin:12px 0 7px;padding-top:12px;border-top:1px solid var(--border);font-size:13.5px;font-weight:700}
.te-inp{display:block;width:100%;height:44px;padding:0 13px;border-radius:12px;border:1px solid transparent;background:var(--surface-2);color:var(--text);font:inherit;font-size:14.5px;outline:0}
[data-theme="dark"] .te-inp{background:var(--surface)}
.te-inp:focus{border-color:var(--te-line);box-shadow:0 0 0 3px var(--te-soft)}

/* кнопка запуска: градиент ИИ, справа — сколько спишется; прилипает к низу экрана, пока колонка длиннее экрана */
.te-run{position:sticky;bottom:0;z-index:5;display:flex;flex-direction:column;gap:8px;margin-top:-4px;padding:10px 0 12px;background:linear-gradient(to bottom,transparent,var(--bg) 12px)}
body.te-body #sc-btn{bottom:var(--te-float,22px)!important;transition:bottom .2s}
body.te-body #sc-panel{bottom:calc(var(--te-float,22px) + 68px)!important}
body.te-body .ait-nudge{bottom:var(--te-float,22px)!important}
body.te-body:has(.modal.show) #sc-btn,body.te-body:has(.ait-modal.show) #sc-btn{display:none!important}
.te-go{display:flex;align-items:center;gap:12px;width:100%;min-height:56px;padding:8px 10px 8px 18px;border:0;border-radius:15px;background:var(--ai-grad);background-size:160% 100%;color:#fff!important;
  cursor:pointer;text-align:left;font-size:16px;font-weight:800;box-shadow:inset 0 1px 0 rgba(255,255,255,.22);transition:background-position .6s ease,transform .08s}
.te-go:hover{background-position:100% 50%}
.te-go:active{transform:scale(.99)}
.te-go:focus-visible{outline:3px solid var(--te-line);outline-offset:2px}
.te-go[disabled]{cursor:default;opacity:.75;transform:none}
.te-go-i{width:22px;height:22px;flex:none}
.te-go-t{flex:1;min-width:0}
.te-go-c{flex:none;display:inline-flex;align-items:center;gap:5px;height:34px;padding:0 12px;border-radius:11px;background:rgba(255,255,255,.18);font-size:15px;font-variant-numeric:tabular-nums}
.te-go-c svg{width:14px;height:14px}
.te-bal{margin:0 2px;font-size:13px;line-height:1.45;color:var(--text-muted);text-align:center}
.te-bal b{color:var(--text)}
.te-lnk{border:0;background:none;padding:0;color:var(--te-ac);font-weight:700;cursor:pointer;text-decoration:underline;text-underline-offset:3px}

/* результат */
.te-res{min-height:420px;display:flex;flex-direction:column}
.te-empty{display:flex;flex-direction:column;gap:12px;padding:6px 4px}
.te-eh{font-size:17px;font-weight:800}
.te-empty>p{margin:0;font-size:14px;line-height:1.55;color:var(--text-muted)}
.te-demo{padding:14px 15px;border-radius:14px;background:var(--surface-2);border:1px solid var(--border)}
[data-theme="dark"] .te-demo{background:var(--surface)}
.te-dl{margin-bottom:6px;font-size:11.5px;font-weight:800;letter-spacing:.07em;text-transform:uppercase;color:var(--text-faint)}
.te-demo p{margin:0;font-size:15px;line-height:1.75}
.te-feat{list-style:none;margin:2px 0 0;padding:0;display:grid;gap:8px}
.te-feat li{display:flex;gap:9px;align-items:flex-start;font-size:13.5px;line-height:1.45;color:var(--text-muted)}
.te-feat svg{width:16px;height:16px;flex:none;margin-top:2px;color:var(--te-ac)}
.te-app ins,.te-app del{text-decoration:none;border-radius:4px;padding:0 1px}
.te-app ins{background:var(--te-ins-bg);color:var(--te-ins);font-weight:600}
.te-app del{background:var(--te-del-bg);color:var(--te-del);text-decoration:line-through;text-decoration-thickness:1.5px}
/* ждём */
.te-wt{display:flex;align-items:center;gap:12px;margin:2px 0 18px}
.te-wi{display:grid;place-items:center;width:40px;height:40px;border-radius:12px;background:var(--ai-grad);color:#fff;flex:none}
.te-wi svg{width:20px;height:20px;animation:tePulse 1.6s ease-in-out infinite}
.te-wt b{display:block;font-size:15px}
.te-wt small{font-size:12.5px;color:var(--text-muted);font-variant-numeric:tabular-nums}
.te-sk{display:grid;gap:12px}
.te-sk i{display:block;height:12px;border-radius:6px;background:linear-gradient(90deg,var(--surface-2) 25%,var(--border) 50%,var(--surface-2) 75%);background-size:300% 100%;animation:teSh 1.4s linear infinite}
@keyframes teSh{from{background-position:100% 0}to{background-position:-200% 0}}
@keyframes tePulse{0%,100%{transform:scale(.85);opacity:.75}50%{transform:scale(1.05);opacity:1}}
/* не вышло */
.te-fl{display:flex;flex-direction:column;align-items:center;gap:8px;margin:auto;padding:30px 10px;text-align:center;max-width:380px}
.te-fi{display:grid;place-items:center;width:46px;height:46px;border-radius:14px;background:var(--danger-bg);color:var(--danger)}
.te-fi svg{width:22px;height:22px}
.te-fl b{font-size:16px}
.te-fl p{margin:0 0 8px;font-size:13.5px;line-height:1.5;color:var(--text-muted)}
/* готово */
.te-rh{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px 12px;margin:0 0 12px}
.te-tabs{display:grid;grid-template-columns:auto auto;gap:3px;padding:3px;border-radius:12px;background:var(--surface-2)}
[data-theme="dark"] .te-tabs{background:var(--surface)}
.te-tabs button{display:inline-flex;align-items:center;gap:6px;height:34px;padding:0 13px;border:0;border-radius:9px;background:transparent;color:var(--text-muted);font-size:13.5px;font-weight:700;cursor:pointer}
.te-tabs button[aria-selected="true"]{background:var(--surface);color:var(--text);box-shadow:0 1px 2px rgba(15,23,42,.14)}
[data-theme="dark"] .te-tabs button[aria-selected="true"]{background:var(--border-strong)}
.te-tabs i{font-style:normal;min-width:20px;height:20px;padding:0 6px;border-radius:7px;background:var(--te-soft);color:var(--te-ac);font-size:12px;line-height:20px;text-align:center}
.te-st{font-size:12.5px;color:var(--text-muted);font-variant-numeric:tabular-nums}
.te-st b{color:var(--text);font-weight:700}
.te-doc{flex:1;min-height:200px;max-height:min(58vh,640px);overflow-y:auto;padding:15px 16px;border-radius:13px;background:var(--surface-2);border:1px solid var(--border);
  font-size:15.5px;line-height:1.7;white-space:pre-wrap;overflow-wrap:anywhere;color:var(--text);outline:0}
[data-theme="dark"] .te-doc{background:var(--surface)}
.te-doc[contenteditable="true"]:focus{border-color:var(--te-line);box-shadow:0 0 0 3px var(--te-soft)}
.te-hint,.te-note{margin:8px 2px 0;font-size:12.5px;color:var(--text-faint)}
.te-notes{margin-top:12px;padding:12px 14px;border-radius:13px;border:1px solid var(--border)}
.te-nh{margin:0 0 8px;font-size:11.5px;font-weight:800;letter-spacing:.07em;text-transform:uppercase;color:var(--text-faint)}
.te-notes ol{margin:0;padding:0 0 0 20px;display:grid;gap:7px}
.te-notes li{font-size:13.5px;line-height:1.45;color:var(--text)}
.te-notes li::marker{color:var(--text-faint);font-size:12px}
.te-np{display:inline-flex;align-items:center;flex-wrap:wrap;gap:4px 6px;vertical-align:baseline}
.te-np svg{width:13px;height:13px;color:var(--text-faint)}
.te-na{color:var(--te-del);text-decoration:line-through;text-decoration-thickness:1.5px}
.te-nb{color:var(--te-ins);font-weight:700}
.te-notes small{display:block;margin-top:1px;font-size:12.5px;color:var(--text-muted)}
.te-ra{display:grid;grid-template-columns:1.2fr 1fr 1fr;gap:8px;margin-top:14px}
.te-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:46px;padding:0 12px;border-radius:13px;border:1px solid var(--border-strong);background:var(--surface);
  cursor:pointer;font-size:14px;font-weight:700;color:var(--text);white-space:nowrap}
[data-theme="dark"] .te-btn{background:var(--surface)}
.te-btn:hover{border-color:var(--te-ac);color:var(--te-ac)}
.te-btn svg{width:17px;height:17px;flex:none}
.te-btn.main{border-color:var(--te-ac);background:var(--te-ac);color:#fff}
.te-btn.main:hover{background:var(--primary-d,#4338ca);color:#fff}
.te-back{display:inline-flex;align-items:center;gap:7px;align-self:center;margin-top:10px;height:34px;padding:0 10px;border:0;border-radius:10px;background:none;color:var(--text-muted);font-size:13px;font-weight:650;cursor:pointer}
.te-back:hover{background:var(--surface-2);color:var(--text)}
.te-back svg{width:15px;height:15px}

/* недавние правки */
.te-hist{margin-top:20px;padding:14px 16px;border-radius:18px;border:1px solid var(--border);background:var(--surface)}
[data-theme="dark"] .te-hist{background:var(--white)}
.te-hh{display:flex;align-items:center;justify-content:space-between;margin:0 2px 10px;font-size:14.5px}
.te-hh a{font-size:13px;font-weight:650;color:var(--te-ac);text-decoration:none}
.te-hl{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.te-hi{display:flex;align-items:center;gap:10px;min-width:0;padding:10px 12px;border-radius:13px;border:1px solid var(--border);background:var(--surface-2);cursor:pointer;text-align:left}
[data-theme="dark"] .te-hi{background:var(--surface)}
.te-hi:hover{border-color:var(--border-strong)}
.te-hic{display:grid;place-items:center;width:34px;height:34px;flex:none;border-radius:10px;background:var(--te-soft);color:var(--te-ac)}
.te-hic svg{width:17px;height:17px}
.te-hit{min-width:0}
.te-hit b{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13.5px;font-weight:650}
.te-hit small{display:block;font-size:12px;color:var(--text-muted)}

/* блоки ниже */
.te-how-g{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;margin-top:16px}
.te-how-g div{padding:16px;border-radius:16px;background:var(--surface-2);border:1px solid var(--border)}
.te-how-g b{display:block;font-size:15px;margin-bottom:6px;color:var(--text)}
.te-how-g span{font-size:13.5px;line-height:1.5;color:var(--text-muted)}
.te-guide-m .modal-card{max-width:560px;text-align:left}
.te-g-list{margin:12px 0 14px;padding-left:20px;font-size:14.5px;line-height:1.55}
.te-g-list li{margin:0 0 8px}
.te-g-note{margin:0 0 10px;padding:11px 13px;border-radius:12px;background:var(--surface-2);font-size:13.5px;line-height:1.5;color:var(--text-muted)}
.te-g-note b{color:var(--text)}

@media(max-width:1000px){.te-how-g{grid-template-columns:repeat(2,1fr)}.te-hl{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:860px){
  .te-grid{grid-template-columns:minmax(0,1fr)}
  .te-out{position:static}
  .te-res{min-height:0}
  .te-doc{max-height:none}
}
@media(max-width:600px){
  .te-head{margin:0 0 12px}
  .te-head h1{font-size:1.35rem}
  .te-head p{font-size:.9rem}
  .te-guide{width:40px;height:40px;padding:0;justify-content:center}.te-guide span{display:none}
  .te-card{padding:13px 12px;border-radius:16px}
  .te-adv{padding:0}.te-advh{padding:12px}.te-advb{padding:0 12px 12px}
  .te-ta{font-size:16px;min-height:220px}
  .te-kbd{display:none}
  .te-tb span{display:none}.te-tb{width:36px;padding:0;justify-content:center}
  .te-chip{height:40px;font-size:13.5px}
  .te-run{padding-bottom:calc(10px + env(safe-area-inset-bottom))}
  .te-lv{flex-direction:column;align-items:stretch}
  .te-seg{grid-template-columns:repeat(3,minmax(0,1fr))}
  .te-seg button{padding:0 6px}
  .te-inp{font-size:16px}
  .te-ra{grid-template-columns:minmax(0,1fr)}
  .te-btn{min-height:50px}
  .te-hl{grid-template-columns:minmax(0,1fr)}
  .te-how-g{grid-template-columns:1fr}
}
@media(prefers-reduced-motion:reduce){.te-sk i,.te-wi svg{animation:none}.te-go,.te-sw,.te-sw::after,.te-chev{transition:none}}
