:root {
  --bg: #f7f7fb;
  --bg-elevated: #ffffff;
  --text: #1c1d21;
  --text-muted: #5a5d68;
  --border: #e4e4ea;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --sidebar-bg: #14152b;
  --sidebar-text: #c9cade;
  --sidebar-text-active: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 21, 43, 0.06), 0 4px 12px rgba(20, 21, 43, 0.06);
}

[data-theme="dark"] {
  --bg: #101018;
  --bg-elevated: #191a26;
  --text: #eceef5;
  --text-muted: #9a9cb0;
  --border: #2a2b3d;
  --accent: #8b85f7;
  --accent-text: #101018;
  --sidebar-bg: #0b0c16;
  --sidebar-text: #a9abc4;
  --sidebar-text-active: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); }

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: margin-left 0.2s ease;
}

.sidebar-heading {
  display: block;
  padding: 1.5rem 1.25rem 1rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--sidebar-text-active);
  text-decoration: none;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0.75rem;
  gap: 0.15rem;
}

.sidebar-nav a {
  color: var(--sidebar-text);
  text-decoration: none;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.94rem;
}

.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--sidebar-text-active);
}

.sidebar-nav a.active {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.topbar button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text);
}

.search-wrap { flex: 1; }

#buscador {
  width: 100%;
  max-width: 420px;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.container {
  padding: 1.75rem 2rem 3rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

h1 { margin-top: 0; }

.lead { color: var(--text-muted); max-width: 60ch; }

.grupo { margin-top: 2.25rem; }

.grupo h2 {
  font-size: 1.15rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-img {
  width: 100%;
  height: 120px;
  object-fit: contain;
  background: var(--bg);
  padding: 0.75rem;
}

.card-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.card-body h3 { margin: 0; font-size: 1.02rem; }

.card-body p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  flex: 1;
}

.btn {
  align-self: flex-start;
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
}

.card.is-hidden { display: none; }

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.home-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  text-decoration: none;
  color: var(--text);
}

.home-card h2 { margin: 0 0 0.4rem; font-size: 1.05rem; }
.home-card p { margin: 0; color: var(--text-muted); font-size: 0.9rem; }

.site-footer {
  padding: 1.5rem 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    z-index: 20;
    margin-left: -260px;
  }
  .sidebar.open { margin-left: 0; }
  .container { padding: 1.25rem 1rem 2rem; }
}
