:root {
  --k: #5c1b91; --k2: #3b1066; --k-soft: #f1e9fb; --acc: #ff7a45;
  --bg: #f6f4fa; --card: #fff; --ink: #1d1530; --muted: #6d6680; --line: #e6e1ef;
  --ok: #1f9d55; --bad: #d23c3c; --r: 16px;
  --shadow: 0 1px 2px rgba(40, 20, 80, .06), 0 4px 16px rgba(40, 20, 80, .06);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
body.has-tabs { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
a { color: var(--k); }
h1 { font-size: 1.5rem; line-height: 1.2; margin: .2em 0 .5em; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 1.2em 0 .5em; }
p { margin: .4em 0 .8em; }
code { background: var(--k-soft); padding: .1em .4em; border-radius: 6px; font-size: .95em; }

/* Cabecera */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: linear-gradient(120deg, var(--k2), var(--k)); color: #fff; }
.brand { color: #fff; text-decoration: none; font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em; }
.brand-k { opacity: .75; font-weight: 600; }
.brand small { font-weight: 500; opacity: .8; font-size: .75rem; margin-left: .3em; padding: 2px 8px; border: 1px solid rgba(255,255,255,.4); border-radius: 99px; }
.klaro { display: block; background: #fff; border-radius: 10px; padding: 4px 5px; line-height: 0; opacity: .95; }
.klaro img { width: 28px; height: auto; }

.wrap { max-width: 760px; margin: 0 auto; padding: 16px; }
.wrap.narrow { max-width: 480px; }

/* Barra de pestañas */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 20px rgba(40,20,80,.06); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 9px; color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600; }
.tabbar svg { width: 24px; height: 24px; fill: currentColor; }
.tabbar a[aria-current] { color: var(--k); }
@media (min-width: 900px) {
  body.has-tabs { padding-bottom: 0; }
  .tabbar { position: sticky; top: 56px; bottom: auto; max-width: 760px; margin: 0 auto; border: 0; box-shadow: none; background: transparent; }
  .tabbar a { flex-direction: row; justify-content: center; gap: 6px; font-size: .9rem; }
}

/* Tarjetas y formularios */
.card { background: var(--card); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.hero { text-align: center; padding: 18px 8px 8px; }
.hero h1 { font-size: 1.8rem; background: linear-gradient(120deg, var(--k2), var(--k) 60%, var(--acc)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.chip { display: inline-block; background: var(--k-soft); color: var(--k); font-weight: 600; font-size: .8rem; padding: 3px 10px; border-radius: 99px; margin: 0 0 .4em; }
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; }
.field small, legend small { color: var(--muted); font-weight: 400; }
.field > small { display: block; margin-top: 4px; }
input[type=text], input[type=tel], input[type=email], input[type=search], input[type=password], input:not([type]), select, textarea {
  width: 100%; font: inherit; color: inherit; background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px; min-height: 46px; }
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--k); box-shadow: 0 0 0 3px var(--k-soft); }
.field.bad input, .field.bad select { border-color: var(--bad); }
.err { display: block; color: var(--bad); font-style: normal; font-size: .85rem; margin-top: 4px; }
fieldset.contacts { border: 0; padding: 0; margin: 6px 0 10px; }
legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 14px; font-size: .95rem; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--k); flex: none; }
.consent { background: var(--k-soft); padding: 12px; border-radius: 12px; }
.alert { background: #fff1ef; color: #a32c1b; border-radius: 12px; padding: 10px 12px; }
.flash { background: #e9f8ef; color: #17643a; border-radius: 12px; padding: 10px 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  color: var(--k); background: var(--k-soft); border: 0; border-radius: 12px; padding: 11px 16px; min-height: 46px; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--k); color: #fff; }
.btn.danger { background: #fdeceb; color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.block { display: flex; width: 100%; margin-top: 8px; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: .85rem; border-radius: 10px; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--k); cursor: pointer; text-decoration: underline; }
.link.danger { color: var(--bad); font-size: .85rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > select, .row > input { flex: 1 1 160px; width: auto; }
.inline { display: inline; margin: 0; }
.big-emoji { font-size: 3rem; }
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.keybox { background: var(--k-soft); border-radius: 12px; padding: 12px; margin: 10px 0 14px; }
.keybox input { font-size: .85rem; margin-bottom: 8px; }
.keybox .btn { flex: 1; }

/* Directorio */
.filters { position: sticky; top: 56px; z-index: 5; background: var(--bg); padding: 4px 0 8px; display: grid; gap: 8px; }
@media (min-width: 900px) { .filters { top: 100px; } }
.count { margin: 2px 2px 8px; }
.people { display: grid; gap: 10px; }
.person { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); }
.person summary { list-style: none; display: flex; gap: 12px; align-items: center; padding: 14px; cursor: pointer; }
.person summary::-webkit-details-marker { display: none; }
.person[open] summary { padding-bottom: 6px; }
.pinfo { display: flex; flex-direction: column; min-width: 0; }
.pinfo strong { font-size: 1.02rem; }
.sector { color: var(--k); font-size: .82rem; font-weight: 700; }
.tagline { color: var(--muted); font-size: .9rem; }
.person:not([open]) .tagline { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.you { background: var(--k-soft); color: var(--k); font-size: .7rem; padding: 1px 6px; border-radius: 99px; vertical-align: middle; }
.pmore { padding: 0 14px 14px 70px; }
.cbtns { display: flex; flex-wrap: wrap; gap: 8px; }
.cbtn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 99px; background: var(--k-soft); color: var(--k); text-decoration: none; font-weight: 600; font-size: .88rem; }
.cbtn svg { width: 18px; height: 18px; fill: currentColor; }
.cbtn.wa { background: #e5f8ec; color: #128c4b; }

.av { flex: none; display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; color: #fff; font-weight: 800; font-size: .95rem; letter-spacing: .02em; }
.av.sm { width: 30px; height: 30px; font-size: .72rem; }
.av-h0 { background: #5c1b91; } .av-h1 { background: #7b2cbf; } .av-h2 { background: #c2185b; } .av-h3 { background: #e85d04; }
.av-h4 { background: #2a9d8f; } .av-h5 { background: #1d6fb8; } .av-h6 { background: #6a4c93; } .av-h7 { background: #b5179e; }
.av-h8 { background: #3a7d44; } .av-h9 { background: #d1495b; } .av-h10 { background: #00798c; } .av-h11 { background: #8d5524; }

/* Dudas e ideas */
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.head-row h1 { margin: 0; }
.fchips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 10px; margin: 0 -16px; padding-left: 16px; scrollbar-width: none; }
.fchips::-webkit-scrollbar { display: none; }
.fchip { flex: none; padding: 6px 12px; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: .85rem; font-weight: 600; }
.fchip[aria-current] { background: var(--k); color: #fff; border-color: var(--k); }
.posts { display: grid; gap: 10px; }
.post { display: flex; flex-direction: column; gap: 4px; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; text-decoration: none; color: inherit; }
.ptag { align-self: flex-start; font-size: .72rem; font-weight: 700; color: var(--k); background: var(--k-soft); padding: 2px 8px; border-radius: 99px; }
.meta { color: var(--muted); font-size: .82rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: .2em 0; }
.thread h1 { margin-top: .4em; }
.replies-h { font-size: 1rem; color: var(--muted); }
.replies { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 10px; }
.reply { display: flex; gap: 10px; background: var(--card); border-radius: var(--r); padding: 12px; box-shadow: var(--shadow); }
.reply p { margin: .1em 0 .3em; }
.reply > div { min-width: 0; overflow-wrap: anywhere; }
.prose p { margin: .6em 0; }

/* Panel */
.anav { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.anav a { padding: 7px 12px; border-radius: 99px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 600; font-size: .88rem; }
.anav a[aria-current] { background: var(--k); color: #fff; border-color: var(--k); }
.anav form { margin-left: auto; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--acc); color: #fff; font-size: .75rem; text-align: center; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stats div { background: #fff; border-radius: 14px; padding: 12px 8px; text-align: center; box-shadow: var(--shadow); }
.stats b { display: block; font-size: 1.5rem; color: var(--k); }
.stats span { font-size: .75rem; color: var(--muted); }
.alist { display: grid; gap: 8px; margin-bottom: 16px; }
.arow { display: flex; gap: 10px; justify-content: space-between; align-items: center; flex-wrap: wrap; background: #fff; border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
.arow > div:first-child { min-width: 0; flex: 1 1 260px; overflow-wrap: anywhere; }
.arow .actions, .card .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.arow .grow { flex: 1; }
.is-hidden { opacity: .55; }
.st { display: inline-block; font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: #eee; color: #555; }
.st-active { background: #e5f8ec; color: #17643a; } .st-pending { background: #fff3dc; color: #8a5a00; } .st-rejected { background: #fdeceb; color: var(--bad); }
.grid2 { display: grid; gap: 10px; grid-template-columns: 1fr; align-items: end; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr auto; } .grid2 .field { margin: 0; } }

/* Ajustes tras probar en móvil */
.people > *, .posts > *, .alist > * { min-width: 0; }
.person summary .pinfo { flex: 1; }
.row > select, .row > input { min-width: 0; flex: 1 1 140px; }
.keybox .btn { background: #fff; }
.card > h1:first-child, .card > h2:first-child { margin-top: 0; }
.card > .chip:first-child + h1 { margin-top: .2em; }
.sec-h { font-size: .95rem; color: var(--k); margin: 18px 2px 8px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.ptag.ty-diferenciacion { background: #fff0e8; color: #b4480f; }
.ptag.ty-entrada { background: #e6f6f3; color: #127566; }
.ptag.ty-otra { background: #eef0f4; color: #4b5563; }
.fchip.t[aria-current] { background: var(--acc); border-color: var(--acc); }
.seg-field { border: 0; padding: 0; margin: 0 0 14px; }
.seg-field legend { font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg.three { grid-template-columns: 1fr 1fr 1fr; }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; }
.seg-opt span { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 48px; padding: 6px 8px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; font-weight: 700; font-size: .9rem; cursor: pointer; }
.seg-opt input:checked + span { border-color: var(--k); background: var(--k-soft); color: var(--k); }
.seg-opt input:focus-visible + span { box-shadow: 0 0 0 3px var(--k-soft); }
