/* A light editor throughout: the preview is a white page, and a dark editor
   next to it reads as two unrelated applications. */

:root {
  --ink: #1b1a17;
  --muted: #6b6560;
  --rule: #dcd7d0;
  --bg: #f7f5f2;
  --accent: #8a4b2a;
  --danger: #a32020;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--rule);
  background: #fff;
}

.toolbar h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.field input,
.field select {
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.status {
  margin-left: auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
}

.status[data-state="error"] {
  color: var(--danger);
}

button {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

button:disabled {
  color: var(--muted);
  cursor: default;
}

button:not(:disabled):hover {
  border-color: var(--accent);
  color: var(--accent);
}

.panes {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.pane-editor {
  border-right: 1px solid var(--rule);
}

#editor {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

.cm-editor {
  height: 100%;
}

.cm-editor.cm-focused {
  outline: none;
}

.error {
  margin: 0;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--rule);
  background: #fdf1f1;
  color: var(--danger);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.8125rem;
}

/* The 16px padding and page margin are PAGE_GUTTER in main.js. */
#preview {
  position: relative; /* anchors the pages' offsetTop for scroll syncing */
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px;
  background: #e8e4df;
  /* Scrolling is driven from the editor; keep the browser's anchoring and a
     late-appearing scrollbar from shifting things under it. */
  overflow-anchor: none;
  scrollbar-gutter: stable;
}

#preview .page {
  margin: 0 auto 16px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(27, 26, 23, 0.25);
  /* Clicking a page jumps the editor to that spot. */
  cursor: text;
}

#preview .page:last-child {
  margin-bottom: 0;
}

#preview .page canvas {
  display: block;
}

@media (max-width: 800px) {
  .panes {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  }

  .pane-editor {
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }
}
