:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-on: #0f172a;
  --danger: #f87171;
}

* { box-sizing: border-box; }
/* hidden 属性は UA スタイルシート由来で優先度が低く、display を設定する自作クラスに
   上書きされてしまうため、hidden な要素は常に非表示になるよう明示的に強制する */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 1.25rem) 1.25rem
           calc(env(safe-area-inset-bottom) + 1.25rem);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.app__header { text-align: center; position: relative; }
.app__title { font-size: 1.25rem; margin: 0; letter-spacing: 0.02em; }
.app__net { margin: 0.25rem 0 0; min-height: 1.1em; font-size: 0.8rem; color: var(--accent); }
.app__logout {
  position: absolute;
  top: 0;
  right: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.3rem;
}

/* 認証ゲート */
.auth-splash {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}
.login-gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.login-gate__card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: 18px;
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.login-gate__title { margin: 0; font-size: 1.2rem; }
.login-gate__sub { margin: 0; font-size: 0.85rem; color: var(--muted); }
.login-gate__form { display: flex; flex-direction: column; gap: 0.6rem; }
.field-label { font-size: 0.85rem; color: var(--muted); }
.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  color: var(--text);
  font: inherit;
}
.login-gate__error { margin: 0; min-height: 1.1em; font-size: 0.85rem; color: var(--danger); }
.login-gate__submit {
  background: var(--accent);
  color: var(--accent-on);
  border: none;
  border-radius: 10px;
  padding: 0.7rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.login-gate__submit:disabled { opacity: 0.6; cursor: default; }

/* 種目選択 */
.picker { display: grid; gap: 0.75rem; }
.picker__btn {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem 1.1rem;
  border: 2px solid transparent;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.picker__btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--surface-2);
}
.picker__name { font-size: 1.05rem; font-weight: 700; }
.picker__sub { font-size: 0.8rem; color: var(--muted); }

/* 他の曜日・フルセットの選択 */
.variant { display: grid; gap: 0.35rem; margin-top: 0.75rem; }
.variant__label { font-size: 0.8rem; color: var(--muted); }
.variant__select {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--surface-2);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

/* プレイヤー */
.player {
  margin-top: auto;
  background: var(--surface);
  border-radius: 18px;
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.player__now { margin: 0; text-align: center; font-size: 1.1rem; font-weight: 700; }

.seek { display: flex; flex-direction: column; gap: 0.4rem; }
.seek__bar { width: 100%; accent-color: var(--accent); height: 1.5rem; }
.seek__times {
  display: flex;
  justify-content: space-between;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--muted);
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}
.controls__skip {
  background: var(--surface-2);
  color: var(--text);
  border: none;
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  font: inherit;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.controls__play {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-on);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.controls__play:active { transform: scale(0.96); }

.offline-btn {
  background: transparent;
  border: 1px solid var(--surface-2);
  color: var(--muted);
  border-radius: 10px;
  padding: 0.55rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.offline-status { margin: 0; min-height: 1.1em; text-align: center; font-size: 0.8rem; color: var(--muted); }

/* 目次（チャプター） */
.toc {
  background: var(--surface);
  border-radius: 16px;
  padding: 1rem;
}
.toc__title { margin: 0 0 0.5rem; font-size: 0.95rem; color: var(--muted); }
.toc__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.toc__item {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}
.toc__time {
  flex: 0 0 auto;
  min-width: 3.2em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}
.toc__name { flex: 1 1 auto; }
.toc__item--active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}
.toc__item--active .toc__time { color: var(--accent); }

/* フォーカス可視化（A11y） */
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .controls__play:active { transform: none; }
}
