:root {
  color-scheme: light;
  --bg: #f8f5ed;
  --surface: #fffdf8;
  --ink: #1e2820;
  --muted: #647067;
  --line: #dfe3d7;
  --accent: #bf291d;
  --accent-ink: #fff8f3;
  --shadow: 0 8px 30px #1e282012;
  font:
    16px/1.5 system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101712;
  --surface: #172019;
  --ink: #edf5ed;
  --muted: #a9b7ac;
  --line: #314237;
  --accent: #72d293;
  --accent-ink: #102617;
  --shadow: none;
}

/* Identidad visual compartida: legible tanto sobre papel claro como en modo oscuro. */
body {
  background-image:
    linear-gradient(rgb(248 245 237 / 0.86), rgb(248 245 237 / 0.92)),
    url("brand/site-background-v1.png");
  background-size: cover;
  background-attachment: fixed;
}

:root[data-theme="dark"] body {
  background-image:
    linear-gradient(rgb(16 23 18 / 0.93), rgb(16 23 18 / 0.96)),
    url("brand/header-banner-v1.png");
}

.site-header {
  min-height: 108px;
  border-bottom: 0;
  background-image:
    linear-gradient(90deg, rgb(24 38 28 / 0.92) 0%, rgb(24 38 28 / 0.72) 46%, rgb(24 38 28 / 0.1) 100%),
    url("brand/header-banner-v1.png");
  background-position: center right;
  background-size: cover;
}

.site-header .brand,
.site-header .community-link {
  color: #f8f5ed;
  text-shadow: 0 1px 8px rgb(0 0 0 / 0.36);
}

.site-header .brand span {
  color: #d7f5df;
}

.site-header .brand img {
  width: 44px;
  height: 44px;
  margin-right: 10px;
}

.site-header .brand {
  display: flex;
  max-width: 300px;
  flex-wrap: wrap;
  align-items: center;
}

.site-header .brand span {
  flex-basis: calc(100% - 54px);
  margin-left: 54px;
}

.site-header .icon-button {
  color: #f8f5ed;
  border-color: rgb(248 245 237 / 0.55);
  background: rgb(24 38 28 / 0.35);
}

