:root {
  --bg: #f6f2f4;
  --surface: #ffffff;
  --sidebar: #1f1822;
  --sidebar-ink: #e9e2ec;
  --sidebar-muted: #9b8fa6;
  --ink: #2b2430;
  --muted: #897f8c;
  --accent: #d6336c;
  --accent-soft: #fce4ee;
  --line: #ece6ea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30,20,35,.05), 0 6px 20px rgba(30,20,35,.06);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 18px; margin: 0 0 4px; }

/* ── App shell ── */
.app { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar); color: var(--sidebar-ink);
  display: flex; flex-direction: column; padding: 20px 16px;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px; font-weight: 700;
  font-size: 16px; padding: 4px 6px 18px;
}
.brand-mark { color: var(--accent); font-size: 20px; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-bottom: 18px; }
.nav-item {
  padding: 10px 12px; border-radius: 10px; color: var(--sidebar-ink);
  font-size: 14px; font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,.07); }

.side-section { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  text-transform: uppercase; font-size: 11px; letter-spacing: .08em;
  color: var(--sidebar-muted); padding: 0 8px 8px;
}
.icon-btn {
  background: rgba(255,255,255,.08); color: var(--sidebar-ink); border: none;
  width: 24px; height: 24px; border-radius: 7px; cursor: pointer; font-size: 16px;
  line-height: 1; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--accent); color: #fff; }

.cat-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.cat-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border-radius: 9px; font-size: 14px; color: var(--sidebar-ink);
}
.cat-item:hover { background: rgba(255,255,255,.07); }
.cat-item.active { background: var(--accent); color: #fff; }
.cat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count {
  font-size: 12px; background: rgba(255,255,255,.12); color: var(--sidebar-ink);
  border-radius: 999px; padding: 1px 8px; min-width: 24px; text-align: center;
}
.cat-item.active .cat-count { background: rgba(255,255,255,.25); color: #fff; }
.cat-empty { color: var(--sidebar-muted); font-size: 13px; padding: 8px 12px; }

.side-foot { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.side-foot .link { color: var(--sidebar-muted); }
.side-foot .link:hover { color: var(--sidebar-ink); }

/* ── Content ── */
.content { padding: 28px 32px; max-width: 1200px; }
.content-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 22px;
}
.head-sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.head-meta { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

/* ── Buttons ── */
.btn, button.primary, button.ghost {
  display: inline-flex; align-items: center; gap: 6px; font: inherit;
  padding: 10px 18px; border-radius: 10px; cursor: pointer; border: none; font-weight: 600;
}
.primary { background: var(--accent); color: #fff; }
.primary:hover { background: #c02560; }
.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.ghost:hover { background: var(--bg); }
button.link {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font: inherit; padding: 0; font-weight: 600; font-size: 13px;
}
button.link.danger { color: #c92a2a; }
.inline { display: inline; margin: 0; }

/* ── Card grid (tarjetas uniformes) ── */
.grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.card {
  margin: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column; transition: transform .12s, box-shadow .12s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 26px rgba(30,20,35,.12); }
.thumb {
  position: relative; aspect-ratio: 4 / 3; background: #efe7ec;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-icon { font-size: 34px; color: var(--accent); opacity: .7; }
.type-tag {
  position: absolute; top: 10px; left: 10px; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; color: #fff; backdrop-filter: blur(2px);
}
.type-tag.image { background: rgba(214,51,108,.9); }
.type-tag.video { background: rgba(108,91,123,.92); }

.card-body { padding: 13px 14px 6px; flex: 1; }
.card-title {
  font-size: 15px; margin: 0 0 4px; line-height: 1.3; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-desc {
  margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 2.9em;
}
.card-foot {
  display: flex; align-items: center; gap: 14px; padding: 10px 14px;
  border-top: 1px solid var(--line);
}
.card-foot form { margin-left: auto; }
.card-foot .link:first-child { margin-right: auto; }

/* ── Empty state ── */
.empty-state {
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 48px 24px; text-align: center; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}

/* ── Forms ── */
.form { display: flex; flex-direction: column; gap: 16px; max-width: 520px; }
.card-form {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
}
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
input, select, textarea {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ── Modal ── */
.modal {
  border: none; border-radius: var(--radius); padding: 0; box-shadow: var(--shadow);
  width: min(420px, 92vw); color: var(--ink);
}
.modal::backdrop { background: rgba(31,24,34,.45); }
.modal-form { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: min(380px, 92vw); background: var(--surface); padding: 32px;
  border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.brand-lg { font-size: 18px; padding: 0 0 10px; }
.login-card h1 { margin: 0 0 18px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card .primary { margin-top: 4px; justify-content: center; }

.error { color: #c92a2a; background: #fff0f0; padding: 9px 12px; border-radius: 9px; font-size: 14px; }

/* ── Responsive ── */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: column; }
  .cat-list { max-height: 220px; }
  .content { padding: 20px; }
}
