:root {
  --accent: #57b6ea;
  --label-30: #4f8a73;
  --label-33: #557aa8;
  --font-latin: "Cormorant Garamond", "Shippori Mincho", serif;
  --font-ja: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #1d2433;
  color: var(--ink);
  font-family: var(--font-ja);
  font-weight: 500;
  /* 欧文書体の数字は背の揃った形で(上下に出入りする古風な数字は読みにくい) */
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
}

/* 画面いっぱいに窓辺の 3D。メニューと操作はその上に重ねる */
.player {
  position: relative;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  --calm: .9s cubic-bezier(.4, 0, .2, 1);
  /* 曇りガラス: 半透明に後ろの景色をぼかして透かす。文字は昼も夜も白。
     明るい景色の上でも白い文字が読めるよう、昼のガラスは少しだけ暗く曇らせる(夜の見た目は data-tone="dark") */
  --ink: #f4f6f8;
  --ink-soft: rgba(244, 246, 248, .78);
  --rule: rgba(255, 255, 255, .22);
  --glass-bg: rgba(38, 44, 50, .1);
  --glass-strong: rgba(38, 44, 50, .16);
  --glass-hover: rgba(255, 255, 255, .16);
  --glass-border: rgba(255, 255, 255, .32);
  --glass-shadow: 0 8px 30px rgba(10, 16, 22, .14);
  --ink-shadow: 0 1px 3px rgba(10, 16, 22, .32);
  --chip-on-bg: rgba(255, 255, 255, .95);   /* 選択中: 白地に黒い文字(昼も夜も同じ) */
  --chip-on-fg: #1f2427;
  --frost: blur(10px) saturate(.75);   /* 後ろの色は拾いすぎない(夜のランプで茶色っぽくならないように) */
  color: var(--ink);
  transition: color var(--calm);
}

.player[data-tone="dark"] {
  --ink: #f2f5f7;
  --ink-soft: rgba(242, 245, 247, .66);
  --rule: rgba(255, 255, 255, .14);
  --glass-bg: rgba(255, 255, 255, .07);
  --glass-strong: rgba(30, 32, 42, .24);
  --glass-hover: rgba(255, 255, 255, .14);
  --glass-border: rgba(255, 255, 255, .2);
  --glass-shadow: 0 8px 30px rgba(0, 0, 0, .25);
  --chip-on-bg: rgba(255, 255, 255, .95);
  --chip-on-fg: #1f2427;
  --ink-shadow: none;
}

/* 曇りガラスの共通の見た目 */
.icon-btn, .now, .drawer {
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: var(--frost);
  backdrop-filter: var(--frost);
  color: var(--ink);
  text-shadow: var(--ink-shadow);
  transition: background var(--calm), border-color var(--calm), color var(--calm), transform var(--calm), opacity var(--calm);
}

/* 選択中(白地)の文字には影を付けない */
.seg button[aria-pressed="true"], .song__notes { text-shadow: none; }

.stage {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- 左上: タイトル ---------- */
.top {
  position: absolute;
  z-index: 3;
  top: 22px;
  left: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.top__title {
  margin: 0;
  font-family: var(--font-latin);
  font-style: italic;
  font-weight: 500;
  font-size: 22px;
  letter-spacing: .02em;
  color: #fff;
  opacity: .9;
  text-shadow: 0 1px 12px rgba(0, 0, 0, .25);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  cursor: pointer;
  transition: background .5s ease;
}

.icon-btn svg { width: 22px; height: 22px; stroke: currentColor; }
.icon-btn:hover { background: var(--glass-hover); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- サイドメニュー ---------- */
.scrim {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: rgba(12, 18, 24, .12);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--calm);
}

.drawer {
  position: absolute;
  z-index: 5;
  top: 12px;
  bottom: 12px;
  left: 12px;
  width: min(380px, calc(100% - 24px));
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(16px) saturate(.75);
  backdrop-filter: blur(16px) saturate(.75);
  transform: translateX(calc(-100% - 24px));
  visibility: hidden;
}

.drawer.is-open { transform: none; visibility: visible; }
.drawer.is-open ~ .dock { opacity: .0; pointer-events: none; }
.player:has(.drawer.is-open) .scrim { opacity: 1; pointer-events: auto; }

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 10px 20px;
}

.drawer__head .icon-btn { box-shadow: none; background: transparent; border-color: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
.drawer__head .icon-btn:hover { background: var(--glass-hover); }

.drawer__tabs { display: flex; gap: 20px; padding-left: 4px; }

/* タブ: 選んでいる方の文字を濃くし、下に細い白い線を引く */
.drawer__tab {
  position: relative;
  padding: 8px 2px;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-family: var(--font-latin);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  transition: color .5s ease;
}

.drawer__tab::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  height: 1.5px;
  border-radius: 1px;
  background: #fff;
  transform: scaleX(0);
  transition: transform .5s ease;
}

.drawer__tab[aria-selected="true"] { color: var(--ink); }
.drawer__tab[aria-selected="true"]::after { transform: none; }
.drawer__tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.drawer__panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 20px 24px;
  /* スクロールはできるまま、バーは隠す */
  scrollbar-width: none;
}

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

