:root {
  --bg: #0b0d12;
  --panel: #12151c;
  --panel-2: #181c25;
  --line: #262b36;
  --text: #e9ecf2;
  --muted: #8b93a3;
  --blue: #3d8bff;
  --blue-dim: #1f4f99;
  --danger: #ff6b6b;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, sans-serif; }
h1, h2, h3 { margin: 0 0 12px; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 1em; }
.hidden { display: none !important; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 8px; padding: 8px 14px; background: var(--panel-2); }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--blue); color: #fff; font-weight: 600; }
.primary:hover:not(:disabled) { background: #5a9cff; }
.secondary { background: var(--panel-2); border: 1px solid var(--line); }
.secondary:hover { border-color: var(--blue); }
.link { background: none; padding: 4px 6px; color: var(--muted); }
.link:hover { color: var(--text); }
.danger { color: var(--danger); }
label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 12px; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 14px; width: 100%; }
textarea { resize: vertical; min-height: 60px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px; padding: 10px 20px; background: rgba(11, 13, 18, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, #3d8bff, #1d5fd1); }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tabs button { background: none; color: var(--muted); padding: 8px 12px; border-radius: 0; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--text); border-bottom-color: var(--blue); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; white-space: nowrap; }

main { padding: 20px; }
.tab { display: none; }
.tab.active { display: block; }
.split { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.side { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; position: sticky; top: 72px; max-height: calc(100vh - 92px); overflow: auto; }
.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.side-head h2 { margin: 0; }
.pane { min-width: 0; }
.empty { padding: 40px 0; text-align: center; }
.controls { display: flex; flex-direction: column; gap: 12px; }
.row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.row2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.list li:hover { background: var(--panel-2); }
.list li.active { background: var(--panel-2); box-shadow: inset 2px 0 0 var(--blue); }
.list img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; }
.list .sub { display: block; color: var(--muted); font-size: 12px; }

.refs-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.file-btn { flex-direction: row; cursor: pointer; color: var(--blue); font-size: 13px; }
.refs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ref { position: relative; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.ref img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.ref select { border: 0; border-top: 1px solid var(--line); border-radius: 0; font-size: 11px; padding: 4px; }
.ref .x { position: absolute; top: 4px; right: 4px; background: rgba(0, 0, 0, .65); padding: 2px 7px; font-size: 12px; }
.ref.primary-ref { border-color: var(--blue); }
.ref .star { position: absolute; top: 4px; left: 4px; background: rgba(0, 0, 0, .65); padding: 2px 7px; font-size: 11px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card .media { background: #000; display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; cursor: zoom-in; }
.card .meta { padding: 8px 10px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.card .actions { display: flex; flex-wrap: wrap; gap: 4px; }
.card .actions button { padding: 4px 8px; font-size: 12px; }
.placeholder { aspect-ratio: 4 / 5; display: flex; align-items: center; justify-content: center; color: var(--muted); background: repeating-linear-gradient(45deg, #11141b, #11141b 10px, #141821 10px, #141821 20px); }
.gallery-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.gallery-head select { width: auto; }

/* Campaign editor */
.camp-head { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; margin-bottom: 16px; }
.camp-settings { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; margin-bottom: 16px; }
.camp-settings .row4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.camp-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.shots { display: grid; gap: 14px; }
.shot { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: grid; grid-template-columns: 260px 1fr; gap: 16px; padding: 14px; }
.shot-media { display: flex; flex-direction: column; gap: 8px; }
.shot-media .main { width: 100%; border-radius: 8px; background: #000; cursor: zoom-in; display: block; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumbs img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; cursor: pointer; opacity: .6; border: 1px solid transparent; }
.thumbs img.picked { opacity: 1; border-color: var(--blue); }
.shot-fields { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.shot-title { display: flex; gap: 8px; align-items: center; }
.shot-title input { font-weight: 600; }
.shot-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.working { color: var(--blue); }

.char-form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; margin-bottom: 16px; }
.char-refs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 16px; max-width: min(1100px, 94vw); max-height: 92vh; }
dialog::backdrop { background: rgba(0, 0, 0, .7); }
.viewer-body { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; margin-bottom: 12px; }
#viewerMedia img, #viewerMedia video { max-width: 100%; max-height: 78vh; border-radius: 8px; display: block; margin: auto; }
#viewerInfo { font-size: 12px; color: var(--muted); overflow: auto; max-height: 78vh; white-space: pre-wrap; word-break: break-word; }
.small-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); max-height: 65vh; overflow: auto; margin-bottom: 12px; }
.small-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
.small-grid img:hover { border-color: var(--blue); }

.login { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.login-card { width: min(360px, 90vw); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; display: grid; gap: 12px; }

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
  .shot { grid-template-columns: 1fr; }
  .camp-settings .row4 { grid-template-columns: repeat(2, 1fr); }
  .viewer-body { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; gap: 8px; }
}
