/* ============ Variables y base ============ */
:root {
  --bg: #ffffff;
  --fg: #1d1d1f;
  --muted: #86868b;
  --sb-bg: #f5f5f7;
  --hover: rgba(0, 0, 0, 0.05);
  --hover-strong: rgba(0, 0, 0, 0.09);
  --border: #e2e2e7;
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.1);
  --code-bg: #f5f5f7;
  --callout-bg: #f5f5f7;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  --red: #ff3b30;
  --green: #34a853;
  --orange: #e8841a;
}
body[data-theme="dark"] {
  --bg: #161617;
  --fg: #f5f5f7;
  --muted: #86868b;
  --sb-bg: #1d1d1f;
  --hover: rgba(255, 255, 255, 0.06);
  --hover-strong: rgba(255, 255, 255, 0.11);
  --border: #2d2d30;
  --accent: #2997ff;
  --accent-soft: rgba(41, 151, 255, 0.16);
  --code-bg: #232325;
  --callout-bg: #232325;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 0 0.5px rgba(255, 255, 255, 0.08);
  --red: #ff453a;
  --green: #30d158;
  --orange: #ff9f0a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  font-size: 15.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; color: inherit; }

/* iconos SVG */
.ic { vertical-align: -3px; flex: none; }
.mono-ic { color: var(--muted); display: inline-flex; align-items: center; }
.tb-btn .ic, .btn .ic, .tpl-chip .ic { margin-right: 2px; }

/* ============ Sidebar ============ */
#sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--sb-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 8px;
  user-select: none;
  height: 100vh;
  overflow-y: auto;
}
.sb-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 12px;
  font-weight: 600;
  font-size: 14px;
}
.sb-brand-icon { font-size: 18px; }
.sb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--fg);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}
.sb-item:hover { background: var(--hover); }
.sb-item.active { background: var(--hover-strong); font-weight: 500; }
.sb-item-icon { width: 18px; text-align: center; }
.kbd {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  background: var(--bg);
}
.sb-section { margin-top: 16px; }
.sb-section.grow { flex: 1; }
.sb-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 4px 10px;
}
.sb-label button {
  border: none;
  background: none;
  font-size: 16px;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
  width: 22px;
  height: 22px;
  line-height: 1;
}
.sb-label button:hover { background: var(--hover-strong); color: var(--fg); }

.pg-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  position: relative;
}
.pg-row:hover { background: var(--hover); }
.pg-row.active { background: var(--hover-strong); font-weight: 500; }
.pg-chev {
  width: 18px;
  height: 18px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
  font-size: 10px;
  padding: 0;
  flex: none;
  transition: transform 0.15s;
}
.pg-chev.open { transform: rotate(90deg); }
.pg-chev:hover { background: var(--hover-strong); }
.pg-chev.empty { visibility: hidden; }
.pg-icon { flex: none; }
.pg-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pg-actions { display: none; gap: 2px; flex: none; }
.pg-row:hover .pg-actions { display: flex; }
.pg-actions button {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
  width: 20px;
  height: 20px;
  font-size: 12px;
  padding: 0;
  line-height: 1;
}
.pg-actions button:hover { background: var(--hover-strong); color: var(--fg); }
.pg-children { margin-left: 14px; }
.sb-footer { padding-top: 8px; border-top: 1px solid var(--border); }
.sb-empty { color: var(--muted); font-size: 13px; padding: 4px 12px; }

/* ============ Main / topbar ============ */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
#topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  flex: none;
}
.crumb { color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 4px; }
.crumb:hover { background: var(--hover); color: var(--fg); }
.crumb.last { color: var(--fg); }
.crumb-sep { color: var(--muted); }
.topbar-spacer { flex: 1; }
.tb-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}
.tb-btn:hover { background: var(--hover); }
.tb-btn.primary {
  background: var(--accent);
  color: #fff;
  border-radius: 980px;
  padding: 6px 16px;
}
.tb-btn.primary:hover { filter: brightness(1.08); background: var(--accent); }

#content { flex: 1; overflow-y: auto; }

/* ============ Editor ============ */
.editor {
  max-width: 780px;
  margin: 0 auto;
  padding: 30px 60px 30vh;
}
.page-icon-big {
  font-size: 56px;
  cursor: pointer;
  display: inline-block;
  border-radius: 8px;
  padding: 4px;
  line-height: 1;
}
.page-icon-big:hover { background: var(--hover); }
.page-title {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
  outline: none;
  margin: 8px 0 20px;
  line-height: 1.15;
}
.page-title:empty::before { content: "Sin título"; color: var(--muted); }

