/* ==========================================================================
   LLM Agent UI · Tilda-hardened v18.3
   КУДА: Настройки сайта → Ещё → HTML-код для вставки внутрь HEAD   ИЛИ
         блок T123 «HTML-код» САМЫМ ПЕРВЫМ на странице.
   ВСЕГДА в  ... </style>.

   ПОЧЕМУ ТАК: префикс #allrecords .llmag даёт вес (1,1,x) — выше, чем у
   встроенных правил Тильды (#allrecords input = (1,0,1)). Поэтому поля,
   кнопки и заголовки не сбрасываются стилями Тильды.

   ОБЯЗАТЕЛЬНО: вокруг разметки виджета должна быть обёртка
   <div class="llmag"> ... </div>  — без неё не работает НИ ОДНО правило.
   Локальный тест вне Тильды: <div id="allrecords"><div class="llmag">…</div></div>
   ========================================================================== */

:root{
  --lm-bg:#f5f7fc;--lm-card:#fff;--lm-line:#e6ecf5;--lm-line2:#eef2f8;
  --lm-text:#172033;--lm-muted:#6b788d;
  --lm-blue:#0066cc;--lm-blue2:#0047b3;--lm-bsoft:#f0f4ff;--lm-bline:#d5e2f5;
  --lm-green:#168653;--lm-gsoft:#edfff4;
  --lm-orange:#b86c00;--lm-osof:#fff6e6;
  --lm-red:#c43f3f;--lm-rsoft:#fff0f0;
  --lm-font:'Google Sans','Roboto','Segoe UI',Arial,sans-serif;
  --lm-mono:'SF Mono',Consolas,'Liberation Mono',monospace;
}

/* --- 0. ПРОБА: этот блок обязан исчезнуть после подключения CSS --- */
.lm-probe{display:none!important}

/* --- 1. КОРЕНЬ ВИДЖЕТА --- */
#allrecords .llmag{display:block;max-width:1560px;margin:0 auto;padding:24px 16px 60px;
  background:var(--lm-bg);color:var(--lm-text);font-family:var(--lm-font);
  font-size:14px;line-height:1.5;text-align:left;-webkit-font-smoothing:antialiased}
#allrecords .llmag *,#allrecords .llmag *::before,#allrecords .llmag *::after{box-sizing:border-box}
#allrecords .llmag h1,#allrecords .llmag h2,#allrecords .llmag h3,#allrecords .llmag h4,
#allrecords .llmag p,#allrecords .llmag figure{margin:0;padding:0;font-family:var(--lm-font)}
#allrecords .llmag ul,#allrecords .llmag ol{margin:0;padding:0;list-style:none}
#allrecords .llmag b,#allrecords .llmag strong{font-weight:700}
#allrecords .llmag .full{grid-column:1/-1}

/* --- 2. ШАПКА --- */
#allrecords .llmag .hero{text-align:center;margin-bottom:20px}
#allrecords .llmag .hero h1{font-size:clamp(1.5rem,3.2vw,2.2rem);font-weight:700;letter-spacing:-.02em;margin-bottom:6px;color:var(--lm-text)}
#allrecords .llmag .hero p{max-width:920px;margin:0 auto;color:var(--lm-muted);font-size:13.5px}
#allrecords .llmag .badges{display:flex;flex-wrap:wrap;justify-content:center;gap:6px;margin-top:12px}
#allrecords .llmag .badge{display:inline-block;padding:3px 11px;border:1px solid var(--lm-bline);
  border-radius:50px;background:var(--lm-bsoft);color:var(--lm-blue);font-size:11px;font-weight:600}

/* --- 3. ПОДСКАЗКИ СВЕРХУ --- */
#allrecords .llmag .guide{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;max-width:1050px;margin:0 auto 22px}
#allrecords .llmag .guide-step{padding:14px;border:1.5px solid var(--lm-line);border-radius:14px;background:#fafcff}
#allrecords .llmag .guide-num{width:30px;height:30px;border-radius:50%;background:var(--lm-blue);color:#fff;
  display:flex;align-items:center;justify-content:center;font-size:15px;font-weight:700;margin-bottom:8px}
#allrecords .llmag .guide-step h4{font-size:14px;font-weight:700;margin-bottom:4px}
#allrecords .llmag .guide-step p{font-size:12.5px;color:#555;line-height:1.5}
#allrecords .llmag .guide-step b{color:var(--lm-blue)}

