:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --border: #e4e0d6;
  --text: #26215c;
  --text-secondary: #6b6880;
  --accent: #3c3489;
  --accent-light: #eeedfe;
  --chord: #d85a30;
  --danger: #a32d2d;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: var(--accent);
  color: #fff;
}
.topbar h1 {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
}
.icon-btn:active { background: rgba(255,255,255,0.3); }

.tabbar {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: calc(56px + env(safe-area-inset-top));
  z-index: 9;
}
.tabbar.hidden { display: none; }
.tab-btn {
  flex: 1;
  padding: 12px 0;
  background: none;
  border: none;
  font-size: 14px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 12px 32px;
}

.search-box {
  position: sticky;
  top: calc(56px + 45px + env(safe-area-inset-top));
  background: var(--bg);
  padding: 8px 0;
  z-index: 8;
}
.search-box input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 15px;
}

.song-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.song-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.song-row .num {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 62px;
  font-variant-numeric: tabular-nums;
}
.song-row .title {
  flex: 1;
  font-size: 15px;
}
.song-row .fav-star {
  color: #d8b400;
  font-size: 16px;
}
.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 20px;
  font-size: 14px;
}

.song-tabs {
  display: flex;
  gap: 8px;
  margin: 8px 0 14px;
}
.song-tabs button {
  flex: 1;
  padding: 8px 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
}
.song-tabs button.active {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.song-header {
  margin-bottom: 6px;
}
.song-header .title {
  font-size: 20px;
  font-weight: 600;
  margin: 4px 0 2px;
}
.song-header .subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
}
.song-actions {
  display: flex;
  gap: 8px;
  margin: 10px 0;
  flex-wrap: wrap;
  align-items: center;
}
.song-actions button, .song-actions .transpose-group {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.song-actions button.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}
.transpose-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
}
.transpose-group button {
  border: none;
  background: var(--accent-light);
  color: var(--accent);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1;
  padding: 0;
}
.transpose-group span {
  min-width: 40px;
  text-align: center;
  font-size: 13px;
}

.lyrics {
  font-size: 15px;
  line-height: 1.9;
}
.lyrics .comment {
  color: var(--text-secondary);
  font-size: 12px;
  font-style: italic;
  margin: 10px 0 2px;
}
.lyrics .info {
  color: var(--text-secondary);
  font-size: 12px;
  margin: 2px 0;
}
.lyrics .blank {
  height: 10px;
}
.lyrics .section {
  margin: 4px 0;
  padding-left: 10px;
  border-left: 3px solid transparent;
}
.lyrics .section.chorus,
.lyrics .section.bridge {
  border-left-color: var(--accent);
}
.lyrics .line {
  white-space: normal;
}
.frag {
  display: inline-block;
  position: relative;
  padding-top: 1.1em;
  white-space: pre;
}
.frag .chord {
  position: absolute;
  top: 0;
  left: 0;
  color: var(--chord);
  font-weight: 600;
  font-size: 0.78em;
  white-space: nowrap;
}

.pdf-frame {
  width: 100%;
  height: 78vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.pdf-missing {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 20px;
  font-size: 14px;
}

.setlist-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
}
.setlist-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
}
.setlist-songs {
  font-size: 13px;
  color: var(--text-secondary);
}
.new-setlist {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.new-setlist input {
  flex: 1;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.new-setlist button, .primary-btn {
  padding: 10px 16px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.small-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.small-btn.danger { color: var(--danger); border-color: var(--danger); }
.small-btn.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.setlist-card { cursor: pointer; }

.list-picker {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  margin: -4px 0 14px;
}
.list-picker-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.list-picker .new-setlist { margin-bottom: 0; }

.legal-footer {
  text-align: center;
  padding: 18px 8px 8px;
}
.legal-footer a {
  font-size: 12px;
  color: var(--text-secondary);
}
.legal {
  font-size: 14px;
  line-height: 1.7;
  padding-bottom: 20px;
}
.legal h2 {
  font-size: 17px;
  margin: 4px 0 12px;
}
.legal h3 {
  font-size: 14px;
  margin: 18px 0 4px;
  color: var(--accent);
}
.legal a { color: var(--accent); }

.account-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  max-width: 360px;
}
.account-box h3 {
  font-size: 14px;
  margin: 0 0 8px;
}
.account-box h3:not(:first-child) {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.account-box input {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  font-size: 14px;
}
.account-box .primary-btn {
  width: 100%;
}
.account-error {
  color: var(--danger);
  font-size: 12px;
  margin: 6px 0 0;
}
.account-hint {
  color: var(--text-secondary);
  font-size: 12px;
  margin: 16px 0 0;
}
.share-current {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  padding: 4px 6px 4px 10px;
  border-radius: 14px;
}
.chip-x {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 2px;
}
.hint-inline {
  font-size: 12px;
  color: var(--text-secondary);
}
.share-favs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.user-result {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.star-btn {
  border: none;
  background: none;
  color: #d8b400;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 4px;
}
.badge {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  vertical-align: middle;
}

.toast {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 50;
}
