:root {
  --bg:      #0e0e10;
  --surface: #18181b;
  --card:    #1f1f23;
  --border:  #2c2c31;
  --fg:      #e4e4e7;
  --muted:   #71717a;
  --accent:  #e8a838;
  --radius:  6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ── */
#top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(14,14,16,.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

#brand { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
#logo  { color: var(--accent); font-size: 17px; line-height: 1; }
#site-name { font-size: 15px; font-weight: 600; letter-spacing: .3px; }

#search-wrap { flex: 1 1 180px; display: flex; align-items: center; gap: 8px; min-width: 0; }

#q {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  padding: 6px 11px;
  outline: none;
  transition: border-color .15s;
  -webkit-appearance: none;
}
#q::placeholder { color: var(--muted); }
#q:focus { border-color: var(--accent); }

#search-hint { font-size: 12px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
#stats { font-size: 12px; color: var(--muted); flex-shrink: 0; }

/* ── Tabs ── */
#tabs-wrap {
  position: sticky;
  top: 49px;
  z-index: 19;
  background: rgba(14,14,16,.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
#tabs-wrap::-webkit-scrollbar { display: none; }

#tabs { display: flex; padding: 0 20px; white-space: nowrap; }

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
  font-family: var(--font);
}
.tab:hover { color: var(--fg); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-count {
  font-size: 11px;
  background: var(--surface);
  border-radius: 10px;
  padding: 1px 6px;
  color: var(--muted);
}
.tab.active .tab-count { background: rgba(232,168,56,.15); color: var(--accent); }

/* ── Toolbar ── */
#toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

#page-info { font-size: 12px; color: var(--muted); }

#sort-wrap { display: flex; align-items: center; gap: 8px; }
#sort-wrap label { font-size: 12px; color: var(--muted); }

#sort {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font: inherit;
  font-size: 12px;
  padding: 4px 8px;
  outline: none;
  cursor: pointer;
}
#sort:focus { border-color: var(--accent); }

/* ── Skeleton ── */
#skeleton { padding: 20px; display: flex; flex-direction: column; gap: 1px; }
.sk-row {
  height: 52px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 25%, #222226 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  margin-bottom: 1px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Table ── */
#main { padding: 0 20px 20px; }

.tbl-wrap { overflow-x: auto; margin-top: 16px; }

table { width: 100%; border-collapse: collapse; }

thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  padding: 6px 12px 6px 0;
  letter-spacing: .3px;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
tbody tr:hover { background: rgba(255,255,255,.035); }
tbody tr:last-child { border-bottom: none; }

td { padding: 10px 12px 10px 0; font-size: 13px; vertical-align: middle; }

.c-title { font-weight: 500; color: var(--fg); }
.c-muted { color: var(--muted); }
.c-num   { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.c-ep    { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.genre-tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--muted);
  margin-right: 3px;
}

/* ── Pagination ── */
#pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 20px;
  flex-wrap: wrap;
}

.pg-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pg-btn:hover:not(:disabled) { color: var(--fg); border-color: var(--muted); }
.pg-btn.active { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 600; }
.pg-btn:disabled { opacity: .35; cursor: default; }

/* ── Detail overlay ── */
#detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
}
#detail-overlay[hidden] { display: none; }

#detail-panel {
  width: min(480px, 100vw);
  height: 100vh;
  background: var(--card);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 24px;
  position: relative;
  animation: slide-in .2s ease;
}
@keyframes slide-in { from { transform: translateX(32px); opacity: 0; } }

#detail-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  line-height: 1;
}
#detail-close:hover { color: var(--fg); background: var(--surface); }

#detail-body { padding-top: 8px; }

.det-type  { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); margin-bottom: 6px; }
.det-title { font-size: 21px; font-weight: 700; line-height: 1.25; margin-bottom: 14px; color: var(--fg); }
.det-row   { display: flex; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.det-label { color: var(--muted); min-width: 82px; flex-shrink: 0; }
.det-value { color: var(--fg); }
.det-divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.det-links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.det-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
  font-size: 13px;
  transition: border-color .15s;
}
.det-link:hover { border-color: var(--accent); color: var(--accent); }

/* ── Empty / error ── */
#no-results, #error-msg {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
#error-msg { color: #f87171; }

/* ── Footer ── */
#updated { text-align: center; font-size: 11px; color: var(--muted); padding: 12px 20px 28px; }

/* ── Mobile ── */
@media (max-width: 600px) {
  #top, #toolbar, #main { padding-left: 14px; padding-right: 14px; }
  #tabs { padding: 0 14px; }
  .tab  { padding: 10px 10px; font-size: 12px; }
  #detail-panel { border-left: none; }
}
