@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,600;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap");

:root {
  --bg: #0f1218;
  --surface: #171b24;
  --border: #2a3142;
  --text: #e8eaef;
  --muted: #9aa3b5;
  --accent: #7c9cff;
  --accent-dim: #5a74c9;
  --error: #ff6b7a;
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: radial-gradient(1200px 800px at 15% -10%, #1a2240 0%, transparent 55%),
    radial-gradient(900px 600px at 90% 20%, #1e2838 0%, transparent 50%), var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
}

.hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}

.tagline {
  color: var(--muted);
  max-width: 52ch;
  margin: 0;
  font-size: 0.95rem;
}

.tagline code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface);
  padding: 0.12em 0.4em;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: #c5d4ff;
}

.layout {
  display: grid;
  gap: 1.25rem;
  margin-top: 2rem;
}

@media (min-width: 840px) {
  .layout {
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.editor-panel label,
.panel-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.latex-frame {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0c0f14;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.latex-frame:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 156, 255, 0.2);
}

.latex-frame-brace {
  flex-shrink: 0;
  padding: 0.55rem 1rem;
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.45;
  color: #7a8499;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border);
  user-select: none;
}

.latex-frame-brace:last-of-type {
  border-bottom: none;
  border-top: 1px solid var(--border);
}

.latex-frame-brace code {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  padding: 0;
  border: none;
}

#latex-input {
  width: 100%;
  resize: vertical;
  min-height: 180px;
  margin: 0;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.45;
}

#latex-input:focus {
  outline: none;
}

.appearance-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin-top: 1rem;
}

.appearance-row--top {
  align-items: flex-start;
}

.appearance-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
}

.appearance-check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.appearance-check input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.appearance-controls.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.appearance-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.appearance-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#equation-color,
#bg-color {
  width: 2.5rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

#equation-color::-webkit-color-swatch-wrapper,
#bg-color::-webkit-color-swatch-wrapper {
  padding: 2px;
}

#equation-color::-webkit-color-swatch,
#bg-color::-webkit-color-swatch {
  border: none;
  border-radius: 5px;
}

.hex-input {
  width: 6.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0c0f14;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.8rem;
}

.hex-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124, 156, 255, 0.2);
}

.btn {
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #222833;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: #2a3140;
  border-color: #3d4658;
}

.btn.primary {
  background: linear-gradient(165deg, var(--accent) 0%, var(--accent-dim) 100%);
  border: none;
  color: #0a0c10;
}

.btn.primary:hover {
  filter: brightness(1.06);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-block {
  display: block;
  width: 100%;
  text-align: center;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.75rem 0 0;
  min-height: 1.25em;
}

.hint.error {
  color: var(--error);
}

.preview-panel {
  display: flex;
  flex-direction: column;
}

.preview-actions {
  margin-top: 1rem;
  flex-shrink: 0;
}

.preview-shell {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  padding: 1.5rem;
  border-radius: 10px;
  background-color: #fafbfd;
  border: 1px dashed var(--border);
  transition: background-color 0.15s ease;
}

.preview-shell.preview-shell--transparent {
  background-color: transparent;
  background-image: repeating-conic-gradient(#ddd 0% 25%, #f6f6f6 0% 50%);
  background-size: 16px 16px;
}

.math-preview {
  font-size: 1.15rem;
  text-align: center;
}

.math-preview .katex {
  font-size: 1.05em;
  color: inherit;
}

.math-preview .katex-display {
  margin: 0;
}
