:root {
  --bg-primary: #0f1015;
  --bg-secondary: #181920;
  --bg-tertiary: #22232d;
  --accent: #4f46e5;
  --accent-light: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --text-main: #f8fafc;
  --text-sub: #94a3b8;
  --text-dim: #64748b;
  --border: #282a36;
  --success: #10b981;
  --warning: #f59e0b;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg-primary);
  color: var(--text-main);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ヘッダー */
header {
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 20;
}

.book-selector-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.book-selector-btn:active {
  transform: scale(0.97);
  background: var(--border);
}

.book-selector-btn svg {
  width: 14px;
  height: 14px;
  fill: var(--text-sub);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-sub);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:active {
  background: var(--bg-tertiary);
  color: var(--text-main);
}

/* 聖書本文エリア */
.verse-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px 200px;
  scroll-behavior: smooth;
  user-select: text;
}

.verse-item {
  padding: 12px 14px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  line-height: 1.8;
  font-size: 1.05rem;
  color: #cbd5e1;
  transition: background 0.25s, color 0.25s;
  cursor: pointer;
}

.verse-item:active {
  background: rgba(255, 255, 255, 0.05);
}

.verse-item.active {
  background: var(--accent-glow);
  color: #ffffff;
  border-left: 3px solid var(--accent-light);
  font-weight: 500;
}

.verse-label {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-light);
  margin-right: 8px;
  user-select: none;
}

/* ボトム固定プレイヤー */
.bottom-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(24, 25, 32, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  z-index: 50;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
}

.player-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.current-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.cache-pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--bg-tertiary);
  color: var(--text-sub);
  display: flex;
  align-items: center;
  gap: 4px;
}

.cache-pill.cached {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* シークバー */
.seek-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.time-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  width: 36px;
}

.time-label.right {
  text-align: right;
}

.seek-bar {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-tertiary);
  outline: none;
  cursor: pointer;
}

.seek-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-light);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent);
}

/* 再生操作ボタン */
.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px 8px;
}

.ctrl-btn {
  background: none;
  border: none;
  color: var(--text-sub);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s;
}

.ctrl-btn:active {
  transform: scale(0.9);
  color: var(--text-main);
}

.play-pause-btn {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: white;
  border-radius: 50%;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.play-pause-btn:active {
  transform: scale(0.92);
}

/* 洗練されたアクション・ツールバー (ミニマル・ピルバー) */
.action-pills-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

/* 3D空間音響ボタン (タップで設定モーダルを開く) */
.spatial-settings-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.spatial-settings-btn svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.spatial-settings-btn.active {
  background: rgba(99, 102, 241, 0.16);
  border-color: rgba(99, 102, 241, 0.45);
  color: #fff;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

.spatial-settings-btn:active {
  transform: scale(0.96);
}

/* 再生速度セレクター (直接選べるピル型ドロップダウン) */
.speed-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.speed-select-pill {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 20px;
  padding: 6px 26px 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all 0.15s;
}

.speed-select-pill:active {
  border-color: var(--accent-light);
}

.speed-select-arrow {
  position: absolute;
  right: 10px;
  pointer-events: none;
  font-size: 0.65rem;
  color: var(--text-dim);
}

/* モーダル内 iOS 風トグルスイッチ */
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-tertiary);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.toggle-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.toggle-desc {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.ios-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.ios-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.ios-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #33343d;
  transition: .3s;
  border-radius: 28px;
}

.ios-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.ios-switch input:checked + .ios-slider {
  background-color: var(--accent);
}

.ios-switch input:checked + .ios-slider:before {
  transform: translateX(20px);
}

.binaural-controls-wrap {
  transition: opacity 0.25s, pointer-events 0.25s;
}

.binaural-controls-wrap.disabled {
  opacity: 0.35;
  pointer-events: none;
}


/* モーダル / ドロワー */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  background: var(--bg-secondary);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -10px 40px rgba(0,0,0,0.6);
}

