:root {
  --bg: #0b1220;
  --surface: #131c2e;
  --surface-2: #1c2740;
  --border: #243049;
  --text: #e6edf7;
  --muted: #8a96b1;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #334155;
  --danger: #b91c1c;
  --ok: #16a34a;
  --warn: #f59e0b;
  --radius: 10px;
  --pad: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: 'Segoe UI', 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  min-height: 100vh;
}

.hidden { display: none !important; }

a { color: var(--text); text-decoration: none; }
input, textarea, select, button { font-family: inherit; font-size: inherit; }

/* ---------------- login ---------------- */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-title { margin: 0 0 6px; font-size: 26px; font-weight: 700; }
.login-subtitle { margin: 0 0 24px; color: var(--muted); }
.google-btn-host { display: flex; justify-content: center; min-height: 44px; }
.login-error { color: var(--danger); margin: 12px 0 0; font-size: 13px; min-height: 18px; }

/* ---------------- topbar ---------------- */
.topbar {
  display: flex; align-items: center;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 24px;
  flex-wrap: wrap;
  position: sticky; top: 0; z-index: 10;
}
.topbar__title { margin: 0; font-size: 18px; font-weight: 700; }
.topbar__nav { display: flex; gap: 6px; flex: 1; }
.nav-link {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.is-active { background: var(--surface-2); color: var(--text); }
.topbar__right { display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--muted); font-size: 13px; }

/* ---------------- views ---------------- */
.view-root { padding: 24px; max-width: 1100px; margin: 0 auto; }

.section-title { margin: 0 0 16px; font-size: 20px; font-weight: 600; }
.section-sub { color: var(--muted); margin: -10px 0 18px; font-size: 13px; }

/* ---------------- buttons ---------------- */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  transition: background 0.15s;
}
.btn--small { padding: 6px 12px; font-size: 13px; }
.btn--block { width: 100%; }
.btn--primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn--primary:hover { background: var(--primary-hover); }
.btn--secondary { background: var(--secondary); color: white; }
.btn--ghost { background: transparent; border-color: var(--border); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------------- inputs ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 500; }
.input, .textarea, .select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
}
.input:focus, .textarea:focus, .select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.textarea { min-height: 220px; resize: vertical; font-family: 'JetBrains Mono', 'Consolas', monospace; }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row .field { flex: 1; min-width: 140px; margin-bottom: 0; }

/* ---------------- card ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
}

/* ---------------- table ---------------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; font-size: 14px; }
.table th {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
}
.table tbody tr { border-bottom: 1px solid var(--border); }
.table tbody tr:hover { background: var(--surface); }

/* ---------------- library ---------------- */
.upload-row { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.upload-status { color: var(--muted); font-size: 13px; }

.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.lib-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.lib-card__thumb {
  aspect-ratio: 16 / 9;
  background: #000 center / cover no-repeat;
  border-bottom: 1px solid var(--border);
}
.lib-card__body { padding: 12px; }
.lib-card__title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lib-card__meta { color: var(--muted); font-size: 12px; margin: 0 0 10px; }
.lib-card__actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------- gerador ---------------- */
.generator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 800px) {
  .generator-grid { grid-template-columns: 1fr; }
}
.preview-frame {
  background: #000;
  border-radius: 8px;
  border: 1px solid var(--border);
  aspect-ratio: 16 / 9;
  display: flex; align-items: center; justify-content: center;
  color: white;
  text-align: center;
  padding: 30px;
  overflow: hidden;
}
.preview-frame__inner {
  white-space: pre-line;
  line-height: 1.3;
  font-weight: 700;
}
.preview-counter { color: var(--muted); font-size: 13px; text-align: center; margin: 8px 0; }
.preview-nav { display: flex; gap: 8px; justify-content: center; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.tag--gen { background: rgba(37,99,235,0.18); color: #93c5fd; }
.tag--up { background: rgba(22,163,74,0.16); color: #86efac; }

.empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 12px;
}

/* ---------------- toast ---------------- */
.toast-stack {
  position: fixed; right: 16px; bottom: 16px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 50;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  min-width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.toast--ok { border-color: rgba(22,163,74,0.5); }
.toast--err { border-color: rgba(185,28,28,0.55); }

/* token reveal modal */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 40;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  width: 100%;
  max-width: 480px;
}
.modal h3 { margin: 0 0 8px; }
.modal p { color: var(--muted); margin: 0 0 14px; font-size: 13px; }
.token-display {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  word-break: break-all;
  margin-bottom: 14px;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
