:root {
  --bg: #faf6ef;
  --surface: #ffffff;
  --surface-2: #f3ecdf;
  --text: #26221a;
  --text-muted: #6b6357;
  --border: #e2d8c5;
  --accent: #2f7d4f;
  --accent-contrast: #ffffff;
  --accent-soft: #e3efe6;
  --ring: #2f7d4f;
  --shadow: 0 1px 3px rgba(38, 34, 26, 0.08);
  --header-h: 64px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #12131c;
  --surface: #1a1c28;
  --surface-2: #232636;
  --text: #eceef5;
  --text-muted: #9aa0b4;
  --border: #2e3245;
  --accent: #4cc07a;
  --accent-contrast: #0c1a12;
  --accent-soft: #1d2f26;
  --ring: #4cc07a;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: 96px;
}
h1, h2, h3 { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; }
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1080px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { font-size: 1.35rem; margin: 0; display: flex; align-items: center; gap: 10px; letter-spacing: -0.01em; }
.brand-mark { width: 26px; height: 26px; color: var(--accent); flex: none; }
.brand-sub { color: var(--text-muted); font-weight: 400; font-style: italic; }
.header-controls { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.search-wrap { position: relative; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
#search {
  width: min(300px, 56vw); padding: 9px 12px 9px 34px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font-size: 16px;
}
#search::placeholder { color: var(--text-muted); }

/* Icon buttons */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: none; border-radius: 10px;
  background: transparent; color: var(--text);
  transition: background-color 160ms ease;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
.icon-sun { display: none; }

/* Tabs */
.tabs {
  max-width: 1080px; margin: 20px auto 0; padding: 0 16px;
  display: flex; gap: 8px;
}
.tab {
  padding: 10px 18px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-muted); font-weight: 600;
  transition: background-color 160ms ease, color 160ms ease;
  min-height: 44px;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.tab .count { font-weight: 400; opacity: 0.85; font-size: 0.85em; }

/* Toolbar */
.toolbar {
  max-width: 1080px; margin: 16px auto; padding: 0 16px;
  display: flex; gap: 12px; align-items: end; flex-wrap: wrap;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.field select {
  min-height: 44px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font-size: 15px; max-width: 230px;
}
.toolbar-spacer { flex: 1; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); font-weight: 600;
  transition: background-color 160ms ease, transform 120ms ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.97); }
.btn svg { width: 18px; height: 18px; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn-accent:hover { background: var(--accent); filter: brightness(1.08); }

/* Song list */
#song-list { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.meter-group { margin-bottom: 8px; }
.meter-head {
  position: sticky; top: var(--header-h); z-index: 10;
  display: flex; align-items: baseline; gap: 10px;
  padding: 10px 4px 8px; margin: 0;
  background: var(--bg); border-bottom: 2px solid var(--accent);
  font-size: 1.15rem;
}
.meter-head .count { color: var(--text-muted); font-size: 0.85rem; font-family: -apple-system, sans-serif; font-weight: 400; }
.meter-head .meter-name { color: var(--accent); font-size: 0.9rem; font-style: italic; font-weight: 400; }
.lyrics { max-height: 380px; white-space: pre-wrap; }
.song {
  border-bottom: 1px solid var(--border);
}
.song-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 4px; border: none; background: none; text-align: left;
  transition: background-color 120ms ease;
  border-radius: 8px;
}
.song-row:hover { background: var(--surface-2); }
.song.playing .song-row { background: var(--accent-soft); }
.song-play {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--accent);
}
.song.playing .song-play { background: var(--accent); color: var(--accent-contrast); }
.song-play svg { width: 16px; height: 16px; }
.song-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.song-tags { flex: none; display: flex; gap: 6px; align-items: center; }
.tag {
  font-size: 0.72rem; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-muted); white-space: nowrap;
}
.tag-key { font-variant-numeric: tabular-nums; }
.song-detail {
  padding: 6px 12px 18px 52px;
  display: grid; gap: 10px;
  animation: reveal 200ms ease;
}
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.song-detail dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 0.9rem; }
.song-detail dt { color: var(--text-muted); }
.song-detail dd { margin: 0; }
.song-detail .abc {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; overflow-x: auto; font: 12.5px/1.45 ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  max-height: 300px; overflow-y: auto; white-space: pre;
}
.song-links { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.9rem; }
.preview-note { font-size: 0.82rem; color: var(--text-muted); font-style: italic; }
.empty-state { text-align: center; color: var(--text-muted); padding: 64px 16px; }
.show-more { display: block; margin: 20px auto; }

/* Player bar */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
  padding-bottom: env(safe-area-inset-bottom);
}
.player-progress { height: 4px; background: var(--surface-2); cursor: pointer; }
.player-progress-fill { height: 100%; width: 0; background: var(--accent); transition: width 250ms linear; }
.player-inner {
  max-width: 1080px; margin: 0 auto; padding: 8px 16px;
  display: flex; align-items: center; gap: 16px;
}
.player-now { flex: 1; min-width: 0; }
.player-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-meta { font-size: 0.8rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-controls { display: flex; align-items: center; gap: 4px; }
.play-btn { background: var(--accent); color: var(--accent-contrast); width: 52px; height: 52px; border-radius: 50%; }
.play-btn:hover { background: var(--accent); filter: brightness(1.08); }
.icon-pause { display: none; }
.player.playing .icon-pause { display: block; }
.player.playing .icon-play { display: none; }
#shuffle-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.player-time { font-variant-numeric: tabular-nums; font-size: 0.85rem; color: var(--text-muted); min-width: 44px; text-align: right; }

/* Footer */
.site-footer {
  max-width: 1080px; margin: 48px auto 0; padding: 16px;
  font-size: 0.85rem; color: var(--text-muted);
  border-top: 1px solid var(--border);
}

@media (max-width: 640px) {
  .header-inner { gap: 8px; }
  .brand { font-size: 1.1rem; }
  .brand-sub { display: none; }
  .song-tags .tag-cat { display: none; }
  .song-detail { padding-left: 8px; }
  .player-time { display: none; }
  .field select { max-width: 44vw; }
}