.modal-overlay.open .drawer {
  transform: translateY(0);
}

.drawer-header {
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.drawer-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.drawer-close {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 1.3rem;
  cursor: pointer;
}

/* 聖書セレクターのタブ（旧約 / 新約） */
.testament-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.testament-tab {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  color: var(--text-sub);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.testament-tab.active {
  color: var(--accent-light);
  border-bottom-color: var(--accent-light);
  background: rgba(99, 102, 241, 0.05);
}

.selector-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* 巻リスト */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
}

.book-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}

.book-card.has-audio {
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.08);
}

.book-card.selected {
  background: var(--accent);
  color: white;
  border-color: var(--accent-light);
}

.book-card.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.book-card-name {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.book-card-count {
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* 章グリッド */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.chapter-badge {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 12px 0;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
}

.chapter-badge.available {
  border-color: rgba(99, 102, 241, 0.4);
  color: #fff;
}

.chapter-badge.current {
  background: var(--accent);
  color: white;
}

.chapter-badge.disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* キャッシュ管理モーダル */
.cache-panel {
  padding: 20px;
}

.cache-stat-box {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.cache-stat-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.cache-action-btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-md);
  border: none;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  margin-bottom: 10px;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ダブルタップ 10秒シーク・インジケーター (YouTube風) */
.double-tap-ripple {
  position: fixed;
  top: 0;
  bottom: 160px; /* プレイヤーの上 */
  width: 45%;
  pointer-events: none;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease-out;
}

.double-tap-ripple.left {
  left: 0;
  border-top-right-radius: 50% 100%;
  border-bottom-right-radius: 50% 100%;
  background: radial-gradient(circle at left center, rgba(99, 102, 241, 0.35), transparent 70%);
}

.double-tap-ripple.right {
  right: 0;
  border-top-left-radius: 50% 100%;
  border-bottom-left-radius: 50% 100%;
  background: radial-gradient(circle at right center, rgba(99, 102, 241, 0.35), transparent 70%);
}

.double-tap-ripple.active {
  opacity: 1;
}

.ripple-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: white;
  font-weight: 700;
  font-size: 0.95rem;
  background: rgba(0, 0, 0, 0.6);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  backdrop-filter: blur(8px);
  transform: scale(0.85);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.double-tap-ripple.active .ripple-content {
  transform: scale(1);
}

/* 3Dバイノーラル音響パネル */
.binaural-panel {
  padding: 16px 20px 24px;
}

.radar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 16px 0;
}

.radar-circle {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 2px dashed var(--border);
  background: radial-gradient(circle, var(--bg-tertiary) 0%, var(--bg-primary) 70%);
  position: relative;
  touch-action: none;
  cursor: crosshair;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

.radar-circle::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255,255,255,0.06);
}

.radar-circle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255,255,255,0.06);
}

.radar-center-listener {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  z-index: 2;
  box-shadow: 0 0 10px var(--accent-glow);
}

.radar-speaker-node {
  position: absolute;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-light);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transform: translate(-50%, -50%);
  z-index: 5;
  box-shadow: 0 0 16px var(--accent-light);
  cursor: grab;
  transition: transform 0.05s ease-out;
}

.radar-speaker-node:active {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.15);
}

.mode-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.mode-btn {
  flex: 1;
  padding: 8px 4px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-sub);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.mode-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent-light);
}

.slider-group {
  margin-top: 10px;
}

.slider-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-sub);
  margin-bottom: 4px;
}

/* 3D プリセットボタングループ */
.presets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.preset-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  font-size: 0.78rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all 0.15s;
}

.preset-btn:active {
  background: var(--accent);
  border-color: var(--accent-light);
  transform: scale(0.96);
}

.preset-btn span.icon {
  font-size: 1.1rem;
}

.preset-btn span.label {
  font-size: 0.7rem;
  color: var(--text-sub);
}