.block {
  display: flex;
  align-items: flex-start;
  position: relative;
  padding: 2px 0;
  border-radius: 4px;
}
.block-controls {
  position: absolute;
  left: -46px;
  top: 4px;
  display: flex;
  gap: 0;
  opacity: 0;
  transition: opacity 0.1s;
}
.block:hover .block-controls { opacity: 1; }
.block-controls button {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
  width: 22px;
  height: 22px;
  font-size: 14px;
  padding: 0;
  line-height: 1;
}
.block-controls button:hover { background: var(--hover); }
.bk-handle { cursor: grab; font-size: 12px !important; letter-spacing: -2px; }
.block.drop-above { box-shadow: 0 -2px 0 var(--accent); }
.block.drop-below { box-shadow: 0 2px 0 var(--accent); }
.block.dragging { opacity: 0.4; }

.block-content {
  flex: 1;
  outline: none;
  min-width: 0;
  word-break: break-word;
  white-space: pre-wrap;
}
.block-content:focus:empty::before,
.block.b-h1 .block-content:empty::before,
.block.b-h2 .block-content:empty::before,
.block.b-h3 .block-content:empty::before {
  content: attr(data-ph);
  color: var(--muted);
  pointer-events: none;
}

.block.b-h1 { margin-top: 24px; }
.block.b-h1 .block-content { font-size: 28px; font-weight: 700; line-height: 1.3; }
.block.b-h2 { margin-top: 16px; }
.block.b-h2 .block-content { font-size: 22px; font-weight: 600; line-height: 1.3; }
.block.b-h3 { margin-top: 10px; }
.block.b-h3 .block-content { font-size: 18px; font-weight: 600; line-height: 1.3; }

.bk-marker {
  flex: none;
  width: 22px;
  text-align: center;
  color: var(--fg);
  user-select: none;
}
.bk-num { width: auto; min-width: 22px; padding-right: 4px; font-variant-numeric: tabular-nums; }

.bk-check {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 5px 8px 0 0;
  border: 1.5px solid var(--muted);
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #fff;
}
.block.checked .bk-check { background: var(--accent); border-color: var(--accent); }
.block.checked .block-content { text-decoration: line-through; color: var(--muted); }

.bk-chev {
  flex: none;
  border: none;
  background: none;
  cursor: pointer;
  width: 22px;
  height: 24px;
  color: var(--fg);
  font-size: 11px;
  padding: 0;
  border-radius: 4px;
  transition: transform 0.15s;
}
.bk-chev.open { transform: rotate(90deg); }
.bk-chev:hover { background: var(--hover); }

.block.b-quote .block-content {
  border-left: 3px solid var(--fg);
  padding-left: 14px;
  font-style: italic;
}
.block.b-callout {
  background: var(--callout-bg);
  border-radius: 6px;
  padding: 12px 14px;
  margin: 4px 0;
}
.bk-callout-icon { flex: none; margin-right: 10px; }

.block.b-code .block-content {
  background: var(--code-bg);
  border-radius: 6px;
  padding: 14px 16px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 13.5px;
  white-space: pre-wrap;
  tab-size: 2;
}

.block.b-divider { padding: 8px 0; }
.bk-hr { flex: 1; height: 1px; background: var(--border); align-self: center; }

.block.b-image, .block.b-video, .block.b-embed, .block.b-audio,
.block.b-bookmark, .block.b-table { flex-direction: column; }
.bk-img { max-width: 100%; border-radius: 6px; display: block; }
.bk-img-placeholder {
  background: var(--code-bg);
  border: none;
  color: var(--muted);
  border-radius: 6px;
  padding: 12px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
}
.bk-img-placeholder:hover { background: var(--hover-strong); }
.bk-del {
  position: absolute;
  right: 4px;
  top: 4px;
  border: none;
  background: var(--bg);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  width: 22px;
  height: 22px;
  opacity: 0;
  box-shadow: var(--shadow);
}
.block:hover .bk-del { opacity: 1; }
.bk-del:hover { color: var(--red); }

/* tablas */
.bk-table-wrap { width: 100%; overflow-x: auto; }
.bk-table {
  border-collapse: collapse;
  width: 100%;
  margin: 4px 0 2px;
  font-size: 14.5px;
}
.bk-table th, .bk-table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  min-width: 80px;
  outline: none;
  vertical-align: top;
  text-align: left;
}
.bk-table th { background: var(--code-bg); font-weight: 600; }
.bk-cell:focus { box-shadow: inset 0 0 0 2px var(--accent-soft); }
.tbl-bar { display: flex; gap: 6px; margin: 4px 0 2px; opacity: 0; transition: opacity 0.1s; }
.block:hover .tbl-bar { opacity: 1; }
.tbl-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 5px;
  font-size: 12px;
  padding: 2px 9px;
  cursor: pointer;
  color: var(--muted);
}
.tbl-btn:hover { background: var(--hover); color: var(--fg); }

/* vídeo / incrustado */
.bk-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 4px 0;
}
.bk-frame.embed { aspect-ratio: auto; height: 480px; }
.bk-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 8px;
  background: var(--code-bg);
}
.bk-videofile { width: 100%; border-radius: 8px; margin: 4px 0; }

