:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1d2125;
  --muted: #5e6670;
  --border: #d7dbe0;
  --accent: #7719aa;          /* OneNote purple */
  --accent-text: #ffffff;
  --accent-hover: #5f1488;
  --editor-bg: #ffffff;
  --focus: #2f6fde;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 4px 16px rgba(0, 0, 0, .04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --surface: #1f2227;
    --text: #e6e8eb;
    --muted: #9aa2ad;
    --border: #353a42;
    --accent: #a35fd1;
    --accent-text: #ffffff;
    --accent-hover: #b77de0;
    --editor-bg: #1a1c20;
    --focus: #6ea0ff;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

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

/* ---- Toolbar ---- */

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  font-size: 16px;
  letter-spacing: -.01em;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.format {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

select, button {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  min-height: 34px;
  cursor: pointer;
}

select { padding-right: 28px; }

button:hover, select:hover { border-color: var(--muted); }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
}

.hint {
  margin: 0;
  padding: 8px 16px;
  color: var(--muted);
  font-size: 13px;
}

/* ---- Panes ---- */

.panes {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 0 16px 12px;
}

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

.pane-title {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

#editor {
  flex: 1;
  min-height: 0;
  width: 100%;
  resize: none;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--editor-bg);
  color: var(--text);
  font: 13.5px/1.55 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  tab-size: 4;
  box-shadow: var(--shadow);
}

#editor.drop { outline: 2px dashed var(--accent); outline-offset: -6px; }

.page-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  background: #ffffff;
}

/* The preview is always a white page, like OneNote or a document */
.page {
  min-height: 100%;
  padding: 16px 20px;
  background: #ffffff;
  color: #000000;
  overflow-wrap: anywhere;
}

.page pre.plain {
  margin: 0;
  white-space: pre-wrap;
  font: 13px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: #000000;
}

.page .empty { color: #8a8f96; font: 14px/1.4 system-ui, sans-serif; }

/* ---- Footer and status ---- */

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 0 16px 12px;
  color: var(--muted);
  font-size: 12.5px;
}

.foot a { color: var(--muted); }
.foot a:hover { color: var(--text); }

.status {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 8px;
  background: #1d2125;
  color: #ffffff;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, transform .15s;
}

.status.show { opacity: 1; transform: translate(-50%, 0); }
.status.error { background: #b3261e; }

/* ---- Phones: stack the panes ---- */

@media (max-width: 760px) {
  body { height: auto; min-height: 100%; }
  .panes { grid-template-columns: 1fr; }
  #editor { min-height: 45vh; }
  .page-wrap { min-height: 45vh; }
  .sep { display: none; }
  .actions { width: 100%; }
  .actions button.primary { flex: 1 1 100%; }
}
