:root {
  --bs: 1; /* blockScale 0.75–1.5 */
  --ink: #2b2620;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #efe9df;
  font-family: 'Rubik', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: #2b2620;
}

a { color: #3B5FA0; }
a:hover { color: #2c4a80; }

button { font-family: inherit; }

.app {
  height: 100dvh;
  max-width: 540px;
  margin: 0 auto;
  background: #faf7f1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(60,45,20,.12);
  color: #2b2620;
}

/* ---------- Library ---------- */

.lib-header { padding: 28px 22px 18px; }

.mini-xylo {
  display: flex;
  gap: 5px;
  align-items: flex-end;
  margin-bottom: 18px;
}

.mini-bar {
  width: 34px;
  border-radius: 6px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 5px;
  font-size: 13px;
  font-weight: 700;
}

.lib-title {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -.5px;
}

.lib-sub {
  margin: 6px 0 0;
  font-size: 15px;
  color: #7d7466;
}

.lib-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 18px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: #fff;
  border: 1px solid #e8e1d5;
  border-radius: 16px;
  padding: 16px 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.card:hover {
  border-color: #c9bfae;
  box-shadow: 0 4px 14px rgba(60,45,20,.08);
}
.card:active { transform: scale(.985); }

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title { font-size: 19px; font-weight: 700; }

.chip {
  font-size: 12.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
  white-space: nowrap;
}

.preview { display: flex; gap: 4px; }
.preview div { width: 14px; height: 22px; border-radius: 4px; }

.card-meta { font-size: 13px; color: #8d8375; }

/* ---------- Song view ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
}

.btn-back {
  border: 1px solid #e0d8c9;
  background: #fff;
  border-radius: 12px;
  width: 42px;
  height: 42px;
  font-size: 20px;
  cursor: pointer;
  color: #2b2620;
}
.btn-back:hover, .btn-restart:hover { background: #f3eee4; }

.topbar-info { flex: 1; min-width: 0; }

.song-title {
  font-size: 19px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-meta { font-size: 12.5px; color: #8d8375; }

.btn-restart {
  border: 1px solid #e0d8c9;
  background: #fff;
  border-radius: 12px;
  height: 42px;
  padding: 0 14px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  color: #2b2620;
}

.toggle {
  display: flex;
  gap: 4px;
  margin: 2px 16px 10px;
  background: #efe9dd;
  border-radius: 12px;
  padding: 4px;
}
.toggle button {
  flex: 1;
  border: none;
  border-radius: 9px;
  height: 38px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  background: transparent;
  color: #6d6456;
}
.toggle button.active {
  background: #2b2620;
  color: #fff;
}

.refstrip {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  padding: 6px 16px 12px;
  border-bottom: 1px solid #eee7da;
}
.ref-bar {
  flex: 1;
  border-radius: 5px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 3px;
  font-size: 11px;
  font-weight: 700;
  transition: box-shadow .15s;
}
.ref-bar.ring { box-shadow: 0 0 0 3px #2b2620; }

.notation {
  flex: 1;
  overflow-y: auto;
  position: relative;
  padding: 20px 16px 30px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.phrase {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  row-gap: 18px;
  align-items: flex-start;
}

.note {
  width: calc(58px * var(--bs));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: opacity .2s;
}
.note.long { width: calc(98px * var(--bs)); }
.note.done { opacity: .4; }

.block {
  width: 100%;
  height: calc(52px * var(--bs));
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(60,45,20,.18);
  transform: none;
  transition: transform .18s, box-shadow .18s;
}
.note.current .block {
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px #2b2620, 0 10px 22px rgba(0,0,0,.22);
  transform: scale(1.1);
}

.syl {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.1;
  text-align: center;
}
.note.current .syl { font-weight: 900; }

.syl2 {
  font-size: 11.5px;
  color: #8d8375;
  line-height: 1.1;
  text-align: center;
}

/* ---------- Bottom bar (auto mode) ---------- */

.bottombar {
  border-top: 1px solid #eee7da;
  background: #fff;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}

.bb-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-play {
  border: none;
  background: #2b2620;
  color: #fff;
  border-radius: 14px;
  height: 64px;
  padding: 0 28px;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  flex: none;
}
.btn-play.playing {
  background: #fff;
  color: #2b2620;
  border: 1px solid #e0d8c9;
}
.btn-play:active { transform: scale(.97); }

.bb-mid {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.cur-chip {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 900;
  flex: none;
}

.cur-info { min-width: 0; }

.cur-syl {
  font-size: 17px;
  font-weight: 900;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress {
  font-size: 12px;
  color: #8d8375;
  white-space: nowrap;
}

.tempo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: none;
  width: 110px;
}
.tempo input { width: 100%; accent-color: #2b2620; }
.tempo-caption {
  font-size: 11.5px;
  color: #8d8375;
  white-space: nowrap;
}

.fin-text { flex: 1; font-size: 18px; font-weight: 900; }

.btn-again {
  border: none;
  background: #2b2620;
  color: #fff;
  border-radius: 14px;
  height: 56px;
  padding: 0 24px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.btn-again:hover { background: #403a31; }

.hidden { display: none !important; }

/* ---------- Print ---------- */

@media print {
  body { background: #fff; }
  .noprint { display: none !important; }
  .app, .notation {
    height: auto !important;
    overflow: visible !important;
    box-shadow: none !important;
  }
}
