:root {
  --bg: #f6f4ef; --card: #ffffff; --text: #1d2a27; --muted: #6b7a76; --line: #e5e1d8;
  --brand: #1f6f5c; --brand-ink: #ffffff; --brand-text: var(--brand); --danger: #c0392b; --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) { --bg: #121815; --card: #1b2420; --text: #eef3f0; --muted: #93a39d; --line: #2a3631; --brand: #3fbf9f; --brand-ink: #08201a; --brand-text: color-mix(in srgb, var(--brand) 60%, #fff); }
}
:root[data-theme=dark] { --bg: #121815; --card: #1b2420; --text: #eef3f0; --muted: #93a39d; --line: #2a3631; --brand: #3fbf9f; --brand-ink: #08201a; --brand-text: color-mix(in srgb, var(--brand) 60%, #fff); }
:root[data-accent] { --brand-ink: #ffffff; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

.screen { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 96px); }
.center { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding-bottom: 32px; }
h1 { font-size: 28px; margin: 0 0 4px; }
h2 { font-size: 20px; margin: 24px 0 10px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.logo { font-size: 56px; margin-bottom: 8px; }

label { display: block; font-weight: 600; font-size: 15px; margin: 14px 0 6px; }
input[type=text], input[type=password] {
  width: 100%; padding: 14px 16px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--card); outline: none; }
input:focus { border-color: var(--brand); }
.btn { display: block; width: 100%; padding: 15px; border: 0; border-radius: 14px; background: var(--brand);
  color: var(--brand-ink); font-weight: 700; margin-top: 18px; }
.btn.secondary { background: transparent; color: var(--text); border: 1.5px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
.btn.small { display: inline-block; width: auto; padding: 8px 14px; margin: 0; font-size: 15px; }
.err { color: var(--danger); min-height: 1.4em; margin-top: 10px; font-size: 15px; }

/* Tarjetas de familiares */
.person { display: flex; gap: 14px; align-items: center; background: var(--card); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px; border: 1px solid var(--line); }
.person.me { border-color: var(--brand); }
.avatar { flex: none; width: 52px; height: 52px; border-radius: 50%; color: #fff; font-weight: 800; font-size: 22px;
  display: grid; place-items: center; }
.pinfo { min-width: 0; flex: 1; }
.pname { font-weight: 700; }
.pstatus { font-size: 18px; overflow-wrap: anywhere; }
.pwhen { color: var(--muted); font-size: 14px; }
.empty-status { color: var(--muted); font-style: italic; }

.feed-item { display: flex; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.feed-item .avatar { width: 38px; height: 38px; font-size: 16px; }

/* Barra inferior */
nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
nav .inner { display: flex; width: 100%; max-width: 560px; }
nav button { flex: 1; background: none; border: 0; padding: 10px 0 8px; color: var(--muted); font-size: 12px; }
nav button span { display: block; font-size: 24px; }
nav button.on { color: var(--brand-text); font-weight: 700; }

.fab { position: fixed; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 6; border: 0;
  background: var(--brand); color: var(--brand-ink); font-weight: 700; padding: 16px 22px; border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: 17px; }

/* Hoja de estado */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; border-radius: 24px 24px 0 0; padding: 20px 16px calc(env(safe-area-inset-bottom) + 20px);
  max-height: 90dvh; overflow: auto; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.opt { background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 12px 4px; text-align: center; font-size: 14px; }
.opt span { display: block; font-size: 30px; margin-bottom: 2px; }
.opt:active { border-color: var(--brand); transform: scale(.97); }

.member-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.member-row .grow { flex: 1; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px 18px; margin-bottom: 14px; }

#toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 14px); transform: translate(-50%, -80px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; transition: transform .25s; z-index: 50; font-size: 15px; }
#toast.show { transform: translate(-50%, 0); }
.offline { background: #b7791f; color: #fff; text-align: center; padding: 6px; font-size: 14px; position: sticky; top: 0; z-index: 4; }

/* ---- Fotos y personalización ---- */
.avatar.img { object-fit: cover; background: var(--line); display: block; }
.banner { position: relative; height: 170px; border-radius: var(--radius); background-size: cover; background-position: center;
  margin-bottom: 16px; overflow: hidden; }
.banner .shade { position: absolute; inset: 0; background: linear-gradient(rgba(0,0,0,0) 30%, rgba(0,0,0,.7)); }
.banner .t { position: absolute; left: 16px; right: 16px; bottom: 12px; color: #fff; }
.banner .t h1 { margin: 0; text-shadow: 0 1px 6px rgba(0,0,0,.5); }
.banner .t p { margin: 2px 0 0; opacity: .9; }
.people.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.people.grid .person { flex-direction: column; text-align: center; margin: 0; padding: 16px 10px; gap: 8px; }
.people.grid .avatar { width: 76px; height: 76px; font-size: 32px; }
.people.grid .pinfo { width: 100%; }
.section-label { font-weight: 700; font-size: 14px; color: var(--muted); margin: 18px 0 0; text-transform: uppercase; letter-spacing: .04em; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.sw { width: 42px; height: 42px; border-radius: 50%; border: 3px solid transparent; outline: 2px solid transparent; }
.sw.on { border-color: var(--card); outline-color: var(--text); }
.seg { display: flex; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; margin-top: 6px; }
.seg button { flex: 1; padding: 10px 4px; background: none; border: 0; font-size: 15px; }
.seg button.on { background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.profile-row { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.profile-row .avatar { width: 72px; height: 72px; font-size: 30px; }
.profile-row .btns { display: flex; flex-direction: column; gap: 8px; }
.banner-prev { height: 90px; border-radius: 14px; background-size: cover; background-position: center; background: var(--line) center/cover; margin-top: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg); border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 8px 6px 12px; font-size: 15px; }
.chip button { background: none; border: 0; color: var(--muted); font-size: 16px; padding: 0 4px; }
.row2 { display: flex; gap: 8px; margin-top: 10px; }
.row2 input[type=text]:first-child { width: 74px; text-align: center; flex: none; }
.emoji-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.emoji-row button { font-size: 24px; background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; width: 44px; height: 44px; }
.emoji-row button.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 15%, var(--card)); }
.hint { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
.sheet h3 { margin: 18px 0 0; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.opt { overflow-wrap: anywhere; }
.sheet label { margin-top: 0; }