/* --- 4. КАРКАС --- */
#allrecords .llmag .workspace{display:grid;grid-template-columns:minmax(0,1fr) minmax(430px,600px);gap:18px;align-items:start}
#allrecords .llmag .panel{padding:20px;border:1px solid var(--lm-line);border-radius:20px;
  background:var(--lm-card);box-shadow:0 4px 20px rgba(0,0,0,.04)}
#allrecords .llmag .result-panel{position:sticky;top:16px;max-height:calc(100vh - 32px);display:flex;flex-direction:column}
#allrecords .llmag .section{padding:16px 0;border-bottom:1px solid var(--lm-line2)}
#allrecords .llmag .section:first-child{padding-top:0}
#allrecords .llmag .section:last-child{padding-bottom:0;border-bottom:0}
#allrecords .llmag .section-title{display:flex;align-items:center;flex-wrap:wrap;gap:8px;
  margin-bottom:7px;font-size:15px;font-weight:700;color:var(--lm-text)}
#allrecords .llmag .num{display:inline-flex;align-items:center;justify-content:center;width:23px;height:23px;
  border-radius:50%;background:var(--lm-bsoft);color:var(--lm-blue);font-size:11px;font-weight:700}
#allrecords .llmag .note{margin-bottom:10px;color:var(--lm-muted);font-size:12.5px;line-height:1.5}
#allrecords .llmag .hint{padding:10px 12px;margin-top:8px;border-left:3px solid var(--lm-blue);
  border-radius:0 8px 8px 0;background:#f8fbff;color:#40516c;font-size:12.5px;line-height:1.5}
#allrecords .llmag .sublabel{display:block;margin:14px 0 6px;color:var(--lm-muted);font-size:12px;
  font-weight:600;text-transform:uppercase;letter-spacing:.3px}

/* --- 5. ПЕРЕКЛЮЧАТЕЛЬ РЕЖИМОВ --- */
#allrecords .llmag .mode-switch{display:flex;gap:6px;padding:5px;margin-bottom:16px;
  border:1px solid var(--lm-line);border-radius:14px;background:#fff;overflow-x:auto}
#allrecords .llmag .mode-switch button{flex:1 1 auto;width:auto!important;min-width:110px;min-height:0!important;
  margin:0!important;padding:9px 14px!important;border:0!important;border-radius:10px!important;
  background:transparent!important;color:var(--lm-muted)!important;box-shadow:none!important;
  font-family:var(--lm-font)!important;font-size:13px!important;line-height:1.3!important;
  font-weight:600!important;text-transform:none!important;letter-spacing:normal!important;
  white-space:nowrap;cursor:pointer;text-align:center}
#allrecords .llmag .mode-switch button:hover{background:var(--lm-bsoft)!important;color:var(--lm-text)!important}
#allrecords .llmag .mode-switch button.active{background:var(--lm-blue)!important;color:#fff!important}

/* --- 6. ЧИПЫ --- */
#allrecords .llmag .chips{display:flex;flex-wrap:wrap;gap:7px}
#allrecords .llmag .chip{display:inline-block;width:auto!important;min-height:0!important;margin:0!important;
  padding:6px 14px!important;border:1.5px solid var(--lm-line)!important;border-radius:30px!important;
  background:#fff!important;color:#555!important;box-shadow:none!important;
  font-family:var(--lm-font)!important;font-size:12px!important;line-height:1.35!important;
  font-weight:500!important;text-transform:none!important;letter-spacing:normal!important;
  white-space:nowrap;cursor:pointer;user-select:none}
#allrecords .llmag .chip:hover{border-color:#b0c8e5!important;color:var(--lm-text)!important}
#allrecords .llmag .chip.sel{border-color:var(--lm-blue)!important;background:var(--lm-blue)!important;color:#fff!important}
#allrecords .llmag .chip.fill{border-style:dashed!important;color:#7a8aa0!important}
#allrecords .llmag .chip.forb.sel{background:var(--lm-rsoft)!important;border-color:var(--lm-red)!important;color:var(--lm-red)!important}

