:root {
  color-scheme: light;
  --bg: #eef2f8;
  --bg-strong: #e6ebf4;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --surface-soft: rgba(245, 248, 252, 0.94);
  --text: #142033;
  --muted: #66758d;
  --line: rgba(20, 32, 51, 0.1);
  --accent: #2f6fed;
  --accent-strong: #1d5bd6;
  --accent-soft: rgba(47, 111, 237, 0.1);
  --accent-warm: #f59e0b;
  --danger: #d94b62;
  --success: #1f9d67;
  --shadow: 0 18px 40px rgba(22, 34, 54, 0.08);
  --shadow-strong: 0 28px 60px rgba(22, 34, 54, 0.12);
  --radius: 24px;
  --radius-sm: 16px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1220;
  --bg-strong: #121a2d;
  --surface: rgba(17, 24, 39, 0.9);
  --surface-strong: #161f33;
  --surface-soft: rgba(20, 29, 48, 0.95);
  --text: #e7edf9;
  --muted: #94a3bc;
  --line: rgba(180, 197, 225, 0.14);
  --accent: #75a7ff;
  --accent-strong: #9bc0ff;
  --accent-soft: rgba(117, 167, 255, 0.16);
  --accent-warm: #f7b84b;
  --danger: #ff7b90;
  --success: #45c48b;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.26);
  --shadow-strong: 0 28px 60px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(47, 111, 237, 0.14), transparent 32%),
    radial-gradient(circle at 90% 8%, rgba(245, 158, 11, 0.12), transparent 24%),
    linear-gradient(180deg, #f8fbff 0%, #eef2f8 42%, #e9edf5 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Manrope", "Segoe UI", sans-serif;
  line-height: 1.5;
  background: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

pre,
.lyrics {
  font-family: "JetBrains Mono", "Consolas", monospace;
}

.backdrop {
  position: fixed;
  inset: auto;
  width: 30rem;
  height: 30rem;
  border-radius: 999px;
  filter: blur(72px);
  opacity: 0.55;
  pointer-events: none;
  z-index: -1;
}

.backdrop-a {
  top: -10rem;
  left: -10rem;
  background: rgba(47, 111, 237, 0.16);
}

.backdrop-b {
  right: -8rem;
  top: 16rem;
  background: rgba(245, 158, 11, 0.12);
}

.container {
  width: min(1160px, calc(100% - 2rem));
  margin: 0 auto;
}

.page-shell.book-page-shell {
  width: min(100%, calc(100% - 1rem));
  max-width: 1680px;
}

body.book-page-shell .topbar {
  display: none;
}

body.book-page-shell .page-shell {
  padding-top: 0.5rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(18px);
  background: rgba(248, 251, 255, 0.78);
  border-bottom: 1px solid var(--line);
}

html[data-theme="dark"] .topbar {
  background: rgba(13, 18, 32, 0.78);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 1rem;
  color: white;
  background: linear-gradient(135deg, var(--accent) 0%, #1f4fb9 100%);
  box-shadow: 0 14px 28px rgba(47, 111, 237, 0.24);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.nav a {
  padding: 0.7rem 1rem;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  transition: all 150ms ease;

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
}

.nav a:hover {
  color: var(--text);
  border-color: rgba(47, 111, 237, 0.12);
  background: rgba(47, 111, 237, 0.05);
}

.page-shell {
  padding: 2rem 0 4rem;
}

.card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero,
.admin-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.9fr);
  gap: 1.6rem;
  padding: 2.2rem;
}

.hero h1,
.admin-hero h1,
.song-detail h1,
.auth-card h1,
.form-card h1 {
  margin: 0.15rem 0 0.6rem;
  font-size: clamp(2rem, 4vw, 3.55rem);
  line-height: 1.04;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.8rem;
  font-weight: 800;
}

.lede,
.detail-subtitle,
.muted,
.song-note,
.empty-hint,
.table-card .muted {
  color: var(--muted);
}

.lede {
  max-width: 62ch;
  font-size: 1.03rem;
}

.hero-stats {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.stat,
.metric {
  padding: 1rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(22, 34, 54, 0.06);
}

.stat strong,
.metric strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
}

.hero-actions,
.search-actions,
.row-actions,
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.8rem;
  padding: 0.75rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.button:hover {
  transform: translateY(-1px);
  border-color: rgba(47, 111, 237, 0.25);
  box-shadow: 0 10px 24px rgba(47, 111, 237, 0.12);
}

.button.primary {
  border-color: transparent;
  color: white;
  background: linear-gradient(135deg, var(--accent) 0%, #1f4fb9 100%);
  font-weight: 800;
}

.button.ghost {
  background: rgba(255, 255, 255, 0.7);
}

html[data-theme="dark"] .button.ghost {
  background: rgba(17, 24, 39, 0.82);
}

.button-active {
  border-color: rgba(47, 111, 237, 0.3);
  background: rgba(47, 111, 237, 0.14);
}

.button.danger {
  border-color: rgba(217, 75, 98, 0.2);
  color: #a92f45;
  background: rgba(217, 75, 98, 0.08);
}

.button.small {
  min-height: 2.25rem;
  padding: 0.55rem 0.85rem;
}

.search-card,
.form-card,
.table-card,
.song-detail,
.auth-card {
  padding: 1.6rem;
  margin-top: 1.5rem;
}

.search-form,
.stack-form {
  display: grid;
  gap: 1.25rem;
}

.inline-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.field-group,
.stack-form label {
  display: grid;
  gap: 0.5rem;
}

.search-grid {
  grid-template-columns: minmax(0, 1.6fr) minmax(220px, 0.8fr);
  gap: 1rem;
}

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 0.9rem 1rem;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 1rem;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(47, 111, 237, 0.42);
  box-shadow: 0 0 0 4px rgba(47, 111, 237, 0.1);
}

textarea {
  resize: vertical;
  min-height: 18rem;
}

.section-label {
  margin-bottom: 0.7rem;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  cursor: pointer;
}

.chip input {
  margin: 0;
}

.chip-active {
  border-color: rgba(47, 111, 237, 0.25);
  background: rgba(47, 111, 237, 0.08);
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-top: 2rem;
  padding-inline: 0.2rem;
}

.results-header.compact {
  margin-top: 0;
}

.results-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.results-header p {
  margin: 0;
  color: var(--muted);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.song-card,
.empty-state {
  padding: 1.25rem;
}

.song-card {
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.song-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-strong);
  border-color: rgba(47, 111, 237, 0.18);
}

.song-title {
  font-size: 1.15rem;
  font-weight: 800;
}

.song-title:hover {
  color: var(--accent);
}

.song-artist {
  margin-top: 0.25rem;
  color: var(--muted);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.9rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(47, 111, 237, 0.14);
  background: rgba(47, 111, 237, 0.08);
  color: var(--accent-strong);
  font-size: 0.85rem;
}

.tag-muted {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
}

.song-detail {
  padding: 1.8rem;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  margin-bottom: 1rem;
}

.detail-head h1 {
  margin-bottom: 0.3rem;
}

.detail-note {
  margin-top: 1rem;
}

.transpose-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: start;
  margin-top: 1.2rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  background: rgba(255, 255, 255, 0.74);
}