/* audio */
.bk-audio { width: 100%; margin: 6px 0; }

/* tarjeta de enlace */
.bk-bookmark {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--fg);
  margin: 4px 0;
}
.bk-bookmark:hover { background: var(--hover); }
.bk-bm-text { display: flex; flex-direction: column; min-width: 0; font-weight: 500; }
.bk-bm-url {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-tail { height: 120px; cursor: text; }

a { color: var(--accent); }
.block-content code {
  background: var(--code-bg);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 85%;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  color: #eb5757;
}

/* ============ Menú slash y popovers ============ */
#slash-menu, #popover {
  position: fixed;
  z-index: 100;
  background: var(--bg);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 6px;
  min-width: 260px;
  max-height: 320px;
  overflow-y: auto;
}
.slash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.slash-item.sel { background: var(--hover-strong); }
.slash-item:hover { background: var(--hover); }
.slash-icon {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex: none;
  background: var(--bg);
}
.slash-label { font-weight: 500; }
.slash-empty { color: var(--muted); font-size: 13px; padding: 8px 10px; }

.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; min-width: 0; }
.emoji-grid button {
  border: none;
  background: none;
  font-size: 20px;
  padding: 4px;
  border-radius: 5px;
  cursor: pointer;
}
.emoji-grid button:hover { background: var(--hover); }

