/* ============================================
   材木町お囃子会 — 会員専用（譜面・アレンジ編集） v4.2
   iPhone を基準にした「アプリ型」の画面。
   上：操作の帯 ／ 中：譜面（画面の残りをすべて使う） ／ 下：操作の帯
   選ぶ・保存するなどは、下から出る「シート」で行う。
   ============================================ */

/* ---------- 画面の骨組み ---------- */
.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; background: #e8e4da; }
.app-bar, .app-foot { flex: none; display: flex; align-items: center; gap: 8px; background: var(--sumi); color: #fff; }
.app-bar {
  padding: max(6px, env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px)) 6px max(8px, env(safe-area-inset-left, 0px));
}
.app-foot {
  justify-content: space-between;
  padding: 6px max(8px, env(safe-area-inset-right, 0px)) max(6px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
}
.app-main { position: relative; flex: 1 1 0; min-height: 0; background: #e8e4da; }

.icon-btn, .foot-btn {
  flex: none; display: inline-grid; place-items: center;
  width: 48px; height: 48px; padding: 0; border: 0; border-radius: 8px; cursor: pointer;
  background: transparent; color: inherit; font: inherit; font-size: 20px; font-weight: 700; text-decoration: none;
}
.foot-btn { background: rgba(255, 255, 255, .14); }
.foot-btn.wide { width: 64px; }
.icon-btn:disabled, .foot-btn:disabled { opacity: .3; cursor: default; }
.icon-btn[hidden], .foot-btn[hidden] { display: none; }
.app-bar svg, .app-foot svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.app :focus-visible { outline: 2px solid var(--ki); outline-offset: 2px; }

/* いま開いているもの（押すと選ぶシートが出る） */
.app-pick {
  flex: 1 1 0; min-width: 0; min-height: 48px; padding: 2px 12px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 8px;
  background: rgba(255, 255, 255, .12); color: #fff; border: 0; border-radius: 8px; cursor: pointer; text-align: left; font: inherit;
}
.app-pick b { display: block; font-family: var(--display); font-weight: 400; font-size: 19px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-pick small { display: block; font-size: 12px; line-height: 1.4; color: var(--usu); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-pick svg { grid-column: 2; grid-row: 1 / span 2; width: 18px; height: 18px; }
.app-save { flex: none; min-height: 48px; padding: 0 18px; border: 0; border-radius: 8px; cursor: pointer; background: var(--ki); color: var(--sumi); font: inherit; font-size: 15px; font-weight: 700; }
.count { font-family: var(--display); font-size: 19px; letter-spacing: .1em; font-variant-numeric: tabular-nums; }
.foot-group { display: flex; align-items: center; gap: 8px; }

/* 譜面を置く場所：右から左へ読むので、横スクロールも右端から始まる。
   二本指で広げると拡大する（ページ全体の拡大は止めてある） */
/* 譜面は、一枚の紙のように周りに余白をとって置く */
.pages {
  position: absolute; overflow: auto; direction: rtl;
  inset: 10px max(10px, env(safe-area-inset-right, 0px)) 10px max(10px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column;
  scroll-snap-type: x proximity; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y; background: #fffdf8;
  border-radius: 10px; box-shadow: 0 0 0 1px rgba(20, 17, 13, .07), 0 2px 8px rgba(20, 17, 13, .06);
}
.pages.is-zoomed { scroll-snap-type: none; }
.pages:has(.paged):not(.is-zoomed) { scroll-snap-type: x mandatory; }

/* ページに分けた譜面：1ページ＝画面の幅。列はページのまん中に寄せる */
.sc.paged { padding-inline: 0; gap: 0; justify-content: flex-start; }
.sc-page {
  flex: none; display: flex; align-items: flex-start; justify-content: center; gap: calc(var(--rh) * .4);
  width: calc(var(--rh) * var(--pw)); padding-inline: calc(var(--rh) * .8);
  scroll-snap-align: start;
}
.sc-page .sc-item { scroll-snap-align: none; }
.sc-page .sc-bar { align-self: stretch; }

.toast {
  position: absolute; left: 50%; top: 8px; z-index: 5; transform: translateX(-50%); width: max-content;
  max-width: calc(100% - 24px); padding: 8px 14px; border-radius: 8px;
  background: rgba(20, 17, 13, .92); color: #fff; font-size: 14px; font-weight: 700; line-height: 1.5; text-align: center;
  pointer-events: none; transition: opacity .3s ease;
}
.toast:empty { opacity: 0; }

/* ============================================
   譜面そのもの（.sc）
   --rh が1マスの高さ。丸・線・文字はすべてこの値から決まる。
   ============================================ */
.sc {
  --rh: 20px; --off: calc(var(--rh) * 1.39); --head: calc(var(--rh) * 1.6);
  display: flex; align-items: flex-start; justify-content: center; gap: calc(var(--rh) * .4);   /* 画面より短い譜面は中央に寄せる */
  width: max-content; min-width: 100%; margin-block: auto;      /* 紙の上下のまん中に置く */
  padding: calc(var(--rh) * .2) calc(var(--rh) * .8) calc(var(--rh) * .5);
  direction: rtl; color: #4a463f;
}
.sc-item { flex: none; direction: ltr; scroll-snap-align: start; }
.sc-title {
  margin-top: var(--head); padding-inline: calc(var(--rh) * .3);
  writing-mode: vertical-rl; font-family: var(--display); font-size: calc(var(--rh) * 1.7); line-height: 1.2; letter-spacing: .12em; color: var(--sumi);
}
.sc-col { width: calc(var(--rh) * 3.9); }
.sc-col.wr { padding-right: calc(var(--rh) * 1.1); width: calc(var(--rh) * 5); }
.sc-col.wl { padding-left: calc(var(--rh) * 1.1); width: calc(var(--rh) * 5); }
.sc-col.wr.wl { width: calc(var(--rh) * 6.1); }
.sc-head {
  height: var(--head); display: flex; align-items: center; justify-content: center; gap: .4em;
  font-size: calc(var(--rh) * .74); font-weight: 700; line-height: 1; white-space: nowrap;
}
.sc-mark { font-size: calc(var(--rh) * 1.05); font-weight: 400; }
.sc-rep { padding: .25em .9em 0; border-top: 1px solid #6b665d; border-radius: 50% 50% 0 0 / 100% 100% 0 0; }
.sc-q { color: var(--shu); font-size: calc(var(--rh) * .9); }
.sc-tag {                                                  /* 列の頭の札（ステップ1 など） */
  padding: .2em .5em; border: 1px solid #6b665d; border-radius: 2px;
  font-size: calc(var(--rh) * .52); font-weight: 700; letter-spacing: .04em; color: #4a463f;
}
.sc-foot {                                                 /* 列の下の一言（Ⓐへ、同じく など） */
  margin-top: calc(var(--rh) * .4); text-align: center;
  font-size: calc(var(--rh) * .56); font-weight: 700; line-height: 1.4; color: var(--shu);
}
.sc-foot::before { content: "→ "; }

/* 譜面の下の注意書き（横書き） */
.memo {
  position: absolute; z-index: 1; bottom: 10px;
  left: max(10px, env(safe-area-inset-left, 0px)); right: max(10px, env(safe-area-inset-right, 0px));
  padding: 10px 14px 12px; white-space: pre-line;
  background: #fffdf8; border-top: 1px solid rgba(20, 17, 13, .1); border-radius: 0 0 10px 10px;
  box-shadow: 0 0 0 1px rgba(20, 17, 13, .07), 0 2px 8px rgba(20, 17, 13, .06);
  font-size: 13px; line-height: 1.7; color: var(--nezu);
}
.memo[hidden] { display: none; }
.has-memo .pages { border-radius: 10px 10px 0 0; }
.sc-cells { position: relative; margin-top: calc(var(--rh) * var(--top, 0)); }

.cell { position: relative; display: block; width: 100%; height: var(--rh); padding: 0; border: 0; background: none; color: inherit; font: inherit; }
.cell.b4 { box-shadow: inset 0 1px 0 rgba(20, 17, 13, .22); }       /* 1拍（4マス）ごとの線 */
.ch {
  position: absolute; inset: 0; z-index: 1; display: grid; place-items: center;
  writing-mode: vertical-rl; text-orientation: upright;
  font-family: var(--text); font-size: calc(var(--rh) * .86); line-height: 1; white-space: nowrap;
}
/* 丸：右側＝右手、左側＝左手。大きい丸＝強く。白丸は ○ */
.m {
  --d: calc(var(--rh) * .62);
  position: absolute; z-index: 2; top: 50%; width: var(--d); height: var(--d);
  border-radius: 50%; background: var(--sumi); transform: translate(-50%, -50%);
}
.ml { left: calc(50% - var(--off)); }
.mr { left: calc(50% + var(--off)); }
.m2 { --d: calc(var(--rh) * .96); }
.m3 { --d: calc(var(--rh) * 1.08); }
.mo { background: #fff; box-shadow: inset 0 0 0 1.5px var(--sumi); }
.mw { --d: calc(var(--rh) * .78); background: #fff; box-shadow: inset 0 0 0 1.5px var(--sumi), inset 0 0 0 calc(var(--d) * .2) #fff, inset 0 0 0 calc(var(--d) * .2 + 1.5px) var(--sumi); }   /* 二重丸（鉦） */
.sl { position: absolute; left: calc(50% + var(--rh) * .62); width: 0; border-left: 1.5px solid var(--sumi); }                       /* 傍線（鉦） */
.m.pop { animation: pop .22s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { from { transform: translate(-50%, -50%) scale(.3); } to { transform: translate(-50%, -50%) scale(1); } }
/* つなぐ線：右手の丸から、次のマスの左手の丸へ */
.cell.lk::before {
  content: ""; position: absolute; z-index: 0; left: calc(50% + var(--off)); top: 50%;
  width: calc(var(--rh) * 2.954); height: 1px; background: #9a958b;
  transform-origin: 0 50%; transform: rotate(160.2deg);
}
.hl { position: absolute; left: 50%; width: calc(var(--rh) * 1.6); transform: translateX(-50%); background: rgba(20, 17, 13, .1); border-radius: 2px; }
.wedge { position: absolute; width: calc(var(--rh) * .9); overflow: visible; }
.wedge path { fill: none; stroke: #9a958b; stroke-width: 1; vector-effect: non-scaling-stroke; }
.wedge.wr { left: calc(50% + var(--off) + var(--rh) * .7); }
.wedge.wl { right: calc(50% + var(--off) + var(--rh) * .7); }

.sc-note {
  margin-top: calc(var(--head) + var(--rh) * var(--top, 0));
  max-height: calc(var(--rh) * var(--rows, 16)); padding-inline: calc(var(--rh) * .3);
  writing-mode: vertical-rl; text-orientation: upright;
  font-size: calc(var(--rh) * .8); line-height: 1.5; letter-spacing: .06em;
}
.sc-note.boxed { padding: calc(var(--rh) * .5) calc(var(--rh) * .35); border: 1px solid #6b665d; }
.sc-label { font-size: calc(var(--rh) * .72); }
.sc-bar { align-self: stretch; width: 1px; margin-inline: calc(var(--rh) * .4); background: #b9b4aa; }

/* ============================================
   笛の運指（.fu）：横に指穴7つ（左が口元）、縦に時間。下へ送って読む
   --u が指穴ひとつぶんの幅。画面の幅から決まる。
   ============================================ */
.pages.is-fue { display: block; direction: ltr; scroll-snap-type: none; overflow-x: hidden; }
.app-foot.is-vert .wide svg { transform: rotate(-90deg); }          /* めくる矢印を上下向きに */
.fu { --u: min(38px, calc((100vw - 32px) / 10.6)); width: calc(var(--u) * 10.6); max-width: 100%; margin-inline: auto; padding: 0 0 48px; color: #4a463f; }
.fu-row {
  display: grid; grid-template-columns: repeat(3, var(--u)) calc(var(--u) * .7) repeat(4, var(--u)) minmax(0, 1fr);
  align-items: center; height: calc(var(--u) * .84);
}
.fu-row.thin { height: calc(var(--u) * .5); }
.fu-row.gap { height: calc(var(--u) * .55); }
.fu-cols {
  position: sticky; top: 0; z-index: 2; height: 34px;
  background: #fffdf8; box-shadow: 0 1px 0 rgba(20, 17, 13, .2);
  font-size: 13px; font-weight: 700; color: var(--nezu); text-align: center;
}
.fu-cols .fu-t { font-size: 12px; text-align: left; white-space: nowrap; writing-mode: horizontal-tb; }
.fh { justify-self: center; width: calc(var(--u) * .66); height: calc(var(--u) * .66); border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 1.5px var(--fc, var(--sumi)); }
.fh.on { background: var(--fc, var(--sumi)); }
.fh.tap { box-shadow: inset 0 0 0 1.5px var(--fc, var(--sumi)), inset 0 0 0 calc(var(--u) * .14) #fff, inset 0 0 0 calc(var(--u) * .14 + 1.5px) var(--fc, var(--sumi)); }
.fu-sp { grid-column: 4; }
.fu-t { grid-column: 9; justify-self: start; padding-left: .5em; font-size: calc(var(--u) * .56); line-height: 1; writing-mode: vertical-rl; text-orientation: upright; }   /* 縦に読むので「ー」も縦向きに */
.fu-row.c-r { --fc: #d0271d; color: #b3211a; }       /* 元の譜の色をそのまま写す */
.fu-row.c-o { --fc: #c9631a; color: #a34f12; }
.fu-row.c-g { --fc: #a9a49b; color: #7c776e; }
.fu-head { margin: 22px 0 6px; padding-top: 12px; border-top: 2px solid var(--sumi); font-family: var(--display); font-size: 19px; line-height: 1.5; color: var(--sumi); }
.fu-cols + .fu-head { margin-top: 10px; border-top: 0; padding-top: 0; }
.fu-label { margin: 10px 0 2px; font-size: 14px; font-weight: 700; color: var(--shu); }
.fu-blk { padding-block: 8px; }
.fu-blk + .fu-blk { border-top: 1px solid rgba(20, 17, 13, .16); }

/* ---------- 編集するときの譜面 ---------- */
.is-edit .sc-col { background: #fff; border-radius: calc(var(--rh) * .3); box-shadow: 0 0 0 1px rgba(20, 17, 13, .16); }
.is-edit .sc-head { justify-content: space-between; padding-inline: calc(var(--rh) * .35); color: var(--nezu); font-size: calc(var(--rh) * .5); }
.is-edit .cell { cursor: pointer; -webkit-tap-highlight-color: transparent; box-shadow: inset 0 -1px 0 rgba(20, 17, 13, .09); }
.is-edit .cell.b4 { box-shadow: inset 0 1.5px 0 rgba(20, 17, 13, .4), inset 0 -1px 0 rgba(20, 17, 13, .09); }
/* まん中の細い線：ここより右が右手、左が左手 */
.is-edit .sc-cells::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 0; border-left: 1px dashed rgba(20, 17, 13, .16); }
.is-edit .cell:active { background: rgba(240, 212, 58, .35); }
.is-edit .cell.sel { background: var(--ki); }
.is-edit .cell:focus-visible { outline: 2px solid var(--shu); outline-offset: -2px; }
.sc-menu {
  width: calc(var(--rh) * 1.6); height: calc(var(--rh) * 1.3); padding: 0; border: 0; border-radius: calc(var(--rh) * .3); cursor: pointer;
  background: rgba(20, 17, 13, .08); color: var(--sumi); font: inherit; font-size: calc(var(--rh) * .9); font-weight: 700; line-height: 1;
}
/* 列を足す：点線の枠に ＋ */
.sc-add {
  width: calc(var(--rh) * 3); height: calc(var(--rh) * 16); margin-top: var(--head); padding: 0; cursor: pointer;
  display: grid; place-items: center;
  background: transparent; color: var(--nezu); border: 2px dashed #a9a396; border-radius: calc(var(--rh) * .3);
  font: inherit; font-size: calc(var(--rh) * 1.8); font-weight: 400; line-height: 1;
}
.sc-add:active { background: rgba(240, 212, 58, .35); }

/* ============================================
   下から出るシート（選ぶ・保存する・列の操作・文字）
   ============================================ */
.sheet { position: fixed; inset: 0; z-index: 150; display: flex; align-items: flex-end; justify-content: center; background: rgba(12, 10, 8, .5); }
.sheet[hidden] { display: none; }
.sheet-card {
  width: 100%; max-width: 560px; max-height: 88vh; max-height: 88dvh; overflow: auto;
  padding: 8px max(16px, env(safe-area-inset-right, 0px)) max(20px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: #fff; color: var(--sumi); border-radius: 18px 18px 0 0;
  animation: sheetUp .28s var(--ease);
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-head h2 { font-family: var(--display); font-weight: 400; font-size: 22px; line-height: 1.4; }
.sheet-close { color: var(--sumi); font-size: 26px; font-weight: 400; }
.sheet-body { display: grid; gap: 18px; padding-top: 6px; }
.sheet :focus-visible { outline-color: var(--shu); }
.m-label { margin-bottom: 8px; font-size: 13px; font-weight: 700; letter-spacing: .12em; color: var(--nezu); }
.sheet-note { font-size: 13px; line-height: 1.8; color: var(--nezu); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); border: 1.5px solid var(--sumi); border-radius: 8px; overflow: hidden; }
.seg button { min-height: 50px; padding: 6px 4px; background: #fff; color: var(--sumi); border: 0; cursor: pointer; font-family: var(--display); font-size: 20px; line-height: 1.3; }
.seg button + button { border-left: 1.5px solid var(--sumi); }
.seg button[aria-pressed="true"] { background: var(--ki); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 48px; padding: 8px 16px; cursor: pointer;
  background: #fff; color: var(--sumi); border: 1.5px solid #8b8478; border-radius: 8px;
  font-family: var(--display); font-size: 18px; line-height: 1.4;
}
.chip.small { min-height: 44px; padding: 6px 14px; font-family: var(--text); font-size: 14px; font-weight: 700; text-align: left; }
.chip[aria-pressed="true"] { background: var(--sumi); border-color: var(--sumi); color: #fff; }
.chip.ch1 { min-width: 48px; padding-inline: 8px; text-align: center; font-family: var(--text); font-size: 20px; }
.btn-main, .btn-sub {
  width: 100%; min-height: 54px; padding: 10px 16px; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: 16px; font-weight: 700;
}
.btn-main { background: var(--sumi); color: #fff; border: 0; }
.btn-sub { background: #fff; color: var(--sumi); border: 1.5px solid var(--sumi); }
.btn-sub[hidden] { display: none; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 700; letter-spacing: .1em; }
.field input {
  width: 100%; min-height: 50px; padding: 8px 12px;
  font: inherit; font-size: 16px; font-weight: 400; letter-spacing: .03em; color: var(--sumi);
  background: #fff; border: 1.5px solid #8b8478; border-radius: 8px;
}
.field input:focus { outline: none; border-color: var(--sumi); box-shadow: 0 0 0 4px var(--ki); }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.row2 .btn-sub { width: auto; min-height: 50px; }

/* 絵で選ぶボタン（列の操作） */
.acts { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 10px; }
.act {
  display: grid; justify-items: center; gap: 6px; min-height: 88px; padding: 12px 6px 8px; cursor: pointer;
  background: #f6f4ee; color: var(--sumi); border: 0; border-radius: 12px; font: inherit; font-size: 12px; font-weight: 700; line-height: 1.4;
}
.act svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.act.danger { color: var(--shu); }
.act:active { background: var(--ki); }

.legend { display: grid; gap: 10px; font-size: 15px; }
.legend span { display: flex; align-items: center; gap: 12px; }
.dot { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--sumi); }
.dot.d3 { width: 20px; height: 20px; }
.dot.do { width: 16px; height: 16px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--sumi); }
.dot.dw { width: 18px; height: 18px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--sumi), inset 0 0 0 4px #fff, inset 0 0 0 5.5px var(--sumi); }

/* 下の帯：丸／文字 の切り替え */
.mode { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(72px, 1fr); border-radius: 8px; overflow: hidden; background: rgba(255, 255, 255, .14); }
.mode button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 14px; border: 0; cursor: pointer; background: transparent; color: #fff; font: inherit; font-size: 15px; font-weight: 700;
}
.mode button[aria-pressed="true"] { background: var(--ki); color: var(--sumi); }
.mode .dot { background: currentColor; }

/* ---------- 入口（プレビュー用のパスワード画面） ---------- */
.gate {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center; padding: var(--pad);
  background: var(--sumi); color: #f4f0e7;
}
.gate[hidden] { display: none; }
.gate-card { width: 100%; max-width: 400px; text-align: center; }
.gate-mark {
  width: 52px; height: 72px; margin: 0 auto 28px;
  display: grid; place-items: center;
  background: #fff; color: var(--sumi);
  border-block: 8px solid var(--shu); border-radius: 24px / 28px;
  font-family: var(--display); font-size: 30px; line-height: 1;
}
.gate-title { font-family: var(--display); font-weight: 400; font-size: clamp(34px, 8vw, 48px); line-height: 1.3; }
.gate-sub { margin-top: 10px; font-size: 15px; color: var(--usu); }
.gate-form { display: grid; gap: 12px; margin-top: 28px; text-align: left; }
.gate-form label { font-size: 13px; font-weight: 700; letter-spacing: .1em; }
.gate-input {
  width: 100%; min-height: 56px; padding: 12px 16px;
  background: #fff; color: var(--sumi); border: 0; border-radius: 8px;
  font: inherit; font-size: 16px; letter-spacing: .1em;
}
.gate-input:focus { outline: none; box-shadow: 0 0 0 4px var(--ki); }
.gate-submit { min-height: 56px; border: 0; border-radius: 8px; cursor: pointer; background: var(--ki); color: var(--sumi); font: inherit; font-weight: 700; letter-spacing: .12em; }
.gate-error { min-height: 1.8em; font-size: 14px; font-weight: 700; color: #ffb4a6; }
.gate-back { display: inline-block; margin-top: 20px; padding: 10px; font-size: 14px; color: var(--usu); text-underline-offset: 4px; }

@media (prefers-reduced-motion: reduce) {
  .sheet-card, .m.pop { animation: none; }
}
@media print {
  .app { height: auto; overflow: visible; }
  .app-bar, .app-foot, .gate, .sheet, .toast { display: none !important; }
  .pages { position: static; overflow: visible; }
  .sc { flex-wrap: wrap; width: auto; }
}

/* ============================================
   v5：見る画面。曲は下の帯で選ぶ（タップ1つ）。楽器は上の右のボタンから
   ============================================ */
.icon-btn { width: 44px; height: 44px; }
.app-title { flex: 1 1 0; min-width: 0; padding-left: 2px; }
.app-title b { display: block; font-family: var(--display); font-weight: 400; font-size: 20px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-title small { display: block; min-height: 1.3em; font-size: 11.5px; line-height: 1.3; color: var(--usu); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-btn {
  flex: none; display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 10px 0 16px; cursor: pointer;
  background: rgba(255, 255, 255, .14); color: #fff; border: 0; border-radius: 22px;
  font-family: var(--display); font-size: 18px; line-height: 1;
}
.app-bar .who-btn svg { width: 16px; height: 16px; }

/* 下の帯 */
.dock {
  flex: none; display: grid; gap: 6px; background: var(--sumi); color: #fff;
  padding: 8px max(8px, env(safe-area-inset-right, 0px)) max(4px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
}
.dock-pieces { display: grid; gap: 6px; }
.dock-pieces[hidden] { display: none; }
.dock-row { display: flex; gap: 6px; }
.pc {
  position: relative; flex: 1 1 0; min-width: 0; min-height: 42px; padding: 2px 2px; cursor: pointer;
  display: grid; place-items: center; align-content: center;
  background: rgba(255, 255, 255, .13); color: #fff; border: 0; border-radius: 8px;
  font-family: var(--display); font-size: min(15.5px, 3.9vw); line-height: 1.15; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.pc small { display: block; margin-bottom: 1px; font-family: var(--text); font-size: 9.5px; font-weight: 700; letter-spacing: .1em; line-height: 1.2; color: var(--usu); }
.pc:active { background: rgba(255, 255, 255, .26); }
.pc[aria-pressed="true"] { background: var(--ki); color: var(--sumi); }
.pc[aria-pressed="true"] small { color: rgba(20, 17, 13, .66); }
.pc.none:not([aria-pressed="true"]) { color: rgba(255, 255, 255, .42); background: rgba(255, 255, 255, .06); }
.pc.is-next { box-shadow: inset 0 0 0 2px var(--ki); }                /* 譜に書いてある「このあとの曲」 */
.pc.is-next::after {
  content: "つぎ"; position: absolute; top: -6px; right: -2px; padding: 1px 6px; border-radius: 8px;
  background: var(--ki); color: var(--sumi); font-family: var(--text); font-size: 9.5px; font-weight: 700; line-height: 1.5;
}
.dock-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.dock-pieces:not([hidden]) + .dock-tabs { border-top: 1px solid rgba(255, 255, 255, .16); }
.tab {
  position: relative; min-height: 42px; padding: 0 2px; cursor: pointer; background: transparent; color: var(--usu); border: 0;
  font: inherit; font-size: 13px; font-weight: 700; white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.tab[aria-pressed="true"] { color: #fff; }
.tab[aria-pressed="true"]::before { content: ""; position: absolute; left: 22%; right: 22%; bottom: 3px; height: 3px; border-radius: 2px; background: var(--ki); }
@media (max-height: 620px) {
  .pc { min-height: 36px; }
  .tab { min-height: 36px; }
}

/* ページの位置は曲名の下に小さく出す。拡大しているあいだは、元に戻すボタンを右下に出す */
.app-title .count { margin-left: .9em; font-family: var(--text); font-size: 11.5px; font-weight: 700; letter-spacing: .08em; color: #fff; }
.app-title .count:empty { display: none; }
.fit-btn {
  position: absolute; z-index: 4; right: 20px; bottom: 20px; display: inline-grid; place-items: center; width: 48px; height: 48px; padding: 0; cursor: pointer;
  background: rgba(20, 17, 13, .86); color: #fff; border: 0; border-radius: 50%;
}
.fit-btn[hidden] { display: none; }
.fit-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* 左右に続きがあるときの目印（端をタップするとめくれる） */
.app-main::before, .app-main::after {
  content: ""; position: absolute; z-index: 3; top: 50%; width: 9px; height: 9px; margin-top: -5px; pointer-events: none;
  border-left: 2px solid rgba(20, 17, 13, .42); border-bottom: 2px solid rgba(20, 17, 13, .42); opacity: 0; transition: opacity .2s;
}
.app-main::before { left: 20px; transform: rotate(45deg); }
.app-main::after { right: 20px; transform: rotate(-135deg); }
.app-main.more-l::before, .app-main.more-r::after { opacity: 1; }
.empty { margin: auto; padding: 24px; direction: ltr; text-align: center; font-size: 15px; line-height: 1.9; color: var(--nezu); }

/* 附け：同じフレーズは同じ色の丸（色付きの譜と同じ） */
.m { background: var(--mc, var(--sumi)); }
.mo { background: #fff; box-shadow: inset 0 0 0 1.5px var(--mc, var(--sumi)); }
.mw { background: #fff; box-shadow: inset 0 0 0 1.5px var(--mc, var(--sumi)), inset 0 0 0 calc(var(--d) * .2) #fff, inset 0 0 0 calc(var(--d) * .2 + 1.5px) var(--mc, var(--sumi)); }
.ph-red { --mc: #d93025; }
.ph-blue { --mc: #1c63c7; }
.ph-green { --mc: #189a4f; }
.ph-yellow { --mc: #dba100; }
.ph-sky { --mc: #17a3dc; }
.ph-orange { --mc: #e56f17; }
.cell.cr { --mc: #d0271d; color: #b3211a; }                           /* 元の譜で赤くしてある、変えたところ */
.dot.ph { background: conic-gradient(#d93025 0 33%, #1c63c7 0 66%, #189a4f 0); }

/* シートの中 */
.seg5 button { font-size: 18px; }
.seg-note { margin-top: 8px; }
.btn-link { display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn-link[hidden] { display: none; }
.btn-link svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.howto { border-top: 1px solid rgba(20, 17, 13, .14); border-bottom: 1px solid rgba(20, 17, 13, .14); }
.howto summary { min-height: 50px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; font-size: 15px; font-weight: 700; list-style: none; }
.howto summary::-webkit-details-marker { display: none; }
.howto summary::after { content: "＋"; font-weight: 400; font-size: 20px; }
.howto[open] summary::after { content: "－"; }
.howto > :not(summary) { margin-bottom: 14px; }
.legend[hidden], .sheet-note[hidden] { display: none; }

/* ============================================
   合わせ譜（.sy）：附け・玉・鉦の同じ小節を横に並べ、上から下へ読む
   ============================================ */
.pages.is-sync { display: block; direction: ltr; scroll-snap-type: none; overflow-x: hidden; }
.sy { --rh: 22px; --gut: 24px; --off: calc(var(--rh) * 1.39); --head: 0px; padding-bottom: 56px; color: #4a463f; }
.sy-row { display: grid; grid-template-columns: var(--gut) repeat(3, minmax(0, 1fr)); }
.sy.has-fue .sy-row { grid-template-columns: var(--gut) calc(var(--rh) * 2.2) repeat(3, minmax(0, 1fr)); }
.sy-head {
  position: sticky; top: 0; z-index: 3; height: 34px; align-items: center; text-align: center;
  background: #fffdf8; box-shadow: 0 1px 0 rgba(20, 17, 13, .22); font-size: 13px; font-weight: 700; color: var(--sumi);
}
.sy-note { padding: 8px 12px; font-size: 12px; line-height: 1.7; color: var(--nezu); border-bottom: 1px solid rgba(20, 17, 13, .12); }
.sy-ref { padding: 10px 12px 12px; border-bottom: 1px solid rgba(20, 17, 13, .12); font-size: 13px; line-height: 1.75; }
.sy-ref b { display: block; font-size: 12px; color: var(--shu); }
.sy-ref small { display: block; margin-top: 4px; font-size: 11.5px; color: var(--nezu); }
.sy-bar {
  position: relative; border-bottom: 1.5px solid #6b665d;
  background: repeating-linear-gradient(to bottom, rgba(20, 17, 13, .14) 0 1px, transparent 1px calc(var(--rh) * 4));     /* 1拍ごとの横線 */
}
.sy-bar.has-mark { border-top: 3px double #6b665d; }
.sy-no { padding-top: 3px; text-align: center; font-size: 10.5px; font-weight: 700; line-height: 1.3; color: var(--nezu); background: #f5f2ea; }
.sy-no b { display: block; font-size: 15px; font-weight: 400; color: var(--shu); }
.sy-lane { display: flex; justify-content: center; min-width: 0; border-left: 1px solid rgba(20, 17, 13, .1); }
.sy .sc-head, .sy .sc-foot { display: none; }
.sy .sc-col { width: 100%; max-width: calc(var(--rh) * 3.9); }
.sy .cell.b4 { box-shadow: none; }
.sy-fue {
  flex-direction: column; align-items: center; justify-content: space-evenly; padding-block: calc(var(--rh) * .3);
  font-size: calc(var(--rh) * .7); line-height: 1.02; color: #3a352d; background: rgba(240, 212, 58, .12);
}
.sy-fue span { writing-mode: vertical-rl; text-orientation: upright; white-space: nowrap; }
.sy-fue .sub { font-size: .8em; color: var(--nezu); }
.howto[hidden] { display: none; }
.howto + .howto { border-top: 0; margin-top: -18px; }
.about { white-space: pre-line; font-size: 14px; line-height: 1.9; color: var(--sumi); }
.pages.is-sync .empty, .pages.is-fue .empty { padding-top: 38%; }
.app-main > .toast { top: auto; bottom: 14px; }          /* 見る画面のお知らせは、譜面の下のほうに出す */

/* スマホを横にしたとき：高さが足りないので、下の帯を1段にまとめて横に送れるようにする */
@media (orientation: landscape) and (max-height: 480px) {
  .dock { display: flex; gap: 6px; overflow-x: auto; padding-top: 6px; scrollbar-width: none; }
  .dock::-webkit-scrollbar { display: none; }
  .dock-pieces { display: flex; flex: none; }
  .dock-row { flex: none; }
  .pc { flex: none !important; min-height: 40px; padding-inline: 12px; }
  .dock-tabs { flex: none; display: flex; }
  .dock-pieces:not([hidden]) + .dock-tabs { border-top: 0; border-left: 1px solid rgba(255, 255, 255, .2); padding-left: 6px; }
  .tab { min-height: 40px; padding-inline: 12px; }
  .tab[aria-pressed="true"]::before { left: 12px; right: 12px; bottom: 2px; }
  .app-title b { font-size: 17px; }
  .app-bar { padding-block: 2px; }
}

/* 拍どおりの列：いちばん下に、列（16マス）の終わりの線 */
.sc-col.beat .sc-cells { box-shadow: 0 1.5px 0 rgba(20, 17, 13, .5); }
.sy .sc-col.beat .sc-cells { box-shadow: none; }          /* 合わせ譜は、小節の区切り線がその役をする */
.cell.cue .ch { color: #8f897e; }                         /* 目安として入れた、附けの叩き方（白丸） */


/* WordPress に置いたとき：ログアウトはリンクになる */
a.btn-sub { display: flex; align-items: center; justify-content: center; text-decoration: none; }