.transpose-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.transpose-value {
  min-width: 5.5rem;
  font-weight: 800;
  color: var(--accent-strong);
}

.tag-chord {
  border-color: rgba(31, 157, 103, 0.18);
  background: rgba(31, 157, 103, 0.08);
  color: #16694b;
}

.lyrics {
  margin: 1.25rem 0 0;
  padding: 1.25rem;
  white-space: pre-wrap;
  font-family: "JetBrains Mono", monospace;
  line-height: 1.75;
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  overflow-x: auto;
  color: #1a2638;
}

.lyrics .chord {
  display: inline-block;
  margin: 0 0.1rem;
  padding: 0.05rem 0.42rem;
  border-radius: 0.65rem;
  background: rgba(47, 111, 237, 0.12);
  color: var(--accent-strong);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.card-inner {
  margin-top: 1rem;
}

.book-link-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.25rem;
  font-size: 0.9rem;
}

.book-link-line a {
  color: var(--accent-strong);
  font-weight: 800;
}

.book-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 1.25rem;
  align-items: start;
  margin-top: 1.5rem;
}

.book-shell {
  display: grid;
  gap: 1rem;
  padding: 0.55rem;
}

.book-empty {
  padding: 1.4rem;
}

.book-mini-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.book-mini-title h1 {
  margin: 0.1rem 0 0.15rem;
}

.book-mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: flex-end;
}

.book-mini-actions.compact-only {
  justify-content: flex-start;
  align-items: center;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 0.8rem;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--accent-strong);
}

.icon-button svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: currentColor;
}

.icon-button:hover {
  border-color: rgba(47, 111, 237, 0.24);
  box-shadow: var(--shadow);
}

.icon-button[aria-pressed="true"],
.button[aria-disabled="true"] {
  opacity: 0.65;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.button[aria-disabled="true"] {
  pointer-events: none;
}

.chord-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.chord-tools .transpose-value {
  min-width: 5rem;
  text-align: center;
}

.book-toc-toggle {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.68);
  padding: 0.7rem 0.85rem;
}

html[data-theme="dark"] .book-toc-toggle {
  background: rgba(17, 24, 39, 0.76);
}

.book-toc-toggle summary {
  cursor: pointer;
  font-weight: 800;
  list-style: none;
}

.book-toc-toggle summary::-webkit-details-marker {
  display: none;
}

.book-toc-compact {
  margin-top: 0.85rem;
}

.book-toc-active {
  border-color: rgba(47, 111, 237, 0.28);
  background: rgba(47, 111, 237, 0.08);
}

.book-song-head.minimal {
  margin-bottom: 0.2rem;
}