/* ============ Modales ============ */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 15, 0.5);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.modal {
  background: var(--bg);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: 440px;
  max-width: 92vw;
  padding: 24px;
}
.modal h3 { margin: 0 0 14px; font-size: 17px; letter-spacing: -0.01em; }
.modal label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }
.modal input[type="text"], .modal input[type="date"], .modal input[type="time"], .modal input[type="url"], .modal input[type="password"] {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.modal input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.modal-row { display: flex; gap: 10px; }
.modal-row > div { flex: 1; }
.modal-btns { display: flex; gap: 8px; margin-top: 18px; justify-content: flex-end; }
.modal-btns .danger { margin-right: auto; color: var(--red); }
.btn {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 980px;
  padding: 7px 16px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { border: none; }

.gh-status {
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
  min-height: 18px;
}
.gh-status.ok { color: #4d9a6a; }
.gh-status.err { color: var(--red); }

.color-swatches { display: flex; gap: 8px; margin-top: 4px; }
.swatch {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
}
.swatch.sel { border-color: var(--fg); }

/* búsqueda */
.search-modal { width: 560px; padding: 0; overflow: hidden; }
.search-modal input {
  width: 100%;
  border: none !important;
  box-shadow: none !important;
  padding: 16px 18px !important;
  font-size: 16px !important;
  border-bottom: 1px solid var(--border) !important;
  border-radius: 0 !important;
}
.search-results { max-height: 50vh; overflow-y: auto; padding: 6px; }
.search-result { padding: 8px 12px; border-radius: 6px; cursor: pointer; }
.search-result.sel, .search-result:hover { background: var(--hover); }
.search-result .sr-title { font-weight: 500; font-size: 14px; }
.search-result .sr-snippet { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-none { padding: 16px; color: var(--muted); font-size: 14px; text-align: center; }

/* ============ Agenda ============ */
.agenda { display: flex; flex-direction: column; height: 100%; }
.ag-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 24px 14px;
  flex: none;
}
.ag-title { font-size: 22px; font-weight: 700; margin-right: 8px; }
.ag-range { color: var(--muted); font-size: 14px; }
.ag-nav { display: flex; gap: 4px; margin-left: auto; }
.ag-nav button {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 6px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 14px;
}
.ag-nav button:hover { background: var(--hover); }

.ag-grid { flex: 1; overflow-y: auto; padding: 0 24px 24px; }
.ag-head {
  display: grid;
  grid-template-columns: 52px repeat(7, 1fr);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
  border-bottom: 1px solid var(--border);
}
.ag-day-head {
  text-align: center;
  padding: 8px 0;
  font-size: 13px;
  color: var(--muted);
}
.ag-day-head .ag-day-num {
  font-size: 18px;
  font-weight: 600;
  color: var(--fg);
  display: block;
}
.ag-day-head.today .ag-day-num {
  background: var(--red);
  color: #fff;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  line-height: 30px;
  margin: 2px auto 0;
}
.ag-body { display: grid; grid-template-columns: 52px repeat(7, 1fr); }
.ag-times { position: relative; }
.ag-time-label {
  position: absolute;
  right: 8px;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--muted);
}
.ag-col {
  position: relative;
  border-left: 1px solid var(--border);
  cursor: cell;
}
.ag-col:last-child { border-right: 1px solid var(--border); }
.ag-col.today { background: var(--accent-soft); }
.ag-hline {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
  pointer-events: none;
}
.ag-now {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--red);
  z-index: 4;
  pointer-events: none;
}
.ag-now::before {
  content: "";
  position: absolute;
  left: -4px;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}
.ag-ev {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  overflow: hidden;
  cursor: pointer;
  color: #fff;
  z-index: 3;
  line-height: 1.3;
}
.ag-ev:hover { filter: brightness(1.08); }
.ag-ev .ev-title { font-weight: 600; }
.ag-ev .ev-time { opacity: 0.85; font-size: 11px; }
.ev-blue { background: #4a7edd; }
.ev-green { background: #4d9a6a; }
.ev-orange { background: #d9760a; }
.ev-red { background: #d4554f; }
.ev-purple { background: #9065b0; }
.ev-gray { background: #787774; }

/* toggle semana/mes en toolbar */
.ag-view-toggle {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  border-color: transparent !important;
  font-weight: 600;
}

/* ============ Agenda mensual ============ */
.month-view { overflow: hidden; }
.month-view .ag-grid { overflow-y: unset; padding: 0 24px 24px; }

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.month-col-hdr {
  background: var(--code-bg);
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  padding: 8px 4px;
  border-bottom: 2px solid var(--border);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.month-cell {
  min-height: 108px;
  padding: 6px 5px 4px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  overflow: hidden;
  transition: background 0.1s;
}
.month-cell:nth-child(7n) { border-right: none; }
.month-cell:nth-last-child(-n+7) { border-bottom: none; }
.month-cell:hover { background: var(--hover); }
.month-cell.other-month { background: var(--code-bg); }
.month-cell.other-month .month-day-num { color: var(--muted); opacity: .5; }

.month-day-num {
  font-size: 13px;
  font-weight: 600;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-bottom: 3px;
}
.month-cell.today .month-day-num {
  background: var(--red);
  color: #fff;
}
.month-ev {
  display: block;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  color: #fff;
  line-height: 1.5;
}
.month-ev:hover { filter: brightness(1.1); }
.month-more {
  font-size: 11px;
  color: var(--muted);
  padding: 1px 4px;
  cursor: pointer;
  display: inline-block;
}
.month-more:hover { color: var(--accent); text-decoration: underline; }

/* popover de día */
.day-popover {
  min-width: 220px;
  max-width: 280px;
}
.pop-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--fg);
}
.pop-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
}
.pop-row:last-of-type { border-bottom: none; }
.pop-row:hover { color: var(--accent); }
.pop-ev-time { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

/* ============ Presentación ============ */
#present {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.pr-progress {
  height: 4px;
  background: var(--accent);
  transition: width 0.25s;
  flex: none;
}
.pr-slide {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6vh 12vw;
  cursor: pointer;
}
.pr-slide.title-slide { align-items: center; text-align: center; }
.pr-slide .pr-icon { font-size: 90px; margin-bottom: 20px; }
.pr-slide h1 { font-size: 52px; margin: 0 0 28px; line-height: 1.15; }
.pr-slide .pr-block { font-size: 26px; margin: 10px 0; }
.pr-slide .pr-h2 { font-size: 38px; font-weight: 700; margin: 22px 0 8px; }
.pr-slide .pr-h3 { font-size: 30px; font-weight: 600; margin: 16px 0 6px; }
.pr-slide .pr-bullet::before { content: "•  "; }
.pr-slide .pr-quote { border-left: 4px solid var(--fg); padding-left: 20px; font-style: italic; }
.pr-slide .pr-callout { background: var(--callout-bg); border-radius: 10px; padding: 18px 22px; }
.pr-slide .pr-code {
  background: var(--code-bg);
  border-radius: 10px;
  padding: 20px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 20px;
  white-space: pre-wrap;
}
.pr-slide .pr-todo-done { text-decoration: line-through; color: var(--muted); }
.pr-slide img { max-width: 100%; max-height: 55vh; border-radius: 8px; }
.pr-slide .pr-table { border-collapse: collapse; width: 100%; font-size: 24px; }
.pr-slide .pr-table th, .pr-slide .pr-table td {
  border: 1px solid var(--border);
  padding: 10px 16px;
  text-align: left;
}
.pr-slide .pr-table th { background: var(--code-bg); }
.pr-slide .bk-frame { max-height: 60vh; }
.pr-slide .bk-bookmark { font-size: 22px; }
.pr-footer {
  flex: none;
  display: flex;
  align-items: center;
  padding: 12px 24px;
  color: var(--muted);
  font-size: 14px;
}
.pr-footer .pr-counter { margin-left: auto; }
.pr-exit {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 6px;
  padding: 4px 12px;
  cursor: pointer;
  color: var(--muted);
}
.pr-exit:hover { background: var(--hover); }

/* ============ Vista de tareas ============ */
.tasks-view {
  max-width: 780px;
  margin: 0 auto;
  padding: 30px 60px 80px;
}
.tasks-head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 10px; }
.tasks-head h1 { font-size: 34px; margin: 0; letter-spacing: -0.02em; }
.tasks-summary { color: var(--muted); font-size: 14px; }
.tasks-empty { color: var(--muted); }
.tasks-empty code, .tasks-view code {
  background: var(--code-bg);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 85%;
}
.tasks-group { margin-top: 22px; }
.tasks-group-title {
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  display: inline-block;
}
.tasks-group-title:hover { background: var(--hover); }
.task-row {
  display: flex;
  align-items: flex-start;
  padding: 4px 6px;
  border-radius: 6px;
}
.task-row:hover { background: var(--hover); }
.task-row .bk-check { margin-top: 4px; }
.task-row.done .bk-check { background: var(--accent); border-color: var(--accent); }
.task-row.done .task-text { text-decoration: line-through; color: var(--muted); }
.task-text { flex: 1; min-width: 0; word-break: break-word; }

/* ============ Plantillas ============ */
.tpl-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: -8px 0 18px;
}
.tpl-label { color: var(--muted); font-size: 13px; }
.tpl-chip {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 980px;
  padding: 4px 13px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s;
}
.tpl-chip:hover { background: var(--hover); border-color: var(--muted); }

/* ============ Extras de modales ============ */
.modal select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.modal select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.modal .check-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  color: var(--fg) !important;
  font-size: 14px !important;
  font-weight: 400 !important;
  text-transform: none;
  margin-top: 14px !important;
  cursor: pointer;
}
.modal-note { color: var(--muted); font-size: 13px; margin: 0 0 6px; line-height: 1.5; }

/* ============ Temporizador de presentación ============ */
.pr-timer-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 16px;
}
.pr-timer { min-width: 86px; text-align: center; font-variant-numeric: tabular-nums; }
.pr-timer-over {
  background: var(--red) !important;
  border-color: var(--red) !important;
  color: #fff !important;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0.45; } }

/* ============ Asignaturas ============ */
.pg-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}
.dot.big { width: 22px; height: 22px; }
.dot-none { border: 1.5px dashed var(--muted); background: none; }

.page-meta { margin: -10px 0 16px; }
.subject-chip {
  border: none;
  border-radius: 12px;
  padding: 3px 12px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
}
.subject-chip:hover { opacity: 0.85; }
.subject-chip.empty {
  background: none;
  border: 1px dashed var(--border);
  color: var(--muted);
  font-weight: 400;
}
.subject-chip.empty:hover { border-color: var(--muted); color: var(--fg); opacity: 1; }

.subject-view {
  max-width: 780px;
  margin: 0 auto;
  padding: 30px 60px 80px;
}
.subject-head { display: flex; align-items: center; gap: 14px; }
.subject-head h1 { margin: 0; font-size: 34px; letter-spacing: -0.02em; }
.subject-stats { color: var(--muted); font-size: 14px; margin: 8px 0 4px; }
.subject-section h2 {
  font-size: 18px;
  margin: 28px 0 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.subj-muted { color: var(--muted); font-size: 14px; padding: 2px 8px; }
.subj-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.subj-row:hover { background: var(--hover); }
.subj-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  min-width: 175px;
}
.task-src {
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  margin-left: 10px;
  margin-top: 4px;
}
.task-src:hover { color: var(--accent); text-decoration: underline; }

.task-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 14px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
}
.filter-chip:hover { background: var(--hover); }
.filter-chip.sel { border-color: var(--fg); font-weight: 600; }

