:root {
  --bg: #121212;
  --surface: #1e1e1e;
  --surface-2: #2a2a2a;
  --text: #f5f5f5;
  --muted: #9a9a9a;
  --accent: #1db954;
  --player-h: 180px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.appbar {
  position: sticky;
  top: 0;
  padding: max(12px, env(safe-area-inset-top)) 16px 0;
  background: var(--bg);
  z-index: 5;
}
.appbar h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
}

.tabs {
  display: flex;
  gap: 16px;
  margin-top: 10px;
}
.tab {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  font-weight: 600;
  padding: 10px 4px;
  border-bottom: 3px solid transparent;
  cursor: pointer;
}
.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.content {
  padding: 12px 16px;
  padding-bottom: calc(var(--player-h) + 24px);
}

/* 取り込み */
.import {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}
.btn {
  display: inline-block;
  background: var(--accent);
  color: #08240f;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: 24px;
  cursor: pointer;
  font-size: 16px;
  border: none;
}
.btn.secondary {
  background: var(--surface-2);
  color: var(--text);
}
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 16px;
  cursor: pointer;
  padding: 8px 0;
}
.import-status {
  width: 100%;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 15px;
}
.storage-status {
  width: 100%;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* 設定ビュー */
.settings-heading {
  font-size: 18px;
  font-weight: 700;
  margin: 20px 0 10px;
}
.settings-heading:first-child {
  margin-top: 4px;
}
.settings-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-group .btn {
  display: block;
  width: 100%;
  text-align: center;
  padding: 16px;
  font-size: 17px;
  border-radius: 14px;
}
.settings-hint {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  margin: 10px 0 0;
}
.search {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  color: var(--text);
  border-radius: 22px;
  padding: 13px 16px;
  font-size: 16px;
  margin-bottom: 10px;
}
.search::placeholder {
  color: var(--muted);
}
.lib-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.lib-group {
  font-size: 15px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.lib-group select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--surface-2);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 15px;
}

/* グループ見出し */
.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 12px 6px;
  border-bottom: 1px solid var(--surface-2);
  margin-top: 6px;
}
.group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.group-caret {
  flex-shrink: 0;
  width: 14px;
  font-size: 13px;
  color: var(--muted);
}
.group-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-count {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}
.group-act {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
}

/* 選択モード */
.track-check {
  font-size: 20px;
  padding-left: 10px;
  color: var(--muted);
  flex-shrink: 0;
}
.track-check.checked {
  color: var(--accent);
}
.track.selected {
  background: rgba(29, 185, 84, 0.12);
}
.selection-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--player-h);
  background: var(--surface-2);
  border-top: 1px solid #000;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 9;
}
/* hidden 時は確実に隠す (display:flex が UA の [hidden] を上書きするため明示) */
.selection-bar[hidden] {
  display: none;
}
.sel-count {
  font-size: 16px;
  font-weight: 600;
}
.sel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn.danger {
  background: #e53935;
  color: #fff;
}
.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* プロパティ */
.prop-field {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 12px;
}
.prop-field input {
  display: block;
  width: 100%;
  margin-top: 4px;
  background: var(--bg);
  border: 1px solid var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 16px;
}
.prop-meta {
  margin: 4px 0 16px;
  font-size: 14px;
  color: var(--muted);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
}
.prop-meta dt {
  font-weight: 600;
}
.prop-meta dd {
  margin: 0;
  word-break: break-all;
}
.prop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

/* 一覧 */
.empty {
  color: var(--muted);
  line-height: 1.8;
  font-size: 16px;
  margin-top: 32px;
  text-align: center;
}
.track-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.track {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 8px;
}
.track.playing {
  background: var(--surface);
}
.track-play {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  padding: 14px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.t-title {
  font-size: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.t-artist {
  font-size: 14px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.track.playing .t-title {
  color: var(--accent);
  font-weight: 700;
}
.track-act {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  padding: 12px 10px;
  cursor: pointer;
}

.pl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 4px;
}
.pl-head h2 {
  font-size: 18px;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* プレーヤー */
.player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--player-h);
  background: var(--surface);
  border-top: 1px solid #000;
  padding: 10px 16px max(10px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}
.now-playing {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
}
.art {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}
.np-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.cur-title {
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cur-artist {
  font-size: 14px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.seekbar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.time {
  font-size: 13px;
  color: var(--muted);
  width: 40px;
  text-align: center;
  flex-shrink: 0;
}
.seek {
  flex: 1;
  accent-color: var(--accent);
}
.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
}
.ctrl {
  background: none;
  border: none;
  color: var(--text);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
}
.ctrl.mini {
  font-size: 20px;
  opacity: 0.5;
}
.ctrl.mini.on {
  opacity: 1;
  color: var(--accent);
}
.ctrl.play {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: #08240f;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* モーダル */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}
/* hidden 属性が付いている時は確実に隠す
   (.modal の display:flex が UA の [hidden] ルールを上書きしてしまうため明示) */
.modal[hidden] {
  display: none;
}
.modal-box {
  background: var(--surface);
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 360px;
  max-height: 70vh;
  overflow-y: auto;
}
.modal-box h3 {
  margin: 0 0 12px;
  font-size: 19px;
}
.modal-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}
.modal-item {
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: none;
  color: var(--text);
  padding: 14px;
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 16px;
  cursor: pointer;
}
.modal-hint {
  color: var(--muted);
  font-size: 13px;
  list-style: none;
  margin-bottom: 8px;
}
.modal-new {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.modal-new input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
}