.book-footer-nav {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.book-index-card {
  margin-top: 1.5rem;
  padding: 1.4rem;
}

.book-index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.book-index-item {
  display: grid;
  gap: 0.25rem;
  padding: 0.9rem 1rem;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

html[data-theme="dark"] .book-index-item {
  background: rgba(17, 24, 39, 0.76);
}

.book-index-item strong {
  font-size: 1rem;
}

.book-index-item span {
  color: var(--muted);
  font-size: 0.88rem;
  word-break: break-all;
}

.book-index-item:hover {
  border-color: rgba(47, 111, 237, 0.22);
  box-shadow: var(--shadow);
}

.book-sidebar {
  position: sticky;
  top: 6.25rem;
  padding: 1.1rem;
  max-height: calc(100vh - 7.5rem);
  overflow: auto;
}

.book-sidebar,
.book-index-card,
.book-toc-toggle,
.book-shell,
.book-empty {
  background: var(--surface);
}

.book-sidebar-head,
.book-song-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

.book-sidebar-head {
  margin-bottom: 1rem;
}

.book-toc {
  display: grid;
  gap: 0.65rem;
}

.book-toc:empty {
  min-height: 5rem;
}

.book-toc-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.2rem 0.75rem;
  align-items: start;
  padding: 0.8rem 0.85rem;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

html[data-theme="dark"] .book-toc-item {
  background: rgba(17, 24, 39, 0.76);
}

.book-toc-item:hover {
  border-color: rgba(47, 111, 237, 0.22);
  box-shadow: var(--shadow);
}

.book-toc-index {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  background: rgba(47, 111, 237, 0.12);
  color: var(--accent-strong);
  font-weight: 800;
  font-size: 0.85rem;
}

.book-toc-title {
  font-weight: 800;
}

.book-toc-artist {
  color: var(--muted);
  font-size: 0.92rem;
}

.book-content {
  display: grid;
  gap: 1rem;
}

.book-song {
  padding: 0.35rem 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}

.book-song-head {
  margin-bottom: 0.8rem;
}

.book-toolbar {
  display: grid;
  gap: 0.75rem;
  justify-items: end;
}

.book-view-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.book-lyrics {
  margin-top: 0.55rem;
}

.plain-view {
  white-space: pre-wrap;
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .song-card,
html[data-theme="dark"] .table-row,
html[data-theme="dark"] .flash,
html[data-theme="dark"] .lyrics,
html[data-theme="dark"] .transpose-panel,
html[data-theme="dark"] .book-toc-item,
html[data-theme="dark"] .book-song,
html[data-theme="dark"] .book-sidebar {
  background: rgba(17, 24, 39, 0.9);
}

html[data-theme="dark"] .lyrics {
  color: var(--text);
}

html[data-theme="dark"] .tag-muted,
html[data-theme="dark"] .button.ghost,
html[data-theme="dark"] .flash,
html[data-theme="dark"] .table-row,
html[data-theme="dark"] .lyrics,
html[data-theme="dark"] .book-toc-item,
html[data-theme="dark"] .book-sidebar,
html[data-theme="dark"] .book-song,
html[data-theme="dark"] .transpose-panel {
  border-color: var(--line);
}

.auth-layout {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 8rem);
}

.auth-card {
  width: min(540px, 100%);
}

.flash {
  margin-top: 1rem;
  padding: 0.95rem 1.1rem;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
}

.flash-success {
  border-color: rgba(31, 157, 103, 0.24);
  background: rgba(31, 157, 103, 0.08);
}

.flash-error {
  border-color: rgba(217, 75, 98, 0.24);
  background: rgba(217, 75, 98, 0.08);
}

.table-list {
  display: grid;
  gap: 0.8rem;
}

.table-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.metric span {
  color: var(--muted);
}

@media (max-width: 840px) {
  .hero,
  .admin-hero,
  .search-grid,
  .detail-head,
  .inline-form,
  .table-row,
  .book-layout,
  .book-sidebar,
  .book-song-head,
  .book-toolbar,
  .topbar-inner {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar-inner,
  .results-header {
    flex-direction: column;
    align-items: start;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .book-sidebar {
    position: relative;
    top: 0;
    max-height: none;
  }

  .page-shell.book-page-shell {
    width: min(100%, calc(100% - 1rem));
  }

  .nav {
    gap: 0.5rem;
  }

  .song-detail,
  .search-card,
  .table-card,
  .form-card,
  .auth-card,
  .hero,
  .admin-hero {
    padding: 1.1rem;
  }

  .detail-actions,
  .search-actions,
  .hero-actions,
  .row-actions,
  .transpose-panel {
    width: 100%;
  }

  .button,
  .row-actions form,
  .row-actions .button,
  .search-actions .button,
  .hero-actions .button {
    width: 100%;
  }

  .book-view-toggle,
  .book-toolbar .button {
    width: 100%;
  }

  .book-mini-bar,
  .book-footer-nav {
    grid-template-columns: 1fr;
    display: grid;
  }

  .book-mini-actions {
    justify-content: start;
  }

  .chord-tools {
    width: 100%;
  }

  .book-shell {
    padding: 0.45rem;
  }

  .book-index-card {
    padding: 1rem;
  }

  .book-toc-item {
    grid-template-columns: auto 1fr;
  }

  .results-header {
    margin-top: 1.4rem;
  }
}
