:root {
  /* Tema claro */
  --bg: #f8fafc;          /* slate-50 */
  --card: #ffffff;
  --muted: #475569;       /* slate-600 */
  --text: #0f172a;        /* slate-900 */
  --accent: #2563eb;      /* blue-600 */
  --accent-2: #3b82f6;    /* blue-500 */
  --danger: #b91c1c;      /* red-700 */
  --warn: #d97706;        /* amber-600 */
  --focus: #60a5fa;       /* blue-400 */
  --chip: #f1f5f9;        /* slate-100 */
  --border: #e2e8f0;      /* slate-200 */
  --overlay: rgba(2, 6, 23, .5);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  background:
    radial-gradient(1200px 800px at 15% -10%, rgba(59,130,246,0.08), transparent 60%),
    radial-gradient(1200px 800px at 110% 10%, rgba(37,99,235,0.08), transparent 50%),
    var(--bg);
  color: var(--text);
}

.topbar { padding: 24px clamp(16px, 4vw, 40px); border-bottom: 1px solid var(--border); }
.topbar h1 { margin: 0 0 8px; font-size: clamp(20px, 4vw, 28px); }

/* Aviso topo */
.notice {
  background: #eef2ff; color: #1e293b;
  border: 1px solid #c7d2fe; border-radius: 10px;
  padding: 10px 12px; margin: 8px 0 16px;
}

