/* Dark by default: this is used while playing along with music, often in a
   dim room, and a white screen between the player and the instrument is
   the wrong thing to look at. */
:root {
  --bg: #12131a;
  --surface: #1c1e28;
  --surface-high: #252838;
  --text: #e8e9f0;
  --dim: #9095a8;
  --accent: #7c6cf0;
  --danger: #e05a6a;
  --outline: #333749;
  --radius: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans",
               "Noto Sans JP", system-ui, sans-serif;
  /* Installed to the home screen on iOS the page runs under the status bar
     and the home indicator, so the safe areas are not optional. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

.hidden { display: none !important; }
.dim { color: var(--dim); }
.error { color: var(--danger); }

.bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--outline);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.bar h1 {
  font-size: 15px; margin: 0; flex: 1; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

main { padding: 14px; max-width: 720px; margin: 0 auto; }
section#mixer-view { padding: 12px 14px 40px; max-width: 720px; margin: 0 auto; }

/* --------------------------------------------------------------- controls */
button {
  font: inherit;
  color: var(--text);
  background: var(--surface-high);
  border: 1px solid var(--outline);
  border-radius: 9px;
  padding: 10px 14px;
  cursor: pointer;
}
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.small { padding: 6px 11px; font-size: 12px; }
button.wide { width: 100%; padding: 13px; }
.icon-button { background: none; border: none; font-size: 20px; padding: 6px 10px; color: var(--text); }
.icon-button.active { color: var(--accent); }

input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  height: 26px;
}
input[type="password"] {
  width: 100%;
  padding: 11px;
  border-radius: 9px;
  border: 1px solid var(--outline);
  background: var(--surface-high);
  color: var(--text);
  font: inherit;
}

.card { background: var(--surface); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.hint { color: var(--dim); font-size: 12px; line-height: 1.6; margin: 6px 0 0; }
.section-title { font-size: 11px; color: var(--dim); letter-spacing: 0.1em; margin: 24px 0 6px; }
.track { height: 6px; background: var(--surface-high); border-radius: 3px; overflow: hidden; margin: 10px 0; }
.fill { height: 100%; width: 0; background: var(--accent); transition: width 0.25s linear; }

/* ----------------------------------------------------------------- unlock */
.unlock { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 24px; }
.unlock-inner { width: 100%; max-width: 280px; text-align: center; }
.unlock h1 { font-size: 20px; margin: 0 0 6px; letter-spacing: 0.02em; }
.unlock input {
  text-align: center; letter-spacing: 0.5em; font-size: 20px; margin: 16px 0 12px;
}

/* ---------------------------------------------------------------- library */
.picker {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 13px; background: var(--surface-high);
}
.picker-icon {
  width: 38px; height: 38px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 18px;
  background: rgba(124, 108, 240, 0.18); color: var(--accent);
}
.picker strong { display: block; font-size: 14px; font-weight: 600; }
.picker small { display: block; font-size: 11px; margin-top: 2px; }

.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 12px 0; }
.mode { padding: 9px 6px; text-align: center; line-height: 1.35; }
.mode strong { display: block; font-size: 12px; font-weight: 600; }
.mode small { display: block; font-size: 10px; color: var(--dim); margin-top: 2px; }
.mode.selected { border-color: var(--accent); background: rgba(124, 108, 240, 0.16); }
.mode.selected strong { color: var(--accent); }

.switches { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.switch { display: flex; align-items: center; gap: 9px; padding: 7px 2px; font-size: 13px; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }

.library { list-style: none; margin: 0; padding: 0; }
.library li {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 4px; border-bottom: 1px solid var(--outline);
}
.library .art {
  width: 42px; height: 42px; border-radius: 9px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 15px;
  background: var(--surface-high); color: var(--accent);
}
.library .name { flex: 1; min-width: 0; }
.library .name strong {
  display: block; font-size: 14px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.library .name span { font-size: 11px; color: var(--dim); }

/* ------------------------------------------------------------------ mixer */
.now-playing { display: flex; align-items: center; gap: 4px; margin-bottom: 12px; }
.now-playing .titles { flex: 1; min-width: 0; }
.title { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artist { font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chord-lane {
  display: flex; align-items: stretch; gap: 8px;
  background: var(--surface); border-radius: 10px;
  padding: 6px 8px; margin-bottom: 10px; overflow: hidden;
}
.chord-key { font-size: 11px; line-height: 1.3; align-self: center; white-space: nowrap; }
.chord-cells { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.chord-cells::-webkit-scrollbar { display: none; }
.chord-cell {
  flex: 0 0 auto; min-width: 50px; text-align: center;
  padding: 7px 9px; border-radius: 8px;
  background: rgba(124, 108, 240, 0.14); color: var(--accent);
  font-weight: 600; font-size: 13px;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}
.chord-cell.current { background: var(--accent); color: #fff; font-weight: 800; transform: scale(1.06); }
.chord-cell.past { opacity: 0.35; }

.lyric-strip { text-align: center; margin-bottom: 8px; min-height: 40px; }
#lyric-current { font-size: 15px; font-weight: 700; min-height: 21px; }
#lyric-next { font-size: 12px; min-height: 17px; }

.transport { display: flex; align-items: center; gap: 9px; }
.transport .time { font-size: 11px; color: var(--dim); width: 38px; }
.buttons { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 4px 0 14px; }
.play {
  width: 54px; height: 54px; border-radius: 50%; padding: 0;
  background: var(--accent); border-color: var(--accent); color: #fff; font-size: 20px;
}
.small-play { width: 40px; height: 40px; font-size: 15px; }

.quick { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.master { flex: 1; font-size: 12px; }
.master span:first-child { width: 30px; }
.master span:last-child { width: 42px; text-align: right; }

.stems { list-style: none; margin: 0; padding: 0; }
.stems li { background: var(--surface); border-radius: 10px; padding: 8px 12px 4px; margin-bottom: 7px; }
.stem-head { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.stem-head .dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.stem-head .label { flex: 1; font-weight: 600; }
.stem-head .value { font-size: 11px; color: var(--dim); width: 38px; text-align: right; }
.toggle { width: 30px; height: 27px; padding: 0; font-size: 12px; font-weight: 700; color: var(--dim); }
.toggle.on { color: var(--accent); border-color: var(--accent); }
.toggle.muted { color: var(--danger); border-color: var(--danger); }

/* ----------------------------------------------------------------- lyrics */
.lyrics-scroll {
  height: calc(100vh - 170px);
  height: calc(100dvh - 170px);
  overflow-y: auto;
  padding: 40vh 20px;
  scroll-behavior: smooth;
}
.lyric-line {
  text-align: center; padding: 11px 0; font-size: 16px; color: var(--dim);
  transition: color 0.25s, font-size 0.25s;
  cursor: pointer;
}
.lyric-line.current { color: var(--accent); font-size: 21px; font-weight: 700; }
.lyric-line.past { opacity: 0.45; }
.lyrics-transport {
  position: sticky; bottom: 0; background: var(--bg);
  border-top: 1px solid var(--outline);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
}

/* ---------------------------------------------------------------- dialogs */
dialog {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--outline); border-radius: var(--radius);
  padding: 18px; max-width: 420px; width: calc(100% - 32px);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin: 0 0 12px; font-size: 15px; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 16px 0 0; }
.field { display: block; margin-bottom: 8px; }
.field > span { display: block; font-size: 12px; color: var(--dim); margin-bottom: 4px; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--surface-high); border: 1px solid var(--outline);
  border-radius: 9px; padding: 10px 16px; font-size: 13px; z-index: 20;
  max-width: calc(100% - 32px); text-align: center;
}
