/* ===========================================================
   warq — block editor skin
   The bundled Tiptap editor ships no CSS. It renders every block as
   [data-be-type="..."] plus a handful of .be-* helper classes, so all
   of its styling lives here.
   =========================================================== */

.block-editor {
  position: relative;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--fg);
  min-height: 160px;
}
.block-editor .ProseMirror { outline: none; min-height: 160px; }

/* placeholder on an empty doc */
.block-editor .ProseMirror > p:only-child:empty::before,
.block-editor .ProseMirror > [data-be-type="p"]:only-child:empty::before {
  content: "Write something, or press / for blocks…";
  color: var(--fg-dim);
  pointer-events: none;
  float: left;
  height: 0;
}

/* ---------- blocks ---------- */

.block-editor [data-be-type] { margin: 2px 0; position: relative; }

.block-editor [data-be-type="h1"] { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; margin: 16px 0 4px; }
.block-editor [data-be-type="h2"] { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; margin: 14px 0 3px; }
.block-editor [data-be-type="h3"] { font-size: 15px; font-weight: 600; margin: 12px 0 2px; }
.block-editor [data-be-type="h1"]:first-child,
.block-editor [data-be-type="h2"]:first-child,
.block-editor [data-be-type="h3"]:first-child { margin-top: 0; }

.block-editor [data-be-type="p"] { margin: 4px 0; min-height: 1.6em; }

/* list-like blocks share a hanging marker gutter */
.block-editor [data-be-type="bullet"],
.block-editor [data-be-type="num"],
.block-editor [data-be-type="todo"],
.block-editor [data-be-type="toggle"] {
  padding-left: 22px;
  margin: 2px 0;
}
.block-editor [data-be-type="bullet"]::before {
  content: "•";
  position: absolute;
  left: 6px;
  color: var(--fg-muted);
  font-size: 16px;
  line-height: 1.5;
}
/* A numbered list has to actually count. The counter resets on any block
   that isn't a num, so each run restarts at 1 — which is exactly what the
   markdown serializer does. */
.block-editor { counter-reset: be-num; }
.block-editor [data-be-type]:not([data-be-type="num"]) { counter-reset: be-num; }
.block-editor [data-be-type="num"] { counter-increment: be-num; }
.block-editor [data-be-type="num"]::before {
  content: counter(be-num) ".";
  position: absolute;
  left: 0;
  width: 18px;
  text-align: right;
  color: var(--fg-muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  line-height: 1.6;
}
.block-editor [data-be-type="toggle"]::before {
  content: "▸";
  position: absolute;
  left: 6px;
  color: var(--fg-muted);
  font-size: 11px;
  line-height: 2.1;
}

/* to-do: the ::before is the click target, wired up in editor.js */
.block-editor [data-be-type="todo"]::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 4px;
  width: 14px;
  height: 14px;
  border: 1.6px solid var(--line-strong);
  border-radius: 3px;
  cursor: pointer;
  background: var(--bg-elev);
}
.block-editor [data-be-type="todo"][data-checked="true"]::before {
  background: var(--accent);
  border-color: var(--accent);
}
.block-editor [data-be-type="todo"][data-checked="true"]::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 6.5px;
  width: 4px;
  height: 8px;
  border: solid var(--accent-fg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  pointer-events: none;
}
.block-editor [data-be-type="todo"][data-checked="true"] {
  color: var(--fg-dim);
  text-decoration: line-through;
}

