:root {
  --bg: #0e0f12;
  --bg-1: #15171c;
  --bg-2: #1c1f26;
  --bg-3: #252932;
  --line: #2d323d;
  --line-2: #3a414f;
  --fg: #e6e8ec;
  --fg-dim: #9aa0ac;
  --fg-mute: #6a6f7a;
  --accent: #ffb454;
  --accent-2: #ff8c42;
  --ok: #6cc788;
  --warn: #ffcc66;
  --bad: #ef6f6c;
  --placeholder: #b08aff;
  --wip: #ffcc66;
  --final: #6cc788;
  --radius: 8px;
  --shadow: 0 6px 18px rgba(0,0,0,0.4);
  --font: -apple-system, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* Scrollbar custom (proibido scrollbar default) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--line-2); }

/* Focus ring custom (proibido azul default) */
*:focus { outline: none; }
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ------ topbar ------ */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px var(--accent-2);
}
.brand-name { font-size: 15px; }
.brand-domain { color: var(--fg-mute); }
.spacer { flex: 1; }

.crumbs { display: flex; align-items: center; gap: 6px; color: var(--fg-dim); font-size: 13px; }
.crumbs .sep { color: var(--fg-mute); }
.crumbs a:hover { color: var(--fg); }
.crumbs .here { color: var(--fg); }

/* ------ buttons ------ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: var(--bg-2); color: var(--fg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit; font-size: 13px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--bg-3); border-color: var(--line-2); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a1a1a; border-color: transparent; font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--bad); border-color: var(--line-2); }
.btn-danger:hover { background: rgba(239, 111, 108, 0.12); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

/* ------ inputs ------ */
.input, .textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-1);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit; font-size: 13px;
}
.input:focus, .textarea:focus { border-color: var(--accent); }
.textarea { resize: vertical; min-height: 64px; }

