/* =====================================================================
   Assistant LaTeX — styles (limités à .lx / .lx-*), variables --ot-*
   ===================================================================== */
.lx { --lx-accent: #0f766e; --lx-sel: #2563eb; --lx-warn: #b45309; --lx-err: #c81e1e; --lx-ok: #15803d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lx { --lx-accent: #2dd4bf; --lx-sel: #60a5fa; --lx-warn: #fbbf24; --lx-err: #f87171; --lx-ok: #4ade80; } }
:root[data-theme="dark"] .lx { --lx-accent: #2dd4bf; --lx-sel: #60a5fa; --lx-warn: #fbbf24; --lx-err: #f87171; --lx-ok: #4ade80; }

.lx-head h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); }
.lx-project { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: -4px 0 var(--ot-space); font-size: .88rem; color: var(--ot-text-soft); }

/* Onglets */
.lx-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 var(--ot-space); border-bottom: 1px solid var(--ot-border); }
.lx-tab { font: inherit; font-weight: 700; font-size: .92rem; padding: 9px 14px; border: 1px solid transparent; border-bottom: 0; border-radius: var(--ot-radius-s) var(--ot-radius-s) 0 0;
  background: transparent; color: var(--ot-text-soft); cursor: pointer; margin-bottom: -1px; }
.lx-tab:hover { color: var(--ot-text); background: var(--ot-surface-2); }
.lx-tab[aria-selected="true"] { color: var(--ot-text); background: var(--ot-surface); border-color: var(--ot-border); border-bottom-color: var(--ot-surface); }
.lx-tab:focus-visible { outline: 2px solid var(--lx-accent); outline-offset: 2px; }
@media (max-width: 560px) { .lx-tab { padding: 7px 9px; font-size: .82rem; } }

