:root {
  --bg: #0b0e14;
  --bg-soft: #10141d;
  --panel: #121722;
  --panel-2: #171d2b;
  --line: #232b3d;
  --line-strong: #2e3852;
  --text: #e8ecf3;
  --muted: #8b93a6;
  --accent: #1ed760;
  --accent-deep: #14a04a;
  --teal: #14b8a6;
  --amber: #ffb454;
  --danger: #ff5c6c;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --player-h: 86px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(30, 215, 96, 0.09), transparent 60%),
    radial-gradient(900px 480px at -10% 110%, rgba(20, 184, 166, 0.08), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

#app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 clamp(12px, 3vw, 28px);
  padding-left: max(clamp(12px, 3vw, 28px), env(safe-area-inset-left));
  padding-right: max(clamp(12px, 3vw, 28px), env(safe-area-inset-right));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: max(calc(14px + env(safe-area-inset-top)), env(safe-area-inset-top));
  padding-bottom: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.brand-mark { width: 30px; height: 30px; color: var(--accent); }

.brand-name {
  font-size: 1.22rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.brand-name em {
  font-style: normal;
  color: var(--accent);
  margin: 0 1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn svg { width: 17px; height: 17px; fill: currentColor; }
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #17c653 100%);
  border-color: transparent;
  color: #06130c;
}
.btn-primary:hover { filter: brightness(1.07); border-color: transparent; }

.btn-accent {
  background: linear-gradient(135deg, var(--teal) 0%, #0ea5a5 100%);
  border-color: transparent;
  color: #04100e;
}

.btn-lg { padding: 13px 26px; font-size: 1.05rem; }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: 0.9rem; }

.btn-ghost { background: transparent; }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-danger-ghost:hover { color: var(--danger); border-color: var(--danger); }
.icon-btn { width: 40px; min-width: 40px; padding: 8px; }

.profile-widget {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-height: 46px;
  padding: 6px 14px 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.profile-widget:hover { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(255, 92, 108, 0.12); }

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(30, 215, 96, 0.55);
  animation: pulse 2.6s infinite;
  flex: none;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(30, 215, 96, 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(30, 215, 96, 0); }
  100% { box-shadow: 0 0 0 0 rgba(30, 215, 96, 0); }
}

.profile-avatar,
.profile-initial {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}
.profile-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--panel), var(--line-strong));
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent);
}

.profile-meta { display: flex; flex-direction: column; line-height: 1.25; }
.profile-name { font-weight: 600; font-size: 0.92rem; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-sub { display: flex; gap: 7px; align-items: baseline; font-size: 0.72rem; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.profile-tier { color: var(--teal); font-weight: 700; }

.power-icon { width: 16px; height: 16px; color: var(--muted); flex: none; transition: color 0.15s ease; }
.profile-widget:hover .power-icon { color: var(--danger); }

.gate { display: grid; place-items: center; padding: clamp(14px, 3.5vw, 48px) 0 64px; }

.hero { max-width: 660px; }
.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  font-weight: 700;
  margin: 0 0 10px;
}
.hero h1 {
  font-size: clamp(2.1rem, 6vw, 3.6rem);
  line-height: 1.06;
  margin: 0 0 18px;
  letter-spacing: -0.02em;
}
.lede { color: var(--muted); font-size: 1.06rem; margin: 0 0 26px; }
.lede em { color: var(--text); font-style: italic; }
.lede-follow { margin-top: -14px; }
.lede strong { color: var(--text); }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-bottom: 30px; }
.hero-note { color: var(--muted); font-size: 0.85rem; margin: 0; }

.feature-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  color: var(--muted);
}
.feature-list li { display: flex; align-items: center; gap: 10px; }

.attr {
  margin: 34px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.privacy { margin-top: 14px; }
.privacy summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  width: fit-content;
}
.privacy summary:hover { color: var(--accent); }
.privacy-body {
  margin-top: 12px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  max-width: 620px;
}
.privacy-body p { margin: 0 0 10px; font-size: 0.86rem; color: var(--muted); }
.privacy-body p:last-child { margin-bottom: 0; }
.privacy-body strong { color: var(--text); }
.attr a,
.api-note a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.attr a:hover,
.api-note a:hover { color: var(--accent); }