.field-label {
  display: block; margin-bottom: 4px;
  color: var(--fg-dim); font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.field-hint {
  margin-top: 4px;
  color: var(--fg-mute);
  font-size: 11px;
  font-family: var(--mono);
}

.checkbox {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 0;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
}
.checkbox input[type="checkbox"] {
  width: 16px; height: 16px; margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ------ main view ------ */
main { padding: 24px 18px 80px; max-width: 1280px; margin: 0 auto; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 18px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: 0.6px; }
.muted { color: var(--fg-mute); }
.dim { color: var(--fg-dim); }

.empty {
  padding: 40px;
  text-align: center;
  color: var(--fg-mute);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* ------ project cards ------ */
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.section-head h1 { margin: 0; flex: 1; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.12s, transform 0.12s;
}
.card:hover { border-color: var(--line-2); transform: translateY(-1px); }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.card-desc { color: var(--fg-mute); font-size: 12px; margin-bottom: 10px; line-height: 1.4; max-height: 2.8em; overflow: hidden; }
.card-stats { display: flex; gap: 6px; flex-wrap: wrap; font-size: 11px; }
.stat { padding: 2px 8px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); }
.stat.placeholder { color: var(--placeholder); }
.stat.wip { color: var(--wip); }
.stat.final { color: var(--final); }

/* ------ asset table/grid ------ */
.toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-bottom: 16px;
}
.toolbar .input { width: auto; min-width: 240px; }

.paste-hint {
  margin: -12px 0 16px;
  font-size: 11px;
  color: var(--fg-mute);
  font-style: italic;
}

.dev-bar { margin-bottom: 16px; }
.dev-toggle { color: var(--fg-mute); }
.dev-panel {
  margin-top: 10px;
  padding: 14px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 12px;
}
.dev-row { display: flex; flex-direction: column; gap: 6px; }
.dev-url { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dev-url code {
  background: var(--bg-2); padding: 6px 10px; border-radius: 4px;
  font-size: 12px; color: var(--fg-dim);
  word-break: break-all;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.asset-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.12s;
}
.asset-card:hover { border-color: var(--line-2); }
.asset-thumb {
  aspect-ratio: 1 / 1;
  background:
    linear-gradient(45deg, #1a1c20 25%, transparent 25%),
    linear-gradient(-45deg, #1a1c20 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1a1c20 75%),
    linear-gradient(-45deg, transparent 75%, #1a1c20 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  background-color: #0a0b0d;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.asset-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.asset-thumb .empty-thumb { color: var(--fg-mute); font-size: 22px; }
.asset-thumb .badge {
  position: absolute; top: 6px; left: 6px;
  padding: 2px 8px; font-size: 10px; border-radius: 999px;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
}
.asset-thumb .badge.placeholder { color: var(--placeholder); }
.asset-thumb .badge.wip { color: var(--wip); }
.asset-thumb .badge.final { color: var(--final); }
.asset-meta { padding: 10px 12px; }
.asset-meta .name { font-weight: 600; font-size: 13px; }
.asset-meta .desc {
  color: var(--fg-mute); font-size: 11px; line-height: 1.35;
  margin-top: 2px; max-height: 2.7em; overflow: hidden;
}

/* ------ asset detail ------ */
.asset-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}
@media (max-width: 880px) { .asset-layout { grid-template-columns: 1fr; } }

.slot-stack { display: flex; flex-direction: column; gap: 16px; }

.slot {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.slot-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.slot-head .label { font-weight: 600; }
.slot-head .pill {
  padding: 2px 8px; font-size: 10px; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--line);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.slot-head .pill.active { color: var(--final); border-color: var(--final); }
.slot-head .spacer { flex: 1; }

.dropzone {
  border: 1.5px dashed var(--line-2);
  border-radius: var(--radius);
  background: rgba(0,0,0,0.2);
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  color: var(--fg-mute);
  transition: border-color 0.12s, background 0.12s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: rgba(255,180,84,0.06);
  color: var(--fg-dim);
}
.dropzone .hint { font-size: 12px; margin-top: 6px; }

.dropzone-modal {
  padding: 14px;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dropzone-placeholder {
  display: flex; flex-direction: column; gap: 4px; align-items: center;
}
.dropzone-preview {
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: 100%;
}
.dropzone-preview img {
  max-width: 100%;
  max-height: 200px;
  object-fit: contain;
  image-rendering: pixelated;
  border-radius: 4px;
}
.preview-audio-icon {
  font-size: 14px;
  color: var(--fg-dim);
  padding: 8px 14px;
}

.preview-img {
  width: 100%;
  background:
    linear-gradient(45deg, #1a1c20 25%, transparent 25%),
    linear-gradient(-45deg, #1a1c20 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1a1c20 75%),
    linear-gradient(-45deg, transparent 75%, #1a1c20 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  background-color: #0a0b0d;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  min-height: 180px;
  margin-bottom: 10px;
}
.preview-img img, .preview-img canvas { max-width: 100%; max-height: 380px; object-fit: contain; image-rendering: pixelated; }
.preview-audio { width: 100%; margin-bottom: 10px; }

.anim-preview { display: flex; flex-direction: column; gap: 6px; }
.anim-meta {
  display: flex; gap: 12px; flex-wrap: wrap;
  font-size: 11px; color: var(--fg-mute);
  margin-bottom: 4px;
}
.anim-sheet {
  margin-top: 6px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  text-align: center;
  overflow: auto;
}
.anim-sheet canvas { image-rendering: pixelated; max-width: 100%; }

.slot-info { display: flex; gap: 10px; font-size: 11px; color: var(--fg-mute); flex-wrap: wrap; }
.slot-info .copy {
  cursor: pointer; padding: 2px 8px; border-radius: 4px;
  background: var(--bg-2); border: 1px solid var(--line);
  font-family: var(--mono); color: var(--fg-dim);
}
.slot-info .copy:hover { background: var(--bg-3); color: var(--fg); }

.refs-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.ref-card {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--bg-2);
  border-radius: 6px;
  overflow: hidden;
}
.ref-card img { width: 100%; height: 100%; object-fit: cover; }
.ref-del {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: var(--bad);
  border: 0; cursor: pointer; display: none;
  align-items: center; justify-content: center;
}
.ref-card:hover .ref-del { display: flex; }

.side {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
  height: fit-content;
}
.side-row { display: flex; flex-direction: column; gap: 4px; }
.side-row .field-label { margin: 0; }
.side-row .value { color: var(--fg); font-size: 13px; word-break: break-word; }
.side-row .value.mono { font-family: var(--mono); font-size: 11px; }

.kind-image { color: var(--placeholder); }
.kind-audio { color: var(--accent); }
.status-placeholder { color: var(--placeholder); }
.status-wip { color: var(--wip); }
.status-final { color: var(--final); }

/* ------ modal ------ */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 320px; max-width: 460px;
  box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal-fields { display: flex; flex-direction: column; gap: 12px; }
.modal-error {
  margin-top: 14px;
  padding: 10px 12px;
  background: rgba(239, 111, 108, 0.12);
  border: 1px solid var(--bad);
  border-radius: 6px;
  color: var(--bad);
  font-size: 13px;
  line-height: 1.4;
}

/* ------ toast ------ */
#toast-root {
  position: fixed; bottom: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease-out;
}
.toast.error { border-color: var(--bad); }
.toast.ok { border-color: var(--ok); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ------ select-custom (proibido <select> nativo) ------ */
.select-custom {
  position: relative;
  display: inline-block;
}
.select-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  color: var(--fg);
}
.select-trigger:hover { border-color: var(--line-2); }
.select-trigger .caret { color: var(--fg-mute); font-size: 10px; }
.select-popup {
  position: absolute; top: calc(100% + 4px); left: 0;
  min-width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 4px;
  box-shadow: var(--shadow);
  z-index: 60;
  display: none;
}
.select-popup.open { display: block; }
.select-option {
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}
.select-option:hover, .select-option.active { background: var(--bg-3); }
