/* NASPlay — EV 車載ディスプレイ風 UI
 *
 * 設計思想: 洗練・直感・静けさ・先進感
 * モノトーン基調 + アクセント 1 色 (electric blue)
 * 余白を大きく、情報密度は低め
 * 大きく読みやすいタイポグラフィ
 * 滑らかで短いアニメーション
 * フルスクリーン感のあるレイアウト
 */

:root {
  --bg:         #f7f7f8;
  --bg-surface: #ffffff;
  --bg-hover:   #f0f1f3;
  --bg-active:  #e8ecf4;
  --fg:         #1a1a2e;
  --fg-sec:     #6b6e78;
  --fg-ter:     #a0a3ab;
  --accent:     #2d5af0;
  --accent-soft: rgba(45, 90, 240, 0.08);
  --border:     rgba(0, 0, 0, 0.06);
  --radius:     14px;
  --player-h:   136px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg:         #0e0e12;
  --bg-surface: #18181e;
  --bg-hover:   #22222a;
  --bg-active:  #2a2a36;
  --fg:         #e4e4ea;
  --fg-sec:     #8e8e9a;
  --fg-ter:     #5a5a66;
  --accent:     #5b8af0;
  --accent-soft: rgba(91, 138, 240, 0.12);
  --border:     rgba(255, 255, 255, 0.08);
}

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

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, "Helvetica Neue", "Inter", "Segoe UI",
               "Hiragino Sans", "Noto Sans CJK JP", system-ui, sans-serif;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
  overflow: hidden;
  height: 100vh;
  letter-spacing: 0.015em;
}

/* ======================== TOP BAR ======================== */
#top-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 28px;
  height: 60px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

#title-text {
  font-size: 1.2em;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg);
  opacity: 0.7;
}

#search-wrap { flex: 1; max-width: 380px; }

#search-input {
  width: 100%;
  height: 42px;
  padding: 0 18px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid transparent;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 400;
  outline: none;
  transition: border var(--transition), background var(--transition);
}
#search-input:focus {
  border-color: var(--accent);
  background: var(--bg-surface);
}

/* Dark mode toggle button */
#btn-theme {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--fg-ter);
  font-size: 20px;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
  flex-shrink: 0;
}
#btn-theme:hover { color: var(--fg-sec); }
#search-input::placeholder { color: var(--fg-ter); }

#view-tabs { display: flex; gap: 4px; }

.tab {
  padding: 8px 20px;
  background: transparent;
  color: var(--fg-ter);
  border: none;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  min-height: 40px;
  letter-spacing: 0.03em;
  transition: all var(--transition);
}
.tab:hover { color: var(--fg-sec); }
.tab.active {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ======================== LIST AREA ======================== */
#content {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--player-h));
}

#list-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

#folder-path {
  padding: 14px 28px;
  font-size: 14px;
  color: var(--fg-sec);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.back-btn, .play-folder-btn {
  padding: 12px 28px;
  border: none;
  border-radius: 28px;
  font-size: 16px;
  font-weight: 400;
  cursor: pointer;
  min-height: 52px;
  min-width: 52px;
  transition: all var(--transition);
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.back-btn {
  background: var(--bg-hover);
  color: var(--fg);
}
.back-btn:active { background: var(--bg-active); }
.play-folder-btn {
  background: var(--accent);
  color: #fff;
}
.play-folder-btn:active { opacity: 0.85; }

#track-list {
  list-style: none;
}
#track-list.grid-2col {
  columns: 2;
  column-gap: 0;
}

/* ======================== FOLDER / FILE ITEMS ======================== */
.folder-item, .track-item {
  display: flex;
  align-items: center;
  padding: 16px 28px;
  cursor: pointer;
  min-height: 56px;
  gap: 16px;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}
.grid-2col .folder-item,
.grid-2col .track-item {
  break-inside: avoid;
}
.grid-2col .folder-item {
  min-height: 84px;
  padding: 22px 28px;
}
.folder-item:hover, .track-item:hover { background: var(--bg-hover); }
.folder-item:active, .track-item:active { background: var(--bg-active); }

.track-item.playing {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding-left: 25px;
}

.folder-icon {
  width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-ter);
}
.folder-name {
  flex: 1;
  font-weight: 400;
  font-size: 1em;
}
.folder-count {
  color: var(--fg-ter);
  font-size: 0.82em;
}

