:root {
  --bg: #0d0d10;
  --surf: #17161c;
  --surf2: #1b1a20;
  --chip: #1e1c24;
  --line: #232128;
  --code: #0f0e13;
  --txt: #f4f2f7;
  --txt2: #93919e;
  --txt3: #6b6975;
  --accent: #b9a6ff;
  --accent-strong: #a68bff;
  --mint: #8fdcb6;
  --peach: #f3c176;
  --danger: #f3766b;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
/* .login-screen, .app-shell, and .drawer-overlay all set `display` unconditionally
   below, which silently overrides the `hidden` attribute the JS toggles (author
   CSS beats the browser's default [hidden] styling at equal specificity) — this
   guarantees `hidden` always wins regardless of what any other rule sets. */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: Outfit, system-ui, sans-serif;
  font-size: 14px;
}
code {
  font-family: 'JetBrains Mono', monospace;
  background: var(--code);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12.5px;
}
button { font-family: inherit; cursor: pointer; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(140deg, #c9baff, #8f74ff);
  color: #20143f; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-weight: 600; letter-spacing: -0.01em; font-size: 16px; }

/* ---------- login ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(900px 600px at 50% -10%, #17141f, #0d0d10 70%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surf);
  border: 1px solid var(--line); border-radius: 20px; padding: 32px;
}
.login-sub { color: var(--txt2); font-size: 13.5px; margin: 16px 0 20px; line-height: 1.5; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--txt2); }
.login-form input {
  background: var(--surf2); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; color: var(--txt); font-size: 14px;
}
.login-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-footnote { margin-top: 18px; font-size: 11.5px; color: var(--txt3); line-height: 1.6; }
.form-error { color: var(--danger); font-size: 12.5px; margin: 0; }

/* ---------- app shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex: none; background: var(--surf); border-right: 1px solid var(--line);
  padding: 20px 16px; display: flex; flex-direction: column; gap: 28px;
}
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; background: none; border: none;
  color: var(--txt2); padding: 10px 12px; border-radius: 10px; font-size: 14px; font-weight: 500;
  text-align: left;
}
.nav-item:hover { background: var(--surf2); color: var(--txt); }
.nav-item.is-active { background: var(--chip); color: var(--txt); }
.nav-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.user-email { font-size: 11.5px; color: var(--txt3); word-break: break-all; }

.main { flex: 1; padding: 32px 40px; overflow-y: auto; }
.view-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.view-header h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.view-sub { margin: 4px 0 0; color: var(--txt3); font-size: 13px; }

/* ---------- filters ---------- */
.filters { display: flex; gap: 10px; margin-bottom: 16px; }
.filters select, .filters input {
  background: var(--surf); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; color: var(--txt); font-size: 13px;
}
.filters input { flex: 1; }

/* ---------- table ---------- */
.table-wrap { background: var(--surf); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11px; letter-spacing: 0.04em; color: var(--txt3);
  font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--line);
}
tbody td { padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surf2); }
.table-empty { text-align: center; color: var(--txt3); padding: 32px !important; }
.cell-cover { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; display: block; background: var(--chip); }
.tag-pill { display: inline-block; padding: 3px 9px; border-radius: 999px; background: var(--chip); color: var(--txt2); font-size: 11.5px; }
.pill-mint { background: var(--mint); color: #0b2f1d; font-weight: 600; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- buttons ---------- */
.btn {
  border: none; border-radius: 999px; padding: 10px 18px; font-size: 13.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--accent); color: #1c1330; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: var(--surf2); color: var(--txt2); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--txt); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(243,118,107,0.4); }
.btn-danger:hover { background: rgba(243,118,107,0.1); }
.btn-small { padding: 7px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: none; background: var(--surf2);
  color: var(--txt2); display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--txt); }

/* ---------- drawer ---------- */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; justify-content: flex-end; z-index: 50;
}
.drawer {
  width: 460px; max-width: 100%; background: var(--surf); height: 100%; overflow-y: auto;
  border-left: 1px solid var(--line); padding: 24px; animation: slideIn .18s ease-out;
}
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.drawer-header h2 { margin: 0; font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field span { font-size: 12px; color: var(--txt2); font-weight: 500; }
.field input, .field select, .field textarea {
  background: var(--surf2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; color: var(--txt); font-size: 13.5px; font-family: inherit;
}
.field textarea { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; line-height: 1.6; resize: vertical; }
.field-hint { font-size: 11px; color: var(--txt3); }
.checkbox-field { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.checkbox-field input { width: 16px; height: 16px; }
.cover-preview {
  width: 100%; aspect-ratio: 3/4; border-radius: 12px; background: var(--chip);
  background-size: cover; background-position: center; margin-bottom: 10px;
  display: flex; align-items: center; justify-content: center; color: var(--txt3); font-size: 12px;
  overflow: hidden;
}
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.upload-row { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; }
.drawer-actions { display: flex; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surf2); border: 1px solid var(--line); color: var(--txt);
  padding: 12px 20px; border-radius: 999px; font-size: 13px; z-index: 100;
}
.toast.is-error { border-color: rgba(243,118,107,0.5); color: var(--danger); }

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 12px 16px; }
  .nav { flex-direction: row; }
  .sidebar-footer { display: none; }
  .main { padding: 20px; }
}
