/* /latex-editor: files | code | divider | the PDF (Code / Preview tabs on phones). Uses the site's tokens from style.css.
   --lx-code / --lx-pdf (the split) are set by latex.js while the divider is dragged. */
.tool.latex { max-width: 1320px; }
.lx-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: var(--s3) 0 var(--s3); }
.lx-bar .btn { min-height: 40px; padding: 0 14px; font-size: 14px; }
.lx-bar .btn svg { width: 16px; height: 16px; }
.lx-grow { flex: 1; }
.lx-auto { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; user-select: none; }
.lx-auto input { appearance: none; -webkit-appearance: none; position: relative; width: 34px; height: 20px; margin: 0; border-radius: 999px; background: var(--line-strong); cursor: pointer; transition: background .15s; }
.lx-auto input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .15s; }
.lx-auto input:checked { background: var(--ok); }
.lx-auto input:checked::after { transform: translateX(14px); }
.lx-auto input:focus-visible { outline: 2px solid color-mix(in srgb, var(--ink) 30%, transparent); outline-offset: 2px; }
.lx-status { font-size: 13.5px; font-weight: 600; color: var(--muted); }
.lx-tabs { display: none; }
.lx { display: grid; grid-template-columns: 214px minmax(0, var(--lx-code, 44fr)) 14px minmax(0, var(--lx-pdf, 56fr)); align-items: stretch; height: min(78vh, 900px); }
.lx.dragging { cursor: col-resize; user-select: none; -webkit-user-select: none; }
.lx-split { cursor: col-resize; touch-action: none; position: relative; border-radius: 4px; }
.lx-split::after { content: ""; position: absolute; left: 5px; top: 50%; width: 4px; height: 44px; margin-top: -22px; border-radius: 2px; background: var(--line-strong); transition: background .15s; }
.lx-split:hover::after, .lx-split:focus-visible::after, .lx.dragging .lx-split::after { background: var(--muted); }
.lx-split:focus-visible { outline: 2px solid color-mix(in srgb, var(--ink) 30%, transparent); }
.lx-back { display: none !important; }

.lx-files { display: flex; flex-direction: column; gap: 8px; margin-right: 14px; padding: 12px; border-radius: var(--r-xl); background: var(--card); border: 1px solid var(--line); min-height: 0; }
.lx-files.over { border-color: color-mix(in srgb, var(--pdf) 50%, var(--line)); background: color-mix(in srgb, var(--pdf) 4%, var(--card)); }
.lx-files-head { display: flex; align-items: center; justify-content: space-between; }
.lx-files-head b { font-size: 14px; }
.lx-add, .lx-back { min-height: 32px !important; padding: 0 10px !important; font-size: 13px !important; cursor: pointer; }
.lx-files ul { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.lx-files li { display: flex; align-items: center; gap: 4px; border-radius: 9px; }
.lx-files li.on { background: var(--soft); }
.lx-file { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; padding: 6px 6px; border: 0; background: none; font: inherit; font-size: 13px; color: var(--ink); text-align: left; cursor: pointer; border-radius: 8px; }
.lx-file:hover { background: var(--soft); }
.lx-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lx-ico { flex: none; min-width: 30px; padding: 2px 4px; border-radius: 5px; font-size: 9px; font-weight: 750; letter-spacing: .03em; text-align: center; }
.lx-ico.t { background: color-mix(in srgb, var(--document) 14%, var(--card)); color: var(--document); }
.lx-ico.b { background: color-mix(in srgb, var(--image) 14%, var(--card)); color: var(--image); }
.lx-main, .lx-main-tag { flex: none; font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line-strong); background: none; color: var(--muted); }
.lx-main { cursor: pointer; }
.lx-main[aria-pressed="true"], .lx-main-tag { color: var(--ink); background: var(--soft); }
.lx-x { flex: none; width: 24px; height: 24px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; }
.lx-x:hover { background: color-mix(in srgb, var(--pdf) 12%, var(--card)); color: var(--pdf); }
.lx-hint { margin: 0; font-size: 12px; color: var(--muted); }
.lx-pdf .ws-view .pv-page { cursor: text; }

