/* --------------------------------------------------------------------------
   ダーク基調・片手操作前提のレイアウト。
   ミニプレイヤーは全画面共通で下部固定（タブバー的なscope）。
   -------------------------------------------------------------------------- */
:root {
  --bg: #12111a;
  --surface: #1c1b26;
  --surface-2: #262435;
  --text: #f2f0f7;
  --text-dim: #a09cb4;
  --accent: #a78bfa;
  --line: #302e40;
  --appbar-h: 52px;
  --mini-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior-y: none;
  /* ダブルタップとピンチによる拡大を止める。縦スクロールだけ許可する */
  touch-action: pan-y;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  padding-top: env(safe-area-inset-top, 0px);
}

body.player-open { overflow: hidden; }

svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg polygon, svg rect { fill: currentColor; stroke: none; }

button, input { font: inherit; color: inherit; }

/* ---- 画面の骨格 ---- */
.screen {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - env(safe-area-inset-top, 0px));
}
.screen[hidden] { display: none; }

.appbar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: var(--appbar-h);
  padding: 0 4px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.appbar__title {
  flex: 1;
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appbar__spacer { width: 44px; flex: none; }

/* ---- アプリ名。アイコンの波形と配色に合わせる ---- */
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.brand__bars {
  display: flex;
  align-items: flex-end;
  gap: 2.5px;
  height: 16px;
  flex: none;
}
.brand__bars i {
  width: 3px;
  border-radius: 2px;
}
.brand__bars i:nth-child(1) { height: 7px; background: #b07cff; }
.brand__bars i:nth-child(2) { height: 12px; background: #7c5cff; }
.brand__bars i:nth-child(3) { height: 16px; background: #4f9bff; }
.brand__name {
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #fff;
}
/* 背景を文字型に切り抜けるなら、アイコンと同じ白→薄紫→青の流れを載せる */
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .brand__name {
    background: linear-gradient(100deg, #ffffff 0%, #ece6ff 45%, #a9c6ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 7px rgba(124, 92, 255, 0.45));
  }
}

.iconbtn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  flex: none;
  border: 0; background: none; color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
}
.iconbtn:active { background: var(--surface-2); }

.scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--safe-bottom) + 16px);
}
/* ミニプレイヤーが出ているときだけ、その分の余白を確保する */
body.is-playing .scroll { padding-bottom: calc(var(--mini-h) + var(--safe-bottom) + 16px); }
/* 中身が少ない画面では、下端に置きたい要素を押し下げる */
.scroll.is-empty { display: flex; flex-direction: column; }
.home__bottom { margin-top: auto; }

/* ---- 並び替えトグル（常時固定・1タップで反転） ---- */
.sortbar {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.sortbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.sortbtn:active { background: var(--accent); color: #17131f; }
.sortbtn__icon { width: 18px; height: 18px; flex: none; }
.sortbtn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sortbtn.is-on { border-color: var(--accent); color: var(--accent); }

/* ---- 汎用リスト行（ホーム / 検索結果） ---- */
.row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 16px;
  border-bottom: 1px solid var(--line);
}
.row__art {
  width: 52px;
  height: 52px;
  flex: none;
  margin-right: 12px;
  border-radius: 10px;
  background: var(--surface-2);
  object-fit: cover;
}
.row__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 0;
  color: inherit;
  text-decoration: none;
}
.row__title { font-size: 15px; font-weight: 600; }
.row__meta { font-size: 12px; color: var(--text-dim); }
.row__remove {
  width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 10px;
  background: none; color: var(--text-dim);
  cursor: pointer;
}
.row__remove:active { background: var(--surface-2); }

