/* fastchord — minimal, no frameworks */

:root {
  --bg: #fbfbf9;
  --fg: #17181c;
  --muted: #77787d;
  --faint: #a3a49f;
  --line: #e4e3de;
  --soft: #f0efeb;
  --accent: #a6402b;
  --accent-soft: #f6ece8;
  --content-size: 16px;
  --radius: 3px;
  --bar-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e10;
    --fg: #e9e8e4;
    --muted: #8d8e93;
    --faint: #64656a;
    --line: #24252a;
    --soft: #17181c;
    --accent: #e0856d;
    --accent-soft: #241a17;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Segoe UI", "Leelawadee UI", "Noto Sans Thai", "Hiragino Sans",
    "Yu Gothic UI", "Malgun Gothic", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-soft); }

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

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* ---------------------------------------------------------------- top bar */

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--bar-h);
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--fg);
  flex: none;
}

.bar-fav {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-size: 19px;
  line-height: 1;
  color: var(--muted);
  border-radius: var(--radius);
}
.bar-fav:hover { background: var(--soft); color: var(--accent); }

.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 460px;
  margin-left: auto;
}

.search-icon {
  position: absolute;
  left: 10px;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--faint);
  stroke-width: 1.6;
  stroke-linecap: round;
  pointer-events: none;
}

#q {
  width: 100%;
  height: 34px;
  padding: 0 30px 0 32px;
  font: inherit;
  font-size: 14px;
  color: var(--fg);
  background: var(--soft);
  border: 1px solid transparent;
  border-radius: var(--radius);
  outline: none;
  transition: border-color .15s, background .15s;
}

#q::placeholder { color: var(--faint); }

#q:focus {
  border-color: var(--line);
  background: var(--bg);
}

#q::-webkit-search-cancel-button { -webkit-appearance: none; }

.search kbd {
  position: absolute;
  right: 9px;
  font-family: inherit;
  font-size: 11px;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0 4px;
  line-height: 15px;
  pointer-events: none;
}

.search kbd.hide { display: none; }

/* ------------------------------------------------------------------ shell */

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px 40vh;
}

.hidden { display: none !important; }

/* ------------------------------------------------------------------- home */

.home,
.favs { padding-top: 28px; }

.home-empty {
  padding: 64px 0 0;
  color: var(--faint);
  font-size: 14px;
}

.home-empty strong {
  display: block;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--fg);
  margin-bottom: 8px;
}

.group { margin-bottom: 32px; }

.group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}

.group-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
}

.group-action {
  font-size: 12px;
  color: var(--faint);
}

.group-action:hover { color: var(--accent); }

/* ------------------------------------------------------------------- list */

.list { border-top: 1px solid var(--line); }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  cursor: pointer;
}

.row:hover, .row:focus-visible {
  background: var(--soft);
  outline: none;
}

.row.active { background: var(--soft); }

.row-main { min-width: 0; flex: 1; }

.row-title {
  font-size: 15px;
  font-weight: 550;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-sub {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.row-meta {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.key-pill {
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1px 5px;
  font-size: 11px;
  color: var(--muted);
}

.src {
  font-size: 10px;
  letter-spacing: .05em;
  color: var(--faint);
}

.row-fav {
  flex: none;
  color: var(--faint);
  font-size: 15px;
  padding: 4px 2px;
  line-height: 1;
}

.row-fav.on { color: var(--accent); }

.status {
  padding: 28px 0;
  font-size: 14px;
  color: var(--faint);
}

.status.err { color: var(--accent); }

/* ------------------------------------------------------------------- song */

.song { padding-top: 26px; }

.song-head { margin-bottom: 18px; }

.song-title {
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin: 0;
  text-wrap: balance;
}

.song-artist {
  margin-top: 4px;
  font-size: 14px;
  color: var(--muted);
}

.song-artist a { border-bottom: 1px solid transparent; }
.song-artist a:hover { border-color: var(--line); }

.song-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--faint);
}

.song-flags span { display: inline-flex; align-items: center; gap: 4px; }

/* toolbar */

.toolbar {
  position: sticky;
  top: var(--bar-h);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0 -20px 22px;
  padding: 6px 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}

.toolbar::-webkit-scrollbar { display: none; }

.tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 30px;
  min-width: 30px;
  padding: 0 8px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.tool:hover { background: var(--soft); color: var(--fg); }
.tool:active { transform: translateY(1px); }
.tool.on { color: var(--accent); background: var(--accent-soft); }

.tool strong {
  font-weight: 600;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  min-width: 22px;
  text-align: center;
}

.tool.on strong { color: var(--accent); }

.tool-label { font-size: 11px; letter-spacing: .02em; }

.sep {
  width: 1px;
  height: 16px;
  background: var(--line);
  margin: 0 6px;
  flex: none;
}

.spacer { flex: 1 1 0; min-width: 8px; }

/* floating auto-scroll bar — always reachable with both hands free */
.scroll-dock {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom, 16px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18), 0 1px 2px rgba(0, 0, 0, 0.08);
}