.lx-code { display: flex; flex-direction: column; min-height: 0; border-radius: var(--r-xl); background: var(--card); border: 1px solid var(--line); overflow: hidden; }
.lx-file-name { padding: 8px 14px; font-size: 12.5px; font-weight: 650; color: var(--muted); border-bottom: 1px solid var(--line); }
.lx-editor { flex: 1; display: grid; grid-template-columns: auto minmax(0, 1fr); min-height: 0; }
.lx-editor[hidden] { display: none; }
.lx-lines, .lx-editor textarea { margin: 0; padding: 12px 10px; font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.lx-lines { overflow: hidden; color: color-mix(in srgb, var(--muted) 70%, transparent); text-align: right; background: var(--sunk); border-right: 1px solid var(--line); user-select: none; min-width: 38px; }
.lx-editor textarea { width: 100%; height: 100%; border: 0; outline: 0; resize: none; background: var(--card); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; overflow-x: hidden; overflow-y: auto; tab-size: 2; }
.lx-editor { position: relative; }
.lx-mirror { position: absolute; top: 0; left: 0; visibility: hidden; pointer-events: none; box-sizing: border-box; padding: 12px 10px;
             font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2; }
.lx-asset { flex: 1; padding: 16px; overflow: auto; font-size: 13.5px; color: var(--muted); }
.lx-asset img { max-width: 100%; max-height: 50vh; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.lx-asset code, .lx-errors b { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.lx-errors { list-style: none; margin: 0; padding: 8px; max-height: 30%; overflow: auto; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--pdf) 5%, var(--card)); }
.lx-errors[hidden] { display: none; }
.lx-errors button { width: 100%; text-align: left; border: 0; background: none; font: inherit; font-size: 13px; color: var(--ink); padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.lx-errors button:hover { background: color-mix(in srgb, var(--pdf) 10%, var(--card)); }
.lx-errors b { color: var(--pdf); margin-right: 6px; }

.lx-pdf { display: flex; flex-direction: column; min-height: 0; border-radius: var(--r-xl); background: var(--sunk); border: 1px solid var(--line); overflow: hidden; container-type: inline-size; }
.lx-pdf:fullscreen { border-radius: 0; border: 0; }
.lx-pdf-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--line); background: var(--card); }
.lx-pdf-bar > * { flex: none; white-space: nowrap; }
.lx-live { flex: 1 1 auto !important; min-width: 0; overflow: hidden; text-overflow: ellipsis; border: 0; background: none; padding: 0; font: inherit; text-align: left; font-size: 12.5px; font-weight: 650; color: var(--muted); }
.lx-live.bad { cursor: pointer; }
.lx-live::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--line-strong); vertical-align: 1px; }
.lx-live.ok::before { background: var(--ok); }
.lx-live.wait::before { background: var(--video); }
.lx-live.bad { color: var(--pdf); }
.lx-live.bad::before { background: var(--pdf); }
.lx-pages { font-size: 12.5px; color: var(--muted); }
.lx-zoom { display: inline-flex; align-items: center; background: var(--soft); border-radius: 9px; padding: 2px; }
.lx-zoom button, .lx-zoom select { border: 0; background: none; font: inherit; font-size: 12.5px; font-weight: 650; color: var(--muted); height: 28px; border-radius: 7px; cursor: pointer; }
.lx-zoom button { min-width: 28px; padding: 0 6px; font-size: 15px; }
.lx-zoom select { padding: 0 4px; color: var(--ink); }
.lx-zoom button:hover { color: var(--ink); background: var(--card); }
.lx-icon { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 9px; border: 0; border-radius: 8px; background: none; font: inherit; font-size: 12.5px; font-weight: 650; color: var(--muted); cursor: pointer; }
.lx-icon[hidden] { display: none; }
.lx-icon:hover { background: var(--soft); color: var(--ink); }
.lx-icon[aria-pressed="true"] { background: var(--soft); color: var(--ink); }
.lx-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@container (max-width: 700px) { .lx-t { display: none; } .lx-icon { padding: 0 7px; } }
@container (max-width: 380px) { .lx-pages { display: none; } }
.lx-pdf:fullscreen [data-wide-toggle] { display: none; }
.lx-pdf-scroll { flex: 1; min-height: 0; overflow: auto; padding: 14px; scrollbar-gutter: stable; }
.lx-pdf .ws-view.pages { display: flex; flex-direction: column; align-items: flex-start; gap: 34px; }
.lx-pdf .ws-view .pv-page { width: var(--pw, 100%); flex: none; margin: 0 auto; }
.lx-pdf .ws-view .pv-page img { height: 100%; }
.lx-note { margin: var(--s3) 0 0; font-size: 13px; color: var(--muted); }

@media (max-width: 1100px) { .lx { grid-template-columns: 184px minmax(0, var(--lx-code, 44fr)) 14px minmax(0, var(--lx-pdf, 56fr)); } }
@media (min-width: 900px) {   /* Preview only: the code folds into a strip of file names */
  .lx.wide { grid-template-columns: 164px minmax(0, 1fr); }
  .lx.wide .lx-code, .lx.wide .lx-split, .lx.wide .lx-add, .lx.wide .lx-hint, .lx.wide .lx-main, .lx.wide .lx-main-tag, .lx.wide .lx-x, .lx.wide .lx-ico { display: none; }
  .lx.wide .lx-back { display: inline-flex !important; }
}
@media (max-width: 899px) {
  .lx-tabs { display: inline-flex; margin-bottom: 10px; background: var(--soft); border-radius: 11px; padding: 3px; }
  .lx-tabs button { border: 0; background: none; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); height: 38px; padding: 0 18px; border-radius: 8px; }
  .lx-tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
  .lx { grid-template-columns: 1fr; height: auto; row-gap: 14px; }
  .lx-split, [data-wide-toggle] { display: none !important; }
  .lx-files { max-height: 180px; margin-right: 0; }
  .lx-code { height: 62vh; }
  .lx-pdf { height: 70vh; }
  .lx[data-show="code"] .lx-pdf, .lx[data-show="pdf"] .lx-files, .lx[data-show="pdf"] .lx-code { display: none; }
}

/* /tex-to-pdf: paste LaTeX and open it in the editor (templates/_latex_paste.html) */
.latex-paste textarea { width: 100%; min-height: 160px; padding: 12px 14px; border-radius: var(--r-lg); border: 1px solid var(--line-strong); background: var(--card); color: var(--ink);
                        font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; resize: vertical; }
.latex-paste textarea:focus { outline: 2px solid color-mix(in srgb, var(--ink) 30%, transparent); outline-offset: 1px; }
.latex-paste-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
