:root {
  --bg-dark: #121212;
  --window-bg: #e8dbc3;
  --sidebar-bg: #dccaa5;
  --border-color: #4a3b2a;
  --gold-accent: #b89548;
  --ink: #2b2018;
  --ink-muted: #665243;
  --tab-bg: #3d2f24;
  --tab-text: #a89582;
  --tab-hover: #4f3d2f;
  --green: #2a7a2a;
  --green-bg: rgba(34,197,94,.06);
  --green-border: rgba(34,197,94,.35);
  --font-title: "Cinzel", serif;
  --font-body: "Lato", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background-color: var(--bg-dark);
  background-image: radial-gradient(circle at center, #1f1f1f 0%, #050505 100%);
  color: var(--tab-text);
  min-height: 100vh;
}

/* ===== NAV BAR ===== */
.nav-bar { display:flex; justify-content:space-between; align-items:center; padding:12px 40px; background:var(--tab-bg); border-bottom:3px solid #2a2118; background-image:linear-gradient(to bottom,rgba(255,255,255,.05),rgba(0,0,0,.2)); flex-wrap:wrap; gap:6px; width:100%; box-sizing:border-box; }
.nav-bar a { color:var(--tab-text); text-decoration:none; font-family:var(--font-title); font-size:.95rem; padding:6px 16px; border-radius:4px; transition:all .2s; }
.nav-bar a:hover { background:var(--tab-hover); color:#dccaa5; }
.nav-bar a.active { color:var(--gold-accent); font-weight:700; }
.nav-bar a.nav-title { color:var(--gold-accent); font-size:1.1rem; font-weight:700; letter-spacing:1px; padding:0; background:none; }
.nav-bar a.nav-title:hover { background:none; color:#dccaa5; }
@media(max-width:768px){ .nav-bar{ padding:10px 15px; } .nav-bar a{ font-size:.8rem; padding:4px 10px; } .nav-bar a.nav-title{ font-size:.9rem; } }

/* ===== LAYOUT ===== */
.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 18px 60px;
}

/* ===== PAGE HEADER ===== */
.page-header {
  margin-bottom: 32px;
  text-align: center;
}

.page-header h1 {
  font-family: var(--font-title);
  font-size: 2rem;
  color: var(--gold-accent);
  margin: 0 0 6px;
  letter-spacing: 1px;
  text-shadow: 0 4px 20px rgba(184,149,72,.3);
}

.page-header .subtitle {
  font-size: 0.95rem;
  color: var(--ink-muted);
  font-style: italic;
  margin-bottom: 14px;
}

/* Realm-wide stat pills */
.realm-stats {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.realm-stat {
  background: var(--tab-bg);
  border: 1px solid rgba(74,59,42,.4);
  border-radius: 20px;
  padding: 4px 14px;
  font-family: var(--font-title);
  font-size: 0.78rem;
  color: var(--tab-text);
  letter-spacing: 0.5px;
}

.realm-stat strong {
  color: var(--gold-accent);
}

/* ===== USER BLOCK ===== */
.user-block {
  background: var(--window-bg);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  margin-bottom: 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  overflow: hidden;
}

.user-block-header {
  background: var(--sidebar-bg);
  border-bottom: 2px solid rgba(74,59,42,.25);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.user-block-header h2 {
  margin: 0;
  font-family: var(--font-title);
  font-size: 1.2rem;
  color: var(--ink);
  flex-shrink: 0;
}

.user-block-header .meta {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

/* User aggregate progress bar */
.user-progress-wrap {
  flex: 1;
  min-width: 80px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.user-progress-track {
  height: 5px;
  background: rgba(74,59,42,.2);
  border-radius: 3px;
  overflow: hidden;
}

.user-progress-fill {
  height: 100%;
  background: linear-gradient(to right, var(--gold-accent), #d4af60);
  border-radius: 3px;
  transition: width 0.6s ease;
}

.user-fraction {
  font-size: 0.72rem;
  font-family: var(--font-title);
  color: var(--ink-muted);
  text-align: right;
}

.user-block-body {
  padding: 12px 16px 16px;
}

/* ===== PLAYLIST DETAILS ===== */
details {
  background: rgba(74,59,42,.06);
  border: 1px solid rgba(74,59,42,.2);
  border-radius: 8px;
  margin: 8px 0;
  overflow: hidden;
  transition: border-color 0.3s, background 0.3s;
}

/* 100% complete playlist */
details.pl-complete {
  border-color: var(--green-border);
  background: var(--green-bg);
}

summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 11px 14px;
  user-select: none;
  font-family: var(--font-title);
  color: var(--ink);
}

summary::-webkit-details-marker { display: none; }

details[open] summary {
  border-bottom: 1px solid rgba(74,59,42,.2);
}

details.pl-complete[open] summary {
  border-bottom-color: var(--green-border);
}

/* Chevron */
.pl-chevron {
  font-size: 0.65rem;
  color: var(--ink-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
  line-height: 1;
}

details[open] > summary .pl-chevron {
  transform: rotate(90deg);
}

.pl-name {
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

details[open] summary .pl-name,
details.pl-complete summary .pl-name {
  color: var(--gold-accent);
}

details.pl-complete summary .pl-name {
  color: var(--green);
}

/* Progress bar inside summary */
.pl-bar-wrap {
  flex: 1;
  min-width: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}

.pl-bar-track {
  height: 7px;
  background: rgba(74,59,42,.18);
  border-radius: 4px;
  overflow: hidden;
}

.pl-bar-fill {
  height: 100%;
  background: linear-gradient(to right, #b89548, #d4af60);
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

details.pl-complete .pl-bar-fill {
  background: linear-gradient(to right, #2a7a2a, #5aaa5a);
}

.pl-fraction {
  font-size: 0.75rem;
  font-family: var(--font-title);
  color: var(--ink-muted);
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.3px;
}

details.pl-complete .pl-fraction {
  color: var(--green);
}

/* Complete badge */
.pl-badge {
  font-size: 0.68rem;
  font-family: var(--font-title);
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.5px;
  border: 1px solid var(--green-border);
  background: rgba(34,197,94,.1);
  color: var(--green);
}

.pl-meta {
  font-size: 0.78rem;
  color: var(--ink-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===== BOOK LIST ===== */
ul {
  list-style: none;
  padding: 4px 14px 8px;
  margin: 0;
}

li {
  padding: 9px 0;
  border-bottom: 1px solid rgba(74,59,42,.15);
  transition: background 0.15s;
}

li:last-child { border-bottom: none; }

li.item-done {
  opacity: 0.72;
}

li.item-done .title {
  text-decoration: line-through;
  text-decoration-color: rgba(74,59,42,.4);
  color: var(--ink-muted);
}

li.item-done .cover {
  filter: grayscale(30%);
}

.item-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.cover {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid rgba(74,59,42,.3);
  flex: 0 0 auto;
  background: rgba(74,59,42,.1);
}

.item-text { flex: 1 1 auto; min-width: 0; }

.title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
  transition: color 0.2s;
}

.author {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

/* Finished check */
.check {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(74,59,42,.3);
  background: rgba(74,59,42,.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  transition: background 0.2s, border-color 0.2s;
}

.check.on {
  border-color: rgba(34,197,94,.6);
  background: rgba(34,197,94,.18);
}

.check.on::after {
  content: "✓";
  font-weight: 800;
  color: #22c55e;
  font-size: 14px;
  line-height: 1;
}

/* Loading / error state */
.state-msg {
  font-family: var(--font-title);
  color: var(--ink-muted);
  text-align: center;
  padding: 40px 20px;
  font-style: italic;
}

/* Empty playlist */
.pl-empty {
  padding: 16px 14px;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

@media (max-width: 600px) {
  .pl-name { max-width: 130px; }
  .pl-meta { display: none; }
  .page-header h1 { font-size: 1.5rem; }
  .user-progress-wrap { display: none; }
}

@media (max-width: 380px) {
  .pl-fraction { display: none; }
}