@media (max-width: 520px) {
  .site-header {
    min-height: 82px;
  }

  .site-header .brand img {
    width: 36px;
    height: 36px;
  }

  .site-header .brand span {
    flex-basis: calc(100% - 46px);
    margin-left: 46px;
  }

  .site-header { gap: 10px; padding-inline: 20px; }
  .site-header .brand { max-width: 170px; font-size: 0.88rem; }
  .site-header .brand span { font-size: 0.65rem; }
  .header-actions { margin-left: auto; gap: 6px; }
  #main-community-link { display: none; }
  .site-header .community-link { display: inline-flex; align-items: center; min-height: 34px; padding: 5px 7px; border: 1px solid rgb(248 245 237 / 0.5); border-radius: 7px; font-size: 0.68rem; text-align: center; }
  .site-header .icon-button { display: none; }
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}
.main-header { justify-content: flex-start; }
.main-menu { display: flex; flex: 1; align-items: center; }
.main-header .account-actions { display:flex; align-items:center; gap:9px; margin-left:28px; }
.main-header .header-actions { margin-left:auto; }
.main-header .community-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: #efffed;
  background: var(--accent);
  font-size: 0.9rem;
  text-shadow: none;
}
.main-header .community-link:nth-of-type(3) {
  color: var(--accent);
  background: #fffdf8;
}
.main-header .account-actions .community-link { color:var(--accent); background:#fffdf8; }
.main-header .account-actions button.community-link { font: inherit; font-weight: 700; cursor: pointer; }
.main-header [hidden] { display: none !important; }
.user-greeting { color: #f8f5ed; font-weight: 700; white-space: nowrap; }

/* En cabecera oscura, los controles necesitan contraste cálido y estable;
   el verde claro del tema oscuro no era legible sobre los botones claros. */
:root[data-theme="dark"] .main-header .community-link {
  border-color: #c43a2f;
  background: #c43a2f;
  color: #fffaf4;
}
:root[data-theme="dark"] .main-header .account-actions .community-link {
  border-color: #fffaf4;
  background: #fffaf4;
  color: #7f211b;
}
:root[data-theme="dark"] .main-header .community-link:nth-of-type(3) {
  border-color: #fffaf4;
  background: #fffaf4;
  color: #7f211b;
}
.community-link {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}
.mobile-menu-toggle { display: none; }
.song-community {
  margin-top: 24px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.song-community h2 {
  margin-top: 0;
}
.community-entry {
  padding: 13px 0;
  border-top: 1px solid var(--line);
}
.community-entry:first-child {
  border-top: 0;
}
.community-entry p {
  white-space: pre-wrap;
  margin: 0.3rem 0;
}
.community-form {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}
.community-form textarea,
.community-form select {
  width: 100%;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}
.community-form button {
  width: max-content;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent-ink);
  background: var(--accent);
  font-weight: 700;
}
.community-action {
  margin: 0.45rem 0 0 0.6rem;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: transparent;
}
.community-action.danger { color: #a11; border-color: #a11; }
.avatar { width:34px; height:34px; border-radius:50%; object-fit:cover; background:var(--line); vertical-align:middle; margin-right:8px; }
.community-meta {
  color: var(--muted);
  font-size: 0.86rem;
}
.community-note {
  color: var(--muted);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
}
.site-header {
  min-height: 64px;
  padding: 12px max(5vw, 20px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
}
.brand {
  color: inherit;
  font-weight: 760;
  text-decoration: none;
  letter-spacing: -0.02em;
}
.brand span {
  display: block;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}
.icon-button,
.favourite {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  min-width: 42px;
  min-height: 42px;
}
.catalogue,
.reader {
  width: min(1120px, 90vw);
  margin: auto;
}
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(350px, .9fr);
  align-items: end;
  gap: clamp(24px, 5vw, 65px);
  padding: clamp(48px, 9vw, 100px) 0 30px;
}
.eyebrow {
  color: var(--accent);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.13em;
}
.hero h1 {
  max-width: 640px;
  margin: 0.2rem 0;
  font-size: clamp(2.2rem, 6vw, 4.8rem);
  line-height: 1.04;
  letter-spacing: -0.06em;
}
.cover-leaderboard { padding: 15px; border: 1px solid var(--line); border-radius: 16px; background: color-mix(in srgb, var(--surface) 90%, transparent); box-shadow: var(--shadow); }
.cover-leaderboard-title { margin: 0 0 10px; color: var(--accent); font-size: .76rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.cover-leaderboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.cover-rank-card { display: grid; gap: 4px; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface); text-decoration: none; }
a.cover-rank-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.cover-rank-card img { width: 100%; border-radius: 6px; aspect-ratio: 16/9; object-fit: cover; }
.cover-rank-period { color: var(--accent); font-size: .68rem; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.cover-rank-card strong { overflow: hidden; font-size: .82rem; line-height: 1.14; text-overflow: ellipsis; white-space: nowrap; }
.cover-rank-artist, .cover-rank-votes, .cover-rank-card.is-empty p { overflow: hidden; margin: 0; color: var(--muted); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.cover-rank-votes { color: var(--accent); font-weight: 750; }
.cover-rank-card.is-empty { min-height: 118px; align-content: center; background: color-mix(in srgb, var(--surface) 70%, transparent); }
.muted {
  color: var(--muted);
}
.filters {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr) auto;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.search {
  grid-column: span 1;
}
.search input,
select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.favourites-toggle {
  white-space: nowrap;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 0 4px;
}
.song-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 14px;
  padding: 30px 0 60px;
}
.rehearsal-card { display: grid; gap: 0.55rem; }
.rehearsal-card > button { width: max-content; padding: 0.5rem 0.75rem; border: 1px solid var(--accent); border-radius: 8px; color: var(--accent); background: transparent; font: inherit; font-weight: 700; }
.song-card {
  min-height: 152px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: inherit;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: transform 0.16s;
}
.song-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}
.song-card h2 {
  margin: 0 32px 4px 0;
  font-size: 1.12rem;
  line-height: 1.2;
}
.song-card p {
  margin: 0;
  color: var(--muted);
}
.song-rating { color: var(--accent) !important; font-weight: 700; font-size: 0.86rem; margin-top: 7px !important; }
.song-card .favourite {
  position: absolute;
  top: 13px;
  right: 13px;
  min-width: 34px;
  min-height: 34px;
}
.favourite.is-active {
  color: #d88800;
  border-color: #d88800;
}
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}
.tag {
  padding: 3px 8px;
  border-radius: 99px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  font-size: 0.75rem;
  font-weight: 650;
}
.empty {
  padding: 50px 0;
  color: var(--muted);
  text-align: center;
}
.reader {
  width: min(800px, 90vw);
  padding: 42px 0 90px;
}
.reader-head {
  position: relative;
  margin-bottom: 25px;
}
.reader-head h1 {
  margin: 0.2rem 0;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1.04;
  letter-spacing: -0.05em;
}
.reader-head p {
  margin: 0.5rem 0;
  color: var(--muted);
}
.reader-tools {
  position: sticky;
  top: 76px;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  padding: 10px;
  margin: 0 -10px 22px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
}
.reader-tools button,
.reader-tools select,
.reader-tools a {
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  text-decoration: none;
}
.reader-tools .favourite {
  margin-left: auto;
}
.reader-tools a[target="_blank"] { display: none; }
.reader-tools a[target="_blank"].admin-original { display: inline-flex; align-items: center; }
.cover-thumbnail {
  position: absolute;
  top: 0;
  right: 0;
  width: 154px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.cover-thumbnail img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.cover-thumbnail span { display: block; padding: 5px 7px; font-size: .72rem; font-weight: 750; text-align: left; }
.cover-voting-panel { margin-top: 26px; padding: clamp(18px, 4vw, 28px); border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.cover-voting-panel h2 { margin: 0 0 16px; }
.cover-vote-card { display: grid; grid-template-columns: 150px 1fr; gap: 15px; align-items: center; padding: 13px 0; border-top: 1px solid var(--line); }
.cover-vote-card:first-of-type { border-top: 0; }
.cover-vote-card img { width: 100%; border-radius: 8px; aspect-ratio: 16/9; object-fit: cover; }
.cover-vote-card strong { display: block; }
.cover-vote-card p { margin: .35rem 0 .7rem; color: var(--muted); }
.cover-vote-card button { min-height: 36px; margin-right: 7px; }
.cover-voted { color: var(--accent); }
.cover-initial-label { display: inline-block; margin: 0 7px; color: var(--muted); font-size: .83rem; font-weight: 700; }
.cover-player-dialog { width: min(900px, 94vw); padding: 10px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow); }
.cover-player-dialog::backdrop { background: rgba(0,0,0,.7); }
.cover-player-dialog iframe { display: block; width: min(880px, 90vw); aspect-ratio: 16/9; border: 0; }
.cover-player-close { display: block; margin: 0 0 8px auto; }
.transpose-note {
  color: var(--muted);
  font-size: 0.85rem;
}
.song-sheet {
  padding: clamp(19px, 4vw, 42px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.song-line {
  margin: 0;
  min-height: 1.5em;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: var(--sheet-size, 18px);
  line-height: 1.58;
}
.song-line.chords {
  padding-top: 0.85em;
  color: var(--accent);
  font-weight: 800;
}
.song-line.lyrics + .song-line.lyrics {
  margin-top: 0.12em;
}
.legacy-link {
  color: var(--muted);
  font-size: 0.85rem;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; gap: 24px; }
  .filters {
    grid-template-columns: 1fr 1fr;
  }
  .search {
    grid-column: 1/-1;
  }
  .favourites-toggle {
    min-height: 42px;
  }
  .reader-tools {
    top: 68px;
  }
  .reader-tools .favourite {
    margin-left: 0;
  }
  .reader-head:has(.cover-thumbnail) { padding-right: 164px; }
  .cover-vote-card { grid-template-columns: 110px 1fr; }
}
@media (max-width: 440px) {
  .cover-leaderboard-grid { grid-template-columns: 1fr; }
  .cover-rank-card.is-empty { min-height: auto; }
  .filters {
    grid-template-columns: 1fr;
  }
  .song-grid {
    grid-template-columns: 1fr;
  }
  .reader-head:has(.cover-thumbnail) { padding-right: 0; }
  .cover-thumbnail { position: relative; display: block; margin: 14px 0 0; }
  .cover-vote-card { grid-template-columns: 1fr; }
  .cover-vote-card img { max-width: 220px; }
}

/* Menú compacto de la cabecera principal en móvil. */
@media (max-width: 760px) {
  .main-header { min-height: 74px; padding-inline: 18px; }
  .main-header .brand { max-width: calc(100% - 64px); }
  .mobile-menu-toggle { display: grid; gap: 5px; width: 43px; min-width: 43px; height: 43px; padding: 11px; margin-left: auto; border: 1px solid rgb(248 245 237 / .62); border-radius: 9px; background: rgb(24 38 28 / .45); }
  .mobile-menu-toggle span { display: block; height: 2px; border-radius: 2px; background: #f8f5ed; }
  .main-header .main-menu { display: none; position: absolute; top: calc(100% - 1px); right: 12px; left: 12px; z-index: 10; flex-direction: column; align-items: stretch; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 0 0 14px 14px; background: #18261c; box-shadow: 0 14px 28px rgb(0 0 0 / .28); }
  .main-header .main-menu.is-open { display: flex; }
  .main-header .account-actions, .main-header .header-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
  .main-header .user-greeting { grid-column: 1 / -1; padding: 2px 4px; }
  .main-header .community-link, .main-header .header-actions .icon-button { justify-content: center; width: 100%; min-height: 42px; margin: 0; font-size: .84rem; }
  .main-header .header-actions .icon-button { display: inline-flex; align-items: center; }
  .main-header #main-community-link { display: inline-flex; }
}

/* Deben quedar al final: las reglas base compactadas aparecen después de
   las variables y, de otro modo, anulan la identidad visual. */
body {
  background-color: #f8f5ed;
  background-image: url("brand/site-background-v1.png");
  background-position: center top;
  background-size: max(1280px, 100%) auto;
  background-attachment: fixed;
}

:root[data-theme="dark"] body {
  background-color: #101712;
  background-image:
    linear-gradient(rgb(16 23 18 / 0.7), rgb(16 23 18 / 0.78)),
    url("brand/site-background-v1.png");
}

.site-header {
  min-height: 108px;
  border-bottom: 0;
  background-color: #18261c;
  background-image:
    linear-gradient(90deg, rgb(24 38 28 / 0.9) 0%, rgb(24 38 28 / 0.65) 44%, rgb(24 38 28 / 0.08) 100%),
    url("brand/header-banner-v1.png");
  background-position: center right;
  background-size: cover;
}

.site-header .brand,
.site-header .community-link {
  color: #f8f5ed;
  text-shadow: 0 1px 8px rgb(0 0 0 / 0.36);
}

.site-header .brand span {
  color: #d7f5df;
}

.site-header .icon-button {
  color: #f8f5ed;
  border-color: rgb(248 245 237 / 0.55);
  background: rgb(24 38 28 / 0.35);
}

@media (max-width: 520px) {
  .site-header {
    min-height: 82px;
  }
}
