:root {
  --bg: #ffffff;
  --bg-elevated: #f6f6f8;
  --border: #e4e4e8;
  --text: #1c1c1e;
  --text-muted: #6b6b72;
  --accent: #5b5ff2;
  --accent-soft: rgba(91, 95, 242, 0.08);
  --success: #17803d;
  --ref-badge: #b45309;
  --ref-badge-soft: rgba(180, 83, 9, 0.1);
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, sans-serif;
  font-size: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 16px;
}
.brand-mark { color: var(--accent); }

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}
.tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}
.tab.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow);
}

.boards {
  display: flex;
  gap: 10px;
  padding: 16px 28px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
}
.board-chip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px 7px 8px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text-muted);
}
.board-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.board-chip.selected {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-soft);
  font-weight: 600;
}

.content {
  padding: 24px 28px 60px;
}

.view { display: none; }
.view.active { display: block; }

.hint { color: var(--text-muted); font-size: 13px; margin: 0 0 18px; }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg);
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s, transform 0.15s;
  display: flex;
  flex-direction: column;
}
.card:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }

.card-thumb {
  height: 108px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  color: rgba(255, 255, 255, 0.92);
}
.card-thumb .play {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  backdrop-filter: blur(2px);
}
.card-thumb .tag {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.28);
  padding: 3px 7px;
  border-radius: 999px;
}
.card-thumb .stat {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 10.5px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.28);
  padding: 3px 7px;
  border-radius: 999px;
}

.card-body { padding: 12px 14px 14px; }
.card-body h3 {
  margin: 0 0 4px;
  font-size: 13.5px;
  line-height: 1.3;
}
.card-body p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

.card-add {
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-style: dashed;
  min-height: 168px;
}
.card-add .card-body { text-align: center; width: 100%; }

/* Modal */
dialog#card-modal {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(640px, 92vw);
  max-height: 84vh;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}
dialog#card-modal::backdrop { background: rgba(20, 20, 24, 0.45); }
.modal-inner { position: relative; padding: 28px; overflow-y: auto; max-height: 84vh; }
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  border: none;
  background: var(--bg-elevated);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-muted);
}
.modal-body h2 { margin: 0 0 12px; font-size: 19px; }
.modal-block { margin-bottom: 18px; }
.modal-block h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin: 0 0 6px;
}
.modal-block p, .modal-block div {
  margin: 0;
  line-height: 1.6;
  font-size: 13.5px;
  white-space: pre-wrap;
}

.embed-wrap {
  display: flex;
  justify-content: center;
  min-height: 0;
}
.embed-wrap iframe { max-width: 100%; }

.watch-original {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.watch-original:hover { background: rgba(91, 95, 242, 0.14); }

.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.badge-meu { color: var(--success); background: rgba(23, 128, 61, 0.1); }
.badge-ref { color: var(--ref-badge); background: var(--ref-badge-soft); }

.markdown-body { line-height: 1.6; font-size: 13.5px; white-space: pre-wrap; max-width: 760px; }
.markdown-body table { border-collapse: collapse; margin: 12px 0; width: 100%; }
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  font-size: 12.5px;
  text-align: left;
}
.markdown-body th { color: var(--accent); }

.empty-hint { color: var(--text-muted); font-size: 13px; }
