/* TeX Editor — Full-page 3-panel layout */

/* Override main container to fill full width ONLY for the editor view */
main:has(.tex-editor-page) {
  padding-left: 0 !important;
  padding-right: 0 !important;
  padding-bottom: 0 !important;
  margin: 0 !important;
  margin-bottom: 0 !important;
  max-width: none !important;
  width: 100% !important;
  overflow: hidden;
}

.tex-editor-page {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: calc(100vh - var(--header-height, 50px));
  overflow: hidden;
  background: var(--color-bg-primary, #fff);
}

/* ─── Compile Progress Bar ────────────────────── */

.tex-progress-bar {
  height: 3px;
  background: var(--color-bg-secondary, #F5F5F5);
  flex-shrink: 0;
  overflow: hidden;
  display: none;
}

.tex-progress-bar.visible {
  display: block;
}

.tex-progress-bar-fill {
  height: 100%;
  background: var(--color-accent, #5A7A6A);
  width: 0%;
  transition: width 0.3s ease;
}

.tex-progress-bar-fill.indeterminate {
  width: 30%;
  animation: tex-progress-slide 1.5s ease-in-out infinite;
}

@keyframes tex-progress-slide {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(200%); }
  100% { transform: translateX(-100%); }
}

/* ─── Header ──────────────────────────────────── */

.tex-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  border-bottom: 1px solid var(--color-border, #E0E0E0);
  background: var(--color-bg-primary, #fff);
  flex-shrink: 0;
}

.tex-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.tex-header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--color-text-primary, #1A1A1A);
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}

.tex-header-logo svg {
  width: 28px;
  height: 28px;
}

.tex-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-secondary, #6B6B6B);
  min-width: 0;
}

.tex-breadcrumb a {
  color: var(--color-text-secondary, #6B6B6B);
  text-decoration: none;
}

.tex-breadcrumb a:hover {
  color: var(--color-text-primary, #1A1A1A);
}

.tex-breadcrumb .separator {
  opacity: 0.4;
}

.tex-project-title {
  font-weight: 600;
  color: var(--color-text-primary, #1A1A1A);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tex-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--color-primary, #1A1A1A);
  color: var(--color-text-inverse);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  border-radius: 4px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.tex-header-center {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tex-view-toggle {
  display: flex;
  background: var(--color-bg-secondary, #F5F5F5);
  border-radius: 8px;
  padding: 3px;
}

.tex-view-toggle button {
  padding: 6px 16px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary, #6B6B6B);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.tex-view-toggle button.active {
  background: var(--color-bg-primary, #fff);
  color: var(--color-text-primary, #1A1A1A);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.tex-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tex-compile-mode {
  margin-right: 4px;
}

.tex-compile-mode button {
  min-width: 56px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
}

.tex-compile-mode button:hover:not(:disabled) {
  color: var(--color-text-primary, #1A1A1A);
}

.tex-compile-mode button.active,
.tex-compile-mode button[aria-checked="true"] {
  background: var(--color-bg-primary, #fff);
  color: var(--color-text-primary, #1A1A1A);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.tex-compile-mode button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.tex-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: 1px solid var(--color-border, #E0E0E0);
  background: var(--color-bg-primary, #fff);
  color: var(--color-text-primary, #1A1A1A);
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.tex-btn:hover {
  background: var(--color-bg-secondary, #F5F5F5);
}

.tex-btn-compile {
  background: var(--color-accent, #5A7A6A);
  color: var(--color-text-inverse);
  border-color: var(--color-accent, #5A7A6A);
}

.tex-btn-compile:hover {
  background: var(--color-accent-dark, #445E50);
  border-color: var(--color-accent-dark, #445E50);
}

.tex-btn-compile.compiling {
  opacity: 0.7;
  pointer-events: none;
}

/* ─── Main Layout ─────────────────────────────── */

.tex-main {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ─── Left Sidebar ────────────────────────────── */

.tex-sidebar {
  width: 200px;
  min-width: 200px;
  border-right: 1px solid var(--color-border, #E0E0E0);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--color-bg-primary, #fff);
}

.tex-sidebar-section {
  padding: 16px;
}

.tex-sidebar-section + .tex-sidebar-section {
  border-top: 1px solid var(--color-border, #E0E0E0);
}

.tex-sidebar-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-primary, #1A1A1A);
  margin-bottom: 10px;
}

/* File tree */
.tex-file-tree {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tex-file-tree li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  font-size: 13px;
  color: var(--color-text-primary, #1A1A1A);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s;
}

.tex-file-tree li:hover {
  background: var(--color-bg-secondary, #F5F5F5);
}

.tex-file-tree li.active {
  background: var(--color-bg-secondary, #F5F5F5);
  font-weight: 600;
}

.tex-file-tree li .file-icon {
  width: 14px;
  height: 14px;
  opacity: 0.5;
  flex-shrink: 0;
}

.tex-file-tree .folder-icon {
  opacity: 0.4;
}

.tex-file-add {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--color-text-secondary, #6B6B6B);
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 4px;
  width: 100%;
  text-align: left;
}

.tex-file-add:hover {
  background: var(--color-bg-secondary, #F5F5F5);
  color: var(--color-text-primary, #1A1A1A);
}

/* Collaboration sidebar items */
.tex-collab-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  font-size: 13px;
  color: var(--color-text-primary, #1A1A1A);
  border-radius: 4px;
  cursor: default;
}

.tex-collab-item .collab-icon {
  width: 14px;
  height: 14px;
  opacity: 0.5;
  margin-right: 8px;
}

.tex-collab-count {
  font-size: 12px;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-secondary, #F5F5F5);
  border-radius: 10px;
}

/* ─── Editor Area ─────────────────────────────── */

.tex-editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* File tabs */
.tex-file-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--color-border, #E0E0E0);
  background: var(--color-bg-secondary, #F5F5F5);
  flex-shrink: 0;
  overflow-x: auto;
}

.tex-file-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--color-text-secondary, #6B6B6B);
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.1s;
}

.tex-file-tab:hover {
  color: var(--color-text-primary, #1A1A1A);
}

.tex-file-tab.active {
  color: var(--color-text-primary, #1A1A1A);
  background: var(--color-bg-primary, #fff);
  font-weight: 500;
}

.tex-file-tab .unsaved-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-accent, #5A7A6A);
  display: none;
}

.tex-file-tab.dirty .unsaved-dot {
  display: block;
}

.tex-file-tab .tab-close {
  opacity: 0;
  width: 14px;
  height: 14px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  color: var(--color-text-secondary);
  transition: opacity 0.1s;
}

.tex-file-tab:hover .tab-close {
  opacity: 0.5;
}

/* CodeMirror container */
.tex-codemirror-wrap {
  flex: 1;
  overflow: hidden;
}

.tex-codemirror-wrap .cm-editor {
  height: 100%;
}

.tex-codemirror-wrap .cm-scroller {
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
  font-size: 13px;
  line-height: 1.6;
}

.tex-codemirror-wrap .cm-gutters {
  background: var(--color-bg-secondary, #F5F5F5);
  border-right: 1px solid var(--color-border, #E0E0E0);
  color: var(--color-text-tertiary, #999);
}

.tex-codemirror-wrap .cm-activeLineGutter {
  background: var(--color-bg-tertiary, #EBEBEB);
}

.tex-codemirror-wrap .cm-activeLine {
  background: rgba(0,0,0,0.02);
}

/* ─── Preview / PDF Viewer ────────────────────── */

.tex-preview-area {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-preview-bg, #525659);
}

.tex-preview-area.visible {
  display: flex;
}

.tex-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  background: var(--color-preview-toolbar, #3B3F42);
  border-bottom: 1px solid var(--color-preview-border, #2A2D30);
  flex-shrink: 0;
}

.tex-preview-toolbar button {
  padding: 4px 12px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08);
  color: var(--color-preview-text, #ddd);
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
}

.tex-preview-toolbar button:hover {
  background: rgba(255,255,255,0.15);
}

.tex-pdf-container {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  gap: 0;
}

.tex-pdf-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

.tex-pdf-container canvas {
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  background: white;
}

.tex-preview-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 14px;
}

/* ─── Right Panel (Comments placeholder) ──────── */

.tex-comments-panel {
  width: 300px;
  min-width: 300px;
  border-left: 1px solid var(--color-border, #E0E0E0);
  display: none;
  flex-direction: column;
  overflow-y: auto;
  background: var(--color-bg-primary, #fff);
}

.tex-comments-panel.visible {
  display: flex;
}

.tex-comments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border, #E0E0E0);
}

.tex-comments-header h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tex-comments-badge {
  background: var(--color-accent, #5A7A6A);
  color: var(--color-text-inverse);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
}

.tex-comments-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

.tex-comments-empty {
  text-align: center;
  color: var(--color-text-secondary, #6B6B6B);
  font-size: 13px;
  padding: 40px 20px;
}

/* ─── Split mode ──────────────────────────────── */

.tex-main.split .tex-editor-area {
  flex: none;
  width: var(--tex-editor-pct, 50%);
  min-width: 200px;
}

.tex-main.split .tex-preview-area {
  flex: 1 1 0;
  display: flex;
  border-left: 1px solid var(--color-border, #E0E0E0);
  min-width: 200px;
}

/* Draggable split divider — only visible in split mode */
.tex-split-divider {
  display: none;
  width: 6px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
  transition: background 0.15s;
}
.tex-main.split .tex-split-divider {
  display: block;
}
.tex-split-divider:hover,
.tex-split-divider.dragging {
  background: var(--color-accent, #5C6F5B);
}
body.tex-resizing,
body.tex-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}
body.tex-resizing .tex-editor-area,
body.tex-resizing .tex-preview-area {
  pointer-events: none;
}

/* ─── Compile status ──────────────────────────── */

.tex-compile-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  font-size: 12px;
  color: var(--color-text-secondary, #6B6B6B);
  background: var(--color-bg-secondary, #F5F5F5);
  border-top: 1px solid var(--color-border, #E0E0E0);
  flex-shrink: 0;
}

.tex-compile-status.error {
  color: var(--color-danger, #8A6060);
  background: var(--color-danger-subtle, #F2EDED);
}

.tex-compile-status.success {
  color: var(--color-success-text, #2D6B4A);
  background: var(--color-success-subtle, #EDF3F0);
}

/* ─── New file modal ──────────────────────────── */

.tex-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  display: none;
}

.tex-modal-overlay.visible {
  display: flex;
}

.tex-modal {
  background: var(--color-bg-primary, #fff);
  border-radius: 12px;
  padding: 24px;
  width: 400px;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.tex-modal h3 {
  margin: 0 0 16px;
  font-size: 16px;
}

.tex-modal input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border, #E0E0E0);
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 16px;
  box-sizing: border-box;
}

.tex-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ─── Image upload area ───────────────────────── */

.tex-image-upload-area {
  border: 2px dashed var(--color-border, #E0E0E0);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 8px;
}

.tex-image-upload-area:hover {
  border-color: var(--color-accent, #5A7A6A);
  background: var(--color-accent-subtle, #D8E8E0);
}

.tex-image-upload-area p {
  margin: 0;
  font-size: 12px;
  color: var(--color-text-secondary, #6B6B6B);
}

/* ─── Editor Preferences Button (sidebar bottom) ── */

.tex-sidebar-bottom {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border, #E0E0E0);
  flex-shrink: 0;
}

.tex-editor-prefs-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--color-border, #E0E0E0);
  background: var(--color-bg-primary, #fff);
  color: var(--color-text-secondary, #6B6B6B);
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.tex-editor-prefs-btn:hover {
  background: var(--color-bg-secondary, #F5F5F5);
  color: var(--color-text-primary, #1A1A1A);
}

/* ─── Editor Preferences Panel ───────────────── */

.tex-prefs-panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 300px;
  background: var(--color-bg-primary, #fff);
  border-right: 1px solid var(--color-border, #E0E0E0);
  z-index: 20;
  display: none;
  flex-direction: column;
  box-shadow: 2px 0 12px rgba(0,0,0,0.08);
}

.tex-prefs-panel.visible {
  display: flex;
}

.tex-prefs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border, #E0E0E0);
  flex-shrink: 0;
}

.tex-prefs-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.tex-prefs-header button {
  border: none;
  background: none;
  font-size: 20px;
  color: var(--color-text-secondary, #6B6B6B);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.tex-prefs-header button:hover {
  color: var(--color-text-primary, #1A1A1A);
}

.tex-prefs-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.tex-prefs-group {
  padding: 10px 16px;
}

.tex-prefs-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-primary, #1A1A1A);
  margin-bottom: 2px;
}

.tex-prefs-hint {
  font-size: 11px;
  color: var(--color-text-secondary, #6B6B6B);
  margin-bottom: 8px;
  line-height: 1.4;
}

.tex-prefs-hint code {
  background: var(--color-bg-secondary, #F5F5F5);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 10px;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
}

.tex-prefs-nav-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.tex-prefs-nav-key {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.tex-prefs-nav-key span {
  font-size: 10px;
  color: var(--color-text-secondary, #6B6B6B);
}

.tex-prefs-nav-key input {
  width: 32px;
  height: 30px;
  text-align: center;
  border: 1px solid var(--color-border, #E0E0E0);
  border-radius: 6px;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 13px;
  font-weight: 600;
  background: var(--color-bg-primary, #fff);
  color: var(--color-text-primary, #1A1A1A);
}

.tex-prefs-nav-key input:focus {
  outline: none;
  border-color: var(--color-accent, #5A7A6A);
  box-shadow: 0 0 0 2px rgba(90, 122, 106, 0.15);
}

.tex-prefs-actions {
  display: flex;
  gap: 6px;
}

.tex-prefs-btn-save {
  padding: 4px 12px;
  background: var(--color-accent, #5A7A6A);
  color: var(--color-text-inverse);
  border: none;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}

.tex-prefs-btn-save:hover {
  background: var(--color-accent-dark, #445E50);
}

.tex-prefs-btn-reset {
  padding: 4px 12px;
  background: var(--color-bg-secondary, #F5F5F5);
  color: var(--color-text-secondary, #6B6B6B);
  border: 1px solid var(--color-border, #E0E0E0);
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
}

.tex-prefs-btn-reset:hover {
  background: var(--color-bg-tertiary, #EBEBEB);
}

.tex-prefs-status {
  font-size: 11px;
  margin-top: 6px;
}

.tex-prefs-divider {
  border: none;
  border-top: 1px solid var(--color-border, #E0E0E0);
  margin: 4px 16px;
}

.tex-prefs-edit-snippets {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  margin: 4px 8px 0;
  font-size: 11px;
  color: var(--color-text-secondary, #6B6B6B);
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 4px;
}

.tex-prefs-edit-snippets:hover {
  background: var(--color-bg-secondary, #F5F5F5);
  color: var(--color-text-primary, #1A1A1A);
}

/* Mappings list */
.tex-prefs-mappings-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.tex-prefs-mapping-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tex-prefs-mapping-row input {
  padding: 4px 6px;
  border: 1px solid var(--color-border, #E0E0E0);
  border-radius: 4px;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 12px;
  background: var(--color-bg-primary, #fff);
  color: var(--color-text-primary, #1A1A1A);
}

.tex-prefs-mapping-row input:focus {
  outline: none;
  border-color: var(--color-accent, #5A7A6A);
}

.tex-prefs-mapping-row select {
  padding: 4px 4px;
  border: 1px solid var(--color-border, #E0E0E0);
  border-radius: 4px;
  font-size: 11px;
  background: var(--color-bg-primary, #fff);
}

.tex-prefs-mapping-row .tex-prefs-mapping-arrow {
  font-size: 11px;
  color: var(--color-text-secondary, #6B6B6B);
  flex-shrink: 0;
}

.tex-prefs-mapping-row .tex-prefs-mapping-remove {
  border: none;
  background: none;
  color: var(--color-danger, #8A6060);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}

/* Vimrc textarea */
.tex-prefs-vimrc {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--color-border, #E0E0E0);
  border-radius: 6px;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
  margin-bottom: 8px;
  background: var(--color-bg-primary, #fff);
  color: var(--color-text-primary, #1A1A1A);
  tab-size: 4;
  white-space: pre;
}

.tex-prefs-vimrc:focus {
  outline: none;
  border-color: var(--color-accent, #5A7A6A);
  box-shadow: 0 0 0 2px rgba(90, 122, 106, 0.15);
}

/* ─── Advanced Settings (legacy compat) ──────── */

.tex-toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  font-size: 13px;
  color: var(--color-text-primary, #1A1A1A);
  border-radius: 4px;
  cursor: pointer;
}

.tex-toggle-label > span:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tex-toggle-label:hover {
  background: var(--color-bg-secondary, #F5F5F5);
}

/* Toggle switch */
.tex-toggle-switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}

.tex-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.tex-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--color-border, #D0D0D0);
  border-radius: 9px;
  transition: background 0.2s;
  cursor: pointer;
}

.tex-toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  bottom: 2px;
  background: var(--color-bg-primary);
  border-radius: 50%;
  transition: transform 0.2s;
}

.tex-toggle-switch input:checked + .tex-toggle-slider {
  background: var(--color-accent, #5A7A6A);
}

.tex-toggle-switch input:checked + .tex-toggle-slider::before {
  transform: translateX(14px);
}

/* Vim status bar */
.tex-vim-status {
  padding: 2px 8px;
  margin: 2px 8px 4px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  letter-spacing: 0.04em;
  color: var(--color-text-secondary, #6B6B6B);
  background: var(--color-bg-secondary, #F5F5F5);
  border-radius: 4px;
  text-align: center;
}

/* ─── Snippet Editor Modal ────────────────────── */

.tex-modal-wide {
  width: 640px;
  max-width: 95vw;
}

.tex-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.tex-modal-header h3 {
  margin: 0;
  font-size: 16px;
}

.tex-btn-small {
  padding: 4px 10px;
  font-size: 11px;
}

.tex-modal-hint {
  font-size: 12px;
  color: var(--color-text-secondary, #6B6B6B);
  margin: 0 0 12px;
  line-height: 1.5;
}

.tex-modal-hint code {
  background: var(--color-bg-secondary, #F5F5F5);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
}

#snippetEditor,
#ultisnipsEditor {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--color-border, #E0E0E0);
  border-radius: 6px;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 12px;
  line-height: 1.6;
  resize: vertical;
  margin-bottom: 16px;
  background: var(--color-bg-primary, #fff);
  color: var(--color-text-primary, #1A1A1A);
  tab-size: 4;
  white-space: pre;
  overflow-x: auto;
}

/* ─── PR Status Badges ───────────────────── */

.tex-pr-status-badge {
  display: inline-flex;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.tex-pr-status-open {
  background: var(--color-success-subtle);
  color: var(--color-success-text);
}

.tex-pr-status-merged {
  background: var(--color-purple-subtle, #EDEBF5);
  color: var(--color-purple, #6f42c1);
}

.tex-pr-status-closed {
  background: var(--color-bg-secondary, #F5F5F5);
  color: var(--color-text-secondary, #6B6B6B);
}

/* ─── Focus Indicators ──────────────────── */

.tex-project-nav-tab:focus-visible {
  outline: 2px solid var(--color-accent, #5A7A6A);
  outline-offset: -2px;
  border-radius: 2px;
}

.tex-view-toggle button:focus-visible {
  outline: 2px solid var(--color-accent, #5A7A6A);
  outline-offset: -2px;
}

.tex-compile-mode button:focus-visible {
  outline: 2px solid var(--color-accent, #5A7A6A);
  outline-offset: -2px;
}

.tex-file-tree li:focus-visible {
  outline: 2px solid var(--color-accent, #5A7A6A);
  outline-offset: -2px;
}

.tex-btn:focus-visible {
  outline: 2px solid var(--color-accent, #5A7A6A);
  outline-offset: 2px;
}

.tex-toggle-switch input:focus-visible + .tex-toggle-slider {
  outline: 2px solid var(--color-accent, #5A7A6A);
  outline-offset: 2px;
}

.tex-file-tab:focus-visible {
  outline: 2px solid var(--color-accent, #5A7A6A);
  outline-offset: -2px;
}

.tex-file-add:focus-visible {
  outline: 2px solid var(--color-accent, #5A7A6A);
  outline-offset: -2px;
}

.tex-collab-item:focus-visible {
  outline: 2px solid var(--color-accent, #5A7A6A);
  outline-offset: -2px;
}

/* Screen reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ========================================
   RESPONSIVE: TABLET (≤ 768px)
   ======================================== */
@media (max-width: 768px) {
  .tex-sidebar {
    display: none;
  }

  .tex-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
  }

  .tex-header-left {
    order: 1;
    flex: 1;
    min-width: 0;
  }

  .tex-header-center {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .tex-header-right {
    order: 2;
    gap: 6px;
  }

  .tex-compile-mode button {
    min-width: 46px;
    padding: 4px 8px;
    font-size: 11px;
  }

  .tex-view-toggle button {
    padding: 5px 10px;
    font-size: 12px;
  }

  .tex-header-btn span {
    display: none;
  }

  .tex-preview-area {
    min-width: 0;
  }

  .tex-main.split .tex-editor-area,
  .tex-main.split .tex-preview-area {
    width: 100%;
  }

  .tex-main.split {
    flex-direction: column;
  }

  .tex-prefs-panel {
    width: 100%;
  }
}