/* ============ Vista «Hoy» ============ */
.today-view {
  max-width: 780px;
  margin: 0 auto;
  padding: 30px 60px 80px;
}
.today-badge {
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 8px;
  color: var(--muted);
  flex: none;
}
.today-badge.now { background: var(--red); border-color: var(--red); color: #fff; }
.today-now { background: var(--accent-soft); }
.today-subj { color: var(--muted); font-size: 13px; }
.today-ev-title { flex: 1; min-width: 0; }

/* ============ Grupos ============ */
.ctl-input {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.ctl-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.group-note { width: 100%; margin: 2px 0 10px; }
.std-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  border-radius: 6px;
}
.std-row:hover { background: var(--hover); }
.std-name { flex: 1; min-width: 0; }
.att-seg { display: flex; gap: 4px; }
.att-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 5px;
  width: 30px;
  height: 26px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
}
.att-btn:hover { background: var(--hover); color: var(--fg); }
.att-btn.sel-P { background: #4d9a6a; border-color: #4d9a6a; color: #fff; }
.att-btn.sel-R { background: #d9760a; border-color: #d9760a; color: #fff; }
.att-btn.sel-A { background: #d4554f; border-color: #d4554f; color: #fff; }
.att-tally { color: var(--muted); font-size: 12px; min-width: 70px; text-align: right; }
.add-student { display: flex; gap: 8px; margin: 4px 0 10px; }
.add-student .ctl-input { flex: 1; }
.std-del {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
  opacity: 0;
}
.std-row:hover .std-del { opacity: 1; }
.std-del:hover { color: var(--red); }
.std-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  font-family: inherit;
  padding: 8px 10px;
  outline: none;
  resize: vertical;
}
.std-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.picker-name {
  font-size: 42px;
  font-weight: 700;
  text-align: center;
  padding: 34px 10px;
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.picker-name.settled { color: var(--accent); }
.picker-sub { text-align: center; color: var(--muted); font-size: 13px; min-height: 18px; }

/* ============ Submenú de asignatura (control segmentado) ============ */
.tab-bar {
  display: inline-flex;
  gap: 2px;
  margin: 16px 0 4px;
  background: var(--code-bg);
  border-radius: 9px;
  padding: 3px;
}
.tab {
  border: none;
  background: none;
  padding: 5px 18px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}
.tab.active {
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
}

/* ============ Temporalización ============ */
.course-progress { margin: 10px 0 16px; }
.cp-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--code-bg);
  overflow: hidden;
}
.cp-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.cp-label { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.eval-head {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 18px 0 4px;
  padding: 0 8px;
}
.unit-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.unit-row:hover { background: var(--hover); }
.unit-row.unit-current { background: var(--accent-soft); }
.unit-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
  flex: none;
}
.unit-dot.on { background: var(--accent); border-color: var(--accent); }
.unit-dot.done { background: var(--green); border-color: var(--green); }
.unit-name { flex: 1; min-width: 0; font-weight: 500; }
.unit-dates { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.unit-status {
  font-size: 11px;
  font-weight: 600;
  border-radius: 980px;
  padding: 2px 10px;
  flex: none;
}
.unit-status.st-current { background: var(--accent); color: #fff; }
.unit-status.st-done { color: var(--green); border: 1px solid var(--green); }
.unit-status.st-pending { color: var(--muted); border: 1px solid var(--border); }

/* ============ Calificaciones ============ */
.grades-wrap { overflow-x: auto; margin-top: 6px; border: 1px solid var(--border); border-radius: 10px; }
.grades-table { border-collapse: collapse; font-size: 13.5px; width: 100%; }
.grades-table th, .grades-table td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 6px 10px;
  text-align: center;
}
.grades-table th:last-child, .grades-table td:last-child { border-right: none; }
.grades-table tr:last-child td { border-bottom: none; }
.grades-table td:first-child, .grades-table th:first-child { text-align: left; min-width: 150px; }
.grades-table thead th { background: var(--code-bg); font-weight: 600; }
.grades-table thead th.gr-act { cursor: pointer; }
.grades-table thead th.gr-act:hover { background: var(--hover-strong); }
.gr-sub { display: block; font-size: 10px; color: var(--muted); font-weight: 400; }
.grade-input {
  width: 52px;
  border: none;
  background: transparent;
  color: var(--fg);
  font: inherit;
  text-align: center;
  outline: none;
}
.grades-table td:focus-within { box-shadow: inset 0 0 0 2px var(--accent); border-radius: 4px; }
.gavg { font-weight: 600; }
.gr-low { color: var(--red); }
.gr-mid { color: var(--orange); }
.gr-ok { color: var(--green); }
.grades-table tfoot td { color: var(--muted); font-size: 12.5px; background: var(--code-bg); }

/* ============ Código: selector de lenguaje y tokens ============ */
.code-lang {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: var(--bg);
  color: var(--muted);
  font-size: 11px;
  font-family: inherit;
  border-radius: 6px;
  padding: 2px 6px;
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.15s;
  outline: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.block:hover .code-lang { opacity: 1; }

.tk-com { color: #8e8e93; font-style: italic; }
.tk-str { color: #248a3d; }
.tk-num { color: #b25000; }
.tk-kw { color: #9b2393; font-weight: 600; }
body[data-theme="dark"] .tk-com { color: #7f8c98; }
body[data-theme="dark"] .tk-str { color: #7ec79a; }
body[data-theme="dark"] .tk-num { color: #d9a35f; }
body[data-theme="dark"] .tk-kw { color: #ff7ab2; }

/* ============ Rúbricas ============ */
.rubrics-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.rubric-card {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}
.rubric-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.10); transform: translateY(-2px); }
.rubric-card-name { font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.rubric-card-meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.rubric-card-del {
  position: absolute;
  top: 10px; right: 10px;
  opacity: 0;
  transition: opacity 0.15s;
}
.rubric-card:hover .rubric-card-del { opacity: 1; }

.ra-list { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.ra-card { background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.ra-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  background: transparent;
  border-bottom: 1px solid var(--border);
}
.ra-name { flex: 1; font-weight: 600; font-size: 14px; }
.ra-weight { font-size: 13px; color: var(--accent); font-weight: 600; white-space: nowrap; margin-right: 4px; }
.ra-body { padding: 4px 14px 12px; }

.criterio-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.criterio-hdr { border-top: none !important; padding-top: 10px; }
.criterio-name { flex: 1; font-size: 13px; min-width: 0; }
/* input de nota en la tabla de calificación */
.rubric-apply-table input[type="number"] { -moz-appearance: textfield; }
.rubric-apply-table input[type="number"]::-webkit-inner-spin-button,
.rubric-apply-table input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }

/* Grid de aplicación */
.rubric-apply-grid {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 4px;
}
.rubric-apply-table { border-collapse: collapse; font-size: 12.5px; width: 100%; }
.rubric-apply-table th,
.rubric-apply-table td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 6px 10px;
  text-align: center;
  white-space: nowrap;
}
.rubric-apply-table th:last-child,
.rubric-apply-table td:last-child { border-right: none; }
.rubric-apply-table tr:last-child td { border-bottom: none; }
.rubric-apply-table td:first-child,
.rubric-apply-table th:first-child {
  text-align: left;
  min-width: 140px;
  position: sticky; left: 0;
  background: var(--bg);
  z-index: 1;
}
.rubric-apply-table thead th { background: var(--code-bg); font-weight: 600; }
.rubric-apply-table thead .ra-span {
  background: var(--hover-strong);
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.level-sel {
  font-size: 11.5px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  padding: 3px 5px;
  cursor: pointer;
  max-width: 130px;
}
.apply-final { font-weight: 700; }

/* Modal ancho */
.modal-wide { max-width: 560px; }

/* Campo inline fuera de modal */
.field-label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.modal-input-inline {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  outline: none;
}
.modal-input-inline:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.modal-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  outline: none;
}
.modal-select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* Vista vacía genérica */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; margin-top: 60px;
  color: var(--muted); text-align: center;
}
.empty-state p { font-size: 14px; line-height: 1.6; }

/* Encabezado de vistas no-editor */
.view-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; gap: 14px;
}
.view-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }

/* Nombre alumno clicable */
.std-name-link {
  cursor: pointer;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--muted);
  transition: color .15s;
}
.std-name-link:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* Textarea genérico de importación */
.std-textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  resize: vertical;
  outline: none;
  margin-bottom: 12px;
}
.std-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* Nota modal */
.modal-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

/* Perfil de alumno */
.profile-stat {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  min-width: 90px;
  text-align: center;
}
.profile-stat-val {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
}
.profile-stat-val.gr-ok  { color: var(--green); }
.profile-stat-val.gr-mid { color: var(--orange); }
.profile-stat-val.gr-low { color: var(--red); }
.profile-stat-lbl {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

/* scrollbars discretos */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--hover-strong); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ Responsive: tablet y móvil ============ */
#btn-hamburger,
#sb-backdrop { display: none; }

@media (max-width: 900px) {
  #btn-hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 8px;
    left: 10px;
    z-index: 120;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    font-size: 17px;
    cursor: pointer;
  }
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 150;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: none;
  }
  body.sidebar-open #sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow);
  }
  body.sidebar-open #sb-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 140;
    background: rgba(0, 0, 0, 0.35);
  }
  #topbar { padding-left: 58px; }
  .editor { padding-left: 20px; padding-right: 20px; }
  .today-view, .tasks-view, .subject-view { padding-left: 20px; padding-right: 20px; }
  .modal { max-width: calc(100vw - 24px); }
}

