/* ===== SONIQ Player - style.css ===== */

/*
 * フォントは完全ローカル（外部通信ゼロ）
 * iOSプリインストールフォントを活用：
 *   display  → Impact（力強い大文字）
 *   body     → -apple-system / Hiragino Sans（iOS標準 / 日本語対応）
 *   mono     → "Courier New" / Menlo
 */

/* ---- CSS変数 ---- */
:root {
  --bg-color: #0a0a0c;
  --surface: #111115;
  --surface2: #18181e;
  --surface3: #222228;
  --border: rgba(255,255,255,0.07);
  --text-primary: #f0f0f5;
  --text-secondary: #8888a0;
  --text-muted: #55555f;
  --accent: #c8a0ff;
  --accent2: #7f5af0;
  --accent-glow: rgba(127,90,240,0.35);
  --danger: #ff4d6d;
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --transition: 0.22s cubic-bezier(0.4,0,0.2,1);
  --font-display: Impact, "Arial Black", "Hiragino Sans", sans-serif;
  --font-body: -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  --font-mono: "Menlo", "Courier New", "Hiragino Sans", monospace;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ---- 背景レイヤー ---- */
#bg-layer {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
}
#bg-image {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center;
  transition: filter 0.4s, opacity 0.4s;
}
#bg-overlay {
  position: absolute; inset: 0;
  background: var(--bg-color);
  opacity: 0.85;
  transition: opacity 0.4s;
}

/* ---- スクリーン ---- */
.screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column;
  background: transparent;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}
.screen.active {
  transform: translateX(0);
}
.screen.slide-left {
  transform: translateX(-30%);
}

/* ---- ヘッダー ---- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 14px) 16px 14px;
  background: rgba(10,10,12,0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
}
.app-header.transparent {
  background: transparent;
  border-bottom: none;
}
.header-title {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow);
}
.header-title.small {
  font-size: 14px;
  font-family: var(--font-body);
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  text-shadow: none;
}

/* ---- アイコンボタン ---- */
.icon-btn {
  width: 44px; height: 44px;
  border: none; background: none;
  cursor: pointer;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-primary);
  font-size: 20px;
  transition: background var(--transition);
  -webkit-user-select: none;
}
.icon-btn:active { background: rgba(255,255,255,0.08); }
.icon-img { width: 22px; height: 22px; object-fit: contain; filter: brightness(0) invert(1); }

/* ---- タブ ---- */
.home-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: rgba(10,10,12,0.6);
  flex-shrink: 0;
}
.tab-btn {
  flex: 1; padding: 14px 0; border: none; background: none;
  color: var(--text-muted); font-family: var(--font-body);
  font-size: 14px; font-weight: 500; cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content { display: none; flex-direction: column; flex: 1; overflow: hidden; }
.tab-content.active { display: flex; }

/* ---- リストヘッダー ---- */
.list-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  flex-shrink: 0;
}
.count-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}
.list-actions { display: flex; gap: 8px; }

/* ---- 小ボタン ---- */
.small-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 12px; font-weight: 500;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}
.small-btn:active { background: var(--surface3); transform: scale(0.97); }
.small-btn.danger { color: var(--danger); border-color: var(--danger); background: rgba(255,77,109,0.08); }

/* ---- 曲リスト ---- */
.song-list {
  flex: 1; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--safe-bottom) + 16px);
}
.song-item {
  display: flex; align-items: center;
  padding: 10px 16px;
  gap: 12px;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  min-height: 66px;
}
.song-item:active { background: rgba(255,255,255,0.04); }
.song-item.playing {
  background: rgba(127,90,240,0.1);
}
.song-item.playing .song-title { color: var(--accent); }

.song-art {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  background: var(--surface3);
  flex-shrink: 0;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.song-art img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: var(--radius-sm);
}
.song-art-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  color: var(--text-muted);
}