.records {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* 曲リスト: 番号・曲名・長さの行を細い罫線で区切る */
.song {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 15px 10px 15px 4px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .6s ease, padding .6s ease;
}

li:first-child .song { border-top: 1px solid var(--rule); }
.song:hover { background: var(--glass-hover); }
.song:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.song__no {
  position: relative;
  width: 30px;
  height: 30px;
  font-family: var(--font-latin);
  font-size: 13px;
  line-height: 30px;
  text-align: center;
  color: var(--ink-soft);
  letter-spacing: .04em;
}

.song__title {
  overflow: hidden;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.song.is-active .song__title { font-weight: 700; }

/* 行: 曲のボタンと削除ボタン */
.records__row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; border-bottom: 1px solid var(--rule); }
.records__row--fixed { grid-template-columns: 1fr; }
.field__label--samples { margin-top: 30px; }
.records__row .song { border-bottom: 0; }
li.records__row:first-child { border-top: 1px solid var(--rule); }
li.records__row:first-child .song { border-top: 0; }
.records__empty { padding: 22px 4px; font-size: 13px; color: var(--ink-soft); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }

/* 削除: ふだんは控えめな ×。押すと「Delete」に変わり、もう一度押すと消える */
.song__del {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  margin-left: 2px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-family: var(--font-latin);
  font-size: 13px;
  font-weight: 600;
  opacity: .45;
  cursor: pointer;
  transition: opacity .4s ease, background .4s ease, color .4s ease;
}
.song__del svg { width: 15px; height: 15px; stroke: currentColor; }

/* 名前の変更: 削除の × の左に鉛筆。押すと曲名の位置が入力欄になる */
.song__edit {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ink-soft);
  opacity: .45;
  cursor: pointer;
  transition: opacity .4s ease, background .4s ease;
}
.song__edit svg { width: 15px; height: 15px; stroke: currentColor; }
.records__row:hover .song__edit, .song__edit:focus-visible { opacity: 1; }
.song__edit:hover { background: var(--glass-hover); }
.song__edit:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (hover: none) { .song__edit { opacity: .7; } }
.records__row.is-renaming .song { cursor: default; }
.records__row.is-renaming .song__edit, .records__row.is-renaming .song__del { visibility: hidden; }
.song__rename {
  min-width: 0;
  width: 100%;
  padding: 5px 10px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, .14);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 15px;
}
.song__rename:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.song__del span { display: none; }
.records__row:hover .song__del, .song__del:focus-visible { opacity: 1; }
.song__del:hover { background: var(--glass-hover); }
.song__del.is-confirm { opacity: 1; background: var(--chip-on-bg); color: var(--chip-on-fg); text-shadow: none; }
.song__del.is-confirm span { display: inline; }
.song__del:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (hover: none) { .song__del { opacity: .7; } }

/* 曲の追加 */
.add-song {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding: 9px 16px 9px 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--font-latin);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .5s ease;
}
.add-song:hover { background: var(--glass-hover); }
.add-song:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.add-song svg { width: 17px; height: 17px; stroke: currentColor; }
.add-note {
  margin: 10px 2px 0;
  font-family: var(--font-latin);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-soft);
  white-space: pre-line;
}
.add-note.is-error { color: #ffd6cc; }

.song__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-latin);
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: .04em;
  font-variant-numeric: lining-nums tabular-nums;
}

/* 30音・33音のしるし: 色を塗って白抜きの数字(昼も夜も読める濃さ) */
.song__notes {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--label-30);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.song[data-notes="33"] .song__notes { background: var(--label-33); }

/* ---------- 眺めの設定 ---------- */
.field__label {
  margin: 22px 0 10px;
  font-family: var(--font-latin);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: .16em;
  text-transform: uppercase;
}

.field__label:first-child { margin-top: 8px; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }

.seg button {
  padding: 9px 15px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-family: var(--font-latin);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .5s ease, border-color .5s ease, color .5s ease;
}

.seg button:hover { background: var(--glass-hover); }
.seg button[aria-pressed="true"] { background: var(--chip-on-bg); border-color: transparent; color: var(--chip-on-fg); }
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- 画面の下: 演奏中の曲と操作 ---------- */
.dock {
  position: absolute;
  z-index: 3;
  left: 22px;
  right: 22px;
  bottom: 20px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
  transition: opacity var(--calm);
}

