:root {
  --bg: #100b0f;
  --panel: #1b1219;
  --panel-2: #251923;
  --card: #2c1d29;
  --text: #f8efe8;
  --muted: #cdbbb0;
  --gold: #d8aa55;
  --rose: #b85d72;
  --green: #82a276;
  --line: rgba(255,255,255,.13);
  --shadow: 0 24px 70px rgba(0,0,0,.26);
  --radius: 24px;
  --max: 1240px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 0%, rgba(216,170,85,.16), transparent 32%),
    radial-gradient(circle at 92% 4%, rgba(184,93,114,.18), transparent 30%),
    linear-gradient(180deg, #100b0f 0%, #191117 45%, #0f0b0e 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
code { color: #f1d48d; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 11, 15, .78);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 850; letter-spacing: .02em; }
.mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #180e10;
  background: linear-gradient(135deg, var(--gold), var(--rose));
  font: 700 24px Georgia, serif;
}
.topnav { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.topnav a, .sidenav a {
  color: var(--muted);
  border-radius: 999px;
  padding: 9px 12px;
  font-size: .95rem;
}
.topnav a:hover, .topnav a.active, .sidenav a:hover, .sidenav a.active {
  color: var(--text);
  background: rgba(255,255,255,.08);
}

.shell {
  width: min(var(--max), calc(100% - 36px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 26px;
  padding: 28px 0 56px;
}
.sidebar {
  position: sticky;
  top: 92px;
  align-self: start;
  min-height: 320px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(27,18,25,.78);
  box-shadow: var(--shadow);
}
.side-title { margin: 0 0 10px; color: #f1d48d; font-weight: 800; }
.sidenav { display: grid; gap: 4px; margin-bottom: 18px; }
.side-box {
  margin-top: 16px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255,255,255,.055);
  border: 1px solid var(--line);
}
.side-box p { color: var(--muted); margin: 8px 0 0; font-size: .92rem; }
.content { min-width: 0; }

.hero {
  padding: 50px;
  border-radius: 36px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 20% 0%, rgba(216,170,85,.21), transparent 32%),
    linear-gradient(145deg, rgba(44,29,41,.92), rgba(20,13,18,.92));
  box-shadow: var(--shadow);
}
.eyebrow {
  display: inline-flex;
  margin: 0 0 14px;
  padding: 7px 12px;
  border: 1px solid rgba(216,170,85,.3);
  border-radius: 999px;
  color: #efd096;
  background: rgba(216,170,85,.08);
  font-size: .9rem;
}
h1, h2, h3 { line-height: 1.08; margin: 0; }
h1 {
  max-width: 870px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 5.6vw, 5.5rem);
  letter-spacing: -.055em;
}
h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.75rem, 3vw, 3rem);
  letter-spacing: -.035em;
}
.lead { max-width: 780px; color: var(--muted); margin: 20px 0 0; font-size: clamp(1.05rem, 2vw, 1.24rem); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.button, button.button {
  appearance: none;
  border: 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-radius: 999px;
  color: #170e10;
  background: linear-gradient(135deg, var(--gold), #f1d48d);
  font-weight: 800;
  cursor: pointer;
}
.button.ghost { color: var(--text); background: rgba(255,255,255,.08); border: 1px solid var(--line); }
.small-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: var(--text);
  font: inherit;
  font-size: .88rem;
  cursor: pointer;
}
.small-button.danger { color: #ffd1d1; border-color: rgba(255,110,110,.26); }

.section { margin-top: 48px; }
.section.narrow { max-width: 760px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.section-head a { color: #efd096; }
.feature-grid, .artist-grid, .card-grid, .gallery-grid, .admin-grid {
  display: grid;
  gap: 16px;
}
.feature-grid { grid-template-columns: repeat(5, 1fr); }
.artist-grid { grid-template-columns: repeat(5, 1fr); }
.artist-grid.large { grid-template-columns: repeat(2, 1fr); }
.card-grid { grid-template-columns: repeat(3, 1fr); }
.gallery-grid { grid-template-columns: repeat(4, 1fr); }

.feature, .artist-card, .admin-card, .empty, .notice {
  display: block;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255,255,255,.055);
}
.feature strong, .artist-card strong, .admin-card strong { display: block; margin-bottom: 8px; font-size: 1.05rem; }
.feature span, .artist-card span, .admin-card span, .empty { color: var(--muted); }
.artist-card em { display: block; margin-top: 14px; color: #f1d48d; font-style: normal; }
.admin-card span { font-size: 1.6rem; color: #f1d48d; font-weight: 850; }

.card {
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.065), rgba(255,255,255,.035));
  box-shadow: 0 18px 42px rgba(0,0,0,.16);
}
.thumb { aspect-ratio: 1.4 / 1; background: linear-gradient(135deg, rgba(216,170,85,.4), rgba(184,93,114,.38)); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.is-empty::after { content: 'Silkesord'; display: grid; place-items: center; height: 100%; color: rgba(255,255,255,.62); font: 700 1.2rem Georgia, serif; }
.card-body { padding: 20px; }
.card h3 { font-size: 1.2rem; margin-bottom: 8px; }
.card p { color: var(--muted); margin: 10px 0 0; }
.meta { color: #e9c47d; font-size: .92rem; }
.linkrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.poem-thumb {
  position: relative;
  overflow: hidden;
  min-height: 230px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255,255,255,.055);
}
.poem-thumb img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 1; }
.poem-thumb span {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(10,7,10,.72);
  backdrop-filter: blur(12px);
}
.poem-thumb strong, .poem-thumb em { display: block; }
.poem-thumb em { color: var(--muted); font-size: .86rem; font-style: normal; }

.filterbar {
  display: grid;
  grid-template-columns: 1fr 260px auto;
  gap: 10px;
  margin: 22px 0;
  padding: 14px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.055);
  border: 1px solid var(--line);
}
input, textarea, select {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 14px;
  background: rgba(255,255,255,.07);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}
select option { background: #1b1219; }
textarea { min-height: 150px; resize: vertical; }

.detail {
  display: grid;
  grid-template-columns: minmax(260px, 420px) 1fr;
  gap: 28px;
  align-items: center;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 34px;
  background: rgba(255,255,255,.055);
}
.detail-image { aspect-ratio: 1; border-radius: 24px; overflow: hidden; background: rgba(255,255,255,.065); }
.detail-image img { width: 100%; height: 100%; object-fit: cover; }
.detail-image.is-empty::after { content: 'Silkesord'; display: grid; place-items: center; height: 100%; color: var(--muted); font-family: Georgia, serif; }

.steps { display: grid; gap: 14px; padding: 0; list-style: none; }
.steps li { padding: 18px; border-radius: 18px; background: rgba(255,255,255,.055); border: 1px solid var(--line); }
.steps span { display: block; color: var(--muted); }

.footer {
  width: min(var(--max), calc(100% - 36px));
  margin: 0 auto;
  padding: 28px 0 44px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
}

.login-box {
  width: min(440px, calc(100% - 32px));
  margin: 12vh auto;
  padding: 32px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: rgba(27,18,25,.9);
  box-shadow: var(--shadow);
}
.login-box h1 { font-size: 2.4rem; margin-bottom: 20px; }
.login-box label, .field { display: grid; gap: 7px; margin-bottom: 14px; color: var(--muted); }
.error { color: #ffd1d1; background: rgba(255,110,110,.09); padding: 10px 12px; border-radius: 14px; }

.admin-hero, .plain {
  padding: 26px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.055);
}
.plain { width: min(760px, calc(100% - 32px)); margin: 10vh auto; }
.admin-grid { grid-template-columns: repeat(3, 1fr); margin-top: 18px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.04); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: #f1d48d; font-size: .9rem; }
td { color: var(--muted); }
.row-actions { display: flex; gap: 8px; align-items: center; }
.row-actions form { margin: 0; }
.admin-form {
  padding: 24px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.055);
  border: 1px solid var(--line);
}
.admin-form h1 { font-size: 2.4rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; }
.check { display: flex; align-items: center; gap: 9px; margin: 14px 0 18px; }
.check input { width: auto; min-height: auto; }
.notice { margin: 18px 0; color: #dce8d3; border-color: rgba(130,162,118,.35); background: rgba(130,162,118,.11); }
.pagination { display: flex; gap: 12px; justify-content: center; align-items: center; margin: 24px 0; }
.pagination a, .pagination span { padding: 8px 12px; border-radius: 999px; background: rgba(255,255,255,.08); }

@media (max-width: 1050px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .sidenav { grid-template-columns: repeat(3, 1fr); }
  .feature-grid, .artist-grid, .card-grid, .gallery-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .topnav { justify-content: flex-start; }
  .shell { width: min(100% - 22px, var(--max)); padding-top: 18px; }
  .hero { padding: 28px; }
  .feature-grid, .artist-grid, .artist-grid.large, .card-grid, .gallery-grid, .admin-grid, .form-grid, .detail, .filterbar { grid-template-columns: 1fr; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .footer { flex-direction: column; }
  .sidenav { grid-template-columns: 1fr; }
}

/* v2: pagination, result counts and safer media loading */
.result-count {
  color: var(--muted);
  margin: 0 0 16px;
  font-size: .95rem;
}

.pagination a.active {
  background: linear-gradient(135deg, var(--gold), #f1d48d);
  color: #160d10;
  font-weight: 800;
}

.filterbar .button.ghost,
.button.ghost {
  background: rgba(255,255,255,.07);
  color: var(--text);
}

.admin-form + .admin-form,
.notice + form,
form + form {
  margin-top: 12px;
}

/* v2.3 bulk gallery admin */
.admin-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.06);
}

.bulk-panel {
  margin: 18px 0;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.055);
}

.form-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.admin-filter {
  align-items: end;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 18px 0;
}

.page-current {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  color: var(--muted);
}

.table-wrap small {
  color: var(--muted);
  word-break: break-all;
}

/* v2.4 YouTube sync and local statistics */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 18px 0 26px;
}

.stat-box {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.065);
}

