:root {
  --bg: #f4f5f3;
  --surface: #ffffff;
  --surface-2: #f1efe8;
  --text: #1d1d1b;
  --text-2: #5f5e5a;
  --text-3: #908f88;
  --border: #e3e1d9;
  --border-strong: #cfcdc4;
  --brand: #0f6e56;
  --brand-bg: #e1f5ee;
  --accent: #185fa5;
  --accent-bg: #e6f1fb;
  --danger: #c2271f;
  --danger-bg: #fceaea;
  --warn: #a85b00;
  --warn-bg: #faeeda;
  --ok: #0f6e56;
  --ok-bg: #e1f5ee;
  --radius: 10px;
  --max: 480px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16160f;
    --surface: #20201a;
    --surface-2: #2a2a23;
    --text: #f1efe8;
    --text-2: #b4b2a9;
    --text-3: #888780;
    --border: #34342c;
    --border-strong: #444441;
    --brand: #5dcaa5;
    --brand-bg: #0f3a30;
    --accent: #85b7eb;
    --accent-bg: #103050;
    --danger: #f09595;
    --danger-bg: #4a1414;
    --warn: #efb866;
    --warn-bg: #3a2a0a;
    --ok: #5dcaa5;
    --ok-bg: #0f3a30;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { display: flex; justify-content: center; min-height: 100vh; }

.app {
  width: 100%;
  max-width: var(--max);
  background: var(--surface);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  border-left: 0.5px solid var(--border);
  border-right: 0.5px solid var(--border);
}

.hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 0.5px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 5;
}
.hdr-l { display: flex; align-items: center; gap: 9px; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 15px; }
.hdr-title { font-weight: 600; font-size: 16px; }
.hdr-sub { font-size: 11px; color: var(--text-2); }
.ctx-btn { background: none; border: none; padding: 0; text-align: left; cursor: pointer; color: inherit; }
.ctx-btn:hover .hdr-sub { color: var(--text); }
.iconbtn { background: none; border: none; color: var(--text-2); font-size: 20px; cursor: pointer; padding: 4px; }

.screen { flex: 1; overflow-y: auto; padding: 14px 16px 90px; }

