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

:root {
  --bg:       #1e1e1e;
  --surface:  #2a2a2a;
  --surface2: #333333;
  --border:   #444444;
  --orange:   #e87d0d;
  --orange-dk:#c46b0a;
  --text:     #e0e0e0;
  --muted:    #999999;
  --green:    #4caf50;
  --gold:     #f0c040;
  --blue:     #5b9bd5;
  --radius:   6px;
  --panel-w:  380px;
  --header-h: 60px;
}

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

/* ── Header ── */
header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 2px solid var(--orange);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--orange);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.logo span { color: var(--text); font-weight: 400; }

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-left: auto;
  flex-wrap: wrap;
}

#search {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 6px 12px;
  font-size: 0.875rem;
  width: 200px;
  outline: none;
  transition: border-color 0.2s;
}

#search:focus { border-color: var(--orange); }
#search::placeholder { color: var(--muted); }

.filter-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 5px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-btn:hover { border-color: var(--orange); color: var(--text); }
.filter-btn.active { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 600; }

/* ── Layout ── */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── Alpha nav ── */
.alpha-nav {
  width: 36px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 2px;
  overflow-y: auto;
  flex-shrink: 0;
}

.alpha-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 600;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.15s;
}

.alpha-nav a:hover { color: var(--orange); background: var(--surface2); }
.alpha-nav a.has-entries { color: var(--text); }
.alpha-nav a.active-letter { color: var(--orange); }

/* ── Main grid ── */
main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  transition: margin-right 0.3s ease;
}

main.panel-open { margin-right: var(--panel-w); }

.alpha-section { margin-bottom: 32px; }

.alpha-heading {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--orange);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: 14px;
  scroll-margin-top: 80px;
}

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

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card:hover {
  border-color: var(--orange);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(232,125,13,0.15);
}

.card.selected { border-color: var(--orange); background: var(--surface2); }

.card-library {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.card-name {
  font-size: 0.78rem;
  color: var(--muted);
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-FREE       { background: rgba(76,175,80,0.2);  color: var(--green); border: 1px solid rgba(76,175,80,0.4); }
.badge-PREMIUM    { background: rgba(91,155,213,0.2); color: var(--blue);  border: 1px solid rgba(91,155,213,0.4); }
.badge-FREEMIUM { background: rgba(240,192,64,0.2); color: var(--gold);  border: 1px solid rgba(240,192,64,0.4); }

.tag {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* ── Empty state ── */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  font-size: 1rem;
}

/* ── Slideout Panel ── */
.panel {
  position: fixed;
  top: var(--header-h);
  right: 0;
  width: var(--panel-w);
  height: calc(100vh - var(--header-h));
  background: var(--surface);
  border-left: 2px solid var(--orange);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  z-index: 200;
  display: flex;
  flex-direction: column;
}

.panel.open { transform: translateX(0); }

.panel-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.panel-title-block { flex: 1; }

.panel-library {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.panel-creator {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
}

.panel-creator a {
  color: var(--orange);
  text-decoration: none;
}

.panel-creator a:hover { text-decoration: underline; }

.close-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.close-btn:hover { color: var(--text); background: var(--surface2); }

.panel-body { padding: 20px; display: flex; flex-direction: column; gap: 20px; }

.panel-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.panel-description {
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.6;
}

.panel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.panel-tag {
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.copy-btn {
  display: block;
  width: 100%;
  background: var(--orange);
  color: #fff;
  border: none;
  text-align: center;
  padding: 10px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

.copy-btn:hover { background: var(--orange-dk); }
.copy-btn.copied { background: var(--green); }

.visit-btn {
  display: block;
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
  text-align: center;
  padding: 10px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  transition: border-color 0.2s, color 0.2s;
}

.visit-btn:hover { border-color: var(--orange); color: var(--orange); }

.yt-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #ff0000;
  color: #fff;
  text-decoration: none;
  padding: 10px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.yt-btn:hover { background: #cc0000; }

.contribute-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--orange);
  border: 2px solid var(--orange);
  border-radius: var(--radius);
  color: #fff;
  padding: 5px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.03em;
  box-shadow: 0 0 10px rgba(232, 125, 13, 0.4);
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.1s;
}

.contribute-btn:hover {
  background: var(--orange-dk);
  border-color: var(--orange-dk);
  box-shadow: 0 0 16px rgba(232, 125, 13, 0.7);
  transform: translateY(-1px);
}

.byline {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
  text-decoration: none;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 10px;
  transition: border-color 0.2s, color 0.2s;
}

.byline:hover { border-color: var(--muted); color: var(--text); }

.byline .yt-icon { color: #ff4444; flex-shrink: 0; }
.byline .pat-icon { color: #ff7878; flex-shrink: 0; }

.byline-sep { display: none; }

/* ── Tag filter bar ── */
.tag-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px 8px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
}

.tag-bar-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
  padding: 0 6px;
}

.tag-filter {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--muted);
  padding: 3px 11px;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.tag-filter:hover { border-color: var(--orange); color: var(--text); }
.tag-filter.active { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 600; }

.panel-tag {
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.panel-tag:hover { border-color: var(--orange); color: var(--orange); }

/* ── Scrollbar styling ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
