/* ===== 全体のベース（明るいデザイン） ===== */
:root {
  --bg: #f5f6fa;
  --bg-grad: linear-gradient(180deg, #eef1fb 0%, #f5f6fa 240px);
  --surface: #ffffff;
  --surface-2: #eef0f7;
  --text: #1d1d2b;
  --text-dim: #7a7a8c;
  --accent: #6c5ce7;
  --accent-2: #8b7bff;
  --border: #e6e8f0;
  --shadow: 0 6px 20px rgba(40, 42, 90, 0.08);
  --shadow-sm: 0 2px 8px rgba(40, 42, 90, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
               "Yu Gothic", Meiryo, sans-serif;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-repeat: no-repeat;
  color: var(--text);
  /* 全体的に文字を少し大きめに */
  font-size: 17px;
  /* iPhone のノッチ・下部バーを避ける余白 */
  padding: env(safe-area-inset-top) 0 calc(env(safe-area-inset-bottom)) 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.hidden { display: none !important; }

/* ===== 画面（view）共通 ===== */
.view {
  /* プレイヤー分の余白を下に確保 */
  padding-bottom: 200px;
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, var(--bg) 75%, transparent);
  padding: 24px 20px 16px;
  z-index: 10;
}
.app-header.with-back {
  display: flex;
  align-items: center;
  gap: 12px;
}
.app-header h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.01em; }
.app-header .subtitle { color: var(--text-dim); font-size: 16px; margin-top: 2px; }

.back-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 36px;
  line-height: 1;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.back-btn:active { background: var(--surface-2); }

/* オフライン保存ボタン（プレイリスト画面） */
.offline-btn {
  margin-left: auto;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.offline-btn:active { background: var(--surface-2); }
.offline-btn.saved { background: #ece9ff; border-color: #d9d2ff; }
.offline-btn:disabled { opacity: 0.65; cursor: default; }

/* 一覧カードの「オフライン保存済み」バッジ */
.offline-badge {
  margin-left: 6px;
  color: var(--accent);
  font-weight: 700;
}

/* ===== プレイリスト一覧（リスト） ===== */
.card-list {
  list-style: none;
  padding: 4px 12px;
}
.card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.card:active { background: var(--surface-2); }
.card .cover {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  object-fit: cover;
  display: block;
}
.card .card-body { flex: 1; min-width: 0; }
.card .card-title {
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .card-meta { color: var(--text-dim); font-size: 14px; margin-top: 2px; }

/* ===== 曲一覧 ===== */
.track-list { list-style: none; padding: 4px 12px; }
.track {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.track:active { background: var(--surface-2); }
.track.playing { background: #ece9ff; }
.track-index {
  width: 26px;
  text-align: center;
  color: var(--text-dim);
  font-size: 16px;
  flex-shrink: 0;
}
.track.playing .track-index { color: var(--accent); }
.track-main { flex: 1; min-width: 0; }
.track-title {
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track.playing .track-title { color: var(--accent); font-weight: 600; }
.track-album {
  color: var(--text-dim);
  font-size: 15px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-time {
  flex-shrink: 0;
  margin-left: 10px;
  color: var(--text-dim);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.track.playing .track-time { color: var(--accent); }

/* ===== 下部ミニプレイヤー ===== */
.player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(40, 42, 90, 0.08);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "info controls" "modes modes" "seek seek";
  align-items: center;
  gap: 8px 12px;
  z-index: 20;
}
.player-info { grid-area: info; min-width: 0; }
.player-title {
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-album {
  font-size: 15px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-controls { grid-area: controls; display: flex; align-items: center; gap: 12px; }
.ctrl {
  background: none;
  border: none;
  color: var(--text);
  font-size: 33px;
  cursor: pointer;
  width: 60px;
  height: 60px;
  border-radius: 50%;
}
.ctrl:active { background: var(--surface-2); }
.ctrl.play {
  background: var(--accent);
  color: #fff;
  font-size: 27px;
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.35);
}
.ctrl.play:active { background: var(--accent-2); }

/* シャッフル / 繰り返し / 1曲で停止 のモード切替ボタン（アイコン＋文字） */
.player-modes {
  grid-area: modes;
  display: flex;
  justify-content: space-around;
  gap: 8px;
}
.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 12px;
  opacity: 0.55;
}
.mode-btn .mode-icon { font-size: 22px; line-height: 1; }
.mode-btn .mode-label { font-size: 12px; line-height: 1.1; white-space: nowrap; font-weight: 600; }
.mode-btn:active { background: var(--surface-2); }
.mode-btn.active { color: var(--accent); opacity: 1; }

.seek-row {
  grid-area: seek;
  display: flex;
  align-items: center;
  gap: 8px;
}
.time {
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 38px;
  text-align: center;
}
.seek {
  flex: 1;
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface-2);
  border-radius: 3px;
  cursor: pointer;
}
.seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--accent);
}
.seek::-moz-range-thumb {
  width: 21px;
  height: 21px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
}