/* --- 7. СЕТКА И ПОЛЯ --- */
#allrecords .llmag .grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px 14px}
#allrecords .llmag .grid .field,#allrecords .llmag .result-controls .field{margin-top:0}
#allrecords .llmag .field+.field{margin-top:12px}
#allrecords .llmag .field label{display:block;margin-bottom:5px;color:var(--lm-muted);font-size:12px;
  font-weight:600;text-transform:uppercase;letter-spacing:.3px;line-height:1.4}

/* --- 8. ФОРМ-КОНТРОЛЫ: главный бой с Тильдой --- */
#allrecords .llmag input:not([type="checkbox"]):not([type="radio"]),
#allrecords .llmag textarea,
#allrecords .llmag select{
  display:block;width:100%!important;min-height:0!important;margin:0!important;
  padding:10px 13px!important;border:1.5px solid var(--lm-line)!important;border-radius:12px!important;
  background:#fff!important;color:var(--lm-text)!important;box-shadow:none!important;outline:none!important;
  font-family:var(--lm-font)!important;font-size:13px!important;line-height:1.5!important;
  font-weight:400!important;text-transform:none!important;letter-spacing:normal!important;
  height:auto!important;vertical-align:top}
#allrecords .llmag input:not([type="checkbox"]):not([type="radio"]):focus,
#allrecords .llmag textarea:focus,
#allrecords .llmag select:focus{border-color:var(--lm-blue)!important;box-shadow:0 0 0 3px rgba(0,102,204,.08)!important}
#allrecords .llmag textarea{resize:vertical;min-height:70px;overflow:auto}
#allrecords .llmag ::placeholder{color:#a8b3c4!important;opacity:1}
#allrecords .llmag input[type="checkbox"]{width:16px!important;height:16px!important;min-height:0!important;
  margin:0!important;padding:0!important;flex:0 0 auto;border-radius:4px!important;accent-color:var(--lm-blue)}
#allrecords .llmag .check-line{display:flex;align-items:center;gap:8px;padding:9px 11px;
  border:1.5px solid var(--lm-bline);border-radius:12px;background:#f8fbff;
  font-size:12px;font-weight:600;color:#3b4d68;cursor:pointer}

/* --- 9. КНОПКИ --- */
#allrecords .llmag .button{display:inline-flex;align-items:center;justify-content:center;gap:6px;
  width:auto!important;min-height:0!important;margin:0!important;padding:9px 16px!important;
  border:1.5px solid var(--lm-line)!important;border-radius:12px!important;
  background:#fff!important;color:#43516a!important;box-shadow:none!important;
  font-family:var(--lm-font)!important;font-size:12.5px!important;line-height:1.3!important;
  font-weight:600!important;text-transform:none!important;letter-spacing:normal!important;
  white-space:nowrap;cursor:pointer;text-align:center;vertical-align:middle}
#allrecords .llmag .button:hover{border-color:#abc1df!important;background:#fafcff!important}
#allrecords .llmag .button.primary{border-color:var(--lm-blue)!important;background:var(--lm-blue)!important;color:#fff!important}
#allrecords .llmag .button.primary:hover{border-color:var(--lm-blue2)!important;background:var(--lm-blue2)!important}
#allrecords .llmag .button.danger{color:var(--lm-red)!important}
#allrecords .llmag .button.danger:hover{border-color:var(--lm-red)!important;background:var(--lm-rsoft)!important}
#allrecords .llmag .button.small{padding:6px 12px!important;font-size:12px!important}
#allrecords .llmag .actions,#allrecords .llmag .row{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}

/* --- 10. ДИНАМИЧЕСКИЕ СПИСКИ --- */
#allrecords .llmag .dynamic{display:flex;flex-direction:column;gap:8px}
#allrecords .llmag .dynamic-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:7px;
  align-items:start;padding:8px;border:1px solid var(--lm-line);border-radius:10px;background:#fbfdff}
#allrecords .llmag .dynamic-row textarea{min-height:44px!important;padding:7px 10px!important;
  border-width:1px!important;border-radius:8px!important;font-size:12.5px!important}
#allrecords .llmag .delete-row{width:28px!important;height:28px!important;min-height:0!important;margin:0!important;
  padding:0!important;border:1px solid var(--lm-line)!important;border-radius:50%!important;
  background:#fff!important;color:#8b97a9!important;font-family:var(--lm-font)!important;
  font-size:12px!important;line-height:1!important;cursor:pointer;box-shadow:none!important}
