:root {
  --bg: #0a0a0f;
  --bg-card: #12121a;
  --bg-surface: #1a1a26;
  --bg-hover: #22222e;
  --bg-active: #2a2a3a;
  --border: #2a2a3a;
  --border-focus: #6366f1;
  --text: #e8e8ed;
  --text-dim: #8888a0;
  --text-muted: #55556a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --success: #10b981;
  --error: #ef4444;
  --radius: 8px;
  --radius-lg: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --transition: 150ms ease;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

/* ---- Login ---- */
.login-section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(99,102,241,0.08) 0%, transparent 60%), var(--bg);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 3rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-icon { color: var(--accent); margin-bottom: 1.5rem; }
.login-card h1 { font-size: 1.5rem; font-weight: 600; margin-bottom: 0.25rem; }
.login-subtitle { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 2rem; }
.error-msg { color: var(--error); font-size: 0.8rem; margin-top: 1rem; min-height: 1.2em; }

.input-group { margin-bottom: 1rem; }
.input-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
  transition: border-color var(--transition);
  outline: none;
}
.input-group input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow); }

/* ---- Buttons ---- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-full { width: 100%; justify-content: center; }

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.4rem 1rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-ghost:hover { border-color: var(--text-dim); color: var(--text); }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  transition: all var(--transition);
}
.btn-icon:hover { color: var(--text); background: var(--bg-hover); }

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.topbar-icon { color: var(--accent); }
.topbar-title { font-weight: 600; font-size: 1rem; }

.badge {
  background: var(--bg-surface);
  color: var(--text-dim);
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 500;
}

/* ---- Layout ---- */
.app-section { display: flex; flex-direction: column; height: 100vh; }
.layout { display: flex; flex: 1; overflow: hidden; }

/* ---- Sidebar ---- */
.sidebar {
  width: 340px;
  min-width: 340px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-search {
  padding: 0.75rem 1rem;
  position: relative;
  border-bottom: 1px solid var(--border);
}
.search-icon {
  position: absolute;
  left: 1.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.sidebar-search input {
  width: 100%;
  padding: 0.55rem 0.75rem 0.55rem 2.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.85rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
}
.sidebar-search input:focus { border-color: var(--border-focus); }

.sidebar-filters {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
}
.filter-row {
  display: flex;
  gap: 0.5rem;
}
.filter-row select {
  flex: 1;
  padding: 0.4rem 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-family: var(--font);
  outline: none;
  cursor: pointer;
}
.filter-row select:focus { border-color: var(--border-focus); }

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
.filter-tags:empty { display: none; }
.filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.filter-tag:hover { background: rgba(99,102,241,0.25); }

/* File list */
.file-list-wrap { flex: 1; overflow-y: auto; }
.file-list { list-style: none; }
.file-list-empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background var(--transition);
}
.file-item:hover { background: var(--bg-hover); }
.file-item.active { background: var(--bg-active); border-left: 3px solid var(--accent); padding-left: calc(1rem - 3px); }

.file-item-cover {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  background: var(--bg-surface);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.file-item-cover img { width: 100%; height: 100%; object-fit: cover; }
.file-item-cover svg { color: var(--text-muted); }

.file-item-info { flex: 1; min-width: 0; }
.file-item-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-item-meta {
  font-size: 0.7rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-item-ext {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  background: var(--bg-surface);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ---- Editor ---- */
.editor {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}

.editor-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--text-muted);
}

/* Hero */
.editor-hero {
  display: flex;
  gap: 1.5rem;
  padding: 2rem;
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
}

.cover-wrap { position: relative; flex-shrink: 0; }
.cover-art {
  width: 160px;
  height: 160px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border);
}
.cover-art img { width: 100%; height: 100%; object-fit: cover; }
.cover-placeholder { color: var(--text-muted); }

.cover-upload-btn {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.cover-upload-btn:hover { color: var(--accent); border-color: var(--accent); }

.editor-hero-info { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.hero-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 0.25rem; }
.hero-artist { color: var(--text-dim); font-size: 1rem; margin-bottom: 0.75rem; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 500;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(99,102,241,0.15);
}
.tag-dim {
  background: var(--bg-surface);
  color: var(--text-dim);
  border-color: var(--border);
}
.tag:empty { display: none; }

/* ---- Form ---- */
.meta-form { padding: 0 2rem 2rem; }

.form-section {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
}
.form-section:last-of-type { border-bottom: none; }
.form-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem; }
.form-grid-4 { grid-template-columns: repeat(4, 1fr); }

.field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}
.field input, .field textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  resize: vertical;
}
.field input:focus, .field textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.field-full { grid-column: 1 / -1; margin-top: 0.5rem; }

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 1.5rem;
  margin-top: 0.5rem;
}

.save-status { font-size: 0.85rem; color: var(--text-muted); }
.save-status.success { color: var(--success); font-weight: 500; }
.save-status.error { color: var(--error); font-weight: 500; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- Spinner ---- */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; min-width: 0; max-height: 45vh; border-right: none; border-bottom: 1px solid var(--border); }
  .editor-hero { flex-direction: column; align-items: center; text-align: center; }
  .cover-art { width: 120px; height: 120px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid-4 { grid-template-columns: 1fr 1fr; }
  .hero-tags { justify-content: center; }
}