/* ---- エピソード行 ---- */
.ep {
  display: flex;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  /* 数百件を一度に並べるため、画面外の行は組版と描画を省く */
  content-visibility: auto;
  contain-intrinsic-size: auto 84px;
}
.ep.is-playing { background: var(--surface); }
.ep__play {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 14px 8px 14px 16px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.ep__play:active { background: var(--surface); }
.ep__menu {
  width: 44px;
  align-self: stretch;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
}
.ep__menu:active { background: var(--surface-2); color: var(--accent); }
/* 縦三点はCSSで描く。行ごとにSVGを置くと要素数が跳ね上がるため */
.ep__menu i {
  display: block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 -6px currentColor, 0 6px currentColor;
}

/* ---- 操作メニュー（下から出るシート） ---- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet[hidden] { display: none; }
.sheet__backdrop { position: absolute; inset: 0; background: #000000a6; }
.sheet__panel {
  position: relative;
  padding: 8px 12px calc(12px + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
}
.sheet__title {
  margin: 4px 8px 10px;
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sheet__item {
  display: block;
  width: 100%;
  min-height: 54px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.sheet__item + .sheet__item { margin-top: 8px; }
.sheet__item:active { background: var(--line); }
.sheet__item--cancel { background: none; color: var(--text-dim); text-align: center; font-weight: 400; }
.ep__dot {
  width: 8px; height: 8px;
  margin-top: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
}
.ep.is-read .ep__dot { background: transparent; border: 1px solid var(--line); }
.ep__body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.ep__title { font-size: 15px; font-weight: 600; }
.ep.is-read .ep__title { font-weight: 400; color: var(--text-dim); }
.ep__meta { font-size: 12px; color: var(--text-dim); }
.ep__bar { height: 3px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.ep__bar i { display: block; height: 100%; background: var(--accent); }

/* ---- 検索フォーム ---- */
.searchbar { display: flex; gap: 8px; padding: 12px 16px; flex: none; }
.searchbar__field { position: relative; flex: 1; min-width: 0; display: flex; }
.searchbar__input {
  flex: 1; min-width: 0;
  height: 42px;
  padding: 0 40px 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
/* 端末が出す消去ボタンと重ならないよう、こちらだけを使う */
.searchbar__input::-webkit-search-cancel-button { display: none; }
.searchbar__clear {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
}
.searchbar__clear[hidden] { display: none; }
.searchbar__clear:active { color: var(--text); background: var(--surface-2); }
.searchbar__clear svg { width: 18px; height: 18px; }
.searchbar__btn {
  height: 42px; padding: 0 16px;
  border: 0; border-radius: 12px;
  background: var(--accent); color: #17131f;
  font-weight: 700;
  cursor: pointer;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 18px;
  border: 0; border-radius: 12px;
  background: var(--accent); color: #17131f;
  font-weight: 700; text-decoration: none;
  cursor: pointer;
}
.btn--small { min-height: 34px; padding: 0 14px; font-size: 13px; flex: none; }
.btn:disabled { background: var(--surface-2); color: var(--text-dim); }

.placeholder { padding: 32px 16px; color: var(--text-dim); text-align: center; }
.tip {
  margin: 0 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.tip__lead { margin: 0 0 8px; font-size: 14px; font-weight: 700; color: var(--accent); }
.tip p { margin: 0; font-size: 13px; line-height: 1.7; color: var(--text-dim); }
.tip__install { margin-top: 14px; }
.tip__icon {
  width: 15px;
  height: 15px;
  margin: 0 3px;
  vertical-align: -3px;
  color: var(--text);
}
.version {
  display: block;
  width: 100%;
  padding: 16px;
  border: 0;
  background: none;
  color: var(--text-dim);
  font-size: 11px;
  text-align: center;
  cursor: pointer;
}
.empty { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 48px 16px 16px; color: var(--text-dim); }

/* ---- ミニプレイヤー ---- */
.mini {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  height: calc(var(--mini-h) + var(--safe-bottom));
  padding: 0 8px var(--safe-bottom) 16px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
}
.mini[hidden] { display: none; }
.mini__tap {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
  color: inherit; text-decoration: none;
}
.mini__title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini__show { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini__bar { height: 2px; margin-top: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.mini__bar i { display: block; height: 100%; background: var(--accent); }
.mini__btn {
  width: 48px; height: 48px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 14px;
  background: none; color: var(--text);
  cursor: pointer;
}
.mini__btn:active { background: var(--surface); }

/* ---- 使い方 ---- */
.help {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding-top: env(safe-area-inset-top, 0px);
}
.help[hidden] { display: none; }
.help__body { padding: 8px 20px calc(32px + var(--safe-bottom)); }
.help__body h2 {
  margin: 24px 0 8px;
  font-size: 15px;
  color: var(--accent);
}
.help__body h2:first-child { margin-top: 12px; }
.help__body p { margin: 0 0 10px; font-size: 14px; line-height: 1.75; color: #d7d3e4; }
.help__body ul { margin: 0 0 10px; padding-left: 20px; }
.help__body li { font-size: 14px; line-height: 1.75; color: #d7d3e4; margin-bottom: 4px; }
.help__body b { color: var(--text); }

/* ---- フルプレイヤー ---- */
.player {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding-top: env(safe-area-inset-top, 0px);
}
.player[hidden] { display: none; }
.player__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding: 24px 24px calc(32px + var(--safe-bottom));
}
.player__show { margin: 0; font-size: 13px; color: var(--text-dim); }
.player__title { margin: 0 0 12px; font-size: 20px; line-height: 1.4; }
.player__seek {
  width: 100%;
  accent-color: var(--accent);
  /* 親が pan-y なので、横方向にドラッグするシークバーだけは自前で操作を受け取る */
  touch-action: none;
}
.player__times { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-dim); }
.player__controls { display: flex; align-items: center; justify-content: center; gap: 28px; margin-top: 16px; }
.ctrl {
  position: relative;
  width: 56px; height: 56px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--surface-2); color: var(--text);
  cursor: pointer;
}
.ctrl span {
  position: absolute;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.ctrl svg { width: 30px; height: 30px; }
.ctrl--main { width: 72px; height: 72px; background: var(--accent); color: #17131f; }
.ctrl--main svg { width: 30px; height: 30px; }
.ratebtn {
  align-self: center;
  margin-top: 20px;
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ---- トースト ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 16px);
  transform: translateX(-50%);
  z-index: 40;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: #000000cc;
  font-size: 13px;
}
.toast[hidden] { display: none; }
.toast { display: flex; align-items: center; gap: 12px; }
body.is-playing .toast { bottom: calc(var(--mini-h) + var(--safe-bottom) + 16px); }
.toast__action {
  flex: none;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
