:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1d2433;
  --muted: #5d667a;
  --border: #dfe4ee;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --good: #16a34a;
  --warn: #d97706;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c;
    --card: #1b2029;
    --text: #e8ecf5;
    --muted: #97a0b5;
    --border: #2b3240;
    --primary: #818cf8;
    --primary-dark: #6366f1;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a { color: var(--primary); }
.wrap { max-width: 980px; margin: 0 auto; padding: 24px 16px 40px; }

/* ---------- Cabeçalho e rodapé ---------- */
.site-header { background: var(--card); border-bottom: 1px solid var(--border); }
.site-header .inner {
  max-width: 980px; margin: 0 auto; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.nav { display: flex; gap: 16px; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; font-size: .95rem; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--primary); }
.site-footer { border-top: 1px solid var(--border); background: var(--card); color: var(--muted); font-size: .9rem; }
.site-footer .inner { max-width: 980px; margin: 0 auto; padding: 20px 16px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }

h1 { margin: 0 0 4px; font-size: 1.7rem; line-height: 1.25; }
.sub { color: var(--muted); margin: 0 0 24px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 18px;
}

/* ---------- Texto corrido ---------- */
.prose h2 { font-size: 1.25rem; margin: 1.6em 0 .4em; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 1.05rem; margin: 1.2em 0 .3em; }
.prose p, .prose li { color: var(--text); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: .95rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--bg); }
.updated { color: var(--muted); font-size: .9rem; }

details { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin: 8px 0; background: var(--bg); }
summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: 6px; }

/* ---------- Espaço de anúncio (some se estiver vazio) ---------- */
.ad-slot { margin: 18px 0; text-align: center; min-height: 0; }
.ad-slot:empty { display: none; }
.ad-slot::before { content: "Publicidade"; display: block; font-size: .7rem; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; margin-bottom: 4px; }
.ad-slot:empty::before { display: none; }

/* ---------- Ferramenta ---------- */
.drop {
  border: 2px dashed var(--border);
  border-radius: 14px;
  padding: 36px 16px;
  text-align: center;
  cursor: pointer;
  transition: .15s;
}
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--primary); background: rgba(79,70,229,.06); outline: none; }
.drop strong { color: var(--primary); }
.drop small { color: var(--muted); display: block; margin-top: 6px; }
input[type=file] { display: none; }

.ctrl-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ctrl-row label { font-weight: 600; }
.pct { font-size: 1.6rem; font-weight: 700; color: var(--primary); }
input[type=range] { width: 100%; margin: 12px 0 4px; accent-color: var(--primary); height: 28px; }
.scale { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 8px; }

.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 18px; }
.opts label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 4px; }
select, input[type=number] {
  width: 100%; padding: 9px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: .95rem;
}

.bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.summary { color: var(--muted); font-size: .95rem; }
.summary b { color: var(--text); }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
button {
  border: 0; border-radius: 9px; padding: 10px 16px; font-size: .95rem; font-weight: 600;
  cursor: pointer; background: var(--primary); color: #fff; transition: .15s;
}
button:hover:not(:disabled) { background: var(--primary-dark); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.ghost:hover:not(:disabled) { background: var(--bg); }
button.small { padding: 6px 12px; font-size: .85rem; }

.list { display: grid; gap: 12px; margin-top: 16px; }
.item {
  display: grid; grid-template-columns: 84px 1fr auto; gap: 14px; align-items: center;
  border: 1px solid var(--border); border-radius: 12px; padding: 10px;
}
.thumb { width: 84px; height: 84px; border-radius: 8px; object-fit: cover; background: var(--bg); }
.name { font-weight: 600; word-break: break-all; }
.meta { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.saved { font-weight: 700; color: var(--good); }
.saved.none { color: var(--warn); }
.status { font-size: .85rem; color: var(--muted); }
.status.err { color: #dc2626; }
.actions { display: flex; flex-direction: column; gap: 6px; }
.empty { text-align: center; color: var(--muted); padding: 24px 0 8px; }

.progress { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; margin-top: 10px; display: none; }
.progress > div { height: 100%; width: 0; background: var(--primary); transition: width .15s; }

@media (max-width: 560px) {
  .item { grid-template-columns: 64px 1fr; }
  .thumb { width: 64px; height: 64px; }
  .actions { grid-column: 1 / -1; flex-direction: row; }
  .actions button { flex: 1; }
}