.song-info { flex: 1; min-width: 0; }
.song-title {
  font-size: 14px; font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 3px;
}
.song-artist {
  font-size: 12px; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--font-mono);
}
.song-duration {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.song-more-btn {
  width: 36px; height: 36px;
  border: none; background: none;
  color: var(--text-muted); font-size: 18px;
  cursor: pointer;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.song-more-btn:active { background: rgba(255,255,255,0.08); }

/* ドロップゾーン */
.drop-zone {
  margin: 12px 16px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  background: rgba(127,90,240,0.03);
}
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(127,90,240,0.1);
}
.drop-zone-inner { text-align: center; }
.drop-icon { width: 32px; height: 32px; opacity: 0.3; margin-bottom: 8px; filter: brightness(0) invert(1); }
.drop-zone p { font-size: 14px; color: var(--text-secondary); margin-bottom: 4px; }
.drop-zone .drop-sub { font-size: 12px; color: var(--text-muted); }

/* ---- フォルダリスト ---- */
.folder-list {
  flex: 1; overflow-y: auto;
  padding: 8px 16px;
  padding-bottom: calc(var(--safe-bottom) + 16px);
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-content: start;
}
.folder-card {
  background: var(--surface2);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid var(--border);
  position: relative;
}
.folder-card:active { transform: scale(0.97); }
.folder-art {
  width: 100%;
  aspect-ratio: 1;
  background: var(--surface3);
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
  overflow: hidden;
}
.folder-art-cell {
  background: var(--surface3);
  overflow: hidden;
}
.folder-art-cell img { width: 100%; height: 100%; object-fit: cover; }
.folder-art-cell.placeholder {
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: var(--text-muted);
}
.folder-art.single { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.folder-info { padding: 10px 12px; }
.folder-name { font-size: 13px; font-weight: 500; color: var(--text-primary); margin-bottom: 2px; }
.folder-song-count { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }

.folder-more-btn {
  position: absolute; top: 6px; right: 6px;
  width: 30px; height: 30px;
  background: rgba(0,0,0,0.5);
  border: none; border-radius: 50%;
  color: var(--text-primary); font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

/* ---- 再生画面 ---- */
#screen-player {
  background: linear-gradient(180deg, rgba(10,10,12,0.4) 0%, rgba(10,10,12,0.95) 40%);
}

#player-main-view {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center;
  padding: 0 24px;
  overflow: hidden;
}

#player-artwork-wrap {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 16px 0;
  width: 100%;
}
#player-artwork {
  width: min(72vw, 300px);
  height: min(72vw, 300px);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface3);
  box-shadow: 0 24px 60px rgba(0,0,0,0.6), 0 0 0 1px var(--border);
  position: relative;
  transition: transform 0.4s cubic-bezier(0.4,0,0.2,1), box-shadow 0.4s;
}
#player-artwork.playing {
  box-shadow: 0 32px 80px rgba(127,90,240,0.4), 0 0 0 1px rgba(127,90,240,0.3);
  transform: scale(1.02);
}
#player-art-img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: var(--radius-lg);
}
#player-art-img:not([src]), #player-art-img[src=""] { display: none; }
#player-art-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 60px; color: var(--text-muted);
}
#player-art-placeholder img { width: 60px; height: 60px; opacity: 0.3; filter: brightness(0) invert(1); }

#player-info {
  width: 100%; text-align: left; margin-bottom: 20px;
}
#player-title {
  font-size: 20px; font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 6px;
}
#player-artist {
  font-size: 14px; color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* プログレスバー */
#progress-container { width: 100%; margin-bottom: 24px; }
#progress-bar-wrap {
  position: relative; height: 4px;
  background: var(--surface3);
  border-radius: 4px;
  margin-bottom: 10px;
  cursor: pointer;
  /* タッチ領域を広げる */
  padding: 14px 0;
  margin-top: -14px;
}
#progress-bg {
  position: absolute; top: 14px; left: 0; right: 0;
  height: 4px; background: var(--surface3); border-radius: 4px;
}
#progress-fill {
  position: absolute; top: 14px; left: 0; height: 4px;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  border-radius: 4px; width: 0%;
  transition: width 0.1s linear;
}
#progress-thumb {
  position: absolute; top: 14px;
  width: 16px; height: 16px;
  background: var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -6px);
  left: 0%;
  box-shadow: 0 0 8px var(--accent-glow);
  transition: left 0.1s linear, transform 0.2s;
  touch-action: none;
}
#progress-thumb:active { transform: translate(-50%, -6px) scale(1.3); }

#time-display {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12px; color: var(--text-muted);
}

/* コントロール */
#player-controls {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding-bottom: calc(var(--safe-bottom) + 24px);
}
.ctrl-btn {
  border: none; background: none; cursor: pointer;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: all var(--transition);
  -webkit-user-select: none;
  position: relative;
}
.ctrl-icon { width: 26px; height: 26px; object-fit: contain; filter: brightness(0) invert(0.7); }
.ctrl-icon.large { width: 32px; height: 32px; filter: brightness(0) invert(1); }
.ctrl-btn:active { opacity: 0.6; transform: scale(0.92); }
.ctrl-btn.active .ctrl-icon { filter: brightness(0) invert(0.9) sepia(1) hue-rotate(220deg) saturate(3); }
.ctrl-btn.main-ctrl {
  width: 68px; height: 68px;
  background: var(--accent2);
  box-shadow: 0 8px 24px rgba(127,90,240,0.5);
  border-radius: 50%;
}
.ctrl-btn.main-ctrl:active { transform: scale(0.92); }

/* ---- キュービュー ---- */
#player-queue-view {
  flex: 1;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.queue-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px 10px;
  font-size: 14px; font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.queue-song-list {
  flex: 1; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--safe-bottom) + 16px);
}
.queue-item {
  display: flex; align-items: center;
  padding: 10px 16px;
  gap: 12px;
  position: relative;
}
.queue-item.playing { background: rgba(127,90,240,0.1); }
.queue-item.playing .song-title { color: var(--accent); }

.drag-handle {
  width: 36px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  cursor: grab;
  touch-action: none;
}
.drag-handle img { width: 18px; height: 18px; opacity: 0.35; filter: brightness(0) invert(1); }
.drag-handle span { font-size: 18px; color: var(--text-muted); }
.drag-handle:active { cursor: grabbing; }