.stat-box strong {
  display: block;
  font-size: 2rem;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 8px;
}

.stat-box span {
  color: var(--muted);
  font-size: .95rem;
}

/* v2.5 sharing and music links */
.share-box {
  margin-top: 22px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.055);
}

.share-box strong {
  display: block;
  margin-bottom: 10px;
}

.share-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-links button.small-button {
  cursor: pointer;
  font: inherit;
}

.notice code {
  word-break: break-all;
}

.tracklist {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.045);
}
.tracklist h2 {
  margin: 0 0 12px;
  font-size: 1.15rem;
}
.tracklist ol {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}
.tracklist li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,.055);
}
.tracklist li strong {
  display: inline-block;
  min-width: 2.1rem;
  color: var(--gold);
}
.tracklist li em {
  font-style: normal;
  white-space: nowrap;
  color: var(--muted);
}
.tracklist li a {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.track-disc {
  margin-left: 8px;
  color: var(--muted);
  font-size: .85rem;
}
@media (max-width: 700px) {
  .tracklist li {
    align-items: flex-start;
    flex-direction: column;
  }
  .tracklist li em {
    white-space: normal;
  }
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.lang-switch {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
}

.lang-switch button {
  border: 0;
  border-radius: 999px;
  padding: 6px 9px;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
}

.lang-switch button.active,
.lang-switch button:hover {
  color: #1a1015;
  background: var(--gold);
}
