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

:root {
  --max-w: 900px;
  --bg: #ffffff;
  --text: #000000;
  --text-muted: #555555;
  --border: #cccccc;
  --row-hover: #f0f0f0;
  --active-bg: #f5f5f5;
  --input-bg: #ffffff;
  --upload-bg: #f9f9f9;
  --player-bg: #efefef;
}

[data-theme="dark"] {
  --bg: #0f0f0f;
  --text: #eeeeee;
  --text-muted: #999999;
  --border: #333333;
  --row-hover: #1a1a1a;
  --active-bg: #1e1e1e;
  --input-bg: #1a1a1a;
  --upload-bg: #141414;
  --player-bg: #1c1c1c;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  transition: background 0.2s, color 0.2s;
}

.container { max-width: var(--max-w); margin: 0 auto; padding: 0 24px; }

/* ── Header ── */
.site-header {
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg); z-index: 100;
}
.header-inner {
  display: flex; align-items: center;
  justify-content: space-between; height: 52px;
}
.logo { font-size: 16px; font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 12px; }

button { font-family: inherit; cursor: pointer; }

.btn-text {
  background: none; border: none; color: var(--text);
  font-size: 15px; text-decoration: underline;
  text-underline-offset: 3px; padding: 0;
}
.btn-text:hover { color: var(--text-muted); }

.btn-theme {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 17px;
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  line-height: 1;
}
.btn-theme:hover { background: var(--row-hover); }

.btn-primary {
  background: var(--text); color: var(--bg);
  border: none; padding: 9px 20px;
  border-radius: 4px; font-size: 15px; font-weight: 500;
}
.btn-primary:hover { opacity: 0.8; }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-cancel {
  background: none; border: none; color: var(--text-muted);
  font-size: 15px; text-decoration: underline; text-underline-offset: 3px;
}

/* ── Upload Panel ── */
.upload-panel {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.35s ease;
  background: var(--upload-bg);
  border-bottom: 3px solid transparent;
}
.upload-panel.open {
  max-height: 640px;
  border-bottom: 3px solid var(--text);
  box-shadow: 0 6px 32px rgba(0,0,0,0.08);
}
[data-theme="dark"] .upload-panel.open {
  box-shadow: 0 6px 32px rgba(0,0,0,0.5);
}

.upload-inner { padding: 28px 0 24px; display: flex; flex-direction: column; gap: 18px; }
.upload-title { font-size: 16px; font-weight: 600; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; color: var(--text-muted); }

.form-input {
  background: var(--input-bg); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text);
  font-family: inherit; font-size: 15px;
  padding: 9px 12px; width: 100%; outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--text); }
.form-input::placeholder { color: var(--text-muted); }

.file-drop-zone {
  border: 1px dashed var(--border); border-radius: 4px;
  padding: 24px; text-align: center; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.file-drop-zone:hover, .file-drop-zone.drag-over { border-color: var(--text); background: var(--row-hover); }
.file-drop-zone.has-file { border-style: solid; border-color: var(--text); }

.drop-text { font-size: 14px; color: var(--text-muted); }
.link-btn {
  color: var(--text); text-decoration: underline; text-underline-offset: 3px;
  background: none; border: none; font-family: inherit; font-size: inherit; cursor: pointer;
}
.drop-filename { font-size: 14px; color: var(--text); margin-top: 6px; }
.form-actions { display: flex; align-items: center; gap: 16px; padding-top: 4px; }

.progress-wrap { display: flex; flex-direction: column; gap: 6px; }
.progress-bar { height: 2px; background: var(--border); border-radius: 1px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--text); width: 0%; transition: width 0.3s; }
.progress-label { font-size: 13px; color: var(--text-muted); }

.upload-msg { font-size: 14px; }
.upload-msg.error { color: #cc0000; }
.upload-msg.success { color: #006600; }
[data-theme="dark"] .upload-msg.success { color: #44bb44; }
[data-theme="dark"] .upload-msg.error { color: #ff5555; }

/* ── Songs ── */
.main-content { padding: 32px 0 80px; }

.songs-header {
  display: flex; align-items: baseline; gap: 12px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--text);
}
.songs-title { font-size: 16px; font-weight: 600; }
.songs-count { font-size: 14px; color: var(--text-muted); }

.songs-list { display: flex; flex-direction: column; }

/* ── Song row ── */
.song-row { border-bottom: 1px solid var(--border); }

.song-row-main {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  align-items: center;
  gap: 0 14px;
  padding: 13px 0;
  cursor: pointer;
  transition: background 0.1s, padding 0.1s;
  border-radius: 4px;
}
.song-row-main:hover,
.song-row.open .song-row-main {
  background: var(--active-bg);
  padding-left: 8px; padding-right: 8px;
  margin: 0 -8px;
}
.song-row-main:hover .song-actions,
.song-row.open .song-actions { opacity: 1; }

.song-num {
  font-size: 14px; color: var(--text-muted);
  text-align: center; font-variant-numeric: tabular-nums;
}
.song-row.open .song-num { color: var(--text); font-weight: 600; }

.song-info { min-width: 0; }
.song-desc {
  font-size: 16px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.song-desc.unnamed { color: var(--text-muted); font-style: italic; font-weight: 400; font-size: 15px; }
.song-date { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.song-dur { font-size: 14px; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.song-actions { display: flex; align-items: center; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.action-btn {
  background: none; border: none; color: var(--text-muted);
  padding: 5px 8px; font-size: 15px; border-radius: 4px; line-height: 1;
}
.action-btn:hover { color: var(--text); background: var(--border); }

/* ── Inline player ── */
.inline-player {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease;
}
.song-row.open .inline-player { max-height: 120px; }

.inline-player-inner {
  background: var(--player-bg);
  border-radius: 4px;
  padding: 12px 14px 14px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ip-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ip-btn {
  background: none; border: none;
  color: var(--text); line-height: 1;
  padding: 0; font-size: 18px; opacity: 0.65;
}
.ip-btn:hover { opacity: 1; }
.ip-play { font-size: 26px; opacity: 1; }

.ip-time {
  font-size: 12px; color: var(--text-muted);
  min-width: 38px; font-variant-numeric: tabular-nums;
}
.ip-time-r { text-align: right; }

input[type=range] {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 3px;
  background: var(--border); border-radius: 2px;
  outline: none; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%; background: var(--text);
}
input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px;
  border-radius: 50%; background: var(--text); border: none;
}
.vol-range { flex: 0 0 75px !important; }
.vol-label { font-size: 12px; color: var(--text-muted); }

/* ── States ── */
.loading-state { padding: 48px 0; text-align: center; color: var(--text-muted); font-size: 15px; }
.empty-state { padding: 64px 0; text-align: center; color: var(--text-muted); font-size: 15px; line-height: 2; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--text); color: var(--bg);
  padding: 9px 20px; border-radius: 4px; font-size: 14px;
  z-index: 999; opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Share page ── */
.share-page {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 20px; text-align: center; padding: 40px 24px;
}
.share-song-title { font-size: 22px; font-weight: 600; }
.share-song-date { font-size: 14px; color: var(--text-muted); }
.share-back { font-size: 14px; color: var(--text-muted); text-decoration: underline; text-underline-offset: 3px; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .container { padding: 0 16px; }
  .song-row-main { grid-template-columns: 28px 1fr auto auto; gap: 0 10px; }
  .song-desc { font-size: 15px; }
  .ip-vol { display: none; }
}
