:root {
  --bg:        #0f0f0f;
  --bg-side:   #141414;
  --bg-hover:  #1c1c1c;
  --border:    #242424;
  --text:      #c9c9c9;
  --text-dim:  #777;
  --text-head: #e8e8e8;
  --accent:    #4a90d9;
  --tag-bg:    #1a1a1a;
  --sidebar-w: 260px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* ── SCROLLBARS ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
}

/* ── SIDEBAR ── */
aside {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-side);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.25s ease;
}

aside::-webkit-scrollbar { width: 4px; }
aside::-webkit-scrollbar-track { background: var(--bg-side); }
aside::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.sidebar-header {
  padding: 22px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header .site-name {
  font-weight: 500;
  font-size: 15px;
  color: var(--text-head);
}
.sidebar-header .site-name span { color: var(--text-dim); font-weight: 300; }
.sidebar-header .site-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
  font-weight: 300;
}

.search-box {
  margin: 12px 14px;
  position: relative;
}
.search-box input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px 7px 30px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  border-radius: 4px;
  outline: none;
  transition: border-color 0.2s;
}
.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: var(--text-dim); }
.search-box svg {
  position: absolute;
  left: 9px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}

.nav-section { padding: 6px 0; border-bottom: 1px solid var(--border); }
.nav-section-title {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-transform: uppercase;
  padding: 10px 18px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  padding: 6px 18px;
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
  gap: 8px;
  border-left: 2px solid transparent;
  user-select: none;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-head); }
.nav-item.active { border-left-color: var(--accent); color: var(--accent); background: rgba(74,144,217,0.06); }
.nav-item .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--text-dim); flex-shrink: 0; }
.nav-item.active .dot { background: var(--accent); }
.nav-item .chevron { margin-left: auto; transition: transform 0.2s; color: var(--text-dim); font-size: 10px; }
.nav-item.open .chevron { transform: rotate(90deg); }

.nav-children { display: none; background: var(--bg); }
.nav-children.open { display: block; }

.nav-group-item {
  padding: 5px 18px 5px 28px;
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 6px;
}
.nav-child-item {
  display: flex;
  align-items: center;
  padding: 4px 18px 4px 36px;
  cursor: pointer;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 12px;
  transition: background 0.15s, color 0.15s;
  border-left: 2px solid transparent;
  gap: 6px;
  font-weight: 300;
}
.nav-child-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-child-item.active { border-left-color: var(--accent); color: var(--accent); }
.nav-child-item .line { width: 10px; height: 1px; background: var(--border); flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
}
.sidebar-footer a { color: var(--text-dim); text-decoration: none; }
.sidebar-footer a:hover { color: var(--accent); }

/* ── MOBILE OVERLAY ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}
.sidebar-overlay.open { display: block; }

/* ── MAIN ── */
main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  border-bottom: 1px solid var(--border);
  padding: 0 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-name { font-size: 13px; font-weight: 500; color: var(--text-head); }
.topbar-sep { color: var(--border); }
.topbar-links { display: flex; gap: 16px; font-size: 12px; }
.topbar-links a { color: var(--text-dim); text-decoration: none; transition: color 0.15s; }
.topbar-links a:hover { color: var(--text); }
.breadcrumb { font-size: 11px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.breadcrumb span { color: var(--text); }
.breadcrumb a { color: var(--text-dim); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }

.menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
}

/* ── CONTENT ── */
.content { padding: 48px 60px; max-width: 1100px; width: 100%; margin: 0 auto; }

.hero-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 40px;
}
.hero-text { flex: 1; }
.page-title { font-size: 22px; font-weight: 600; color: var(--text-head); margin-bottom: 8px; letter-spacing: -0.02em; }
.page-desc { color: var(--text-dim); font-size: 13px; line-height: 1.6; font-weight: 300; }

.stats-row { display: flex; gap: 12px; flex-shrink: 0; }
.stat { background: var(--bg-side); border: 1px solid var(--border); padding: 12px 20px; border-radius: 4px; text-align: center; }
.stat-num { font-size: 20px; font-weight: 600; color: var(--text-head); }
.stat-label { font-size: 10px; color: var(--text-dim); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.06em; }

.section-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

/* Category cards */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1px;
  background: var(--bg);  /* ← cambiar border por bg */
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 48px;
}
.category-card { background: var(--bg-side); padding: 20px 22px; cursor: pointer; transition: background 0.15s; text-decoration: none; display: block; }
.category-card:hover { background: var(--bg-hover); }
.cat-name { font-size: 13px; font-weight: 500; color: var(--text-head); margin-bottom: 6px; }
.cat-count { font-size: 11px; color: var(--text-dim); font-weight: 300; }
.cat-tag { display: inline-block; margin-top: 10px; font-size: 10px; padding: 2px 8px; background: var(--tag-bg); border: 1px solid var(--border); border-radius: 2px; color: var(--text-dim); }