.queue-item.dragging {
  opacity: 0.5;
  background: rgba(127,90,240,0.15);
}
.queue-item.drag-over-top { border-top: 2px solid var(--accent); }
.queue-item.drag-over-bottom { border-bottom: 2px solid var(--accent); }

/* ---- 設定画面 ---- */
.settings-content {
  flex: 1; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: calc(var(--safe-bottom) + 32px);
}
.settings-section {
  background: var(--surface2);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.settings-section-title {
  padding: 12px 16px 8px;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  font-family: var(--font-mono);
  border-bottom: 1px solid var(--border);
}
.setting-row {
  display: flex; align-items: center;
  padding: 14px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-row label {
  flex: 1; font-size: 14px; color: var(--text-primary);
}
.setting-row .slider {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: var(--surface3);
  border-radius: 4px;
  outline: none;
}
.setting-row .slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
}
.slider-val {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  min-width: 38px;
  text-align: right;
}
.settings-info { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }
.how-to-block { padding: 14px 16px; }
.how-to-block p { font-size: 13px; color: var(--text-secondary); line-height: 1.7; }
.app-version { text-align: center; font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); margin-top: 8px; }

/* ---- モーダル ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  transition: opacity var(--transition);
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%; max-width: 320px;
}
.modal-title {
  font-size: 16px; font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}
.modal-input {
  width: 100%; padding: 12px 14px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body); font-size: 15px;
  outline: none;
  margin-bottom: 20px;
}
.modal-input:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 10px; }
.modal-btn {
  flex: 1; padding: 12px;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
}
.modal-btn.cancel { background: var(--surface3); color: var(--text-secondary); }
.modal-btn.confirm { background: var(--accent2); color: #fff; }
.modal-btn:active { opacity: 0.7; }

/* ---- ボトムシート ---- */
.bottom-sheet {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding-bottom: calc(var(--safe-bottom) + 8px);
  transform: translateY(0);
  transition: transform var(--transition);
  max-height: 70vh;
  overflow-y: auto;
}
.bottom-sheet.hidden {
  transform: translateY(110%);
  pointer-events: none;
}
.bottom-sheet-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 4px;
  margin: 12px auto 8px;
}
.bottom-sheet-title {
  font-size: 12px; color: var(--text-muted);
  font-family: var(--font-mono);
  padding: 0 16px 12px;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.option-list { padding: 8px 0; }
.option-btn {
  width: 100%; padding: 16px 20px;
  border: none; background: none;
  color: var(--text-primary); font-family: var(--font-body);
  font-size: 15px; text-align: left;
  cursor: pointer; transition: background var(--transition);
  display: block;
}
.option-btn:active { background: rgba(255,255,255,0.05); }
.option-btn.danger { color: var(--danger); }
.option-btn.hidden { display: none; }

/* ---- ポップアップメニュー ---- */
.popup-menu {
  position: absolute; top: 60px; right: 12px; z-index: 50;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  min-width: 160px;
}
.popup-menu button {
  display: block; width: 100%;
  padding: 14px 18px;
  border: none; background: none;
  color: var(--text-primary); font-family: var(--font-body);
  font-size: 14px; text-align: left;
  cursor: pointer; transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}
.popup-menu button:last-child { border-bottom: none; }
.popup-menu button:active { background: rgba(255,255,255,0.05); }
.popup-menu button.danger { color: var(--danger); }
.popup-menu.hidden { display: none; }

/* ---- トースト ---- */
.toast {
  position: fixed; bottom: calc(var(--safe-bottom) + 90px);
  left: 50%; transform: translateX(-50%);
  background: var(--surface3);
  color: var(--text-primary);
  font-size: 13px; font-family: var(--font-body);
  padding: 10px 20px;
  border-radius: 24px;
  z-index: 200;
  white-space: nowrap;
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  transition: opacity 0.3s;
}
.toast.hidden { opacity: 0; pointer-events: none; }

/* ---- ユーティリティ ---- */
.hidden { display: none !important; }

/* ---- スクロールバー ---- */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 4px; }

/* ---- アニメーション ---- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.song-item, .folder-card {
  animation: fadeIn 0.2s ease both;
}

/* 再生中ビジュアライザー（CSSアニメーション） */
.now-playing-bar {
  display: flex; gap: 2px; align-items: flex-end;
  height: 14px; width: 14px;
  flex-shrink: 0;
}
.now-playing-bar span {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  animation: bar-bounce 0.8s ease-in-out infinite alternate;
}
.now-playing-bar span:nth-child(1) { height: 60%; animation-delay: 0s; }
.now-playing-bar span:nth-child(2) { height: 100%; animation-delay: 0.15s; }
.now-playing-bar span:nth-child(3) { height: 40%; animation-delay: 0.3s; }
.now-playing-bar.paused span { animation-play-state: paused; }

@keyframes bar-bounce {
  from { height: 20%; }
  to { height: 100%; }
}
