:root {
  --bg: #f4f3f1;
  --surface: #ffffff;
  --ink: #1b1b29;
  --ink-2: #4a4a5c;
  --muted: #8a8a99;
  --line: #e6e5e2;
  --track: #efefef;
  --accent: #5b5bd6;
  --accent-ink: #ffffff;
  --accent-soft: #ecebfd;
  --danger: #d9433b;
  --ok: #1f9d6b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 20, 40, .06), 0 8px 24px rgba(20, 20, 40, .06);
  --c1: #3c6ff6;
  --c2: #f49ac1;
  --c3: #f2554a;
  --c4: #2fb58a;
  --c5: #f5a524;
  --c6: #8b5cf6;
  --c7: #14a3c7;
  --c8: #8a6b4f;
  font-family: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); min-height: 100vh; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
.hidden { display: none !important; }

/* ---------- Botões e campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 10px 18px; border-radius: 999px; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { border-color: #cfcfd6; background: #fafafa; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #2e2e44; border-color: #2e2e44; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: #4c4cc4; border-color: #4c4cc4; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(0,0,0,.05); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #c23a33; border-color: #c23a33; }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.icon-btn {
  width: 40px; height: 40px; padding: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  padding: 11px 14px; font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { resize: vertical; min-height: 80px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Topo ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 14px 24px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: conic-gradient(from 200deg, var(--c1), var(--c6), var(--c2), var(--c3), var(--c1));
  color: #fff; font-size: 14px;
}
.spacer { flex: 1; }

/* ---------- Painel (admin) ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 32px 24px 80px; }
.hero { padding: 56px 24px; text-align: center; margin-bottom: 40px;
  background: linear-gradient(135deg, #fff 60%, #ececee); }
.hero h1 { font-size: clamp(26px, 4vw, 36px); font-weight: 500; margin-bottom: 28px; }
.prompt-box {
  max-width: 720px; margin: 0 auto; position: relative; border-radius: 22px; padding: 3px;
  background: linear-gradient(120deg, #9a8cf2, #c58ad8, #f0a070);
  box-shadow: 0 0 0 6px #e3e1fb;
}
.prompt-box textarea {
  display: block; width: 100%; min-height: 150px; border: 0; border-radius: 19px; padding: 20px 22px 64px;
  font-size: 18px; resize: none; outline: none; background: #fff;
}
.prompt-box .send {
  position: absolute; right: 18px; bottom: 16px; width: 52px; height: 52px; border-radius: 50%;
  background: var(--ink); color: #fff; border: 0; cursor: pointer; display: grid; place-items: center;
}
.prompt-box .send:disabled { opacity: .4; cursor: not-allowed; }
.prompt-hint { color: var(--muted); font-size: 14px; margin-top: 14px; }
.hero-actions { margin-top: 24px; }
.hero-actions .btn { padding: 16px 30px; border-radius: 22px; font-size: 17px; }

.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title h2 { font-size: 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.pres-card { padding: 20px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: transform .15s, box-shadow .15s; }
.pres-card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(20,20,40,.06), 0 16px 32px rgba(20,20,40,.09); }
.pres-card h3 { font-size: 17px; }
.pres-card .meta { color: var(--muted); font-size: 14px; display: flex; gap: 12px; flex-wrap: wrap; }
.pres-card .first-q { color: var(--ink-2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pres-card .actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }

/* ---------- Editor ---------- */
.editor { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - 69px); }
.slide-list { background: var(--surface); border-right: 1px solid var(--line); padding: 16px; overflow-y: auto; max-height: calc(100vh - 69px); position: sticky; top: 69px; }
.slide-item {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 10px; cursor: pointer;
  border: 2px solid transparent; margin-bottom: 6px; position: relative;
}
.slide-item:hover { background: #f7f7f8; }
.slide-item.active { border-color: var(--accent); background: var(--accent-soft); }
.slide-item .num { color: var(--muted); font-size: 13px; width: 18px; padding-top: 2px; }
.slide-item .thumb { flex: 1; min-width: 0; }
.slide-item .thumb .type { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.slide-item .thumb .q { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.slide-item.dragging { opacity: .4; }
.add-slide { width: 100%; margin-top: 8px; }

.slide-form { padding: 32px; max-width: 760px; width: 100%; }
.type-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 24px; }
.type-opt {
  border: 2px solid var(--line); border-radius: 12px; padding: 14px 10px; text-align: center; cursor: pointer;
  background: var(--surface); font-weight: 600; font-size: 14px; display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.type-opt:hover { border-color: #cfcfd6; }
.type-opt.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.type-opt svg { width: 28px; height: 28px; }
.option-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.option-row .swatch { width: 12px; height: 32px; border-radius: 4px; flex: none; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.save-state { color: var(--muted); font-size: 14px; }
.title-input { border: 1px solid transparent; background: transparent; font-weight: 600; font-size: 18px; padding: 6px 10px; border-radius: 8px; min-width: 0; width: 360px; max-width: 40vw; }
.title-input:hover { border-color: var(--line); }
.title-input:focus { border-color: var(--accent); outline: none; background: #fff; }
.ai-inline { display: flex; gap: 8px; margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 20, 40, .4); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; color: #1b1b29; --ink: #1b1b29; --ink-2: #4a4a5c; --surface: #fff; --line: #e6e5e2; border-radius: 18px; padding: 28px; width: min(520px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal h2 { margin-bottom: 18px; font-size: 20px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

@media (max-width: 760px) {
  .editor { grid-template-columns: 1fr; }
  .slide-list { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .slide-form { padding: 20px 16px; }
  .type-picker { grid-template-columns: repeat(2, 1fr); }
  .title-input { width: 100%; max-width: none; }
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
  .container { padding: 24px 16px 64px; }
  .hero { padding: 40px 16px; }
}