/* ============ Enlaces wiki y etiquetas ============ */
a[data-wiki] {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed var(--accent);
  cursor: pointer;
}
a[data-wiki]:hover { background: var(--accent-soft); border-bottom-style: solid; }

.hashtag {
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 980px;
  padding: 1px 7px;
  font-size: 0.92em;
  cursor: pointer;
}
.hashtag:hover { filter: brightness(1.1); text-decoration: underline; }

/* ============ Backlinks ============ */
.backlinks {
  margin-top: 44px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.bl-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.bl-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  min-width: 0;
}
.bl-row:hover { background: var(--hover); }
.bl-page { font-weight: 500; font-size: 14px; flex: none; }
.bl-snippet {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============ Página incrustada (transclusión) ============ */
.block.b-pageembed { flex-direction: column; }
.bk-pageembed {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
a.pe-head {
  display: block;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 14px;
  color: var(--fg);
  background: var(--code-bg);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}
a.pe-head:hover { background: var(--hover-strong); }
.pe-tag {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-left: 8px;
}
.pe-body { padding: 10px 14px; max-height: 420px; overflow-y: auto; }

/* bloques estáticos (incrustados y vista de etiqueta) */
.st-block { padding: 2px 0; font-size: 14.5px; min-width: 0; }
.st-block img { max-width: 100%; border-radius: 6px; }
.st-block hr { border: none; height: 1px; background: var(--border); }
.st-h1 { font-size: 1.35em; font-weight: 700; margin-top: 8px; }
.st-h2 { font-size: 1.15em; font-weight: 700; margin-top: 6px; }
.st-h3 { font-size: 1.02em; font-weight: 700; }
.st-quote { border-left: 3px solid var(--fg); padding-left: 12px; font-style: italic; }
.st-callout { background: var(--callout-bg); border-radius: 6px; padding: 8px 12px; }
.st-code {
  background: var(--code-bg);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  white-space: pre-wrap;
}
.st-check { color: var(--muted); }
.st-done { text-decoration: line-through; color: var(--muted); }

/* ============ Destacados con tipo (callouts) ============ */
.bk-callout-icon {
  border: none;
  background: none;
  font-size: 16px;
  padding: 0 2px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.4;
}
.bk-callout-icon:hover { background: var(--hover-strong); }
.block.b-callout.co-idea { background: rgba(255, 204, 0, 0.14); }
.block.b-callout.co-ok { background: rgba(52, 168, 83, 0.13); }
.block.b-callout.co-warn { background: rgba(232, 132, 26, 0.14); }
.block.b-callout.co-danger { background: rgba(255, 59, 48, 0.12); }
.block.b-callout.co-question { background: rgba(175, 82, 222, 0.13); }

/* ============ Topbar: favorito, índice, historial ============ */
.tb-star.on { color: #f7b500; }
.tb-star.on .ic { fill: #f7b500; stroke: #f7b500; }

.slash-item.ol-h2 { padding-left: 26px; }
.slash-item.ol-h3 { padding-left: 42px; }

.block.flash { animation: blockFlash 1.6s ease; border-radius: 6px; }
@keyframes blockFlash {
  0% { background: var(--accent-soft); }
  100% { background: transparent; }
}

/* ============ Historial de versiones ============ */
.hist-list { max-height: 46vh; overflow-y: auto; margin: 6px 0; }
.hist-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.hist-row:last-child { border-bottom: none; }
.hist-when { font-weight: 600; flex: none; min-width: 130px; }
.hist-info {
  color: var(--muted);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist-row .btn { padding: 3px 12px; font-size: 12.5px; flex: none; }

/* ============ Tablero de tareas (kanban) ============ */
.task-mode { display: inline-flex; gap: 6px; margin-left: auto; }
.tasks-head { flex-wrap: wrap; }

.kanban {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-top: 18px;
  overflow-x: auto;
  padding-bottom: 20px;
}
.kb-col {
  flex: none;
  width: 270px;
  background: var(--sb-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  transition: box-shadow 0.12s, border-color 0.12s;
}
.kb-col.drag-over { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.kb-head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 4px 8px;
  font-weight: 600;
  font-size: 14px;
}
.kb-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-doneflag { color: var(--green); font-weight: 700; flex: none; }
.kb-count {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--hover-strong);
  border-radius: 980px;
  padding: 1px 8px;
  flex: none;
}
.kb-cfg {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: 5px;
  padding: 2px 4px;
  opacity: 0;
}
.kb-col:hover .kb-cfg { opacity: 1; }
.kb-cfg:hover { background: var(--hover-strong); color: var(--fg); }

.kb-cards { display: flex; flex-direction: column; gap: 8px; min-height: 8px; }
.kb-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  cursor: grab;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.kb-card.dragging { opacity: 0.45; }
.kb-card.done .kb-text { text-decoration: line-through; color: var(--muted); }
.kb-card-top { display: flex; align-items: flex-start; gap: 9px; }
.kb-card .bk-check {
  flex: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--muted);
  border-radius: 4px;
  font-size: 11px;
  line-height: 14px;
  text-align: center;
  color: #fff;
  cursor: pointer;
  margin-top: 2px;
}
.kb-card.done .bk-check { background: var(--accent); border-color: var(--accent); }
.kb-text { font-size: 13.5px; line-height: 1.4; min-width: 0; overflow-wrap: anywhere; }
.kb-emptytxt { color: var(--muted); font-style: italic; }
.kb-src {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kb-src:hover { color: var(--accent); }

.kb-add {
  width: 100%;
  margin-top: 8px;
  border: none;
  background: none;
  color: var(--muted);
  text-align: left;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
}
.kb-add:hover { background: var(--hover-strong); color: var(--fg); }
.kb-add-input {
  width: 100%;
  margin-top: 8px;
  padding: 7px 10px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--bg);
  color: var(--fg);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.kb-addcol {
  flex: none;
  width: 180px;
  border: 1px dashed var(--border);
  background: none;
  color: var(--muted);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  font-size: 13.5px;
}
.kb-addcol:hover { border-color: var(--accent); color: var(--accent); }

.col-done-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-size: 13.5px !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-weight: 500 !important;
  margin-top: 14px !important;
}
