/* The online editor: a toolbar, one or two panes, a status line. */

/* The editor fills what is left under the site header, and its footer is the
 * status line rather than the site footer. */
.editor-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--nav-h));
  min-height: 30rem;
}
body:has(.editor-page) footer.site { display: none; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.toolbar .group { display: flex; align-items: center; gap: 0.25rem; }
.toolbar .group.right { margin-left: auto; gap: 0.4rem; }
.toolbar .sep {
  width: 1px;
  height: 1.3rem;
  background: var(--border);
  margin: 0 0.35rem;
}

.tool {
  font: inherit;
  font-size: 0.86rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  line-height: 1.2;
}
.tool:hover { background: var(--code-bg); }
.tool.active { background: var(--code-bg); border-color: var(--border); font-weight: 600; }
.tool.primary { background: var(--brand-600); color: #fff; font-weight: 600; }
.tool.primary:hover { background: var(--brand-500); }

.modes { border: 1px solid var(--border); border-radius: 8px; padding: 2px; }

#docname {
  font: inherit;
  font-size: 0.86rem;
  padding: 0.35rem 0.5rem;
  width: 10rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
}

.menu { position: relative; }
.menu-items {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  padding: 0.35rem;
  display: none;
  min-width: 13rem;
  z-index: 40;
}
.menu-items.open { display: block; }
.menu-items button {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 0.7rem;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.menu-items button:hover { background: var(--code-bg); }
.menu-items .toc {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 0.3rem;
}

.panes { flex: 1; display: flex; min-height: 0; background: var(--surface); }
.pane { flex: 1; min-width: 0; overflow-y: auto; background: var(--surface); }
.pane + .pane { border-left: 1px solid var(--border); }

/* The source pane is tinted a shade off the sheet, the way the desktop app
 * separates the two panes. */
#pane-md { background: #fbfbfd; }

#source {
  width: 100%;
  height: 100%;
  border: 0;
  resize: none;
  padding: 1.5rem;
  font-family: var(--mono);
  font-size: 0.92rem;
  line-height: 1.65;
  background: transparent;
  color: var(--text);
  outline: none;
  tab-size: 2;
}

.rich {
  padding: 2.5rem 3rem 6rem;
  max-width: 52rem;
  margin: 0 auto;
  outline: none;
  font-size: 1.02rem;
}

.rich:focus { outline: none; }

.rich h1, .rich h2, .rich h3, .rich h4 {
  line-height: 1.2;
  margin: 1.6em 0 0.5em;
  letter-spacing: -0.01em;
}
.rich h1 { font-size: 1.9rem; color: var(--brand-600); margin-top: 0.4em; }
.rich h2 { font-size: 1.5rem; color: var(--brand-500); }
.rich h3 { font-size: 1.22rem; }
.rich p { margin: 0 0 1em; }
.rich ul, .rich ol { margin: 0 0 1em; padding-left: 1.6em; }
.rich li { margin: 0.25em 0; }
.rich blockquote {
  margin: 0 0 1em;
  padding: 0.2em 1em;
  border-left: 3px solid var(--brand-500);
  color: var(--muted);
}
.rich code {
  background: var(--code-bg);
  color: var(--crimson-500);
  padding: 0.12em 0.35em;
  border-radius: 5px;
  font-size: 0.9em;
}
.rich pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  overflow-x: auto;
}
.rich pre code { background: none; color: var(--text); padding: 0; }
.rich table { border-collapse: collapse; width: 100%; margin: 0 0 1em; }
.rich th, .rich td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.7rem;
  text-align: left;
}
.rich th { background: var(--code-bg); }
.rich hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.rich img { max-width: 100%; height: auto; }
.rich a { color: var(--brand-600); }

.statusbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
}

.statusbar.busy { color: var(--brand-600); }
.statusbar.error { color: var(--crimson-500); }

@media (max-width: 800px) {
  .rich { padding: 1.5rem 1.2rem 5rem; }
  .toolbar .group.format { order: 3; width: 100%; overflow-x: auto; }
}
