.shell-latex {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 2.5rem;
}

.latex-intro {
  margin: 0.5rem 0 0.85rem;
}

.latex-title {
  margin: 0 0 0.35rem;
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  letter-spacing: -0.02em;
}

.latex-intro p {
  margin: 0;
  color: var(--muted);
  max-width: 42rem;
}

.latex-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: end;
  margin-bottom: 0.65rem;
}

.latex-toolbar .spacer {
  flex: 1;
  min-width: 0.5rem;
}

.latex-mode {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.latex-toolbar .btn,
.latex-snippets .snippet,
.latex-mode select,
.latex-toolbar select.download-as {
  appearance: none;
  min-height: 2.25rem;
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.latex-toolbar select.download-as {
  appearance: auto;
  min-width: 11rem;
}

.latex-toolbar .btn.ghost {
  background: transparent;
}

.latex-mode select {
  min-width: 10rem;
  cursor: pointer;
}

.latex-toolbar .btn.ghost:hover,
.latex-snippets .snippet:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  background: var(--accent-soft);
}

.latex-toolbar .status {
  font-size: 0.82rem;
  padding-bottom: 0.35rem;
}

.latex-snippets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.latex-snippets .snippet {
  min-height: 1.9rem;
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
}

.latex-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  min-height: min(62vh, 560px);
}

.latex-panel {
  display: flex;
  flex-direction: column;
  min-height: 18rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.panel-head h3 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 650;
}

#latex-input {
  flex: 1;
  width: 100%;
  min-height: 16rem;
  resize: vertical;
  border: 0;
  padding: 0.85rem 1rem;
  background: transparent;
  color: inherit;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.5;
  outline: none;
}

.latex-preview {
  flex: 1;
  overflow: auto;
  padding: 1.25rem 1rem;
  font-size: 1.2rem;
  line-height: 1.6;
}

.latex-preview .katex-display {
  margin: 0.75rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.latex-panel--preview {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 6%, var(--surface)) 0%, var(--surface) 40%);
}

.latex-error {
  margin: 0;
  padding: 0.65rem 0.85rem 0.85rem;
  color: var(--danger);
  font-size: 0.85rem;
  font-family: var(--font-mono);
  white-space: pre-wrap;
}

.latex-footnote {
  margin: 0.85rem 0 0;
  font-size: 0.82rem;
}

.latex-footnote a {
  color: var(--accent-ink);
}

@media (max-width: 860px) {
  .latex-workspace {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  #latex-input {
    min-height: 12rem;
  }

  .latex-preview {
    min-height: 10rem;
  }
}