.api-note {
  grid-column: 1 / -1;
  order: 3;
  margin-top: -12px;
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  padding-bottom: calc(var(--player-h) + 40px);
}
.tick {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  background: rgba(30, 215, 96, 0.12);
  position: relative;
}
.tick::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.console {
  display: grid;
  grid-template-columns: minmax(340px, 5fr) minmax(420px, 7fr);
  gap: 20px;
  align-items: start;
  padding-bottom: calc(var(--player-h) + 48px);
}

.mobile-notice {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 2px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 180, 84, 0.45);
  background: rgba(255, 180, 84, 0.07);
  border-radius: var(--radius-sm);
}
.mobile-notice span { font-size: 0.86rem; line-height: 1.55; }
.notice-close {
  margin-left: auto;
  flex: none;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
}
.notice-close:hover { color: var(--danger); background: rgba(255, 92, 108, 0.08); }
@media (min-width: 1025px) {
  .mobile-notice { display: none !important; }
}

.panel {
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(6px);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h2 { margin: 0; font-size: 1.05rem; letter-spacing: 0.01em; }

.search-form { margin-bottom: 8px; }

.mode-switch { display: inline-flex; gap: 6px; margin-bottom: 10px; }
.mode-btn {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.is-active {
  color: #06130c;
  background: linear-gradient(135deg, var(--accent) 0%, #17c653 100%);
  border-color: transparent;
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-soft);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input::placeholder { color: #5d6577; }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 215, 96, 0.15);
}

.results { display: flex; flex-direction: column; margin-top: 10px; }

.result-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 9px 8px;
  border-radius: var(--radius-sm);
}
.result-row:hover { background: var(--panel-2); }

.cover {
  width: 44px;
  height: 44px;
  border-radius: 7px;
  object-fit: cover;
  background: var(--line);
  flex: none;
}

.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-title { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.row-side { display: flex; align-items: center; gap: 8px; position: relative; }
.badge-no-preview {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--amber);
  border: 1px solid rgba(255, 180, 84, 0.4);
  padding: 3px 8px;
  border-radius: 999px;
}

.playlist-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.playlist-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px 8px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.playlist-chip img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.playlist-chip .count { color: var(--muted); font-weight: 400; }
.playlist-chip:hover { border-color: var(--line-strong); }
.playlist-chip.is-active { border-color: var(--accent); background: rgba(30, 215, 96, 0.08); }
.playlist-chip.is-playing { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15); }

.empty {
  padding: 26px 8px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.detail-title { margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.detail-actions { display: flex; gap: 8px; align-items: center; }

.track-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  counter-reset: track;
}

.track-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 9px 8px;
  border-radius: var(--radius-sm);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
body.drag-lock { overflow: hidden; }
.track-item.is-dragging { opacity: 0.45; box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35); }
.start-btn {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  font-size: 0.72rem;
  padding: 6px 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.start-btn:hover { color: var(--accent); border-color: var(--accent); }
.track-item:hover { background: var(--panel-2); }
.track-item.is-current { background: rgba(30, 215, 96, 0.07); box-shadow: inset 2px 0 0 var(--accent); }

.track-num { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.play-track-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.play-track-btn svg { width: 15px; height: 15px; fill: currentColor; }
.play-track-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.play-track-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.remove-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.remove-btn svg { width: 15px; height: 15px; fill: currentColor; }
.remove-btn:hover { color: var(--danger); background: rgba(255, 92, 108, 0.1); }

.player-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  min-height: var(--player-h);
  padding: 12px clamp(14px, 3vw, 30px);
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: rgba(13, 17, 26, 0.92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.pb-cover { width: 54px; height: 54px; border-radius: 9px; object-fit: cover; background: var(--line); }
.pb-meta { display: flex; flex-direction: column; min-width: 0; }
.pb-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-sub { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.pb-artist { font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-queue { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }

.phase-chip {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  white-space: nowrap;
}
.phase-chip.is-full { color: var(--accent); border-color: rgba(30, 215, 96, 0.5); background: rgba(30, 215, 96, 0.07); }
.phase-chip.is-fade { color: var(--amber); border-color: rgba(255, 180, 84, 0.5); background: rgba(255, 180, 84, 0.07); }
.phase-chip.is-idle { color: var(--muted); }

.pb-controls { display: flex; gap: 8px; }
.pb-controls .icon-btn.is-active {
  color: var(--accent);
  border-color: rgba(30, 215, 96, 0.55);
  background: rgba(30, 215, 96, 0.08);
}
.code-box {
  height: 120px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.72rem;
  word-break: break-all;
  margin-bottom: 12px;
}
.modal input[type='file'] { width: 100%; color: var(--muted); margin-bottom: 10px; }

.pb-source {
  display: flex;
  align-items: center;
  gap: 10px;
  grid-column: 1 / -1;
  margin-top: 2px;
}
.src-label { font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 700; white-space: nowrap; }
.pb-source input[type='range'] {
  flex: 1;
  min-width: 80px;
  accent-color: var(--accent);
  cursor: pointer;
}
.pb-pos { min-width: 58px; text-align: right; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
#btnSaveSrc { white-space: nowrap; }
.phase-chip.is-paused { color: #9ecbff; border-color: rgba(120, 170, 255, 0.5); background: rgba(120, 170, 255, 0.07); }

.toast-root {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: min(360px, calc(100vw - 32px));
}
.toast {
  padding: 12px 16px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  animation: toast-in 0.22s ease;
}
.toast-error { border-color: rgba(255, 92, 108, 0.6); color: #ffd7dc; }
.toast-success { border-color: rgba(30, 215, 96, 0.55); color: #c9f5d9; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 7, 11, 0.66);
  backdrop-filter: blur(4px);
  animation: fade-in 0.16s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(430px, 100%);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.modal h3 { margin: 0 0 8px; font-size: 1.08rem; }
.modal p { margin: 0 0 18px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal .input { margin-bottom: 18px; }

.seg-group { display: flex; gap: 8px; align-items: flex-start; justify-content: center; margin-bottom: 12px; }
.seg-col { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.seg-group .seg {
  width: 76px;
  min-height: 48px;
  margin: 0;
  padding: 9px 6px;
  text-align: center;
  font-size: 1.06rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
.seg-label { font-size: 0.66rem; letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; font-weight: 700; }
.seg-sep { font-size: 1.2rem; color: var(--muted); font-weight: 700; transform: translateY(10px); }
.seg-preview { text-align: center; margin: 0 0 16px; }

@media (max-width: 480px) {
  .seg-group .seg { width: 64px; }
}

.add-menu {
  position: fixed;
  z-index: 70;
  min-width: 220px;
  max-width: 280px;
  max-height: 300px;
  overflow: auto;
  padding: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  box-shadow: var(--shadow);
}
.add-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.add-menu button:hover { background: var(--panel); }
.add-menu .menu-new { color: var(--accent); font-weight: 600; border-top: 1px solid var(--line); margin-top: 5px; border-radius: 0 0 8px 8px; }

@media (max-width: 1024px) {
  .console { grid-template-columns: 1fr; }
  .panel-search { order: 2; }
  .panel-library { order: 1; }
}

@media (max-width: 720px) {
  :root { --player-h: 150px; }
  .topbar { justify-content: center; }
  .profile-name { max-width: 110px; }
  .console { gap: 14px; padding-bottom: calc(var(--player-h) + 64px); }
  .panel { padding: 14px; }
  .player-bar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "cover meta chip"
      "controls controls controls"
      "source source source";
    row-gap: 10px;
  }
  .pb-cover { grid-area: cover; width: 44px; height: 44px; }
  .pb-meta { grid-area: meta; }
  .phase-chip { grid-area: chip; justify-self: end; }
  .pb-controls { grid-area: controls; justify-content: center; }
  #pbSource { grid-area: source; }
  .track-item { grid-template-columns: 30px minmax(0, 1fr) auto auto auto; gap: 8px; }
  .start-btn { padding: 5px 8px; }
  .detail-actions { width: 100%; justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
  .status-dot { animation: none; }
}
