:root {
  --bg: #0e0e0e;
  --bg2: #161616;
  --bg3: #1e1e1e;
  --bg4: #272727;
  --border: rgba(255,255,255,0.08);
  --border2: rgba(255,255,255,0.14);
  --text: #f0ede8;
  --text2: #9e9b96;
  --text3: #5e5c58;
  --accent: #e8d5a3;
  --accent2: #b8a47a;
  --star: #e8c84a;
  --radius: 10px;
  --radius-sm: 6px;

  --raw:   #4a9eff;
  --rsrch: #f0a500;
  --prod:  #3dba6f;
  --thumb: #4a9eff;
  --edit:  #a78bfa;
  --title: #f0a500;
  --art:   #3dba6f;
  --hire:  #f472b6;
}

* { box-sizing: border-box; }
html, body { background: var(--bg); color: var(--text); }
body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #333; }

/* --- LOGIN --- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
}
.login-title {
  font-family: Georgia, serif;
  font-weight: normal;
  font-size: 28px;
  letter-spacing: 0.02em;
  color: var(--accent);
  margin: 0 0 24px;
  text-align: center;
}
.field { display: block; margin-bottom: 14px; }
.field span {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text2);
  margin-bottom: 6px;
}
input[type=text], input[type=password], input[type=search], input[type=url], textarea, select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-family: Georgia, serif;
  font-size: 14px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent2); }
textarea { resize: vertical; min-height: 80px; }
.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #1a1308;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: Georgia, serif;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  margin-top: 6px;
}
.btn-primary:hover { background: #f0deb5; }
.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-family: Georgia, serif;
  font-size: 13px;
  cursor: pointer;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border2); }
.btn-danger {
  background: transparent;
  color: #e07b7b;
  border: 1px solid rgba(224,123,123,0.3);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-family: Georgia, serif;
  cursor: pointer;
}
.btn-danger:hover { background: rgba(224,123,123,0.08); }
.login-err {
  color: #e07b7b;
  font-size: 13px;
  margin: 10px 0 0;
  text-align: center;
}

/* --- TOPBAR --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(14,14,14,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  padding: 14px 24px;
  gap: 28px;
}
.brand {
  font-size: 19px;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.nav { display: flex; gap: 22px; flex: 1; }
.nav-link {
  color: var(--text2);
  font-size: 14px;
  letter-spacing: 0.02em;
  padding-bottom: 4px;
  border-bottom: 1px solid transparent;
}
.nav-link:hover { color: var(--text); text-decoration: none; }
.nav-link.active { color: var(--accent); border-bottom-color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.save-indicator {
  font-size: 12px;
  color: var(--text2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.save-indicator .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--art);
  display: inline-block;
}
.save-indicator.saving .dot { background: var(--rsrch); }
.save-indicator.error .dot { background: #e07b7b; }

/* --- LAYOUT --- */
.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  max-width: 1600px;
  margin: 0 auto;
  gap: 0;
  padding: 20px 24px 60px;
}
.sidebar {
  padding-right: 20px;
  border-right: 1px solid var(--border);
  font-size: 13.5px;
}
.sidebar h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text3);
  margin: 22px 0 8px;
  font-weight: normal;
}
.sidebar h3:first-child { margin-top: 4px; }
.sidebar .filter {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  user-select: none;
  gap: 8px;
}
.sidebar .filter:hover { background: var(--bg2); color: var(--text); }
.sidebar .filter.active {
  background: var(--bg3);
  color: var(--text);
}
.sidebar .filter .swatch {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
}
.sidebar .filter .count {
  margin-left: auto;
  color: var(--text3);
  font-size: 12px;
}

.main { padding-left: 24px; min-width: 0; }
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  align-items: center;
}
.search { flex: 1; }
.select { width: 170px; }

/* --- GRID --- */
.grid {
  column-count: 4;
  column-gap: 16px;
}
@media (max-width: 1200px) { .grid { column-count: 3; } }
@media (max-width: 820px)  { .grid { column-count: 2; } }
@media (max-width: 520px)  { .grid { column-count: 1; } }