#allrecords .llmag .delete-row:hover{color:var(--lm-red)!important;border-color:var(--lm-red)!important;background:var(--lm-rsoft)!important}
#allrecords .llmag .add-row{width:auto!important;min-height:0!important;padding:6px 14px!important;margin:7px 0 0!important;
  border:1.5px dashed #b9c9dd!important;border-radius:8px!important;background:#fff!important;
  color:var(--lm-blue)!important;font-family:var(--lm-font)!important;font-size:12px!important;
  font-weight:600!important;line-height:1.3!important;cursor:pointer;box-shadow:none!important;text-transform:none!important}
#allrecords .llmag .add-row:hover{border-style:solid!important;background:var(--lm-bsoft)!important}

/* --- 11. БИБЛИОТЕКА ПРОЕКТОВ --- */
#allrecords .llmag .library{display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:12px;
  margin-bottom:16px;border:1px solid var(--lm-bline);border-radius:14px;background:var(--lm-bsoft)}
#allrecords .llmag .library strong{color:var(--lm-blue);font-size:12.5px;font-weight:700}
#allrecords .llmag .library select{flex:1 1 180px;min-width:180px;width:auto!important;padding:8px 11px!important;
  border:1px solid #cbdcf3!important;border-radius:10px!important;font-size:13px!important}

/* --- 12. ПАНЕЛЬ РЕЗУЛЬТАТА --- */
#allrecords .llmag .result-head{display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding-bottom:12px;margin-bottom:12px;border-bottom:1px solid var(--lm-line2)}
#allrecords .llmag .result-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:15px;font-weight:700;color:var(--lm-text)}
#allrecords .llmag .result-controls{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:10px;align-items:end}
#allrecords .llmag .stats{display:flex;flex-wrap:wrap;gap:6px 16px;padding:9px 12px;margin-bottom:10px;
  border:1px solid var(--lm-line2);border-radius:10px;background:#f8fbff;color:var(--lm-muted);font-size:11.5px}
#allrecords .llmag .stats b{color:var(--lm-text)}
#allrecords .llmag .stats .ok b{color:var(--lm-green)}
#allrecords .llmag .stats .warn b{color:var(--lm-orange)}
#allrecords .llmag .stats .over b{color:var(--lm-red)}
#allrecords .llmag .notice{display:none;align-items:center;gap:9px;flex-wrap:wrap;padding:9px 12px;margin-bottom:10px;
  border:1px solid #f1e4bd;border-radius:10px;background:#fffdf0;color:#805f00;font-size:12px}
#allrecords .llmag .notice.visible{display:flex}
#allrecords .llmag .notice .dirty{display:none;padding:2px 8px;border-radius:50px;background:var(--lm-osof);color:var(--lm-orange);font-size:11px;font-weight:700}
#allrecords .llmag .notice.dirty .dirty{display:inline-block}
#allrecords .llmag .notice button{padding:5px 11px!important;margin-left:auto;border:1px solid #e8d595!important;
  border-radius:8px!important;background:#fff!important;color:#805f00!important;font-size:11.5px!important;
  font-weight:700!important;cursor:pointer}
#allrecords .llmag .result-area{display:flex;flex:1;min-height:0;flex-direction:column}
#allrecords .llmag #output{flex:1;width:100%!important;min-height:300px!important;padding:14px 16px!important;
  border:1.5px solid var(--lm-line)!important;border-radius:12px!important;
  font-family:var(--lm-mono)!important;font-size:12.5px!important;line-height:1.7!important;
  white-space:pre-wrap;word-break:break-word;background:#fff!important;color:var(--lm-text)!important}

/* --- 13. СВОРАЧИВАЕМЫЕ БЛОКИ --- */
#allrecords .llmag .collapsible{margin-top:14px;border:1.5px solid var(--lm-line);border-radius:14px;background:#fbfdff;overflow:hidden}
#allrecords .llmag .collapsible-head{display:flex;align-items:center;justify-content:space-between;gap:8px;
  padding:12px 14px;cursor:pointer;font-size:13px;font-weight:700;color:var(--lm-text);user-select:none}
