:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color-scheme: light;
}

body {
  margin: 0;
  padding: 0;
  background: #f4f4f7;
  color: #222;
}

header {
  padding: 0.75rem 1rem;
  background: #1f2933;
  color: #f9fafb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 1rem;
  margin: 0;
  font-weight: 600;
}

header span {
  font-size: 0.8rem;
  opacity: 0.8;
}

main {
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

.layout {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  min-height: calc(100vh - 70px);
}

/* Panes act like two resizable windows */
.pane {
  background: #ffffff;
  border-radius: 0.75rem;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto; /* width controlled via JS */
  min-height: 300px;
  min-width: 200px;
}

.pane h2 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #111827;
}

/* Input textarea */
textarea {
  flex: 1;
  resize: vertical;
  border-radius: 0.5rem;
  border: 1px solid #d1d5db;
  padding: 0.5rem 0.75rem;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1.4;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.25);
}

/* Controls / buttons */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
  font-size: 0.8rem;
}

.controls label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.controls input[type="checkbox"] {
  transform: scale(1.1);
  cursor: pointer;
}

button {
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

button:hover {
  background: #eef2ff;
  border-color: #6366f1;
}

button.primary {
  background: #2563eb;
  color: #f9fafb;
  border-color: #1d4ed8;
}

button.primary:hover {
  background: #1d4ed8;
}

/* Preview area */
#preview {
  flex: 1;
  padding: 0.75rem;
  overflow: auto;
  border-radius: 0.6rem;
  background: #f9fafb;
}

#preview-inner {
  min-height: 200px;
  line-height: 1.6; /* nicer spacing for text + math */
}

/* Extra space between paragraphs from JS */
#preview-inner p {
  margin: 0 0 0.75rem 0;
}

#preview-inner.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  font-size: 0.85rem;
  font-style: italic;
  text-align: center;
}

/* MathJax display alignment: left-align block math */
.mjx-display {
  text-align: left !important;
}

mjx-container[jax="SVG"][display="true"] {
  text-align: left !important;
  margin: 0.25rem 0 0.75rem 0;
}

/* Divider between panes (draggable) */
.divider {
  width: 6px;
  background: #e5e7eb;
  border-radius: 999px;
  cursor: col-resize;
  margin: 0 0.25rem;
  flex: 0 0 auto;
}

/* While dragging, change cursor everywhere */
body.resizing,
body.resizing * {
  cursor: col-resize !important;
}

/* Mobile: stack panes and hide divider */
@media (max-width: 800px) {
  .layout {
    flex-direction: column;
  }

  .divider {
    display: none;
  }

  .pane {
    width: 100% !important;
    flex: 1 1 auto;
  }
}

/* Print styles: show only rendered pane content */
@media print {
  header,
  .input-pane,
  .controls,
  #divider {
    display: none !important;
  }

  body {
    background: #ffffff;
  }

  main,
  .layout,
  .pane.preview-pane,
  #preview,
  #preview-inner {
    margin: 0;
    padding: 0;
    box-shadow: none;
    border-radius: 0;
    max-width: 100%;
  }

  #preview {
    overflow: visible;
  }
}
