:root {
  --bg: #f6f4f2;
  --panel: #ffffff;
  --text: #1d1b1a;
  --muted: #6d6864;
  --line: #e5e1dd;
  --yes: #1f9d6b;
  --no: #e0445a;
  --accent: #ff5864;
  --shadow: 0 10px 30px rgba(0, 0, 0, .12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141312;
    --panel: #1f1d1c;
    --text: #f2efec;
    --muted: #a39d98;
    --line: #34302d;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.center { text-align: center; justify-content: center; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.topbar h1 { margin: 0; font-size: 1.2rem; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }

button, select, input[type=search] {
  font: inherit; color: inherit; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); padding: 8px 14px; cursor: pointer;
}
input[type=search] { flex: 1; min-width: 0; cursor: text; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: transparent; }
button.ghost.active { background: var(--line); }
button.danger { color: var(--no); }

.view { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.panel h2 { margin-top: 0; }
.row { display: flex; gap: 8px; margin-top: 12px; }
.row.wrap { flex-wrap: wrap; margin-top: 0; }
.msg { min-height: 1.4em; }
.msg.err { color: var(--no); }
details { margin-top: 14px; }
summary { cursor: pointer; }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 2px dashed var(--line); border-radius: 14px; padding: 36px 16px; cursor: pointer; text-align: center;
}
.drop.over, .drop:hover { border-color: var(--accent); }

/* ---- tarjetas ---- */
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
#progress-text { margin: 6px 0 10px; font-size: .9rem; }

.stack { position: relative; flex: 1; min-height: 420px; }
.card {
  position: absolute; inset: 0; background: var(--panel); border-radius: 20px; box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column; touch-action: none; user-select: none;
}
.card.under { transform: scale(.95) translateY(10px); opacity: .7; }
.card.top { cursor: grab; }
.card.top:active { cursor: grabbing; }
.photo {
  position: relative; flex: 1; min-height: 180px; display: grid; place-items: center;
  background: linear-gradient(135deg, hsl(var(--h) 65% 55%), hsl(calc(var(--h) + 40) 70% 45%));
}
.photo img { pointer-events: none; }
.photo img.bg { position: absolute; inset: -20px; width: calc(100% + 40px); height: calc(100% + 40px); object-fit: cover; filter: blur(18px) brightness(.8); }
.photo img.face {
  position: relative; width: min(48%, 170px); aspect-ratio: 1; object-fit: cover; border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, .9); box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
}
.photo { overflow: hidden; }
.help { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 8px; font-size: .93rem; }
.help p { margin: 0 0 8px; }
td.who { display: flex; align-items: center; gap: 8px; }
.thumb { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: none; }
.initials.thumb {
  font-size: .8rem; letter-spacing: 0; display: grid; place-items: center;
  background: hsl(var(--h, 200) 55% 50%); color: #fff;
}
.initials { font-size: 5rem; font-weight: 700; color: rgba(255, 255, 255, .92); letter-spacing: 2px; }
.stamp {
  position: absolute; z-index: 2; top: 24px; padding: 4px 12px; border: 4px solid; border-radius: 8px;
  font-weight: 800; font-size: 1.6rem; letter-spacing: 1px; opacity: 0; background: rgba(255, 255, 255, .85);
}
.stamp.yes { left: 20px; color: var(--yes); transform: rotate(-14deg); }
.stamp.no { right: 20px; color: var(--no); transform: rotate(14deg); }
.info { padding: 16px 18px 18px; }
.info h2 { margin: 0 0 6px; font-size: 1.5rem; overflow-wrap: anywhere; }
.stats { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); }
.stats b { color: var(--text); font-size: 1.1rem; }
.reactions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; font-size: .95rem; }
.samples { margin: 10px 0 8px; padding: 0; list-style: none; font-size: .92rem; color: var(--muted); }
.samples li { margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.actions { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 18px; }
.round {
  width: 64px; height: 64px; border-radius: 50%; padding: 0; font-size: 1.8rem; font-weight: 700;
  box-shadow: var(--shadow); border: none; display: grid; place-items: center;
}
.round.small { width: 46px; height: 46px; font-size: 1.2rem; color: var(--muted); }
.round.yes { color: var(--yes); }
.round.no { color: var(--no); }
.round:active { transform: scale(.92); }
.hint { font-size: .82rem; margin-top: 12px; }

/* ---- lista ---- */
.table-wrap { overflow-x: auto; max-height: 60vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { position: sticky; top: 0; background: var(--panel); }
td:nth-child(2), td:nth-child(3), th:nth-child(2), th:nth-child(3) { text-align: center; width: 3.5em; }
select.st { padding: 4px 6px; max-width: 8.5em; }
select.st.conocido { color: var(--yes); border-color: var(--yes); }
select.st.desconocido { color: var(--no); border-color: var(--no); }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); max-width: 420px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog h3 { margin-top: 0; }

@media (max-width: 420px) {
  .topbar h1 { font-size: 1rem; }
  .topbar nav button { padding: 6px 8px; font-size: .9rem; }
  .view { padding: 12px 16px; }
}

/* ---- archivos ---- */
.row.between { justify-content: space-between; align-items: center; margin-top: 0; }
.row.between h2 { margin: 0; }
.badge { font-size: .8rem; padding: 3px 10px; border-radius: 999px; background: var(--line); white-space: nowrap; }
.msg { white-space: pre-line; }
.summary { font-weight: 600; }
button.wide { width: 100%; padding: 12px; margin-bottom: 8px; }
.file-list { list-style: none; padding: 0; margin: 0 0 12px; }
.file-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.small-btn { padding: 4px 10px; }
button.linkish { border: none; background: none; padding: 0; color: var(--accent); text-decoration: underline; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 10;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; max-width: calc(100% - 32px);
}

/* ---- actividad en la tarjeta ---- */
.card .photo { flex: 0 0 34%; min-height: 150px; }
.card .info { flex: 1; overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; }
.info h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 6px; }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { padding: 8px 10px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 10px; font-size: .92rem; }
.activity .post { color: var(--muted); font-size: .82rem; margin-bottom: 4px; }
.activity .post a { color: var(--muted); }
.activity .act { display: flex; gap: 6px; align-items: baseline; margin-top: 3px; }
.activity .act span { overflow-wrap: anywhere; }
.stats a { margin-left: auto; }

.activity .comment { margin-top: 6px; padding: 8px 10px; background: var(--bg); border-radius: 10px; }
.activity .comment .label { font-size: .78rem; color: var(--muted); margin-bottom: 2px; }
.activity .comment p { margin: 0; font-size: .98rem; color: var(--text); overflow-wrap: anywhere; white-space: pre-line; }
.activity .media { display: inline-flex; flex-direction: column; gap: 4px; margin-top: 4px; font-size: .85rem; }
.activity .media img { width: 120px; max-height: 160px; object-fit: cover; border-radius: 8px; }
