:root {
  --bg: #121110;
  --bg-elevated: #1c1916;
  --bg-card: #242019;
  --border: #3a342c;
  --text: #f7f3ed;
  --muted: #a89f92;
  --accent: #c9a962;
  --accent-dim: #8a7340;
  --danger: #d45c5c;
  --success: #6bc48a;
  --radius: 12px;
  --sidebar: 240px;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

.brand-mark {
  font-size: 1.1rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0;
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(ellipse at 30% 20%, #2a241c 0%, var(--bg) 55%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}
.login-card h1 { margin: 0.5rem 0 0; font-size: 1.75rem; font-weight: 500; }
.sub { color: var(--muted); font-size: 0.9rem; margin: 0.35rem 0 1.25rem; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; padding: 1rem; }
  .nav { flex-direction: row; flex-wrap: wrap; width: 100%; }
}

.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.sidebar-tag { color: var(--muted); font-size: 0.75rem; margin: 0 0 1rem; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  text-align: left;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.92rem;
}
.nav-item:hover { background: rgba(201, 169, 98, 0.08); color: var(--text); }
.nav-item.active {
  background: rgba(201, 169, 98, 0.15);
  color: var(--accent);
  font-weight: 600;
}
.sidebar-out { margin-top: auto; }

.main { padding: 1.75rem 2rem 3rem; max-width: 1100px; }
.main-head h1 { margin: 0; font-size: 1.5rem; font-weight: 500; }
.main-head .sub { margin-top: 0.35rem; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card-title { font-size: 1rem; margin: 0 0 1rem; font-weight: 600; }

label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.35rem; }
input, select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}
.field-row { margin-bottom: 0.75rem; }
.field-row.split {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: end;
}

.btn {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #1a1510; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.35rem 0.6rem; font-size: 0.78rem; }

.pill-row { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.pill {
  padding: 0.45rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.pill.active { border-color: var(--accent); color: var(--accent); }

.drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  margin: 0.75rem 0;
}
.drop.drag { border-color: var(--accent); background: rgba(201, 169, 98, 0.06); }
.hint { font-size: 0.8rem; color: var(--muted); margin: 0.25rem 0 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 0.65rem;
}
.thumb {
  position: relative;
  aspect-ratio: 3/4;
  border-radius: 8px;
  overflow: hidden;
  background: #0e0d0c;
  border: 1px solid var(--border);
}
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb .badge {
  position: absolute;
  top: 6px; left: 6px;
  font-size: 0.62rem;
  background: rgba(0,0,0,.75);
  padding: 2px 6px;
  border-radius: 4px;
}
.thumb .actions {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  gap: 4px;
  padding: 6px;
  background: linear-gradient(transparent, rgba(0,0,0,.9));
  justify-content: center;
  flex-wrap: wrap;
}

.cover-list { display: flex; flex-direction: column; gap: 1rem; }
.cover-row {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.cover-row:last-child { border-bottom: none; }
.cover-preview {
  aspect-ratio: 16/10;
  border-radius: 8px;
  overflow: hidden;
  background: #0e0d0c;
  border: 1px solid var(--border);
}
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.cover-label h3 { margin: 0; font-size: 0.95rem; }
.cover-label p { margin: 0.25rem 0 0; font-size: 0.8rem; color: var(--muted); }

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.stat-card .num { font-size: 1.75rem; font-weight: 600; color: var(--accent); }
.stat-card .lbl { font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; }

.stats-toolbar { margin-bottom: 1rem; max-width: 220px; }
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
table.data th, table.data td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
}
table.data th { color: var(--muted); font-weight: 500; }

.msg { font-size: 0.88rem; margin-top: 0.5rem; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--success); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.65);
}
.modal-box {
  position: relative;
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  overflow: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.modal-head h2 { margin: 0; font-size: 1.1rem; }
.picker-grid .thumb { cursor: pointer; }
.picker-grid .thumb:hover { outline: 2px solid var(--accent); }
