#halamanLatex.aktif {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  min-height: 620px;
  overflow: hidden;
  background: #e8eef5;
}

.latex-toolbar {
  min-height: 58px;
  padding: 9px clamp(12px, 2vw, 28px);
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f7fbff;
  background: #1b3554;
  border-top: 1px solid rgba(255,255,255,.08);
  border-bottom: 1px solid #314966;
}

.latex-toolbar .latex-back,
.latex-toolbar .latex-tool-button {
  min-height: 36px;
  padding: 7px 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #eef5fc;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
}

.latex-toolbar .latex-tool-button:hover,
.latex-toolbar .latex-back:hover { background: rgba(255,255,255,.15); }

.latex-toolbar .latex-compile {
  color: #14263e;
  background: var(--gold);
  border-color: var(--gold);
}

.latex-toolbar .latex-compile:hover { background: #e4ae46; }
.latex-toolbar button:disabled { opacity: .65; cursor: wait; }

.latex-project-heading {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
}

.latex-project-heading strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .9rem;
}

.latex-project-heading small {
  display: block;
  color: #b9c8da;
  font-size: .7rem;
  margin-top: 2px;
}

.latex-project-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #61d4ae;
  box-shadow: 0 0 0 3px rgba(97,212,174,.13);
}

.latex-toolbar-actions { display: flex; align-items: center; gap: 7px; }
.latex-mobile-tabs { display: none; }

.latex-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  /* Lebar panel file & pratinjau bisa diubah dengan menyeret pembatas (latex-studio.js) */
  grid-template-columns: var(--lx-files, 220px) 7px minmax(260px, 1fr) 7px var(--lx-preview, 42%);
  overflow: hidden;
}

.latex-file-panel,
.latex-editor-panel,
.latex-preview-panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.latex-file-panel {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid #cbd6e3;
}