.banner { border-radius: 12px; padding: 11px 13px; margin-bottom: 14px; }
.banner-accent { background: var(--accent-bg); }
.banner-title { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.banner-text { font-size: 12px; margin-top: 3px; line-height: 1.5; }
.accent { color: var(--accent); }
.brand { color: var(--brand); }

.h { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.sub { font-size: 12px; color: var(--text-2); margin: 0 0 14px; line-height: 1.5; }
.lbl { font-size: 12px; font-weight: 600; margin: 0 0 7px; }
.muted { font-size: 11px; color: var(--text-3); line-height: 1.5; display: flex; gap: 6px; align-items: flex-start; }

.row-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }

.card { background: var(--surface); border: 0.5px solid var(--border); border-radius: 12px; padding: 12px 13px; margin-bottom: 10px; }
.card-l3 { border-left: 3px solid var(--border-strong); }
.card-t { font-size: 14px; font-weight: 600; }
.card-s { font-size: 12px; color: var(--text-2); margin-top: 2px; line-height: 1.4; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }

.tag { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.tag-danger { background: var(--danger-bg); color: var(--danger); }
.tag-warn { background: var(--warn-bg); color: var(--warn); }
.tag-ok { background: var(--ok-bg); color: var(--ok); }
.tag-accent { background: var(--accent-bg); color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.chip { font-size: 13px; padding: 6px 12px; border-radius: 18px; border: 0.5px solid var(--border-strong);
  color: var(--text-2); cursor: pointer; user-select: none; }
.chip.on { background: var(--text); color: var(--surface); border-color: var(--text); }

.seg { display: flex; gap: 8px; margin-bottom: 16px; }
.seg button { flex: 1; padding: 8px 0; font-size: 13px; border-radius: 8px; border: 0.5px solid var(--border);
  background: var(--surface); color: var(--text-2); cursor: pointer; }
.seg button.on { background: var(--text); color: var(--surface); border-color: var(--text); }

input[type=text], textarea {
  width: 100%; font: inherit; font-size: 14px; padding: 9px 11px; border-radius: 8px;
  border: 0.5px solid var(--border-strong); background: var(--surface); color: var(--text); resize: none;
}
input:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-bg); }

.btn { font: inherit; font-size: 14px; padding: 9px 14px; border-radius: 8px; cursor: pointer;
  border: 0.5px solid var(--border-strong); background: var(--surface); color: var(--text); }
.btn-sm { font-size: 12px; padding: 5px 10px; }
.btn-primary { background: var(--text); color: var(--surface); border: none; }
.btn-brand { background: var(--brand); color: #fff; border: none; }
.btn-block { width: 100%; padding: 12px; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: default; }

.stats { display: flex; gap: 8px; margin-bottom: 16px; }
.stat { flex: 1; background: var(--surface-2); border-radius: 10px; padding: 10px 11px; }
.stat-n { font-size: 20px; font-weight: 600; }
.stat-l { font-size: 10px; color: var(--text-2); }

.map { position: relative; height: 180px; border-radius: 12px; border: 0.5px solid var(--border);
  background: var(--surface-2); overflow: hidden; margin-bottom: 14px; }
.pin { position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--surface);
  transform: translate(-50%, -50%); cursor: pointer; }
.map-expand { position: absolute; top: 8px; left: 8px; z-index: 2; display: flex; align-items: center; gap: 4px;
  background: var(--surface); border: 0.5px solid var(--border-strong); border-radius: 8px; padding: 5px 9px;
  font: inherit; font-size: 11px; color: var(--text); cursor: pointer; }
.maplibregl-popup-content { color: #1d1d1b; font: inherit; font-size: 13px; border-radius: 8px; }
.maplibregl-popup-content a { color: #185fa5; }
.legend { position: absolute; right: 8px; bottom: 8px; background: var(--surface); border: 0.5px solid var(--border);
  border-radius: 8px; padding: 5px 8px; font-size: 10px; color: var(--text-2); display: flex; gap: 9px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 3px; }

.bar { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.bar-l { width: 120px; font-size: 12px; }
.track { flex: 1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.track > div { height: 100%; }
.bar-n { width: 22px; text-align: right; font-size: 11px; color: var(--text-2); }

.step { display: flex; gap: 10px; position: relative; padding-bottom: 13px; }
.step::before { content: ""; position: absolute; left: 9px; top: 19px; bottom: 0; width: 1.5px; background: var(--border-strong); }
.step:last-child::before { display: none; }
.step-dot { width: 19px; height: 19px; border-radius: 50%; flex-shrink: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center; font-size: 12px; }
.step-done { background: var(--ok); color: #fff; }
.step-todo { background: var(--surface-2); color: var(--text-3); border: 0.5px solid var(--border-strong); }
.step-t { font-size: 13px; font-weight: 500; line-height: 1.3; }
.step-s { font-size: 11px; color: var(--text-2); line-height: 1.4; }

.led { display: flex; gap: 9px; padding: 9px 0; border-bottom: 0.5px solid var(--border); }
.led:last-child { border-bottom: none; }
.led-ic { width: 26px; height: 26px; border-radius: 7px; background: var(--surface-2); color: var(--text-2);
  display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.led-t { font-size: 13px; line-height: 1.4; }
.led-m { font-size: 11px; color: var(--text-3); }

.preview { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin-bottom: 16px; }

.nav { position: fixed; bottom: 0; left: 0; right: 0; margin: 0 auto; max-width: var(--max);
  display: flex; background: var(--surface); border-top: 0.5px solid var(--border); }
.nav button { flex: 1; background: none; border: none; cursor: pointer; padding: 8px 0 9px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--text-3); }
.nav button i { font-size: 21px; }
.nav button.on { color: var(--text); }

.empty { text-align: center; color: var(--text-3); font-size: 13px; padding: 30px 10px; }

/* Avatar / login en cabecera */
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-bg); color: var(--brand);
  border: none; font-weight: 600; font-size: 12px; cursor: pointer; }
.enter-btn { background: var(--brand); color: #fff; border: none; border-radius: 8px; font-size: 12px;
  font-weight: 600; padding: 6px 11px; cursor: pointer; }

/* Landing */
.land { flex: 1; overflow-y: auto; padding: 0; }
.land-hero { padding: 40px 22px 30px; text-align: center; }
.land-logo { width: 56px; height: 56px; border-radius: 16px; background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 28px; margin-bottom: 16px; }
.land-h1 { font-size: 26px; font-weight: 700; margin: 0 0 8px; }
.land-tag { font-size: 15px; color: var(--text-2); line-height: 1.5; margin: 0 0 24px; }
.land-cta { display: flex; flex-direction: column; gap: 10px; max-width: 320px; margin: 0 auto; }
.land-sec { padding: 24px 22px; border-top: 0.5px solid var(--border); }
.land-sec h2 { font-size: 17px; font-weight: 600; margin: 0 0 14px; }
.land-step { display: flex; gap: 12px; margin-bottom: 16px; align-items: flex-start; }
.land-num { width: 26px; height: 26px; border-radius: 50%; background: var(--brand-bg); color: var(--brand);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; flex-shrink: 0; }
.land-step-t { font-size: 14px; font-weight: 500; }
.land-step-s { font-size: 13px; color: var(--text-2); line-height: 1.5; }
.land-feat { display: flex; gap: 10px; align-items: center; font-size: 14px; padding: 8px 0; }
.land-feat i { color: var(--brand); font-size: 20px; }
.land-foot { padding: 22px; text-align: center; font-size: 12px; color: var(--text-3); }

/* Overlay / modal */
.ov { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: var(--max); border-radius: 16px 16px 0 0;
  padding: 18px 18px 26px; }
.sheet-grab { width: 36px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 0 auto 14px; }
.sheet h3 { font-size: 17px; font-weight: 600; margin: 0 0 4px; }
.sheet p { font-size: 13px; color: var(--text-2); margin: 0 0 16px; line-height: 1.5; }
.sheet-row { display: flex; align-items: center; gap: 11px; width: 100%; background: none; border: none;
  padding: 12px 4px; font: inherit; font-size: 14px; color: var(--text); cursor: pointer; text-align: left;
  border-bottom: 0.5px solid var(--border); }
.sheet-row i { font-size: 19px; color: var(--text-2); width: 22px; }
.sheet-row.danger { color: var(--danger); }
.otp-note { background: var(--accent-bg); color: var(--accent); border-radius: 8px; padding: 9px 11px;
  font-size: 13px; margin-bottom: 12px; }

/* Muro */
.post { background: var(--surface); border: 0.5px solid var(--border); border-radius: 12px; padding: 12px 13px; margin-bottom: 10px; }
.post.is-pinned { border-color: var(--brand); }
.post-head { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; }
.post-av { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); color: var(--text-2);
  display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; }
.post-name { font-size: 13px; font-weight: 600; }
.role-badge { font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 5px; background: var(--brand-bg); color: var(--brand); }
.post-text { font-size: 14px; line-height: 1.5; }
.post-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }

/* Chat */
.chat-wrap { position: fixed; inset: 0; max-width: var(--max); margin: 0 auto; background: var(--surface);
  z-index: 60; display: flex; flex-direction: column; }
.chat-hdr { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 0.5px solid var(--border); }
.chat-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 9px; }
.bubble { max-width: 78%; padding: 8px 11px; border-radius: 13px; font-size: 14px; line-height: 1.4; }
.bubble .who { font-size: 11px; font-weight: 600; margin-bottom: 2px; opacity: .85; }
.bubble.them { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.bubble.me { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.chat-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 0.5px solid var(--border); }
.chat-input input { flex: 1; }

/* Confianza */
.linkname { background: none; border: none; padding: 0; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text); cursor: pointer; text-decoration: underline; text-decoration-color: var(--border-strong);
  text-underline-offset: 2px; }
.linkname:hover { text-decoration-color: var(--brand); }
.lvl { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 6px; margin-top: 3px; }
.lvl-coord { background: var(--brand-bg); color: var(--brand); }
.lvl-trust { background: var(--accent-bg); color: var(--accent); }
.lvl-ok { background: var(--ok-bg); color: var(--ok); }
.lvl-base { background: var(--surface-2); color: var(--text-2); }
.sheet-row[disabled] { opacity: .55; cursor: default; }
