/* ── Fonts (bundled locally) ───────────────────────────── */
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("fonts/dm-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("fonts/dm-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
    U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

/* ── Theme variables ───────────────────────────────────── */
:root {
  --bg: #1a1a1a;
  --bg-surface: #242424;
  --text: #e4e4e4;
  --text-muted: #888;
  --text-faint: #898989;
  --border: #333;
  --border-light: #2a2a2a;
  --accent: #e4e4e4;
  --checkbox-border: #555;
  --checkbox-hover: #888;
  --checkbox-fill: #ccc;
  --hr-color: #333;
  --blockquote-border: #444;
  --blockquote-text: #999;
  --placeholder: #444;
  --menu-bg: #242424;
  --menu-border: #333;
  --menu-shadow: rgba(0, 0, 0, 0.4);
  --menu-hover: #2e2e2e;
  --menu-icon-bg: #1a1a1a;
  --menu-icon-border: #333;
  --menu-icon-text: #aaa;
  --menu-label: #ddd;
  --toast-bg: #e4e4e4;
  --toast-text: #1a1a1a;
  --toast-error: #d1242f;
  --scrollbar: #444;
}

[data-theme="light"] {
  --bg: #fafafa;
  --bg-surface: #fff;
  --text: #222;
  --text-muted: #555;
  --text-faint: #767676;
  --border: #e5e5e5;
  --border-light: #d4d4d4;
  --accent: #222;
  --checkbox-border: #ccc;
  --checkbox-hover: #999;
  --checkbox-fill: #555;
  --hr-color: #e0e0e0;
  --blockquote-border: #d0d0d0;
  --blockquote-text: #555;
  --placeholder: #c0c0c0;
  --menu-bg: #fff;
  --menu-border: #e5e5e5;
  --menu-shadow: rgba(0, 0, 0, 0.12);
  --menu-hover: #f0f0f0;
  --menu-icon-bg: #fafafa;
  --menu-icon-border: #e5e5e5;
  --menu-icon-text: #555;
  --menu-label: #333;
  --toast-bg: #24292f;
  --toast-text: #fff;
  --toast-error: #d1242f;
  --scrollbar: #d0d0d0;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

main {
  height: 100%;
}

/* ── Editor ───────────────────────────────────────────── */
#editor {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: clamp(24px, 6vw, 80px);
  font-size: 20px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  caret-color: var(--text);
  border: none;
  outline: none;
  overflow-y: auto;
  scrollbar-color: var(--scrollbar) transparent;
  white-space: pre-wrap;
  word-break: break-word;
}

#editor:focus-visible {
  box-shadow: inset 0 0 0 2px var(--border);
}

#editor.is-empty::before {
  content: attr(data-placeholder);
  color: var(--placeholder);
  pointer-events: none;
  position: absolute;
}

#editor a {
  color: var(--text);
  text-decoration: underline;
  cursor: pointer;
}

/* ── Editor block types ──────────────────────────────── */
#editor h1 {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.3;
  margin: 4px 0;
}

#editor h2 {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.35;
  margin: 4px 0;
}

#editor h3 {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.4;
  margin: 4px 0;
}

#editor ul, #editor ol {
  padding-left: 0;
  margin: 2px 0;
  list-style-position: inside;
}

#editor li {
  margin: 2px 0;
  min-height: 1.5em;
}

#editor blockquote {
  border-left: 3px solid var(--blockquote-border);
  padding-left: 16px;
  color: var(--blockquote-text);
  margin: 8px 0;
}

#editor hr {
  border: none;
  border-top: 1px solid var(--hr-color);
  margin: 16px 0;
}

#editor .todo-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0;
  white-space: normal;
}

#editor .todo-item .todo-text {
  flex: 1 1 0%;
  min-width: 0;
  outline: none;
  line-height: 1.5;
  white-space: pre-wrap;
}

#editor .todo-item input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  margin-top: 0;
  width: 18px;
  height: 18px;
  border: 2px solid var(--checkbox-border);
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: border-color 0.15s;
}

#editor .todo-item input[type="checkbox"]::before {
  content: "";
  position: absolute;
  inset: -13px 0 -13px -13px;
}

#editor .todo-item input[type="checkbox"]:hover {
  border-color: var(--checkbox-hover);
}

#editor .todo-item input[type="checkbox"]:focus-visible {
  border-color: var(--checkbox-hover);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--checkbox-hover);
}

#editor .todo-item input[type="checkbox"]:checked {
  border-color: var(--checkbox-hover);
}

#editor .todo-item input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--checkbox-fill);
}

#editor .todo-item.checked {
  text-decoration: line-through;
  color: var(--text-faint);
}

/* ── Slash command menu ──────────────────────────────── */
.slash-menu {
  position: fixed;
  width: 280px;
  max-height: 340px;
  overflow-y: auto;
  background: var(--menu-bg);
  border: 1px solid var(--menu-border);
  border-radius: 10px;
  box-shadow: 0 4px 24px var(--menu-shadow);
  padding: 6px;
  z-index: 500;
}

.slash-menu::-webkit-scrollbar {
  width: 4px;
}

.slash-menu::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 2px;
}

.slash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}

.slash-item:hover,
.slash-item.active {
  background: var(--menu-hover);
}

.slash-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--menu-icon-border);
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--menu-icon-text);
  background: var(--menu-icon-bg);
  flex-shrink: 0;
}

.slash-label {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--menu-label);
}

.slash-hint {
  font-size: 12px;
  color: var(--text-faint);
  font-family: "SF Mono", "Fira Code", monospace;
}

.slash-empty {
  padding: 16px 8px;
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
}

/* ── Toast ────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 18px;
  font-size: 13px;
  border-radius: 8px;
  background: var(--toast-bg);
  color: var(--toast-text);
  box-shadow: 0 4px 16px var(--menu-shadow);
  opacity: 1;
  transition: opacity 0.3s;
  z-index: 1000;
}

.toast.hidden {
  opacity: 0;
  pointer-events: none;
}

.toast.error {
  background: var(--toast-error);
  color: #fff;
}