.latex-panel-title {
  min-height: 43px;
  padding: 8px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid #d9e2ec;
  color: #203854;
  background: #f8fafc;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.latex-file-actions { display: flex; gap: 4px; }
.latex-mini-button {
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  color: #5b6b80;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}
.latex-mini-button:hover { color: #14263e; background: #e8eef5; }

.latex-files {
  flex: 1;
  min-height: 0;
  padding: 7px;
  overflow: auto;
}

.latex-file-item {
  width: 100%;
  padding: 7px 8px;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 7px;
  color: #2d415a;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  font-size: .78rem;
}

.latex-file-item:hover { background: #eef3f9; }
.latex-file-item.active { color: #14263e; background: #f4e8cd; font-weight: 700; }
.latex-file-item.directory { color: #435b76; font-weight: 600; cursor: default; }
.latex-file-item .latex-file-symbol { width: 17px; flex: 0 0 auto; text-align: center; color: #7a8ca2; }
.latex-file-item .latex-file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.latex-file-item.depth-1 { padding-left: 25px; }
.latex-file-item.depth-2 { padding-left: 42px; }

.latex-outline {
  max-height: 220px;
  overflow: auto;
  border-top: 1px solid #d9e2ec;
  background: #fbfcfe;
}

.latex-outline-heading {
  padding: 10px 12px 6px;
  color: #6a7d94;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.latex-outline button {
  width: 100%;
  padding: 6px 12px;
  border: 0;
  color: #5b6b80;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  font-size: .74rem;
}
.latex-outline button:hover { color: #14263e; background: #eef3f9; }

.latex-editor-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  color: #d8e1ec;
  background: #090d13;
  border-right: 1px solid #29364a;
}

.latex-editor-tabs {
  min-height: 43px;
  display: flex;
  align-items: stretch;
  background: #111823;
  border-bottom: 1px solid #273244;
}

.latex-editor-tab {
  max-width: 240px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  border-top: 2px solid var(--gold);
  border-right: 1px solid #273244;
  background: #090d13;
  font-size: .76rem;
}

.latex-editor-tab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.latex-code-area {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  overflow: hidden;
}

.latex-line-numbers,
.latex-source {
  margin: 0;
  padding-top: 13px;
  padding-bottom: 60px;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.62;
}

.latex-line-numbers {
  padding-right: 10px;
  overflow: hidden;
  border-right: 1px solid #202b3a;
  color: #5f6e82;
  text-align: right;
  white-space: pre;
  user-select: none;
}

.latex-source {
  width: 100%;
  height: 100%;
  padding-left: 15px;
  padding-right: 15px;
  overflow: auto;
  resize: none;
  border: 0;
  border-radius: 0;
  outline: 0;
  color: #d8e1ec;
  background: #090d13;
  white-space: pre;
  tab-size: 2;
}

.latex-source:focus { outline: 0; }
.latex-editor-status {
  min-height: 28px;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #aab7c8;
  background: #111823;
  border-top: 1px solid #273244;
  font-size: .67rem;
}

.latex-log-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 28px;
  height: min(230px, 42%);
  display: none;
  z-index: 4;
  color: #c8d4e4;
  background: #0d131c;
  border-top: 1px solid #40516a;
  box-shadow: 0 -12px 30px rgba(0,0,0,.28);
}
.latex-log-panel.open { display: flex; flex-direction: column; }
.latex-log-head { min-height: 36px; padding: 0 10px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #273244; font-size: .72rem; font-weight: 700; }
.latex-log-output { flex: 1; margin: 0; padding: 10px 13px; overflow: auto; color: #9ece6a; white-space: pre-wrap; font-family: "Cascadia Code", Consolas, monospace; font-size: 11px; line-height: 1.5; }

.latex-preview-panel {
  display: flex;
  flex-direction: column;
  background: #dfe6ee;
}

.latex-preview-head {
  min-height: 43px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #203854;
  background: #f8fafc;
  border-bottom: 1px solid #cbd6e3;
  font-size: .76rem;
  font-weight: 700;
}

.latex-compile-state { color: #1e7f6e; font-size: .7rem; font-weight: 700; }
.latex-pdf-frame { width: 100%; flex: 1; min-height: 0; border: 0; background: #dfe6ee; }
.latex-empty-preview { flex: 1; display: grid; place-items: center; padding: 28px; color: #687b91; text-align: center; }
.latex-empty-preview div { max-width: 280px; }
.latex-empty-preview strong { display: block; color: #29425f; margin-bottom: 7px; }
.latex-empty-preview span { font-size: .78rem; line-height: 1.55; }

.latex-lock {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: none;
  place-items: center;
  padding: 22px;
  background: rgba(232,238,245,.76);
  backdrop-filter: blur(5px);
}
.latex-lock.show { display: grid; }
.latex-lock-card {
  width: min(440px, 100%);
  padding: 30px;
  border: 1px solid #d0dbe8;
  border-radius: 14px;
  color: #14263e;
  background: #fff;
  box-shadow: 0 20px 50px rgba(20,38,62,.18);
  text-align: center;
}
.latex-lock-icon { width: 54px; height: 54px; margin: 0 auto 15px; display: grid; place-items: center; border-radius: 50%; background: #f4e8cd; font-size: 1.5rem; }
.latex-lock-card h2 { font-family: "Fraunces", serif; font-size: 1.35rem; margin-bottom: 8px; }
.latex-lock-card p { margin-bottom: 18px; color: #5b6b80; font-size: .85rem; line-height: 1.55; }

.latex-spinner { display: inline-block; animation: latex-spin .8s linear infinite; }
@keyframes latex-spin { to { transform: rotate(360deg); } }

@media (max-width: 780px) {
  #halamanLatex.aktif { height: calc(100vh - 60px); min-height: 560px; }
  .latex-toolbar { min-height: 56px; }
  .latex-toolbar .button-label { display: none; }
  .latex-toolbar .latex-back,
  .latex-toolbar .latex-tool-button { width: 36px; padding-inline: 7px; }
  .latex-project-heading small { display: none; }
  .latex-mobile-tabs { display: flex; min-height: 42px; padding: 5px; gap: 4px; background: #fff; border-bottom: 1px solid #d9e2ec; }
  .latex-mobile-tabs button { flex: 1; padding: 7px; border: 0; border-radius: 6px; color: #61748b; background: transparent; font: inherit; font-size: .75rem; font-weight: 600; }
  .latex-mobile-tabs button.active { color: #14263e; background: #eef3f9; }
  .latex-stage { display: block; }
  .latex-file-panel,
  .latex-editor-panel,
  .latex-preview-panel { display: none; width: 100%; height: 100%; }
  .latex-stage .mobile-active { display: flex; }
}

@media (max-width: 480px) {
  .latex-toolbar { padding-inline: 7px; gap: 6px; }
  .latex-project-heading strong { font-size: .75rem; }
  .latex-toolbar-actions { gap: 4px; }
}

/* ================================================================
   Proyek, berbagi & kolaborasi (latex.engbreaker.com)
   ================================================================ */

/* --- Editor: siapa yang hadir, mode lihat saja, banner konflik --- */
.latex-hadir { display: flex; align-items: center; gap: 4px; min-width: 0; }
.latex-hadir .lx-avatar { width: 26px; height: 26px; font-size: .7rem; border: 2px solid var(--navy, #10233b); margin-left: -6px; }
.latex-hadir .lx-avatar:first-child { margin-left: 0; }
.lx-hadir-teks { margin-left: 6px; color: #b9c8da; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.latex-readonly { align-self: center; margin-left: auto; margin-right: 12px; padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,.1); color: #d5e1ee; font-size: .68rem; font-weight: 700; letter-spacing: .03em; }
.latex-readonly[hidden] { display: none; }
.latex-source[readonly] { cursor: default; }
[data-perlu-ubah][hidden] { display: none !important; }

.latex-konflik { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 9px 12px; background: #fff4dd; color: #5c4210; font-size: .8rem; border-bottom: 1px solid #f1d9a6; }
.latex-konflik[hidden] { display: none; }
.latex-konflik span { flex: 1 1 220px; font-weight: 600; }
.latex-konflik button { padding: 6px 11px; border-radius: 7px; border: 1px solid #d9b56a; background: #fff; color: #5c4210; font: inherit; font-weight: 700; cursor: pointer; }
.latex-konflik button:first-of-type { background: var(--accent, #175cd3); border-color: var(--accent, #175cd3); color: #fff; }

/* --- Avatar inisial (dipakai editor & dialog) --- */
.lx-avatar { display: inline-grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft, #edf5ff); color: var(--accent, #175cd3); font-weight: 800; font-size: .82rem; }

/* --- Daftar proyek --- */
.lp-heading { font-family: "Fraunces", serif; font-size: 1.15rem; margin: 26px 0 12px; }
.lp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.lp-card { display: flex; flex-direction: column; gap: 10px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.lp-card h3 { font-family: "Fraunces", serif; font-size: 1.1rem; overflow-wrap: anywhere; }
.lp-card-top { display: flex; align-items: center; justify-content: space-between; }
.lp-icon { display: grid; place-items: center; width: 42px; height: 34px; border-radius: 8px; background: var(--accent, #175cd3); color: #fff; font-family: "Fraunces", serif; font-size: .72rem; font-weight: 700; }
.lp-meta { color: var(--muted); font-size: .8rem; }
.lp-link { display: flex; gap: 6px; }
.lp-link input { flex: 1; min-width: 0; padding: 7px 9px; font-size: .78rem; color: var(--navy-soft); background: var(--sky); }
.lp-link .btn { padding: 7px 12px; font-size: .78rem; }
.lp-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.lp-actions .btn { padding: 8px 13px; font-size: .8rem; }
.btn.lp-hapus { color: var(--red); }
.lp-kosong { grid-column: 1 / -1; padding: 22px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); font-size: .88rem; text-align: center; background: #fff; }
.lp-role { flex: 0 0 auto; padding: 3px 9px; border-radius: 999px; font-size: .68rem; font-weight: 700; letter-spacing: .03em; }
.lp-role.role-owner { background: var(--accent-soft, #edf5ff); color: var(--accent, #175cd3); }
.lp-role.role-editor { background: #e8f5ee; color: #1c6b43; }
.lp-role.role-viewer { background: #f1f3f6; color: #536981; }

/* --- Dialog berbagi --- */
.lx-dialog { margin: auto; width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--line); border-radius: 16px; color: var(--navy); box-shadow: 0 30px 70px rgba(16, 35, 59, .25); }
.lx-dialog::backdrop { background: rgba(16, 35, 59, .45); }
.lx-dialog-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); background: #fff; }
.lx-dialog-head h2 { font-family: "Fraunces", serif; font-size: 1.2rem; overflow-wrap: anywhere; }
.lx-close { width: 34px; height: 34px; border: 0; border-radius: 8px; background: var(--sky); color: var(--navy); font-size: 1.3rem; cursor: pointer; }
#lxDialogIsi { padding: 4px 20px 20px; }
.lx-bagian { padding: 16px 0; border-bottom: 1px solid #eef2f7; }
.lx-bagian:last-child { border-bottom: 0; }
.lx-bagian h3 { font-size: .92rem; margin-bottom: 8px; }
.lx-note { margin: 6px 0; color: var(--muted); font-size: .78rem; line-height: 1.5; }
.lx-undang { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.lx-undang input { flex: 1 1 200px; min-width: 0; }
.lx-undang select, .lx-daftar select { width: auto; max-width: 100%; font-size: .8rem; padding: 7px 8px; }
.lx-daftar { display: grid; gap: 8px; padding: 0; list-style: none; }
.lx-daftar li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lx-orang { flex: 1 1 160px; min-width: 0; }
.lx-orang b { display: block; font-size: .86rem; overflow-wrap: anywhere; }
.lx-orang small { color: var(--muted); font-size: .74rem; overflow-wrap: anywhere; }
.lx-tertunda .lx-avatar { background: #f1f3f6; color: #536981; }
.lx-x { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--red); font-size: 1.1rem; cursor: pointer; }
.lx-tautan input { flex: 1 1 200px; min-width: 0; padding: 7px 9px; font-size: .76rem; background: var(--sky); }
.lx-tautan .btn { padding: 7px 11px; font-size: .78rem; }
.lx-kosong { color: var(--muted); font-size: .82rem; }
.lx-kaki { display: flex; justify-content: flex-end; padding-top: 12px; }

/* --- Intro: catatan link berbagi --- */
.intro-join { max-width: 640px; margin-top: 16px; padding: 12px 16px; border-radius: 12px; background: var(--accent-soft, #edf5ff); color: var(--accent-dark, #0f3f9e); font-weight: 600; }
.intro-join[hidden] { display: none; }

@media (max-width: 900px) {
  .lx-hadir-teks { display: none; }
}

/* ================================================================
   Asisten AI (panel di atas pratinjau PDF)
   ================================================================ */
.latex-toolbar .latex-ai-button { border-color: rgba(147, 197, 253, .55); background: rgba(23, 92, 211, .35); }
.latex-toolbar .latex-ai-button:hover { background: rgba(23, 92, 211, .55); }
.latex-ai {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 6;
  width: min(460px, 100%); display: flex; flex-direction: column;
  background: #fff; color: var(--navy); border-left: 1px solid var(--line);
  box-shadow: -18px 0 40px rgba(16, 35, 59, .18);
}
.latex-ai[hidden] { display: none; }
.latex-ai-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.latex-ai-head strong { font-family: "Fraunces", serif; font-size: 1.05rem; }
.latex-ai-close { width: 30px; height: 30px; border: 0; border-radius: 8px; background: var(--sky); color: var(--navy); font-size: 1.2rem; cursor: pointer; }
.latex-ai-body { flex: 1; overflow: auto; padding: 14px 16px 20px; display: grid; align-content: start; gap: 10px; }
.latex-ai-intro { color: var(--muted); font-size: .82rem; line-height: 1.5; }
.latex-ai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.latex-ai-chip { padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--sky); color: var(--navy-soft); font: inherit; font-size: .76rem; font-weight: 600; cursor: pointer; }
.latex-ai-chip:hover { border-color: var(--accent, #175cd3); color: var(--accent, #175cd3); }
#latexAiInput { width: 100%; resize: vertical; font: inherit; font-size: .88rem; }
.latex-ai-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.latex-ai-ringkas { padding: 11px 13px; border-radius: 10px; background: var(--accent-soft, #edf5ff); color: var(--navy); font-size: .86rem; line-height: 1.55; white-space: pre-wrap; }
.latex-ai-catatan { margin: 0; padding: 10px 12px 10px 28px; border-radius: 10px; background: #fff4dd; color: #5c4210; font-size: .8rem; line-height: 1.5; }
.latex-ai-judul-edit { font-size: .82rem; font-weight: 700; margin-top: 4px; }
.latex-ai-edits { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.latex-ai-edits li { padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.latex-ai-edits li.gagal { opacity: .65; }
.latex-ai-edits label { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 6px; font-size: .82rem; font-weight: 600; color: var(--navy); cursor: pointer; }
.latex-ai-edits pre { margin: 4px 0 0; padding: 7px 9px; border-radius: 7px; font-size: .72rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 180px; overflow: auto; }
.latex-ai-del { background: #fdecec; color: #8a2b1d; text-decoration: line-through; text-decoration-color: rgba(138, 43, 29, .45); }
.latex-ai-ins { background: #e8f5ee; color: #1c6b43; }
.latex-ai-gagal { display: block; color: var(--red); font-size: .74rem; }
.latex-ai-selesai { display: grid; gap: 8px; padding: 12px; border-radius: 10px; background: #e8f5ee; color: #1c6b43; font-size: .86rem; font-weight: 600; }
.latex-ai-edits input[type="checkbox"] { width: auto; flex: 0 0 auto; margin: 2px 0 0; padding: 0; }
.latex-ai-edits label span { flex: 1; text-align: left; }
#latexAiInput { min-height: 88px; line-height: 1.5; }

/* ================================================================
   Pembatas panel yang bisa diseret (Files | Editor | PDF)
   ================================================================ */
.latex-splitter {
  position: relative;
  z-index: 3;
  cursor: col-resize;
  background: var(--line, #dce5ef);
  touch-action: none;
  outline: none;
}
.latex-splitter::after {            /* pegangan kecil di tengah */
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3px;
  height: 34px;
  transform: translate(-50%, -50%);
  border-radius: 3px;
  background: #aebfd2;
  transition: background .15s, height .15s;
}
.latex-splitter:hover,
.latex-splitter:focus-visible,
.latex-splitter.aktif { background: var(--accent-soft, #edf5ff); }
.latex-splitter:hover::after,
.latex-splitter:focus-visible::after,
.latex-splitter.aktif::after { height: 56px; background: var(--accent, #175cd3); }

/* Saat menyeret: jangan pilih teks, dan iframe PDF jangan "menelan" gerakan mouse */
.latex-stage.lx-menyeret { cursor: col-resize; user-select: none; }
.latex-stage.lx-menyeret iframe { pointer-events: none; }

@media (max-width: 780px) {
  .latex-splitter { display: none; }
}
/* Pembatas sudah menjadi garis antar panel */
.latex-stage > .latex-file-panel,
.latex-stage > .latex-editor-panel { border-right: 0; }
/* Area seret lebih lebar dari garisnya agar mudah diambil */
.latex-splitter::before { content: ""; position: absolute; top: 0; bottom: 0; left: -4px; right: -4px; }

/* ================================================================
   Pembatas horizontal: tinggi Document outline & Compilation log
   ================================================================ */
.latex-outline { flex: 0 0 auto; height: var(--lx-outline, 180px); max-height: none; border-top: 0; }
.latex-log-panel { height: var(--lx-log, min(230px, 42%)); }
.latex-splitter-h {
  position: relative;
  flex: 0 0 auto;
  height: 7px;
  cursor: row-resize;
  background: var(--line, #dce5ef);
  touch-action: none;
  outline: none;
}
.latex-splitter-h::before { content: ""; position: absolute; left: 0; right: 0; top: -4px; bottom: -4px; }
.latex-splitter-h::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 3px;
  transform: translate(-50%, -50%);
  border-radius: 3px;
  background: #aebfd2;
  transition: background .15s, width .15s;
}
.latex-splitter-h:hover,
.latex-splitter-h:focus-visible,
.latex-splitter-h.aktif { background: var(--accent-soft, #edf5ff); }
.latex-splitter-h:hover::after,
.latex-splitter-h:focus-visible::after,
.latex-splitter-h.aktif::after { width: 56px; background: var(--accent, #175cd3); }
.latex-stage.lx-menyeret-h { cursor: row-resize; user-select: none; }
.latex-stage.lx-menyeret-h iframe { pointer-events: none; }

/* ================================================================
   Status simpan, Cari & Ganti (Ctrl+F / Ctrl+H), sorotan hasil
   ================================================================ */
.latex-editor-tabs .latex-readonly { margin-left: 0; }
.latex-cari-tombol {
  align-self: center; margin-left: auto; margin-right: 8px; padding: 4px 10px;
  border: 1px solid var(--line, #dce5ef); border-radius: 7px; background: #fff;
  color: var(--navy-soft, #334a63); font: inherit; font-size: .74rem; font-weight: 600; cursor: pointer;
}
.latex-cari-tombol:hover { color: var(--accent, #175cd3); border-color: #b7d0f5; background: var(--accent-soft, #edf5ff); }
.latex-simpan-status {
  align-self: center; margin-right: 10px; padding: 3px 9px; border-radius: 999px;
  font-size: .68rem; font-weight: 700; white-space: nowrap;
  background: #e8f5ee; color: #1c6b43;
}
.latex-simpan-status[data-status="berubah"], .latex-simpan-status[data-status="menyimpan"] { background: #fff4dd; color: #8a6210; }
.latex-simpan-status[data-status="gagal"] { background: #fdecec; color: var(--red, #b8432f); }
.latex-simpan-status[data-status="lihat"] { display: none; }

/* Kotak cari mengambang di pojok kanan atas editor */
.latex-cari {
  position: absolute; top: 50px; right: 22px; z-index: 5;
  width: min(470px, calc(100% - 24px)); display: grid; gap: 6px; padding: 8px;
  border: 1px solid var(--line, #dce5ef); border-radius: 10px; background: #fff;
  box-shadow: 0 14px 34px rgba(16, 35, 59, .16);
}
.latex-cari[hidden], .latex-ganti-baris[hidden] { display: none; }
.latex-cari-baris { display: flex; align-items: center; gap: 4px; }
.latex-cari-baris input {
  flex: 1; min-width: 0; padding: 6px 8px; border-radius: 7px; font: inherit;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; font-size: .8rem;
}
.latex-cari-baris input.tidak-ada { border-color: var(--red, #b8432f); background: #fff7f6; }
.latex-ganti-baris { padding-left: 30px; }
.latex-cari-ikon, .latex-cari-opsi, .latex-cari-teks {
  flex: 0 0 auto; height: 28px; min-width: 28px; padding: 0 6px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--navy-soft, #334a63); font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer;
}
.latex-cari-ikon:hover, .latex-cari-opsi:hover, .latex-cari-teks:hover { background: #eef3f9; }
.latex-cari-opsi { font-family: "Cascadia Code", Consolas, monospace; font-size: .74rem; }
.latex-cari-opsi[aria-pressed="true"] { color: var(--accent, #175cd3); background: var(--accent-soft, #edf5ff); border-color: #b7d0f5; }
.latex-opsi-kata { text-decoration: underline; text-underline-offset: 3px; }
.latex-cari-teks { border-color: var(--line, #dce5ef); padding: 0 10px; font-size: .74rem; }
.latex-cari-teks:disabled { opacity: .45; cursor: default; }
#latexCariToggle[aria-expanded="true"] { transform: rotate(90deg); }
.latex-cari-hitung { min-width: 74px; text-align: right; color: var(--muted, #536981); font-size: .72rem; white-space: nowrap; }
.latex-cari-hitung.tidak-ada { color: var(--red, #b8432f); }

/* Lapisan sorotan di belakang textarea (metrik harus sama persis dengan .latex-source) */
.latex-code-area { position: relative; }
.latex-source { position: relative; z-index: 1; }
.latex-code-area.cari-aktif .latex-source { background: transparent; }
.latex-sorot {
  position: absolute; top: 0; bottom: 0; left: 48px; right: 0; z-index: 0;
  overflow: hidden; background: #fff; pointer-events: none;
}
.latex-sorot[hidden] { display: none; }
.latex-sorot-isi {
  margin: 0; padding: 13px 15px 60px; white-space: pre; tab-size: 2; color: transparent;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; font-size: 12px; line-height: 1.62;
  will-change: transform;
}
.latex-sorot-isi mark { color: transparent; background: #fde68a; border-radius: 2px; }
.latex-sorot-isi mark.kini { background: #f59e0b; box-shadow: 0 0 0 1px #d97706; }

/* ================================================================
   Penampil PDF (PDF.js) + zoom + lompat ke sumber (SyncTeX)
   ================================================================ */
.latex-pdf-view { flex: 1; min-height: 0; overflow: auto; padding: 14px; background: #eef3f9; outline: none; }
.latex-pdf-view[hidden] { display: none; }
.latex-pdf-page {
  position: relative; margin: 0 auto 14px; background: #fff;
  box-shadow: 0 2px 10px rgba(16, 35, 59, .12);
  --scale-round-x: 1px; --scale-round-y: 1px;
}
.latex-pdf-page canvas { display: block; }
.latex-pdf-galat { padding: 24px; color: var(--muted, #536981); font-size: .85rem; text-align: center; }

.latex-zoom { display: inline-flex; align-items: center; gap: 2px; margin-left: auto; margin-right: 8px; }
.latex-zoom[hidden] { display: none; }
.latex-zoom button {
  min-width: 26px; height: 24px; padding: 0 7px; border: 1px solid var(--line, #dce5ef); border-radius: 6px;
  background: #fff; color: var(--navy-soft, #334a63); font: inherit; font-size: .72rem; font-weight: 700; cursor: pointer;
}
.latex-zoom button:hover { color: var(--accent, #175cd3); border-color: #b7d0f5; background: var(--accent-soft, #edf5ff); }
.latex-zoom #latexZoomLabel { min-width: 48px; }

/* Lapisan teks PDF.js (teks transparan di atas kanvas agar bisa dipilih) */
.textLayer {
  position: absolute; inset: 0; overflow: clip; opacity: 1; line-height: 1; text-align: initial;
  -webkit-text-size-adjust: none; text-size-adjust: none; forced-color-adjust: none;
  transform-origin: 0 0; caret-color: CanvasText; z-index: 0;
  --min-font-size: 1;
  --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));
  --min-font-size-inv: calc(1 / var(--min-font-size));
}
.textLayer span, .textLayer br {
  color: transparent; position: absolute; white-space: pre; cursor: text;
  transform-origin: 0% 0%; -webkit-user-select: text; user-select: text;
}
.textLayer > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) {
  z-index: 1; --font-height: 0; font-size: calc(var(--text-scale-factor) * var(--font-height));
  --scale-x: 1; --rotate: 0deg;
  transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));
}
.textLayer .markedContent { display: contents; }
.textLayer ::selection { background: rgba(23, 92, 211, .25); color: transparent; }
.textLayer br::selection { background: transparent; }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: 0; cursor: default; -webkit-user-select: none; user-select: none; }
.textLayer.selecting .endOfContent { top: 0; }

/* Kilatan singkat di kolom nomor baris setelah lompat dari PDF */
@keyframes latex-kilat { from { background: var(--accent-soft, #edf5ff); } to { background: #fbfcfe; } }
.latex-line-numbers.latex-baris-kilat { animation: latex-kilat 1.2s ease-out; }
