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

:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --border:    #30363d;
  --accent:    #4493f8;
  --text:      #e6edf3;
  --muted:     #7d8590;
  --song-bar:   #388bfd;
  --song-bg:    rgba(56, 139, 253, 0.07);
  --att-bar:    #a371f7;
  --att-bg:     rgba(163, 113, 247, 0.07);
  --title-bar:  #4ac8b4;
  --title-bg:   rgba(74, 200, 180, 0.07);
  --warn:      #d29922;
  --error-bg:  #2d1b1b;
  --error:     #f85149;
  --radius:    8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  padding: 2.5rem 1rem 4rem;
}

.container {
  max-width: 680px;
  margin: 0 auto;
}

header {
  text-align: center;
  margin-bottom: 1.8rem;
}
header h1 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* URL input card */
.url-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.url-row {
  display: flex;
  gap: 8px;
}

.url-row input[type=url] {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 7px 11px;
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
  min-width: 0;
}
.url-row input[type=url]:focus { border-color: var(--accent); }
.url-row input[type=url]::placeholder { color: var(--muted); }

/* Buttons */
button {
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  transition: opacity .15s;
  white-space: nowrap;
}
button:hover:not(:disabled) { opacity: .85; }
button:active:not(:disabled) { opacity: .7; }
button:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }

.btn-download {
  display: block;
  width: 100%;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  padding: 10px;
  border-radius: 6px;
  margin-top: 10px;
  text-align: center;
}

/* Error */
.error {
  background: var(--error-bg);
  border: 1px solid var(--error);
  border-radius: var(--radius);
  color: var(--error);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 1rem;
}

/* Spinner */
.spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  padding: 1.2rem 0;
}
.spinner-ring {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Items list */
.items-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-left: 3px solid transparent;
  min-height: 34px;
}
.item + .item {
  border-top: 1px solid rgba(255,255,255,0.05);
}
.item.song {
  border-left-color: var(--song-bar);
  background: var(--song-bg);
}
.item.attachment {
  border-left-color: var(--att-bar);
  background: var(--att-bg);
}
.item.title {
  border-left-color: var(--title-bar);
  background: var(--title-bg);
}
.item.other {
  background: rgba(255,255,255,0.02);
}

.item-role {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  width: 62px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item.song .item-role       { color: #79c0ff; }
.item.attachment .item-role { color: #c5a3ff; }
.item.title .item-role      { color: #7ee8d8; }

.item-title {
  flex: 1;
  font-size: 13px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-meta {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.item-warn {
  font-size: 12px;
  color: var(--warn);
  white-space: nowrap;
  flex-shrink: 0;
}
.item-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--att-bar);
  background: rgba(163,113,247,0.15);
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Config section */
.config-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.config-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.config-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: 110px;
  flex-shrink: 0;
}

.cfg-number {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 13px;
  padding: 4px 8px;
  width: 64px;
  outline: none;
  transition: border-color .15s;
}
.cfg-number:focus { border-color: var(--accent); }

/* Background image selector */
.bg-options {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.bg-option {
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}

.bg-option input[type=radio] {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}

.bg-option-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
  transition: border-color .15s;
}

.bg-option input[type=radio]:checked + .bg-option-inner {
  border-color: var(--accent);
}

.bg-option-none .bg-option-inner {
  width: 96px; height: 54px;
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
}

.bg-option-thumb .bg-option-inner {
  width: 96px; height: 54px;
}

.bg-option-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.bg-option-label {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  margin-top: 3px;
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hidden { display: none !important; }