#allrecords .llmag .collapsible-head:hover{background:var(--lm-bsoft)}
#allrecords .llmag .collapsible-head .arrow{color:var(--lm-blue);font-size:11px}
#allrecords .llmag .collapsible.open .collapsible-head .arrow{transform:rotate(90deg)}
#allrecords .llmag .collapsible-body{display:none;padding:0 14px 14px}
#allrecords .llmag .collapsible.open .collapsible-body{display:block}
#allrecords .llmag .collapsible-body textarea{min-height:200px!important;padding:12px 14px!important;
  border-radius:10px!important;font-family:var(--lm-mono)!important;font-size:12px!important;line-height:1.6!important}

/* --- 14. РАЗБОР (парсер) --- */
#allrecords .llmag .parse-summary{padding:10px 12px;margin-top:10px;border-radius:10px;font-size:12.5px;line-height:1.55}
#allrecords .llmag .parse-summary.ok{border:1px solid #b8e3c9;background:var(--lm-gsoft);color:#0f5a37}
#allrecords .llmag .parse-summary.warn{border:1px solid #f1e4bd;background:#fffdf0;color:#805f00}
#allrecords .llmag .parse-summary ul{list-style:disc!important;margin:6px 0 0 18px!important;padding:0!important}
#allrecords .llmag .checks{list-style:none!important;margin:0!important;padding:0!important;font-size:12.5px}
#allrecords .llmag .checks li{padding:5px 0 5px 2px;border-bottom:1px solid var(--lm-line2);line-height:1.5}
#allrecords .llmag .checks li.ok{color:var(--lm-green)}
#allrecords .llmag .checks li.bad{color:var(--lm-orange)}

/* --- 15. МОДИФИКАТОРЫ --- */
#allrecords .llmag .modifier-block{padding:12px 14px;margin-top:8px;border:1.5px solid var(--lm-line);border-radius:12px;background:#fff}
#allrecords .llmag .modifier-title{font-size:13px;font-weight:700;margin-bottom:6px;color:var(--lm-text)}
#allrecords .llmag .modifier-desc{font-size:12px;color:var(--lm-muted);margin-bottom:8px;line-height:1.5}
#allrecords .llmag .modifier-chip{display:inline-block;width:auto!important;min-height:0!important;
  padding:5px 12px!important;border:1.5px solid var(--lm-line)!important;border-radius:30px!important;
  background:#fff!important;color:#555!important;font-family:var(--lm-font)!important;
  font-size:11.5px!important;line-height:1.35!important;font-weight:500!important;
  cursor:pointer;box-shadow:none!important;text-transform:none!important;letter-spacing:normal!important}
#allrecords .llmag .modifier-chip:hover{border-color:#b0c8e5!important;color:var(--lm-text)!important}
#allrecords .llmag .modifier-chip.sel{border-color:var(--lm-blue)!important;background:var(--lm-blue)!important;color:#fff!important}
#allrecords .llmag .modifier-chip.disabled{opacity:.4;cursor:not-allowed;text-decoration:line-through}

/* --- 16. ТОСТ --- */
#allrecords .llmag .toast{position:fixed;z-index:100000;bottom:24px;left:50%;max-width:90vw;
  padding:10px 22px;border-radius:60px;background:#172033;color:#fff;font-family:var(--lm-font);
  font-size:13px;font-weight:600;line-height:1.4;text-align:center;opacity:0;pointer-events:none;
  transform:translate(-50%,90px);box-shadow:0 8px 30px rgba(25,50,90,.25)}
#allrecords .llmag .toast.show{opacity:1;transform:translate(-50%,0)}

/* --- 17. АДАПТИВ --- */
@media(max-width:1150px){
  #allrecords .llmag .workspace{grid-template-columns:1fr}
  #allrecords .llmag .result-panel{position:static;max-height:none}
}
@media(max-width:860px){#allrecords .llmag .guide{grid-template-columns:1fr}}
@media(max-width:700px){#allrecords .llmag .grid{grid-template-columns:1fr}}
@media(max-width:650px){
  #allrecords .llmag{padding:16px 10px 50px}
  #allrecords .llmag .panel{padding:14px;border-radius:14px}
  #allrecords .llmag .hero h1{font-size:1.4rem}
  #allrecords .llmag .library{padding:10px;gap:6px}
}
@media(max-width:480px){#allrecords .llmag .result-controls{grid-template-columns:1fr}}