.lx-panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.lx-hint { margin: 0; font-size: .86rem; color: var(--ot-text-soft); }
.lx-h3 { margin: 6px 0 0; font-size: 1rem; }
.lx-mini { min-height: 32px; padding: 4px 12px; font-size: .84rem; }
.lx-mini-sel { min-height: 32px; padding: 3px 8px; font-size: .84rem; width: auto; }
.lx-toolbar { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.lx-tg { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.lx-tl { font-size: .84rem; font-weight: 700; color: var(--ot-text-soft); }
.lx-sw-group { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.lx-sw { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--ot-border); cursor: pointer; padding: 0; display: inline-grid; place-items: center; font-size: .8rem; background: var(--ot-surface); color: var(--ot-text); }
.lx-sw:hover { transform: scale(1.12); }
.lx-sw-pick { position: relative; overflow: hidden; }
.lx-sw-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Grille du tableau */
.lx-grid-wrap { overflow: auto; border: 1px solid var(--ot-border); border-radius: var(--ot-radius-s); background: var(--ot-surface); max-height: 70vh; }
.lx-grid { border-collapse: collapse; min-width: 100%; }
.lx-grid th, .lx-grid td { border: 1px solid var(--ot-border); padding: 0; }
.lx-grid thead th { background: var(--ot-surface-2); position: sticky; top: 0; z-index: 1; }
.lx-colset { display: flex; gap: 3px; padding: 4px; }
.lx-colset select, .lx-colset input { font: inherit; font-size: .75rem; padding: 2px 3px; border: 1px solid var(--ot-border); border-radius: 4px; background: var(--ot-surface); color: var(--ot-text); min-width: 0; }
.lx-colset input { width: 56px; }
.lx-rowh { background: var(--ot-surface-2); width: 1%; }
.lx-rowh input { width: 52px; font: inherit; font-size: .75rem; padding: 2px 3px; margin: 3px; border: 1px solid var(--ot-border); border-radius: 4px; background: var(--ot-surface); color: var(--ot-text); }
.lx-grid td { min-width: 110px; position: relative; }
.lx-grid td input { width: 100%; min-width: 0; height: 100%; min-height: 34px; border: 0; padding: 6px 8px; font: inherit; background: transparent; color: #111; }
.lx-grid td input:focus { outline: none; }
.lx-grid td.is-sel { outline: 2px solid var(--lx-sel); outline-offset: -2px; box-shadow: inset 0 0 0 999px color-mix(in srgb, var(--lx-sel) 12%, transparent); }
:root[data-theme="dark"] .lx-grid td:not([style]) input { color: var(--ot-text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lx-grid td:not([style]) input { color: var(--ot-text); } }

.lx-paste textarea { width: 100%; margin: 6px 0; font-family: var(--ot-mono); font-size: .85rem; }
.lx-paste summary, .lx-more summary { cursor: pointer; font-weight: 700; font-size: .9rem; color: var(--lx-accent); }

/* Options */
.lx-topts h3, .lx-box h3 { margin: 0 0 10px; font-size: 1rem; }
.lx-fields { display: grid; gap: 10px 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); align-items: end; }
.lx-f { display: flex; flex-direction: column; gap: 4px; font-size: .84rem; font-weight: 700; min-width: 0; }
.lx-f .ot-input, .lx-f .ot-select { font-weight: 400; min-height: 38px; padding: 6px 9px; width: 100%; }
.lx-checks { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; gap: 6px 18px; font-weight: 600; }
.lx-checks label { display: inline-flex; align-items: center; gap: 6px; }
.lx-checks input[type=checkbox] { accent-color: var(--lx-accent); width: 16px; height: 16px; }
.lx-checks input[type=color] { width: 30px; height: 24px; padding: 0; border: 1px solid var(--ot-border); border-radius: 4px; }

/* Aperçu */
.lx-preview { overflow: auto; padding: 16px; border: 1px dashed var(--ot-border); border-radius: var(--ot-radius-s); background: #fff; color: #111; min-height: 60px; }
.lx-prev-t { border-collapse: collapse; margin: 0 auto; font-family: "Latin Modern Roman", "Times New Roman", serif; font-size: 1.02rem; }
.lx-prev-t.is-full { width: 100%; }
.lx-prev-t caption { caption-side: top; padding-bottom: 8px; font-size: .95rem; }
.lx-prev-t td { line-height: 1.35; }
.lx-rot { display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
.lx-preview svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.lx-preview .katex { font-size: 1.05em; }

/* Code */
.lx-out { border: 1px solid var(--ot-border); border-radius: var(--ot-radius-s); background: var(--ot-surface); overflow: hidden; }
.lx-out-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--ot-border); background: var(--ot-surface-2); }
.lx-out-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.lx-pre { margin: 0; padding: 12px 14px; max-height: 420px; overflow: auto; font-family: var(--ot-mono); font-size: .84rem; line-height: 1.5; white-space: pre; tab-size: 2; }
.lx-pk { padding: 8px 14px 12px; font-size: .84rem; border-top: 1px dashed var(--ot-border); }
.lx-pk code { font-family: var(--ot-mono); font-size: .82rem; }
.lx-err { color: var(--lx-err); }
.lx-ok { color: var(--lx-ok); }
.lx-warnc { color: var(--lx-warn); }

/* Listes d'objets (TikZ, variations…) */
.lx-box { display: flex; flex-direction: column; gap: 10px; }
.lx-rows { display: flex; flex-direction: column; gap: 6px; }
.lx-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 8px; border: 1px solid var(--ot-border); border-radius: var(--ot-radius-s); background: var(--ot-surface); }
.lx-row input, .lx-row select { font: inherit; font-size: .85rem; padding: 4px 6px; border: 1px solid var(--ot-border); border-radius: 5px; background: var(--ot-surface); color: var(--ot-text); min-width: 0; }
.lx-row input[type=color] { width: 32px; height: 28px; padding: 0; }
.lx-row .lx-w-s { width: 64px; } .lx-row .lx-w-m { width: 110px; } .lx-row .lx-w-l { flex: 1 1 160px; }
.lx-row label { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; color: var(--ot-text-soft); }
.lx-x { border: 0; background: transparent; color: var(--ot-text-soft); cursor: pointer; font-size: 1rem; padding: 2px 6px; border-radius: 5px; margin-left: auto; }
.lx-x:hover { color: var(--lx-err); background: var(--ot-surface-2); }
.lx-two { display: grid; gap: var(--ot-space); grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 900px) { .lx-two { grid-template-columns: minmax(0, 1fr); } }
.lx-mgrid { display: inline-grid; gap: 4px; }
.lx-mgrid input { width: 70px; font: inherit; font-size: .85rem; padding: 5px; border: 1px solid var(--ot-border); border-radius: 5px; background: var(--ot-surface); color: var(--ot-text); text-align: center; }
.lx-palette { display: flex; flex-direction: column; gap: 8px; }
.lx-palette-g { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.lx-palette-g > span { width: 100%; font-size: .78rem; font-weight: 700; color: var(--ot-text-soft); text-transform: uppercase; letter-spacing: .04em; }
.lx-key { min-width: 38px; min-height: 34px; padding: 2px 7px; border: 1px solid var(--ot-border); border-radius: 6px; background: var(--ot-surface); color: var(--ot-text); cursor: pointer; font-size: .9rem; }
.lx-key:hover { border-color: var(--lx-accent); background: color-mix(in srgb, var(--lx-accent) 10%, var(--ot-surface)); }
.lx-key .katex { font-size: .95em; }
.lx-code-in { width: 100%; font-family: var(--ot-mono); font-size: .9rem; line-height: 1.5; min-height: 120px; }
.lx-report { margin: 0; padding-left: 1.2em; font-size: .9rem; }
.lx-report li + li { margin-top: 4px; }

.lx-help { margin-top: calc(var(--ot-space) * 2.5); }
.lx-help code { font-family: var(--ot-mono); font-size: .88em; background: var(--ot-surface-2); padding: 1px 5px; border-radius: 4px; }

/* Variations : aperçu SVG et formulaire */
.lx-fo { width: 100%; height: 100%; display: flex; align-items: center; color: #111; font-size: 15px; line-height: 1; }
.lx-fo.c { justify-content: center; } .lx-fo.l { justify-content: flex-start; } .lx-fo.r { justify-content: flex-end; }
.lx-fo-bg > * { background: #fff; padding: 1px 2px; }
.lx-tline { align-items: flex-start; }
.lx-tcells { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lx-cell-at, .lx-pt { display: inline-flex; align-items: center; gap: 4px; padding: 3px 6px; border-radius: 6px; background: var(--ot-surface-2); }
.lx-cell-in select { font-weight: 700; }
.lx-pt { flex-wrap: wrap; }
.lx-inter { border: 1px dashed var(--ot-border); }

/* TikZ */
.lx-modes { gap: 8px; }
.lx-mode { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--ot-border); border-radius: 999px; font-weight: 700; font-size: .9rem; cursor: pointer; background: var(--ot-surface); }
.lx-mode:has(input:checked) { border-color: var(--lx-accent); background: color-mix(in srgb, var(--lx-accent) 12%, var(--ot-surface)); }
.lx-mode input { accent-color: var(--lx-accent); }
.lx-svgt { font: 11px "Latin Modern Roman", "Times New Roman", serif; fill: #111; }
.lx-it { font-style: italic; font-size: 13px; }
.lx-twarn p { margin: 6px 0 0; font-size: .86rem; }

/* Arbres, matrices, formules, utilitaires */
.lx-auto { color: var(--lx-accent); font-size: .9rem; }
.lx-var { padding: 0 4px; white-space: nowrap; }
.lx-fpre { position: relative; font-size: 1.15rem; }
.lx-eqno { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-family: "Latin Modern Roman", serif; }
.lx-mixsw { display: inline-block; width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--ot-border); vertical-align: middle; margin: 0 2px 0 8px; }
.lx-hz { font-size: .85em; display: inline-flex; align-items: center; gap: 3px; color: var(--ot-muted, #555); }
/* les modules sont construits en JavaScript : place réservée pour que l'aide sous l'outil ne saute pas au chargement (CLS) */
.lx:not(.lx-on) .lx-help { margin-top: 100vh; }
/* raccourcis personnels (onglet Préambule) */
.lx-h4 { margin: 14px 0 4px; font-size: 1rem; }
.lx-macrow { align-items: center; flex-wrap: wrap; }
.lx-macrow .lx-bs { font-family: var(--ot-mono); font-weight: 700; margin-right: -4px; }
.lx-macrow .lx-w-l { flex: 1 1 220px; font-family: var(--ot-mono); }
.lx-macrow input[data-cf="0"] { font-family: var(--ot-mono); width: 9em; }
.lx-macst { flex-basis: 100%; font-size: .9rem; padding-left: 14px; }
.lx-macrow select[data-cf="1"] { width: auto; min-width: 9em; }

/* Export de l'aperçu en image */
.lx-imgbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0 0; font-size: .85rem; color: var(--ot-text-soft); }
