:root {
  --bg: linear-gradient(180deg, #eef3ff 0%, #f6f8fb 55%, #fbfcff 100%);
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #6b7280;
  --accent: #335cff;
  --border: #e5e7ef;
  --shadow: 0 10px 32px rgba(15, 23, 42, 0.12);
  font-family: "Manrope", "Inter", system-ui, -apple-system, sans-serif;
  color: var(--text);
}

:root.dark {
  --bg: #0f172a;
  --panel: #1e293b;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #60a5fa;
  --border: #334155;
  --shadow: 0 10px 32px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  overflow-x: hidden;
}

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

a:hover {
  color: var(--accent);
}

img {
  max-width: 100%;
}

.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 {
  cursor: pointer;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 11px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

:root.dark button:not(.ghost):not(.chip) {
  color: #0f172a;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
  font-weight: 600;
}

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--bg);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand img {
  width: 36px;
  height: 36px;
}

.header-search {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  min-width: 0;
  width: 100%;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.header-search input {
  border: none;
  outline: none;
  background: transparent;
  padding: 10px;
  font-size: 15px;
  color: var(--text);
  min-width: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
}

.page {
  width: 100%;
  max-width: 100vw;
  margin: 0;
  padding: 0 18px 48px;
}

.home-page {
  padding-top: 0;
}

.hero {
  max-width: 780px;
  margin: 80px auto 40px;
  text-align: center;
}

.hero h1 {
  font-size: clamp(32px, 3vw + 12px, 46px);
  letter-spacing: -0.02em;
  margin: 12px 0 10px;
}

.hero-mark {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  border-radius: 22px;
  background: linear-gradient(135deg, #dce9ff 0%, #edf1ff 50%, #dfe5ff 100%);
  box-shadow: 0 12px 28px rgba(24, 47, 99, 0.12);
}

.hero-mark img {
  width: 48px;
  height: 48px;
}

.hero-mark__text {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0f172a;
}

.hero-bg {
  display: flex;
  justify-content: center;
  padding: 18px 0 0;
  background: linear-gradient(180deg, #eef3ff 0%, rgba(238, 243, 255, 0.62) 100%);
}

.hero-bg .hero-mark {
  box-shadow: 0 18px 44px rgba(24, 47, 99, 0.16);
}

.hero p {
  color: var(--muted);
  font-size: 17px;
}

.hero .search-box {
  margin: 28px auto 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.hero .search-box input {
  border: none;
  outline: none;
  font-size: 17px;
  padding: 12px 14px;
  background: transparent;
  color: var(--text);
}

.pill-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.subtle {
  color: var(--muted);
}

.search-page {
  margin: 26px auto 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
}

.results-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.search-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px;
  position: sticky;
  top: 0;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  margin: -16px -16px 16px;
  z-index: 5;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.result-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 120ms ease, border-color 120ms ease;
}

.result-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.result-card h3 {
  margin: 0;
  font-size: 18px;
}

.result-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  flex-wrap: wrap;
}

.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  padding: 0;
  margin: 12px 0;
  list-style: none;
}

.info-grid li {
  padding: 10px 12px;
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}

.info-grid .label {
  color: var(--text);
  font-weight: 700;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.viewer {
  min-height: 420px;
  background: #fdfdfd;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 12px;
  overflow: auto;
}

.player {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.status {
  color: var(--muted);
  font-size: 14px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.inline-form input {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 15px;
  outline: none;
}

.section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 100%;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
}

.viewer-card,
.info-card {
  background: color-mix(in srgb, var(--accent) 4%, transparent);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.info-card h1 {
  margin: 4px 0 0;
  font-size: 24px;
}

.player-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.osmd {
  width: 100%;
  max-width: 100%;
  background: #ffffff;
  border-radius: 12px;
  padding: 12px;
  min-height: 520px;
  height: calc(100vh - 200px);
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  overflow-x: hidden;
}

@media (max-width: 768px) {
  .osmd {
    background: #ffffff;
    /* User requested white */
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Center the 'page' */
    gap: 20px;
  }

  .osmd svg {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-width: 100%;
    height: auto !important;
  }
}

.audio-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

@media (max-width: 1100px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {
  .header {
    flex-wrap: wrap;
  }

  .header-search {
    order: 3;
    width: 100%;
  }

  .header-links {
    width: 100%;
    justify-content: flex-start;
  }

  .hero {
    margin-top: 48px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .search-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px;
    margin: -12px -12px 16px;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 0 12px 32px;
  }

  .section {
    padding: 12px;
  }

  .viewer-card,
  .info-card {
    padding: 10px;
  }

  .section-head {
    align-items: flex-start;
  }

  .detail-grid {
    gap: 12px;
  }

  .header {
    padding: 12px;
    gap: 12px;
    flex-direction: column;
    align-items: stretch;
  }

  .header-search {
    grid-template-columns: 1fr;
    gap: 8px;
    max-width: 100%;
    border-radius: 18px;
  }

  .header-search button {
    width: 100%;
  }

  .brand {
    width: 100%;
    justify-content: flex-start;
  }

  .player-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
  }

  .player-bar .buttons {
    display: flex;
    gap: 10px;
  }

  .osmd {
    min-height: 320px;
    height: auto;
    max-height: none;
    padding: 8px;
  }

  .osmd svg {
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    display: block;
  }

  .search-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px;
    margin: -12px -12px 16px;
  }
}

/* Dialog Styles */
dialog {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  padding: 24px;
  box-shadow: var(--shadow);
  max-width: 400px;
  width: 90%;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

dialog h3 {
  margin: 0 0 12px;
  font-size: 20px;
}

dialog p {
  margin: 0 0 20px;
  color: var(--muted);
}

.transpose-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 24px;
}

.transpose-controls span {
  font-size: 24px;
  font-weight: 700;
  min-width: 40px;
  text-align: center;
}

.transpose-controls button {
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Footer styles */
.footer {
  text-align: center;
  padding: 24px 18px;
  margin-top: 24px;
  color: var(--muted);
  font-size: 14px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.footer a,
.footer button {
  text-decoration: none;
  padding: 2px 6px;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
  font-family: inherit;
  border: none;
  transition: background-color 120ms ease;
  display: inline;
  cursor: pointer;
}

.footer a:hover,
.footer button:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

/* Cookie Consent Banner */
.cookie-consent-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--panel);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 16px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.cookie-consent-banner.hidden {
  display: none;
}

.cookie-consent-message {
  flex: 1;
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
}

.cookie-consent-message a {
  color: var(--accent);
  text-decoration: underline;
}

.cookie-consent-buttons {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.consent-secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  box-shadow: none;
  font-weight: 600;
}

:root.dark .cookie-consent-banner .consent-secondary {
  color: #e2e8f0;
}

.consent-secondary:hover:not(:disabled) {
  background: var(--muted);
  color: var(--panel);
}

.consent-accept:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

/* Cookie Settings Modal */
.cookie-settings-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 101;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.cookie-settings-modal.hidden {
  display: none;
}

.cookie-settings-modal-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 24px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.cookie-settings-modal h3 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
}

.cookie-settings-modal-content p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 15px;
}

.cookie-settings-options {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.cookie-setting {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 2%, transparent);
  cursor: pointer;
  transition: border-color 120ms ease;
}

.cookie-setting:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
}

.cookie-setting input[type="checkbox"] {
  margin: 0;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
}

.cookie-setting div {
  flex: 1;
}

.cookie-setting strong {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}

.cookie-setting p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.cookie-modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

@media (max-width: 640px) {
  .cookie-consent-banner {
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
  }

  .cookie-consent-buttons {
    flex-direction: column;
    gap: 6px;
  }

  .cookie-consent-buttons button {
    width: 100%;
  }

  .cookie-settings-modal-content {
    padding: 16px;
  }

  .cookie-settings-options {
    gap: 12px;
  }

  .cookie-setting {
    padding: 10px;
    flex-direction: column;
    gap: 8px;
  }

  .cookie-setting input[type="checkbox"] {
    align-self: flex-start;
  }
}

@media (max-width: 640px) {
  .footer {
    padding: 20px 12px;
    margin-top: 20px;
  }
}