.editor-block.latex-media-block {
  display: flex;
  align-items: flex-start;
  min-width: 0;
  max-width: none;
}

.latex-block-preview {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  width: 100%;
  min-width: 0;
  max-width: none;
  min-height: 64px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--sidebar);
  color: var(--text);
  overflow: hidden;
  cursor: pointer;
  transition: background 120ms ease, border-color 160ms ease;
}

.latex-block-preview:hover {
  background: var(--surface);
  border-color: var(--muted);
}

.latex-block-preview:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.latex-block-preview-content {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
}

.latex-block-preview-content .katex-display {
  margin: 0;
  padding: 4px 0;
}

.latex-block-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  user-select: none;
}

.latex-block-placeholder svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.latex-block-preview.invalid {
  border-color: var(--danger);
}

.latex-block-preview-content.latex-invalid {
  color: var(--danger);
  font-family: monospace;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.latex-window {
  width: 840px;
  height: min(640px, calc(100dvh - 48px));
}

.latex-window .media-window-body {
  overflow-y: auto;
}

.latex-window-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 24px;
}

.latex-window-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 12px;
  min-width: 0;
  min-height: 0;
}

.latex-window-label {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 8px;
  min-height: 20px;
  color: var(--secondary);
  font-size: 12px;
  font-weight: 600;
  user-select: none;
}

.latex-window-label svg {
  width: 16px;
  height: 16px;
}

.latex-window-input {
  display: block;
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 120px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  outline: none;
  background: var(--background);
  color: var(--text);
  font-family: monospace;
  font-size: 14px;
  line-height: 160%;
  tab-size: 2;
  resize: none;
  overflow: auto;
  transition: border-color 160ms ease;
}

.latex-window-input:hover {
  border-color: var(--muted);
}

.latex-window-input:focus {
  border-color: var(--brand);
}

.latex-window-input::placeholder {
  color: var(--muted);
}

.latex-window-preview {
  display: flex;
  align-items: safe center;
  justify-content: safe center;
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 120px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--background);
  color: var(--text);
  overflow: auto;
}

.latex-window-preview .katex-display {
  flex-shrink: 0;
  margin: 0;
  padding: 8px;
}

.latex-window-preview.latex-empty {
  color: var(--muted);
  font-size: 14px;
}

.latex-window-preview.latex-invalid {
  align-items: flex-start;
  justify-content: flex-start;
  border-color: var(--danger);
  color: var(--danger);
  font-family: monospace;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.latex-window-status {
  display: flex;
  align-items: flex-start;
  flex-shrink: 0;
  gap: 8px;
  min-width: 0;
  min-height: 24px;
  color: var(--muted);
  font-size: 12px;
  line-height: 160%;
}

.latex-window-status > .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.latex-window-status svg {
  width: 16px;
  height: 16px;
}

.latex-window-status.valid > .icon {
  color: var(--brand);
}

.latex-window-status.invalid {
  color: var(--danger);
}

.latex-window-status-text {
  flex: 1;
  min-width: 0;
  max-height: 60px;
  overflow-y: auto;
  overflow-wrap: anywhere;
}

.alignment-track > .latex-media-block .latex-block-preview {
  min-width: 0;
  min-height: 100%;
  padding: 8px;
}

.ratio-track > .latex-media-block .latex-block-preview-content {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}