.block-editor [data-be-type="code"] {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  margin: 8px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.block-editor hr,
.block-editor [data-be-type="divider"] {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 14px 0;
}

/* callouts */
.block-editor .be-callout {
  border-left: 3px solid var(--fg-dim);
  background: var(--bg-sunken);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 8px 11px;
  margin: 8px 0;
  font-size: 13.5px;
}
.block-editor .be-callout-tip     { border-left-color: #2fa36b; }
.block-editor .be-callout-warning { border-left-color: #d98324; }
.block-editor .be-callout-note    { border-left-color: var(--accent); }
.block-editor .be-callout-reminder{ border-left-color: #a15fd0; }

/* media */
.block-editor .be-image,
.block-editor [data-be-type="image"] img {
  max-width: 100%;
  height: auto;
  border-radius: var(--r-sm);
  display: block;
  margin: 8px 0;
}
.block-editor .be-image-placeholder {
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  padding: 18px;
  text-align: center;
  color: var(--fg-dim);
  font-size: 12.5px;
  cursor: pointer;
  margin: 8px 0;
}

.block-editor .be-embed-card {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  margin: 8px 0;
  background: var(--bg-elev);
  font-size: 13px;
  text-decoration: none;
  color: var(--fg);
  overflow-wrap: anywhere;
}
.block-editor .be-embed-favicon { width: 16px; height: 16px; flex: 0 0 auto; }

/* tables */
.block-editor .be-table,
.block-editor [data-be-type="table"] table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 8px 0;
  display: block;
  overflow-x: auto;
}
.block-editor [data-be-type="table"] td,
.block-editor [data-be-type="table"] th {
  border: 1px solid var(--line);
  padding: 5px 8px;
  min-width: 70px;
}
.block-editor [data-be-type="table"] th { background: var(--bg-sunken); font-weight: 600; }
.block-editor .be-table-controls { display: flex; gap: 4px; margin: 4px 0; }

/* widgets that the host app didn't supply a renderer for */
.block-editor .be-widget {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  margin: 8px 0;
  background: var(--bg-sunken);
  font-size: 13px;
}
.block-editor .be-widget-missing { color: var(--fg-dim); font-style: italic; }

/* inline marks + wiki links */
.block-editor strong { font-weight: 700; }
.block-editor em { font-style: italic; }
.block-editor s { text-decoration: line-through; color: var(--fg-muted); }
.block-editor mark {
  background: var(--accent-soft);
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}
.block-editor code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.1em 0.32em;
  overflow-wrap: anywhere;
}
/* a code block is already monospaced; don't double up the chrome */
.block-editor [data-be-type="code"] code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}
.block-editor a, .block-editor .wiki-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-soft);
  cursor: pointer;
}
.block-editor a:hover, .block-editor .wiki-link:hover { border-bottom-color: var(--accent); }

/* ---------- floating UI the bundle injects into <body> ---------- */

.be-slash-menu, #be-slash-menu,
.be-wiki-menu, #be-wiki-menu {
  position: absolute;
  z-index: 400;
  min-width: 190px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-2);
  padding: 4px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--fg);
}
.be-slash-menu > *, .be-wiki-menu > *,
#be-slash-menu > *, #be-wiki-menu > * {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.be-slash-menu > *:hover, .be-wiki-menu > *:hover,
#be-slash-menu > *:hover, #be-wiki-menu > *:hover,
.be-slash-menu > .active, .be-wiki-menu > .active,
#be-slash-menu > .active, #be-wiki-menu > .active,
.be-slash-menu > [aria-selected="true"],
#be-slash-menu > [aria-selected="true"] { background: var(--bg-hover); }

.be-drag-handle {
  position: absolute;
  z-index: 50;
  left: -17px;
  top: 1px;
  width: 15px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 3px;
  color: var(--fg-dim);
  cursor: grab;
  opacity: 0;
  transition: opacity .12s ease;
  background: var(--bg-elev);
  font-size: 13px;
  user-select: none;
}
.block-editor:hover .be-drag-handle { opacity: .75; }
.be-drag-handle:hover { opacity: 1 !important; background: var(--bg-hover); }

/* a narrow pane needs the width more than it needs drag handles */
@media (max-width: 560px) {
  .be-drag-handle { display: none; }
}

/* the bundle tags its injected menus with .slash-menu as well as the id */
.slash-menu { font-family: var(--font); }