.card {
  break-inside: avoid;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 16px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 120ms, transform 120ms;
}
.card:hover { border-color: var(--border2); }
.card .img {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  background: var(--bg3);
}
.card .placeholder {
  display: grid;
  place-items: center;
  height: 140px;
  background: var(--bg3);
  color: var(--text3);
  font-size: 32px;
}
.card .title-card {
  background: var(--bg2);
  padding: 22px 18px;
  min-height: 140px;
  display: flex;
  align-items: flex-start;
  font-family: 'Roboto', sans-serif;
  font-weight: 700;
  font-size: 22px;
  line-height: 1.2;
  color: var(--text);
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-body { padding: 12px 14px 14px; }
.card-title {
  font-size: 15.5px;
  color: var(--text);
  margin: 4px 0 8px;
  line-height: 1.3;
}
.card-hook {
  font-style: italic;
  color: var(--accent);
  font-size: 13.5px;
  margin: 0 0 8px;
}
.card-notes {
  color: var(--text2);
  font-size: 13px;
  margin: 0 0 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
}
.card-source {
  font-size: 12px;
  color: var(--text3);
  margin-top: 6px;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-md {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text2);
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  margin-top: 6px;
}

/* badges */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: bold;
  font-family: Georgia, serif;
}
.badge.raw       { color: var(--raw);   background: rgba(74,158,255,0.12); }
.badge.researching { color: var(--rsrch); background: rgba(240,165,0,0.12); }
.badge.production  { color: var(--prod);  background: rgba(61,186,111,0.12); }
.badge.thumbnail { color: var(--thumb); background: rgba(74,158,255,0.12); }
.badge.editing   { color: var(--edit);  background: rgba(167,139,250,0.12); }
.badge.title     { color: var(--title); background: rgba(240,165,0,0.12); }
.badge.art       { color: var(--art);   background: rgba(61,186,111,0.12); }
.badge.for-hire  { color: var(--hire);  background: rgba(244,114,182,0.12); }

.pill {
  display: inline-block;
  background: var(--bg3);
  color: var(--text2);
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 999px;
}

.stars { color: var(--star); font-size: 14px; letter-spacing: 1px; }
.stars .empty { color: var(--bg4); }

.empty {
  text-align: center;
  color: var(--text3);
  padding: 80px 0;
  font-size: 14px;
}

/* --- MODAL --- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
}
.modal {
  width: 100%;
  max-width: 720px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  margin: 0;
  font-size: 17px;
  color: var(--accent);
  font-weight: normal;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow: auto; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.modal-footer .right { display: flex; gap: 10px; }

/* --- DETAIL --- */
.detail-img {
  width: 100%;
  max-height: 440px;
  object-fit: contain;
  background: var(--bg);
  display: block;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.detail-title {
  font-size: 22px;
  margin: 0 0 8px;
  color: var(--text);
}
.detail-hook {
  font-style: italic;
  color: var(--accent);
  margin: 0 0 14px;
}
.detail-notes {
  color: var(--text);
  font-size: 14.5px;
  white-space: pre-wrap;
  line-height: 1.65;
  margin: 0 0 14px;
}
.detail-source {
  color: var(--text2);
  font-size: 13px;
  margin: 0 0 12px;
  display: block;
}
.detail-md {
  border-top: 1px solid var(--border);
  margin-top: 20px;
  padding-top: 16px;
  color: var(--text);
  font-family: Georgia, serif;
  font-size: 14.5px;
  line-height: 1.65;
}
.detail-md h1, .detail-md h2, .detail-md h3 { color: var(--accent); font-weight: normal; }
.detail-md h1 { font-size: 22px; margin: 16px 0 10px; }
.detail-md h2 { font-size: 18px; margin: 14px 0 8px; }
.detail-md h3 { font-size: 16px; margin: 12px 0 6px; }
.detail-md code {
  background: var(--bg3);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 13px;
  color: var(--accent);
}
.detail-md blockquote {
  border-left: 3px solid var(--accent2);
  margin: 10px 0;
  padding: 4px 14px;
  color: var(--text2);
  font-style: italic;
}
.detail-md hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}
.detail-md ul, .detail-md ol { padding-left: 22px; }
.detail-md li { margin: 4px 0; }

/* --- FORM helpers --- */
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.stars-input { display: inline-flex; align-items: center; gap: 4px; }
.stars-input button {
  background: none;
  border: none;
  color: var(--bg4);
  font-size: 22px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.stars-input button.on { color: var(--star); }
.stars-label {
  margin-left: 10px;
  color: var(--text2);
  font-size: 12px;
}

.dropzone {
  border: 1px dashed var(--border2);
  border-radius: var(--radius-sm);
  padding: 22px;
  text-align: center;
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  position: relative;
}
.dropzone.dragging { border-color: var(--accent); color: var(--accent); }
.dropzone.has-image { padding: 0; }
.dropzone .preview {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  display: block;
  background: var(--bg);
}
.dropzone .remove {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(0,0,0,0.7);
  color: var(--text);
  border: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
}

.tag-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag-toggle {
  background: var(--bg3);
  color: var(--text2);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 12px;
  cursor: pointer;
  font-family: Georgia, serif;
}
.tag-toggle.on {
  background: var(--bg4);
  color: var(--text);
  border-color: var(--border2);
}

.md-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 12.5px;
  margin-top: 8px;
}
.md-badge button {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 14px;
}

label.field-block {
  display: block;
  margin-bottom: 14px;
}
label.field-block > span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 5px;
}
