/* Layout: tarjeta vertical a ancho de celular. Banda azul noche de marca (como el hero
   de gear3.cl, con resplandor morado y grilla de puntos) arriba, hoja clara con acciones
   abajo y QR a pantalla completa al presentar. Colores y fuentes tomados de gear3.cl. */
:root {
  --paper: #f3f5f7;
  --surface: #fdfefe;
  --ink: #0d1520;
  --muted: #66717f;
  --line: #d5dbe2;
  --g3: #7c3aed;
  --g3-ink: #ffffff;
  --g3-soft: #f1ebfe;
  --g3-text: #5b21b6;
  --band: #0b1220;
  --band-ink: #fdfefe;
  --band-muted: #a9b3c0;
  --band-raise: rgba(233, 237, 241, 0.08);
  --band-line: #1e2a3d;

  --f-display: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-body: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --gutter-l: max(20px, env(safe-area-inset-left, 0px));
  --gutter-r: max(20px, env(safe-area-inset-right, 0px));
  --radius: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0b1220;
    --surface: #0f1828;
    --ink: #e9edf1;
    --muted: #a9b3c0;
    --line: #1e2a3d;
    --g3: #7c3aed;
    --g3-ink: #ffffff;
    --g3-soft: #1f1840;
    --g3-text: #b9a2ff;
    --band: #0f1828;
    --band-ink: #fdfefe;
    --band-muted: #a9b3c0;
    --band-line: #2a3850;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.shell {
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

@media (min-width: 560px) {
  .shell {
    min-height: 0;
    margin-block: 40px;
    border-radius: 28px;
    overflow: hidden;
    background: var(--paper);
    box-shadow: 0 1px 0 var(--line), 0 30px 60px -30px rgba(14, 21, 34, 0.35);
  }
}

:focus-visible { outline: 2px solid var(--g3); outline-offset: 2px; }

.mono { font-family: var(--f-mono); }

/* ---------- Banda de marca ---------- */

.band {
  position: relative;
  isolation: isolate;
  background:
    radial-gradient(120% 70% at 85% 0%, rgba(124, 58, 237, 0.38), transparent 60%),
    var(--band);
  color: var(--band-ink);
  padding-block: calc(env(safe-area-inset-top, 0px) + 12px) 36px;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
  border-bottom: 1px solid var(--band-line);
}

/* Grilla de puntos, como el fondo del hero de gear3.cl. */
.band::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(rgba(233, 237, 241, 0.13) 1px, transparent 1.2px);
  background-size: 18px 18px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 85%);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 85%);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}

.brand { display: inline-flex; align-items: center; }
.brand img { display: block; height: 26px; width: auto; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: var(--band-raise);
  color: var(--band-ink);
  cursor: pointer;
}
.icon-btn:active { transform: scale(0.96); }

.hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-top: 28px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin-bottom: 22px;
  border-radius: 24px;
  background: var(--g3);
  color: #fff;
  font: 600 26px/1 var(--f-display);
  letter-spacing: -0.02em;
}

.eyebrow {
  margin: 0;
  font: 500 12px/1.4 var(--f-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--band-muted);
}

