:root {
  --bg: #f6f4ef; --card: #fff; --ink: #1f2a24; --muted: #6b766f; --line: #e3dfd5;
  --brand: #2f7d4f; --brand-ink: #fff; --accent: #f2a541; --danger: #c0392b;
  --radius: 14px; --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
.wrap { max-width: 960px; margin: 0 auto; padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

header.top { background: var(--brand); color: var(--brand-ink); }
header.top .wrap { padding-top: 20px; padding-bottom: 20px; }
header.top h1 { font-size: 1.5rem; margin: 0; }
header.top p { margin: 4px 0 0; opacity: .85; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 16px; }

button, .btn { appearance: none; border: 0; border-radius: 10px; padding: 10px 16px;
  font: inherit; font-weight: 600; cursor: pointer; background: var(--brand); color: var(--brand-ink);
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button.secondary, .btn.secondary { background: #e9efe9; color: var(--ink); }
button.ghost { background: transparent; color: var(--brand); padding: 6px 8px; }
button.danger { background: #fbeae8; color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }

input, textarea, select { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink); }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-weight: 600; font-size: .9rem; margin: 12px 0 4px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
label.check input { width: auto; }

.tabs { display: flex; gap: 4px; background: #e9e5db; padding: 4px; border-radius: 12px; margin: 16px 0; }
.tabs button { flex: 1; white-space: nowrap; justify-content: center; font-size: .9rem; background: transparent; color: var(--ink); font-weight: 600; padding: 10px 6px; }
.tabs button.active { background: #fff; box-shadow: var(--shadow); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 4px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }
.grid .ph { position: relative; aspect-ratio: 1; background: #ddd8cc; border-radius: 6px; overflow: hidden; cursor: pointer; }
.grid .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid .ph .badge { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.6); color: #fff;
  font-size: .7rem; padding: 1px 6px; border-radius: 6px; }
.grid .ph .del { position: absolute; right: 4px; top: 4px; padding: 2px 8px; font-size: .8rem; }

.post-title { font-size: 1.2rem; }
.post-body { white-space: pre-wrap; margin: 6px 0 12px; }

.progress { height: 10px; background: #e9e5db; border-radius: 6px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); width: 0; transition: width .2s; }

.list-item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.pill { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: #e9efe9; }
.pill.off { background: #f5e6d3; }

.code { font-family: ui-monospace, monospace; font-size: 1.3rem; letter-spacing: 2px; font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #222; color: #fff;
  padding: 10px 18px; border-radius: 10px; z-index: 100; }

/* Lightbox */
.lb { position: fixed; inset: 0; background: rgba(0,0,0,.95); z-index: 50; display: flex; flex-direction: column; }
.lb .lb-img { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: pan-y; }
.lb img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; }
.lb .lb-bar { display: flex; gap: 8px; padding: 10px; justify-content: center; flex-wrap: wrap; }
.lb .lb-bar button, .lb .lb-bar a { background: rgba(255,255,255,.15); color: #fff; }
.lb .lb-count { color: #bbb; text-align: center; font-size: .85rem; padding-top: 8px; }
.lb .nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12);
  color: #fff; font-size: 1.6rem; width: 44px; height: 64px; justify-content: center; }
.lb .nav.prev { left: 6px; } .lb .nav.next { right: 6px; }

/* Busca facial */
.face-pick { position: relative; display: inline-block; max-width: 100%; }
.face-pick img { max-width: 100%; max-height: 60vh; display: block; border-radius: 8px; }
.face-pick .fbox { position: absolute; border: 3px solid var(--accent); border-radius: 6px; cursor: pointer; background: transparent; padding: 0; }
.face-pick .fbox:hover, .face-pick .fbox.sel { border-color: #38d36b; background: rgba(56,211,107,.15); }
.refs { display: flex; gap: 8px; flex-wrap: wrap; }
.refs .ref { position: relative; }
.refs .ref img { width: 64px; height: 64px; object-fit: cover; border-radius: 50%; border: 3px solid var(--brand); }
.refs .ref button { position: absolute; right: -6px; top: -6px; padding: 0 6px; border-radius: 99px; font-size: .75rem; }
input[type=range] { padding: 0; }