.dock > * { pointer-events: auto; }


.now {
  width: min(280px, 100%);
  padding: 8px 8px 12px 16px;
  border-radius: 18px;
  cursor: pointer;
  transition: background var(--calm), border-color var(--calm), color var(--calm), transform var(--calm), opacity var(--calm),
    width .5s cubic-bezier(.4, 0, .2, 1);
}
/* 閉じたカードは小さく、開くと中の操作(テンポと Restart)が1行に並ぶ幅まで広がる */
.now.is-open { width: min(320px, 100%); }

/* 1段目: 曲名(タップで広がる)と再生の操作。2段目: 進み具合の線だけ(時間の数字は出さない) */
.now__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.now__name { min-width: 0; border-radius: 8px; }
.now__name:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.now__line { display: flex; align-items: center; gap: 12px; margin-top: 8px; padding-right: 8px; }
.now__line .now__progress { flex: 1; margin-top: 0; }
.now.is-open .now__line .now__progress { visibility: hidden; }

.now__no {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: 12px;
  color: var(--ink-soft);
}

.now__title {
  margin: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.now__progress {
  height: 2px;
  margin-top: 10px;
  border-radius: 1px;
  background: var(--rule);
}

.now__progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 1px;
  background: var(--ink-soft);
}

/* 広げたカード: 曲の位置(バー)・速さ・再生し直し。高さ 0 から中身の高さまで、ふわっと開く */
.now__edit {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  cursor: default;
  transition: grid-template-rows .5s cubic-bezier(.4, 0, .2, 1), opacity .4s ease;
}
.now.is-open .now__edit { grid-template-rows: 1fr; opacity: 1; }
.now__edit-inner { min-height: 0; overflow: hidden; padding-right: 8px; }
.now__seek {
  display: block;
  width: 100%;
  height: 20px;
  margin: 10px 0 0;
  background: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.now__seek::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: var(--rule); }
.now__seek::-moz-range-track { height: 3px; border-radius: 2px; background: var(--rule); }
.now__seek::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -5.5px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  -webkit-appearance: none;
  appearance: none;
}
.now__seek::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.now__seek:disabled { opacity: .4; cursor: default; }
.now__seek:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.now__time {
  font-family: var(--font-latin);
  font-size: 13px;
  color: var(--ink-soft);
  font-variant-numeric: lining-nums tabular-nums;
  white-space: nowrap;
}
.now__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
/* テンポ: Tempo ━━●━━ 100% */
.tempo { display: flex; flex: 1; align-items: center; gap: 10px; min-width: 190px; }
.tempo__label { font-family: var(--font-latin); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.tempo__range {
  flex: 1;
  min-width: 80px;
  height: 20px;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.tempo__range::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: var(--rule); }
.tempo__range::-moz-range-track { height: 3px; border-radius: 2px; background: var(--rule); }
.tempo__range::-webkit-slider-thumb { width: 14px; height: 14px; margin-top: -5.5px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); -webkit-appearance: none; appearance: none; }
.tempo__range::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.tempo__range:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.tempo__value {
  min-width: 52px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-family: var(--font-latin);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: lining-nums tabular-nums;
  cursor: pointer;
  transition: background .4s ease;
}
.tempo__value:hover { background: var(--glass-hover); }
.tempo__value:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.now__restart {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 9px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-family: var(--font-latin);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .5s ease;
}
.now__restart svg { width: 16px; height: 16px; stroke: currentColor; }
.now__restart:hover { background: var(--glass-hover); }
.now__restart:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* 再生の状態(時間・読み込み中など)は、画面には出さず読み上げだけに使う */
.deck__status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.deck__buttons { display: flex; gap: 2px; }

.deck__btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background .5s ease, color .5s ease, opacity .5s ease;
}

.deck__btn svg { width: 20px; height: 20px; fill: currentColor; stroke: currentColor; }
.deck__btn svg[fill="none"] { fill: none; }
.deck__btn:hover:not(:disabled) { background: var(--glass-hover); }
.deck__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.deck__btn:disabled { opacity: .3; cursor: default; }
.deck__btn[aria-pressed="true"] { background: var(--glass-hover); box-shadow: inset 0 0 0 1px var(--rule); }

/* ---------- スマホ ---------- */
@media (max-width: 640px) {
  .top { top: 14px; left: 14px; }
  .dock { left: 12px; right: 12px; bottom: 12px; flex-direction: column; align-items: stretch; gap: 8px; }
  .dock { align-items: flex-start; }
}