/* Groups */
.groups-container { display: flex; flex-direction: column; gap: 32px; }
.group-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.group-title::before {
  content: '';
  width: 3px; height: 12px;
  background: var(--accent);
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
}
.notes-table { width: 100%; border-collapse: collapse; }
.notes-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.notes-table tr:last-child td { border-bottom: none; }
.notes-table tr:hover td { background: var(--bg-hover); cursor: pointer; }
.note-link { color: var(--text); text-decoration: none; transition: color 0.15s; font-weight: 400; }
.note-link:hover { color: var(--accent); }
.note-tag { display: inline-block; font-size: 10px; padding: 2px 7px; background: var(--tag-bg); border: 1px solid var(--border); border-radius: 2px; color: var(--text-dim); }
.empty-state { padding: 40px 0; text-align: center; color: var(--text-dim); font-size: 13px; }

/* ── NOTE VIEWER ── */
#noteWrapper {
  display: none;
  max-width: 1200px;
  margin: 0 auto;
}
#noteWrapper.active { display: block; }

#noteViewer {
  padding: 48px 60px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  margin-right: 280px;
}

@media (max-width: 1200px) {
  #noteViewer { margin-right: auto; }
}

/* ── TOC PANEL ── */
#tocPanel {
  position: fixed;
  top: 64px;
  right: 24px;
  width: 200px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  padding: 8px 0;
}
.toc-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 12px;
}
.toc-item {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
  line-height: 1.4;
  padding: 4px 0 4px 10px;
  border-left: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  cursor: pointer;
}
.toc-item:hover { color: var(--text); }
.toc-item.toc-active { color: var(--accent); border-left-color: var(--accent); }
.toc-h2 { padding-left: 18px; font-size: 11px; }
.toc-h3 { padding-left: 26px; font-size: 11px; }

@media (max-width: 1200px) {
  #tocPanel { display: none !important; }
}

.note-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  margin-bottom: 32px;
  transition: color 0.15s;
  background: none;
  border: none;
  padding: 0;
  font-family: 'Inter', sans-serif;
}
.note-back:hover { color: var(--text); }

#noteViewer h1 { font-size: 26px; font-weight: 600; color: var(--text-head); margin: 72px 0 24px; letter-spacing: -0.02em; }
#noteContent > h1:first-child { margin-top: 0; }
#noteViewer h2 { font-size: 18px; font-weight: 600; color: var(--text-head); margin: 48px 0 12px; }
#noteViewer h3 { font-size: 15px; font-weight: 500; color: var(--text-head); margin: 36px 0 8px; }
#noteViewer h4 { font-size: 14px; font-weight: 500; color: var(--text-head); margin: 28px 0 8px; }
#noteViewer p { margin-bottom: 16px; line-height: 1.7; }
#noteViewer a { color: var(--accent); text-decoration: none; }
#noteViewer a:hover { text-decoration: underline; }
#noteViewer code {
  font-family: 'Fira Code', monospace;
  background: rgba(235,87,87,0.15);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 13px;
  color: #f28b82;
}
#noteViewer pre {
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 16px 0;
  position: relative;
}

#noteViewer .copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #2a2a2a;
  color: #666;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 5px 7px;
  line-height: 0;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
#noteViewer .copy-btn:hover { color: #aaa; border-color: #555; }
#noteViewer .copy-btn.copied { color: var(--accent); border-color: var(--accent); }
#noteViewer pre code { background: none; border: none; padding: 0; font-size: 13px; line-height: 1.6; color: inherit; }
#noteViewer pre code.language-bash,
#noteViewer pre code.language-bash * { color: #f28b82; }
#noteViewer pre code.language-bash .hljs-comment { color: #6a737d; }
#noteViewer blockquote { border-left: 3px solid var(--accent); padding: 8px 16px; margin: 16px 0; color: var(--text-dim); background: var(--bg-side); border-radius: 0 4px 4px 0; }
#noteViewer ul, #noteViewer ol { padding-left: 20px; margin-bottom: 16px; }
#noteViewer li { margin-bottom: 6px; line-height: 1.7; }
#noteViewer table { display: block; overflow-x: auto; width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 13px; }
#noteViewer th { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--text-dim); font-weight: 600; text-transform: uppercase; font-size: 11px; }
#noteViewer td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
#noteViewer tr:last-child td { border-bottom: none; }
#noteViewer img { max-width: 100%; border-radius: 6px; margin: 16px 0; }
#noteViewer hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

.note-loading { color: var(--text-dim); font-size: 13px; padding: 40px 0; }

/* ── RESPONSIVE ── */
.reciente-meta-mobile { display: none; }
.reciente-cat { width: 160px; }
.reciente-fecha { width: 120px; color: var(--text-dim); font-size: 11px; }

@media (max-width: 768px) {
  aside { transform: translateX(-100%); }
  aside.open { transform: translateX(0); }
  main { margin-left: 0; }
  .menu-btn { display: block; }
  .topbar { padding: 0 16px; }
  .topbar-links { display: none; }
  .content { padding: 24px 20px; }
  #noteViewer { padding: 24px 20px; }
  .hero-row { flex-direction: column; gap: 20px; }
  .stats-row { width: 100%; }
  .stat { flex: 1; }
  .breadcrumb { display: none; }
  .reciente-cat { display: none; }
  .reciente-fecha { display: none; }
  .reciente-meta-mobile { display: block; font-size: 10px; color: var(--text-dim); margin-top: 3px; }
}

@media (max-width: 480px) {
  .stats-row { flex-wrap: wrap; }
}