.track-main { flex: 1; overflow: hidden; }
.track-title {
  font-size: 1em;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-sub {
  font-size: 0.78em;
  color: var(--fg-sec);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.track-meta {
  font-size: 0.7em;
  color: var(--fg-ter);
  white-space: nowrap;
  min-width: 50px;
  text-align: right;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.track-dur {
  font-size: 0.85em;
  color: var(--fg-sec);
  min-width: 48px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#loading {
  padding: 60px;
  text-align: center;
  color: var(--fg-ter);
  font-size: 0.95em;
  letter-spacing: 0.05em;
  display: none;
}

/* ======================== PLAYER BAR ======================== */
#player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--player-h);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 10px 28px;
  z-index: 100;
}

#now-playing {
  display: flex;
  gap: 14px;
  align-items: baseline;
  overflow: hidden;
  margin-bottom: 2px;
}
#np-title {
  font-size: 1.05em;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#np-artist {
  font-size: 0.82em;
  color: var(--fg-sec);
  white-space: nowrap;
}

#player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  margin: 4px 0;
}

.ctrl-btn {
  width: 52px;
  height: 52px;
  border: none;
  background: transparent;
  color: var(--fg);
  font-size: 22px;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  opacity: 0.6;
}
.ctrl-btn:hover { opacity: 0.8; background: var(--bg-hover); }
.ctrl-btn:active { background: var(--bg-active); }
.ctrl-btn.big {
  width: 58px;
  height: 58px;
  font-size: 26px;
  background: var(--accent);
  color: #fff;
  opacity: 1;
}
.ctrl-btn.big:hover { opacity: 0.9; }
.ctrl-btn.big:active { transform: scale(0.96); }

#player-modes {
  position: absolute;
  right: 28px;
  top: 36px;
  display: flex;
  gap: 14px;
}

.mode-btn {
  width: 52px;
  height: 52px;
  border: none;
  background: var(--bg);
  color: var(--fg-ter);
  font-size: 18px;
  cursor: pointer;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.mode-btn:hover { color: var(--fg-sec); }
.mode-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
}

#progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

#seek-bar {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(0,0,0,0.08);
  border-radius: 2px;
  outline: none;
  transition: height 0.15s;
}
#seek-bar:hover { height: 6px; }
#seek-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s;
}
#seek-bar:active::-webkit-slider-thumb { transform: scale(1.2); }

#time-display {
  font-size: 0.75em;
  color: var(--fg-ter);
  white-space: nowrap;
  min-width: 90px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

/* ======================== MOBILE (smartphone) ======================== */
@media (max-width: 768px) {
  :root { --player-h: 120px; }

  #top-bar { padding: 8px 12px; gap: 8px; height: 48px; }
  #title-text { font-size: 1em; }
  #search-input { height: 34px; font-size: 14px; }
  .tab { padding: 6px 12px; font-size: 13px; min-height: 34px; }
  #btn-theme { width: 34px; height: 34px; }

  /* Force 1 column on mobile */
  #track-list.grid-2col { columns: 1; }

  .folder-item, .track-item {
    padding: 12px 14px;
    min-height: 56px;
    gap: 10px;
  }
  .grid-2col .folder-item {
    min-height: 56px;
    padding: 12px 14px;
  }
  .folder-icon { width: 28px; }
  .folder-icon svg { width: 18px; height: 14px; }
  .folder-name { font-size: 0.9em; }
  .track-title { font-size: 0.9em; }
  .track-sub { font-size: 0.72em; }
  .track-meta { font-size: 0.65em; min-width: 40px; }
  .track-dur { font-size: 0.78em; min-width: 36px; }

  #folder-path { padding: 8px 14px; font-size: 13px; }
  .back-btn, .play-folder-btn {
    padding: 8px 16px;
    min-height: 40px;
    font-size: 13px;
  }

  /* Player bar compact */
  #player-bar { padding: 6px 14px; }
  #np-title { font-size: 0.9em; }
  #np-artist { font-size: 0.75em; }
  #player-controls { gap: 28px; }
  .ctrl-btn { width: 44px; height: 44px; }
  .ctrl-btn.big { width: 48px; height: 48px; }
  .ctrl-btn.big svg { width: 26px; height: 26px; }
  .mode-btn { width: 40px; height: 40px; }
  #player-modes { right: 14px; top: 28px; gap: 6px; }
}