.name {
  margin: 8px 0 10px;
  font: 600 clamp(2.2rem, 11vw, 3rem)/1 var(--f-display);
  letter-spacing: -0.04em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.name > span { display: block; }

.role {
  margin: 0;
  max-width: 34ch;
  font-size: 17px;
  line-height: 1.4;
  color: var(--band-ink);
  opacity: 0.86;
}

/* ---------- Hoja de acciones ---------- */

.sheet {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-block: 34px calc(env(safe-area-inset-bottom, 0px) + 28px);
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}

.cta-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 58px;
  padding: 0 22px;
  border-radius: 16px;
  border: 0;
  font: 600 17px/1 var(--f-body);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--g3); color: var(--g3-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.square {
  width: 58px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.rows > li + li { border-top: 1px solid var(--line); }

.row {
  display: grid;
  grid-template-columns: 40px 1fr 20px;
  align-items: center;
  gap: 14px;
  min-height: 66px;
  padding: 12px 16px;
  color: inherit;
  text-decoration: none;
}
div.row { grid-template-columns: 40px 1fr; }
a.row:active { background: var(--paper); }
@media (hover: hover) { a.row:hover { background: var(--paper); } }

.ico {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--g3-soft);
  color: var(--g3-text);
}

.txt { display: flex; flex-direction: column; min-width: 0; }

.label {
  font: 500 11px/1.4 var(--f-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.value {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.sub { font-size: 14px; color: var(--muted); line-height: 1.35; }

.chev { color: var(--muted); display: grid; place-items: center; }

.person { grid-template-columns: 44px 1fr 20px; }
.avatar.sm {
  width: 44px;
  height: 44px;
  margin: 0;
  border-radius: 14px;
  font-size: 15px;
  background: var(--g3-soft);
  color: var(--g3-text);
}

.foot {
  margin: 4px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.tip {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
  max-width: 52ch;
}
.tip strong { color: var(--ink); font-weight: 600; }

/* ---------- Modo presentación (QR) ---------- */

.present {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--band);
  color: var(--band-ink);
}
.present::backdrop { background: var(--band); }
.present[open] { animation: rise 0.22s ease-out; }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.close {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: calc(var(--gutter-r) - 4px);
  z-index: 1;
}

.present-inner {
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
  padding-block: calc(env(safe-area-inset-top, 0px) + 64px) calc(env(safe-area-inset-bottom, 0px) + 28px);
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}

.present-head h2 {
  margin: 6px 0 0;
  font: 600 clamp(1.4rem, 6.4vw, 1.75rem)/1.1 var(--f-display);
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.qr-card {
  margin: 0;
  width: min(82vw, 360px, 52dvh);
  padding: 16px;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.6);
}
.qr svg { display: block; width: 100%; height: auto; }

.hint {
  margin: 0;
  max-width: 30ch;
  font-size: 15px;
  line-height: 1.45;
  color: var(--band-muted);
}

.seg {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--band-raise);
}
.seg button {
  min-height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--band-muted);
  font: 600 14px/1 var(--f-body);
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--band-ink); color: var(--band); }

.url { margin: 0; font-size: 12px; color: var(--band-muted); overflow-wrap: anywhere; }

/* ---------- Aviso ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  transform: translateX(-50%);
  margin: 0;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 15px;
  font-weight: 500;
  z-index: 20;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Panel de edición ---------- */

.band-compact { padding-bottom: 28px; }
.band-compact .hero { padding-top: 18px; }
.band-compact .name { font-size: clamp(1.8rem, 8vw, 2.3rem); }
.band-compact .role { font-size: 15px; color: var(--band-muted); opacity: 1; overflow-wrap: anywhere; }

.back { color: var(--muted); font-size: 14px; text-decoration: none; }
.back:hover { color: var(--ink); }

.chip {
  justify-self: end;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--g3-soft);
  color: var(--g3-text);
  font: 500 11px/1.4 var(--f-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.chip.off { background: var(--paper); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.person:has(.chip) { grid-template-columns: 44px 1fr auto; }

.editor { display: flex; flex-direction: column; gap: 16px; }

.group {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0;
  padding: 18px 16px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.group legend {
  float: left;
  width: 100%;
  padding: 0;
  font: 600 17px/1.3 var(--f-display);
  letter-spacing: -0.01em;
}
.group legend + * { clear: both; }
.hint-text { margin: -8px 0 0; font-size: 14px; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span:first-child,
.field.static > span:first-child {
  font: 500 11px/1.4 var(--f-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.field small { font-size: 13px; color: var(--muted); }
.field.static { margin: 0; }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 360px) { .two { grid-template-columns: 1fr; } }
@media (min-width: 440px) {
  .item { grid-template-columns: 132px minmax(0, 1fr) 44px; grid-template-areas: "type value remove" "extra extra extra"; }
}

.editor input:not([type="checkbox"]),
.editor select {
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1 var(--f-body);
}
.editor select {
  appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 21px, calc(100% - 11px) 21px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.editor input:focus,
.editor select:focus { outline: 2px solid var(--g3); outline-offset: 0; border-color: transparent; }

.prefix-input { display: flex; align-items: center; gap: 0; }
.prefix-input .mono {
  height: 48px;
  display: grid;
  place-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-right: 0;
  border-radius: 12px 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}
.editor .prefix-input input { border-radius: 0 12px 12px 0; }

.items { display: flex; flex-direction: column; gap: 10px; }
.items:empty { display: none; }

.item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  grid-template-areas: "type remove" "value value" "extra extra";
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}
.item:last-child { border-bottom: 0; padding-bottom: 0; }
.item > select { grid-area: type; max-width: 220px; }
.item > input { grid-area: value; }
.item > [data-remove] { grid-area: remove; }
.item > .check { grid-area: extra; }

.check { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; color: var(--ink); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--g3); }
.check.big { font-weight: 500; }

.icon-btn.ghost { background: transparent; color: var(--muted); width: 44px; height: 44px; }
.icon-btn.ghost:hover { background: var(--paper); color: var(--ink); }

.btn.ghost {
  height: 48px;
  background: transparent;
  color: var(--g3-text);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 15px;
}
.btn.add { align-self: flex-start; padding: 0 16px; }

.actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.actions .btn.ghost { height: 58px; }
.actions > :only-child { grid-column: 1 / -1; }

.alert {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: #fdecec;
  color: #8a1c1c;
  font-size: 15px;
}
.alert ul { margin: 6px 0 0; padding-left: 18px; }
@media (prefers-color-scheme: dark) { .alert { background: #3a1517; color: #ffc9c9; } }

.flash {
  margin: 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: #e7f6e9;
  color: #1d6a2a;
  font-weight: 500;
}
@media (prefers-color-scheme: dark) { .flash { background: #13301a; color: #a9e5b3; } }

.danger { padding: 4px 2px; color: var(--muted); font-size: 14px; }
.danger summary { cursor: pointer; color: #b42318; font-weight: 500; }
.danger p { margin: 10px 0; }
.danger-btn { height: 48px; background: #b42318; color: #fff; font-size: 15px; }
@media (prefers-color-scheme: dark) { .danger summary { color: #ff8a80; } }