/* Sobre o fotolivro */
.feature { margin-top: 8px; }
.feature h2 { margin: 0 0 6px; font-size: 18px; }
.lead { margin: 0 0 6px; color: #334155; }
.feature-list { margin: 0; padding-left: 18px; color: #0f172a; }
.feature-list li { margin: 4px 0; }

.hero-figure { margin: 16px 0 0; display: grid; gap: 8px; }
.hero-figure img { width: 100%; height: 210px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.hero-figure figcaption { color: var(--muted); font-size: 12px; }

main { padding: 24px clamp(16px, 4vw, 40px); display: grid; gap: 16px; }

.card {
  background: var(--card);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.02) inset;
}
.card h2 { margin-top: 0; font-size: 18px; }
label { display: block; margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="url"], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  background: #fff; color: var(--text);
  border: 1px solid var(--border); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(96,165,250,0.25); }
.hint { color: var(--muted); font-size: 12px; }
.mt8 { margin-top: 8px; }
.hidden { display: none !important; }

.sec-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.actions-inline { display: flex; gap: 8px; }

/* Paletas */
.paletas-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.palette-card {
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--chip);
  cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; outline: none;
}
.palette-card:hover, .palette-card:focus { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.08); }
.palette-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; }
.palette-name { font-weight: 600; }
.palette-colors { display: grid; grid-template-columns: repeat(6, 1fr); height: 44px; }
.palette-colors div { height: 44px; }
.palette-card[aria-checked="true"] { box-shadow: 0 0 0 2px var(--accent), 0 4px 18px rgba(37,99,235,0.2); }
.badge { background: #f8fafc; border: 1px solid var(--border); color: #334155; font-size: 11px; padding: 4px 6px; border-radius: 999px; }

/* Editor de Paleta */
.pm-cores { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.pm-cores .sw { display: grid; gap: 6px; background: #f8fafc; border: 1px solid var(--border); padding: 8px; border-radius: 10px; }
.pm-cores .sw label { font-size: 12px; color: var(--muted); margin-bottom: 0; }
.pm-cores input[type="color"] { width: 100%; height: 44px; border: none; background: transparent; padding: 0; border-radius: 8px; }

/* Frases dinâmicas */
.grid-phrases { display: grid; gap: 8px; }
.phrase-row { display: grid; gap: 8px; grid-template-columns: 1fr minmax(180px, 240px) 40px; }
.btn-icon { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: #fff; display: grid; place-items: center; cursor: pointer; }
.btn-icon:hover { background: #f8fafc; }
.ico { width: 18px; height: 18px; color: var(--text); }

/* Upload */
.dropzone {
  display: grid; place-items: center; padding: 28px; border: 2px dashed var(--border); border-radius: 12px;
  color: var(--muted); text-align: center; background: #fff; position: relative;
}
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone.dragover { border-color: var(--accent-2); background: #f8fafc; box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }

.toolbar { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.counter { margin-left: auto; color: var(--muted); }

/* Toggles de filtro */
.toggles { display: inline-flex; gap: 8px; }
.toggle {
  border: 1px solid var(--border);
  background: #e2e8f0; color: #0f172a;
  padding: 8px 12px; border-radius: 999px; cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease, transform .1s ease;
}
.toggle:hover { transform: translateY(-1px); }
.toggle[aria-pressed="true"] {
  background: var(--accent-2); color: white; border-color: var(--accent);
}

/* Galeria */
.galeria { margin-top: 12px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.thumb { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: #fff; }
.thumb img { width: 100%; height: 180px; object-fit: cover; display: block; }
.thumb .thumb-meta { display: grid; gap: 6px; padding: 8px; border-top: 1px solid var(--border); }
.thumb .row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.thumb .caption-input { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text); }

/* Selo de baixa qualidade (tema claro) */
.lowq::after {
  content: "BAIXA QUALIDADE";
  position: absolute; top: 8px; left: 8px;
  background: #fee2e2; color: #7f1d1d; border: 1px solid #fecaca;
  padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .3px;
  display: inline-flex; align-items: center; gap: 6px;
}
.lowq::before {
  content: "";
  position: absolute; top: 12px; left: 12px;
  width: 10px; height: 10px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.25);
}

/* Thumb select (capa com miniaturas) */
.thumb-select { position: relative; width: 100%; max-width: 520px; }
.ts-button {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--border); color: var(--text); padding: 8px; border-radius: 10px;
}
.ts-thumb { display: inline-flex; align-items: center; gap: 10px; }
.ts-thumb img { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.ts-placeholder { color: var(--muted); }
.ts-list {
  position: absolute; inset: auto 0 0 0; transform: translateY(8px);
  background: #fff; border: 1px solid var(--border); border-radius: 10px; max-height: 320px; overflow: auto; z-index: 5;
  box-shadow: 0 20px 40px rgba(0,0,0,.12);
}
.ts-item {
  width: 100%; display: flex; gap: 10px; align-items: center; padding: 8px; border-bottom: 1px solid var(--border); cursor: pointer; background: transparent;
}
.ts-item:hover { background: #f8fafc; }
.ts-item img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.ts-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.chevron { width: 18px; height: 18px; color: var(--muted); }

/* Modal genérico */
.modal { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; padding: 16px; }
.modal.hidden { display: none; }
.modal-box { width: min(780px, 96vw); background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.modal-header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-header.warn { background: #fff7ed; }
.modal-body { padding: 16px; display: grid; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.list { margin: 0; padding-left: 18px; color: var(--muted); }
.ico.warn { width: 18px; height: 18px; color: var(--warn); }

/* Blocos de referência (temática/fundo) */
.ref-block { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; margin-top: 10px; }
.ref-preview { margin-top: 8px; }
.ref-preview img { max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border); }

/* Botões */
.actions { display: flex; gap: 12px; justify-content: flex-end; }
.btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 10px 14px; border-radius: 10px; cursor: pointer; transition: transform .1s ease, background .2s ease, border-color .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 600; border-color: var(--accent); }
.btn.secondary { background: var(--chip); }
.btn.ghost { background: transparent; }
.btn.danger { background: #fee2e2; border-color: #fecaca; color: #7f1d1d; }

.footer { color: var(--muted); text-align: center; padding: 24px; border-top: 1px solid var(--border); }

/* Responsividade */
@media (max-width: 720px) {
  .phrase-row { grid-template-columns: 1fr; }
  .ref-block { grid-template-columns: 1fr; }
  .hero-figure img { height: 160px; }
  .toolbar { gap: 6px; }
  .toggles { width: 100%; }
}