:root {
  --bg: #0f0f13;
  --surface: #1a1a22;
  --surface2: #22222e;
  --border: #2e2e3e;
  --accent: #6c63ff;
  --accent2: #ff6584;
  --text: #e8e8f0;
  --text2: #9090a8;
  --video: #ff6b6b;
  --article: #51cf66;
  --pdf: #ff9f43;
  --podcast: #a29bfe;
  --radius: 12px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
}

/* HEADER */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

h1 { font-size: 1.4rem; font-weight: 700; white-space: nowrap; }

.search-bar { flex: 1; }
.search-bar input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}
.search-bar input:focus { border-color: var(--accent); }

.filters {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.5rem 1.5rem;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
}

.filter-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text2);
  padding: 0.3rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--text); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* MAIN */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.stats-bar {
  font-size: 0.82rem;
  color: var(--text2);
  margin-bottom: 1.25rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.stats-bar span { display: flex; align-items: center; gap: 0.3rem; }

/* GRID */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

/* CARD */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }

.card-type {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  width: fit-content;
}
.type-article { background: rgba(81,207,102,0.15); color: var(--article); }
.type-video   { background: rgba(255,107,107,0.15); color: var(--video); }
.type-pdf     { background: rgba(255,159,67,0.15);  color: var(--pdf); }
.type-podcast { background: rgba(162,155,254,0.15); color: var(--podcast); }

.card-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 8px;
  background: var(--surface2);
}

.card-title {
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-summary {
  font-size: 0.83rem;
  color: var(--text2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: auto;
}

.tag {
  font-size: 0.72rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.15rem 0.55rem;
  color: var(--text2);
}

.card-date {
  font-size: 0.75rem;
  color: var(--text2);
  margin-left: auto;
}

/* MODAL */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 780px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  z-index: 1;
}

.modal-close {
  position: absolute;
  top: 1rem; right: 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 2rem; height: 2rem;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
}

/* MODAL DETAIL */
.detail-header { margin-bottom: 1.5rem; }
.detail-type { margin-bottom: 0.5rem; }
.detail-title { font-size: 1.3rem; font-weight: 700; line-height: 1.4; margin-bottom: 0.5rem; }
.detail-channel { font-size: 0.85rem; color: var(--text2); }

.detail-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 1.25rem;
}

.detail-section { margin-bottom: 1.5rem; }
.detail-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.detail-section p, .detail-section li {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text2);
}
.detail-section ul, .detail-section ol { padding-left: 1.25rem; }
.detail-section li { margin-bottom: 0.35rem; }

.quote-item {
  background: var(--surface2);
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  border-radius: 0 8px 8px 0;
  margin-bottom: 0.75rem;
}
.quote-text { font-style: italic; font-size: 0.88rem; color: var(--text); margin-bottom: 0.25rem; }
.quote-ts { font-size: 0.75rem; color: var(--text2); }

.index-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.87rem;
}
.index-ts {
  color: var(--accent);
  font-family: monospace;
  white-space: nowrap;
  text-decoration: none;
}
.index-ts:hover { text-decoration: underline; }

.detail-tags { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.detail-link {
  display: inline-block;
  margin-top: 1rem;
  color: var(--accent);
  font-size: 0.85rem;
  text-decoration: none;
}
.detail-link:hover { text-decoration: underline; }

.loading, .empty {
  text-align: center;
  color: var(--text2);
  padding: 3rem;
  font-size: 0.95rem;
}
.hidden { display: none !important; }

@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr; }
  .header-inner { flex-direction: column; align-items: stretch; gap: 0.75rem; }
}

/* ── FILTROS ESTADO ── */
.status-filters {
  border-top: 1px solid var(--border);
  padding-top: .4rem;
}
.status-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  padding: .35rem .9rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: .85rem;
  transition: all .15s;
}
.status-btn.active,
.status-btn:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--accent);
}

/* ── BADGE ESTADO ── */
.status-badge {
  font-size: .72rem;
  padding: .15rem .5rem;
  border-radius: 20px;
  font-weight: 600;
}
.status-badge.pending  { background: rgba(255,159,67,.15); color: #ff9f43; }
.status-badge.archived { background: rgba(108,99,255,.15); color: #a29bfe; }

/* ── CARD HEADER ROW ── */
.card-header-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: .4rem;
}
.card-actions {
  margin-left: auto;
  display: flex;
  gap: .3rem;
}

/* ── BOTONES ACCIÓN ── */
.action-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .2rem .4rem;
  cursor: pointer;
  font-size: .85rem;
  transition: background .15s;
}
.action-btn:hover { background: var(--surface2); }
.btn-delete:hover  { border-color: #e55; }
.btn-archive:hover { border-color: #ff9f43; }
.btn-pending:hover { border-color: #2a9d8f; }

/* ── MODAL CONTRASEÑA ── */
.pwd-modal-content {
  max-width: 380px !important;
  padding: 1.5rem !important;
}
.pwd-modal-content h3 {
  margin-bottom: .5rem;
  font-size: 1.1rem;
}

/* ── MARKDOWN RENDER ── */
.detail-markdown h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  margin: 1.4rem 0 .5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: .3rem;
}
.detail-markdown h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text1);
  margin: 1rem 0 .4rem;
}
.detail-markdown p {
  margin: .5rem 0;
  line-height: 1.7;
  color: var(--text1);
}
.detail-markdown ul, .detail-markdown ol {
  padding-left: 1.4rem;
  margin: .4rem 0 .8rem;
}
.detail-markdown li {
  margin: .3rem 0;
  line-height: 1.65;
  color: var(--text1);
}
.detail-markdown strong {
  color: var(--text1);
  font-weight: 700;
}
.detail-markdown em {
  color: var(--text2);
  font-style: italic;
}
.detail-markdown blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  margin: .8rem 0;
  color: var(--text2);
  font-style: italic;
}
.detail-markdown hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}