.dock-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: none;
  font-size: 19px;
  line-height: 1;
  color: var(--fg);
  border-radius: 999px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.dock-btn:hover,
.dock-btn:focus-visible {
  background: var(--soft);
  color: var(--accent);
  outline: none;
}

.dock-speed {
  width: 38px;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.dock-play {
  width: 56px;
  height: 44px;
  font-size: 14px;
  color: var(--bg);
  background: var(--accent);
}

.dock-play:hover,
.dock-play:focus-visible {
  background: var(--accent);
  color: var(--bg);
  opacity: 0.85;
}

/* content */

.song-body {
  font-size: var(--content-size);
  line-height: 1.5;
  overflow-wrap: break-word;
}

.block { margin: 0 0 0.7em; }

.block.sec {
  margin: 1.6em 0 0.5em;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
}

.block.sec:first-child { margin-top: 0; }

.block.gap { height: 0.7em; margin: 0; }

/* one lyric line */
.line { margin: 0 0 0.95em; line-height: 1.4; }

.chunk {
  display: inline-block;
  vertical-align: top;
  max-width: 100%;
  padding-right: 0.14em;
}

/* chord with no lyric text under it (e.g. a lone "sky" carrying 4 chords) */
.chunk.only { padding-right: 0.45em; }
.chunk.only:last-child { padding-right: 0; }

.chunk .c {
  display: block;
  height: 1.15em;
  margin-bottom: 0.1em;
  font-size: 0.72em;
  line-height: 1.15em;
  font-weight: 650;
  color: var(--accent);
  white-space: nowrap;
  user-select: none;
}

.chunk .t {
  display: block;
  overflow-wrap: anywhere;
}

/* line with chords only */
.chordline {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.55em;
  margin: 0 0 0.55em;
}

.chordline .c { height: auto; min-height: 0; display: inline; line-height: 1.35; }

.chordline .sp { width: 0; }

/* no-chord lyric line */
.lyr { margin: 0 0 0.5em; color: var(--fg); }

.song-body.nolyrics .lyr { color: var(--muted); }

/* source note */
.song-note {
  margin-top: 40px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--faint);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
}

.song-note a { color: var(--muted); border-bottom: 1px solid var(--line); }
.song-note a:hover { color: var(--accent); }

.empty-hint {
  margin-top: 6px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

/* ------------------------------------------------------------------ toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  background: var(--fg);
  color: var(--bg);
  font-size: 13px;
  padding: 7px 14px;
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 50;
  max-width: 80vw;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------------- responsive */

@media (max-width: 560px) {
  .bar { padding: 0 14px; gap: 10px; height: 52px; --bar-h: 52px; }
  :root { --bar-h: 52px; }
  .brand { font-size: 14px; }
  #q { height: 32px; font-size: 13px; }
  .search kbd { display: none; }
  main { padding: 0 14px 50vh; }
  .song-title { font-size: 22px; }
  .toolbar { margin-left: -14px; margin-right: -14px; padding: 5px 10px; }
  .song { padding-top: 20px; }
}
