:root {
  --brand: #3b2a20;
  --brand-fg: #ffffff;
  --bg: #f6f1ea;
  --surface: #ffffff;
  --text: #241b15;
  --muted: #7a6a5d;
  --line: #e6dccf;
  --ok: #1f7a4d;
  --err: #b42318;
  --gold: #c8922a;
  --radius: 16px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: .4em 0; }
h2 { font-size: 1.1rem; margin: 1.4em 0 .5em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.hidden { display: none !important; }

main.narrow { max-width: 440px; margin: 0 auto; padding: 24px 16px 48px; }
main.wide { max-width: 1040px; margin: 0 auto; padding: 24px 16px 48px; }
.logo { width: 88px; height: 88px; object-fit: contain; border-radius: 20px; background: #fff; }

/* Páginas con la marca del negocio */
body.branded {
  background-color: var(--bg);
  background-image: linear-gradient(var(--brand), var(--brand));
  background-size: 100% 300px;
  background-repeat: no-repeat;
  min-height: 100vh;
}
.brand-head { color: var(--brand-fg); text-align: center; padding-bottom: 12px; }
.brand-head .logo { box-shadow: 0 6px 20px rgba(0,0,0,.25); }

/* Formularios */
.card-form {
  background: var(--surface); border-radius: var(--radius); padding: 20px;
  box-shadow: 0 8px 30px rgba(40,25,10,.08); display: grid; gap: 14px; text-align: left;
}
label { display: grid; gap: 6px; font-weight: 600; font-size: .92rem; }
input, select {
  font: inherit; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; width: 100%; min-width: 0;
}
input[type=color] { padding: 4px; height: 46px; }
input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
label.check { grid-template-columns: 22px 1fr; align-items: start; font-weight: 400; }
label.check input { width: 20px; height: 20px; margin-top: 2px; }
input.pin { font-size: 1.6rem; text-align: center; letter-spacing: .4em; }

.btn {
  display: inline-block; border: 0; cursor: pointer; text-decoration: none; text-align: center;
  background: var(--brand); color: var(--brand-fg); font: inherit; font-weight: 700;
  padding: 12px 18px; border-radius: 12px;
}
.btn.block { display: block; width: 100%; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.gold { background: var(--gold); color: #fff; }
.btn.danger { background: var(--err); color: #fff; }
.btn.big { font-size: 1.15rem; padding: 18px; }
.btn.small { padding: 6px 10px; font-size: .85rem; }
.btn:disabled { opacity: .35; cursor: not-allowed; }
button.link { background: none; border: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }

.flash { padding: 12px 14px; border-radius: 12px; font-weight: 600; margin-bottom: 8px; }
.flash.ok { background: #e3f4ea; color: var(--ok); }
.flash.error { background: #fde8e6; color: var(--err); }

/* Tarjeta de fidelización */
.loyalty-card {
  background: var(--brand); color: var(--brand-fg); border-radius: 22px; padding: 20px;
  box-shadow: 0 14px 40px rgba(30,15,5,.25);
}
.loyalty-card.pulse { animation: pulse .6s ease; }
@keyframes pulse { 50% { transform: scale(1.03); } }
.lc-top { display: flex; gap: 12px; align-items: center; }
.lc-logo { width: 48px; height: 48px; border-radius: 14px; object-fit: contain; background: #fff; }
.lc-biz { font-weight: 800; font-size: 1.1rem; }
.lc-name { opacity: .8; font-size: .9rem; }
.lc-status { text-align: center; font-weight: 600; margin: 8px 0 14px; }
.lc-qr { background: #fff; border-radius: 16px; padding: 14px; width: 220px; margin: 0 auto; }
.lc-qr img { display: block; width: 100%; height: auto; }
.lc-hint { text-align: center; font-size: .85rem; opacity: .85; margin: 10px 0 0; }

.stamps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 18px 0 6px; color: var(--brand); }
.stamp {
  aspect-ratio: 1; border-radius: 50%; border: 2px dashed currentColor; opacity: .55;
  display: grid; place-items: center; font-size: 1.3rem;
}
.stamp.on { opacity: 1; border-style: solid; background: currentColor; }
main.wide .stamps, .customer .stamps { max-width: 360px; color: var(--brand); }

.wallet-buttons { display: grid; gap: 10px; margin-top: 18px; }
.wallet-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px;
  background: #000; color: #fff; text-decoration: none; font-weight: 700; border-radius: 26px;
}
.ios-tip { background: var(--surface); border-radius: 12px; padding: 12px 14px; }
.ios-tip summary { cursor: pointer; font-weight: 600; }

/* Escáner */
.staff-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
#reader { position: relative; border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; background: #000; aspect-ratio: 1; }
#reader.hidden { display: none; }
#reader video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.reader-frame { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.9); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); pointer-events: none; }
.reader-close { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 1.1rem; cursor: pointer; }
.search { margin: 14px 0 6px; }
.results { list-style: none; padding: 0; margin: 0; }
.results li { background: var(--surface); padding: 12px 14px; border-radius: 12px; margin-bottom: 6px; cursor: pointer; }
.customer { background: var(--surface); border-radius: var(--radius); padding: 20px; margin-top: 12px; box-shadow: 0 8px 30px rgba(40,25,10,.08); }
.customer h2 { margin-top: 0; font-size: 1.4rem; }
.actions { display: grid; gap: 10px; margin: 14px 0; }
.glow { box-shadow: 0 0 0 4px rgba(200,146,42,.35); }
body.staff #msg { position: fixed; left: 16px; right: 16px; bottom: 16px; max-width: 440px; margin: 0 auto; box-shadow: 0 8px 30px rgba(0,0,0,.2); }

/* Panel */
.topbar {
  display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--brand); color: var(--brand-fg);
}
.tb-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.tb-brand img { width: 32px; height: 32px; border-radius: 8px; background: #fff; object-fit: contain; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; padding: 6px 10px; border-radius: 8px; opacity: .85; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,.15); opacity: 1; }
.quick { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 20px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stats div { background: var(--surface); border-radius: 14px; padding: 14px; display: grid; }
.stats strong { font-size: 1.8rem; }
.stats span { color: var(--muted); font-size: .85rem; }
.activity { list-style: none; padding: 0; background: var(--surface); border-radius: 14px; }
.activity li { display: flex; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.activity li:last-child { border-bottom: 0; }
.activity time { margin-left: auto; color: var(--muted); font-size: .85rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > label { flex: 1 1 160px; }
.row.between { justify-content: space-between; align-items: center; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 14px; overflow: hidden; margin-top: 12px; display: block; overflow-x: auto; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: #faf6f0; }
.grid2 { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
.box { background: var(--surface); border-radius: 14px; padding: 16px; }
.box h2:first-child { margin-top: 0; }
.wide-form { max-width: none; }
.prose { line-height: 1.65; }
.prose h2 { margin-top: 1.6em; }

/* Cartel */
.poster { max-width: 560px; margin: 0 auto; padding: 40px 24px; text-align: center; background: var(--brand); color: var(--brand-fg); border-radius: 28px; }
.poster h1 { font-size: 2.2rem; }
.poster-big { font-size: 1.6rem; line-height: 1.3; }
.poster-qr { width: 300px; max-width: 80%; background: #fff; padding: 16px; border-radius: 20px; }
.poster-cta { font-size: 1.3rem; font-weight: 800; }
@media print {
  .noprint { display: none; }
  body { background: #fff; }
  .poster { -webkit-print-color-adjust: exact; print-color-adjust: exact; margin-top: 20px; }
}

/* Apple Wallet */
.wallet-btn.apple { background: #000; }
.step { margin: 14px 0; }
.step.done { opacity: .8; }
.step .num {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand); color: var(--brand-fg); font-size: .9rem; margin-right: 4px;
}
.step .row input[type=file] { flex: 1 1 200px; padding: 8px; }
.grid2 > * { min-width: 0; }

/* Tarjeta del cliente (formato fijo) */
.loyalty-card { overflow: hidden; min-width: 0; }
.lc-top { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid rgba(255,255,255,.18); }
.lc-biz { font-weight: 800; font-size: 1.25rem; line-height: 1.2; overflow-wrap: anywhere; }
.lc-customer { display: grid; gap: 2px; margin-top: 14px; }
.lc-customer span { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; opacity: .75; }
.lc-customer strong { font-size: 1.15rem; overflow-wrap: anywhere; }
.lc-count { display: flex; align-items: baseline; justify-content: center; gap: 6px; margin-top: 16px; line-height: 1; }
.lc-num { font-size: 3.6rem; font-weight: 800; }
.lc-of { font-size: 1.6rem; font-weight: 600; opacity: .75; }
.lc-count-label { text-align: center; font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; opacity: .75; margin-top: 4px; }
.loyalty-card .stamps, main.wide .loyalty-card .stamps { color: var(--brand-fg); max-width: none; margin: 14px 0 4px; }
.grid2 .loyalty-card { max-width: 420px; }
.lc-status.ready { background: rgba(255,255,255,.16); border-radius: 12px; padding: 10px; }
.lc-id { font-variant-numeric: tabular-nums; letter-spacing: .04em; font-weight: 600; }

/* Personalización de la tarjeta: vista previa estilo Wallet */
h2.first { margin-top: 0; }
.logo-field { display: flex; gap: 14px; align-items: center; }
.logo-field > div { flex: 1; display: grid; gap: 8px; }
#logo-thumb { width: 64px; height: 64px; object-fit: contain; border-radius: 14px; background: #f1ece5; border: 1px solid var(--line); }
.preview-col { position: sticky; top: 16px; }
.wp {
  background: var(--wp-bg); color: var(--wp-fg); border-radius: 16px; padding: 16px 16px 20px; max-width: 340px;
  min-height: 470px; position: relative; box-shadow: 0 14px 40px rgba(30,15,5,.25);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; transition: background .2s, color .2s;
}
.wp small { display: block; font-size: 10px; font-weight: 600; letter-spacing: .02em; margin-top: 18px; }
.wp-top { display: flex; align-items: center; gap: 8px; }
.wp-top img { height: 32px; max-width: 96px; object-fit: contain; border-radius: 8px; }
.wp-top span { font-size: 17px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wp-h { text-align: right; }
.wp-h small { margin: 0; font-size: 9px; opacity: .85; }
.wp-h b { font-weight: 400; font-size: 16px; }
.wp-big { font-size: 30px; line-height: 1.15; }
.wp-mid { font-size: 18px; }
.wp-sub { font-size: 18px; margin: 4px 0 14px; opacity: .95; overflow-wrap: anywhere; }
.wp-dots { font-size: 20px; letter-spacing: 3px; }
.wp-qr { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: #fff; color: #000; border-radius: 8px; padding: 8px 8px 4px; text-align: center; font-size: 11px; }
.wp-qr img { width: 104px; display: block; }

/* ---------- Pantalla de acceso (minimalista) ---------- */
/* ---------- Inicio de sesión: estilo tarjeta de sellos de papel ---------- */
body.auth {
  --paper: #e9e4db; --ink: #1747c2; --page: #f5f3ef;
  min-height: 100vh; display: grid; place-items: center; padding: 28px 16px;
  color: var(--ink);
  background-color: var(--page);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.auth-card {
  width: 100%; max-width: 380px; text-align: center;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  padding: 30px 28px 26px; border-radius: 4px;
  box-shadow: 0 1px 2px rgba(40, 30, 20, .08), 0 18px 40px -18px rgba(40, 30, 20, .35);
}
.auth-kicker, .auth-sub, .auth-foot, .auth-form input, .auth-btn { font-family: 'Courier Prime', 'Courier New', monospace; }
.auth-kicker { margin: 0 0 18px; font-size: .9rem; letter-spacing: .04em; }
.auth-title {
  font-family: 'Archivo', 'Helvetica Neue', Arial, sans-serif; font-weight: 500;
  font-size: clamp(2.6rem, 13vw, 3.4rem); line-height: .95; letter-spacing: -.035em; margin: 0;
}
.auth-sub { margin: 14px 0 22px; font-size: 1rem; line-height: 1.3; letter-spacing: .03em; }
.auth-stamps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 14px; max-width: 250px; margin: 0 auto 24px; }
.zz { position: relative; display: grid; place-items: center; aspect-ratio: 1; }
.zz svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.zz polygon { fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linejoin: miter; }
.zz b { position: relative; font-family: 'Archivo', Arial, sans-serif; font-weight: 500; font-size: 1.25rem; letter-spacing: -.02em; }
.zz.on polygon { fill: var(--ink); }
.zz.on b { color: var(--paper); }
.zz img { position: relative; width: 52%; height: 52%; object-fit: contain; border-radius: 10px; }
.auth-form { display: grid; gap: 10px; text-align: left; margin-bottom: 6px; }
.auth-form input {
  border: 1.5px solid var(--ink); border-radius: 0; padding: 12px 13px; background: transparent;
  color: var(--ink); font-size: 1rem;
}
.auth-form input::placeholder { color: var(--ink); opacity: .55; }
.auth-form input:focus { outline: none; background: rgba(255, 255, 255, .45); box-shadow: 0 0 0 3px rgba(23, 71, 194, .15); }
.auth-btn {
  margin-top: 4px; padding: 13px; border: 0; border-radius: 0; cursor: pointer;
  background: var(--ink); color: var(--paper); font-size: 1.05rem; letter-spacing: .08em; text-transform: uppercase;
}
.auth-btn:hover { background: #0f3596; }
.auth-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.auth-form .flash { font-family: 'Courier Prime', monospace; border-radius: 0; }
.auth-foot { margin: 22px 0 0; font-size: 1.05rem; line-height: 1.3; letter-spacing: .05em; overflow-wrap: anywhere; }
.phone-search { margin: 16px 0 4px; }
.phone-search label { font-weight: 600; }
.phone-search .row { flex-wrap: nowrap; align-items: stretch; }
.phone-search input { font-size: 1.25rem; letter-spacing: .04em; }
.search input { font-size: .95rem; }
.admin-actions { display: flex; gap: 8px; align-items: center; }
.admin-actions form { margin: 0; }
/* Tabla de negocios del admin: que quepa entera sin barra de desplazamiento */
.admin-table { display: table; table-layout: fixed; }
.admin-table th:nth-child(1) { width: 26%; }
.admin-table th:nth-child(2) { width: 26%; }
.admin-table th:nth-child(3) { width: 9%; }
.admin-table th:nth-child(4) { width: 15%; }
.admin-table th:nth-child(5) { width: 24%; }
.admin-table td { white-space: normal; }
.admin-table td.email { overflow-wrap: anywhere; }
.admin-table .slug { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-table .admin-actions { flex-wrap: wrap; }
.admin-table .admin-actions .btn { white-space: nowrap; }
.admin-table tbody tr { cursor: default; }
@media (max-width: 700px) {
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
  .admin-table thead { display: none; }
  .admin-table tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .admin-table td { padding: 3px 0; border: 0; }
  .admin-table td.num::before { content: attr(data-label) ': '; color: var(--muted, #8a7b70); }
  .admin-table .admin-actions { margin-top: 8px; }
}
/* Campo "Final del enlace" del admin: muestra el principio de la dirección */
.slug-field { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; background: #fff; overflow: hidden; }
.slug-prefix { display: flex; align-items: center; padding: 0 2px 0 12px; color: var(--muted, #8a7b70); font-size: .85rem; white-space: nowrap; max-width: 60%; overflow: hidden; text-overflow: ellipsis; }
.slug-field input { border: 0 !important; box-shadow: none !important; padding-left: 2px; min-width: 0; flex: 1; }
.slug-warn { color: var(--err); font-weight: 600; }
.slug-field:focus-within { border-color: var(--brand, #3b2a20); box-shadow: 0 0 0 3px rgba(59, 42, 32, .1); }
.slug-field input:focus { outline: none; }
/* Selector de cuántos sellos sumar en el escáner */
.qty { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 4px; }
.qty-label { font-weight: 600; }
.qty-ctrl { display: flex; align-items: center; gap: 6px; }
.qty-btn { width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--brand); background: transparent; color: var(--brand); font-size: 1.5rem; line-height: 1; cursor: pointer; }
.qty-btn:disabled { opacity: .3; cursor: default; }
#qty-val { min-width: 2.2ch; text-align: center; font-size: 1.6rem; font-weight: 700; }
.search-label { display: grid; gap: 6px; font-weight: 600; }
.search-label input { font-weight: 400; }
.id-input { text-transform: uppercase; }
.id-input::placeholder { text-transform: none; }

/* ---------- Estilos de tarjeta: sencilla / con foto ---------- */
.wp .only-imagen { display: none; }
.wp.style-imagen .only-imagen { display: block; }
.wp.style-imagen .only-sencilla { display: none; }
/* La franja ocupa todo el ancho de la tarjeta, como en Apple Wallet (375 x 144) */
.wp-strip { margin: 12px -16px 0; aspect-ratio: 375 / 144; background: rgba(255,255,255,.12); overflow: hidden; }
.wp-strip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wp.no-photo .wp-strip { display: grid; place-items: center; background: repeating-linear-gradient(45deg, rgba(255,255,255,.10) 0 10px, rgba(255,255,255,.18) 10px 20px); }
.wp.no-photo .wp-strip img { display: none; }
.wp.no-photo .wp-strip::after { content: 'Sube una foto'; font-size: 13px; font-weight: 600; opacity: .8; }
.wp-member small { margin-top: 12px; }

.custom-link { display: flex; justify-content: center; align-items: center; gap: 6px; text-decoration: none; margin: -2px 0 6px; }

.style-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.style-option { position: relative; display: grid; gap: 6px; padding: 12px; border: 2px solid var(--line); border-radius: 14px; cursor: pointer; background: #fff; font-weight: 400; }
.style-option:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,0,0,.05); }
.style-option input { position: absolute; opacity: 0; pointer-events: none; }
.style-option strong { font-size: 1rem; }
/* Miniaturas de cada estilo */
.style-thumb { display: block; position: relative; aspect-ratio: 3 / 4; border-radius: 10px; background: var(--t-bg); overflow: hidden; }
.style-thumb i { position: absolute; left: 8%; top: 6%; width: 16%; aspect-ratio: 1; border-radius: 4px; background: var(--t-fg); opacity: .85; }
.style-thumb u { position: absolute; left: 34%; right: 34%; bottom: 7%; aspect-ratio: 1; background: #fff; border-radius: 3px; }
.thumb-sencilla b { position: absolute; left: 8%; right: 20%; top: 26%; height: 9%; border-radius: 3px; background: var(--t-fg); opacity: .9; }
.thumb-sencilla em { position: absolute; left: 8%; right: 45%; top: 44%; height: 6%; border-radius: 3px; background: var(--t-fg); opacity: .55; }
.thumb-imagen s { position: absolute; left: 0; right: 0; top: 20%; height: 26%; background: linear-gradient(135deg, #d9a96b, #8c5a3c 55%, #4b6b5c); }
.thumb-imagen em { position: absolute; left: 8%; right: 40%; top: 52%; height: 6%; border-radius: 3px; background: var(--t-fg); opacity: .7; }

.pos-field { border: 0; padding: 0; margin: 4px 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pos-field legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.pos-opt { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1.5px solid var(--line); border-radius: 999px; background: #fff; cursor: pointer; font-weight: 500; }
.pos-opt:has(input:checked) { border-color: var(--brand); background: var(--brand); color: var(--brand-fg); }
.pos-opt { position: relative; }
.pos-opt input, .style-option input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; left: 0; top: 0; margin: 0; }
@media (max-width: 420px) { .style-options { grid-template-columns: 1fr 1fr; gap: 8px; } .style-option { padding: 8px; } }
/* Foto del estilo "Con foto" en la tarjeta web: franja de borde a borde */
.lc-photo { display: block; width: calc(100% + 40px); height: auto; aspect-ratio: 375 / 144; object-fit: cover; margin: 16px -20px 4px; }
.style-option:has(input:focus-visible), .pos-opt:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Selector de icono ---------- */
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; margin: 6px 0 4px; }
.icon-opt { position: relative; display: grid; justify-items: center; gap: 6px; padding: 10px 6px 8px; border: 2px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer; font-weight: 500; text-align: center; }
.icon-opt:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,0,0,.05); }
.icon-opt:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.icon-opt input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; left: 0; top: 0; margin: 0; }
.icon-tile { width: 56px; height: 56px; display: grid; place-items: center; }
.icon-tile img { width: 56px; height: 56px; border-radius: 14px; object-fit: contain; }
.icon-none { width: 56px; height: 56px; border-radius: 14px; border: 2px dashed var(--line); display: grid; place-items: center; font-size: 1.5rem; color: var(--muted, #8a7b70); }
.icon-name { font-size: .85rem; }
.no-icon { width: 64px; height: 64px; border-radius: 14px; border: 2px dashed var(--line); display: grid; place-items: center; font-size: .7rem; color: var(--muted, #8a7b70); text-align: center; }

/* ---------- Editor de la foto (marco con la proporción de la franja de Apple) ---------- */
.editor-help { font-size: .9rem; margin: 4px 0 8px; }
.ph-frame { position: relative; width: 100%; aspect-ratio: 375 / 144; overflow: hidden; border-radius: 10px; cursor: grab; touch-action: none; user-select: none; outline: 2px solid var(--line); outline-offset: 2px; }
.ph-frame.dragging { cursor: grabbing; }
.ph-frame img { position: absolute; max-width: none; height: auto; pointer-events: none; -webkit-user-drag: none; }
.ph-frame.removing { opacity: .35; }
.ph-tools { display: flex; align-items: center; gap: 10px; margin: 10px 0 6px; font-size: 1.2rem; font-weight: 700; }
.ph-tools input[type=range] { flex: 1; accent-color: var(--brand); }
.ph-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

/* Vista previa: la foto colocada a mano dentro de la franja */
.wp-strip { position: relative; }
.wp-strip.free img { position: absolute; width: auto; height: auto; max-width: none; object-fit: initial; }

/* Fila del estilo con foto: nombre · nº ID · puntos */
.wp-row { display: flex; gap: 10px; align-items: flex-end; margin-top: 12px; }
.wp-row small { margin-top: 0; }
.wp-cell { min-width: 0; }
.wp-grow { flex: 1; }
.wp-grow .wp-mid { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wp-right { text-align: right; }
.wp-dots-sm { font-size: 14px; letter-spacing: 1px; white-space: nowrap; }
.wp.style-imagen .wp-row.only-imagen { display: flex; }
/* La vista previa acompaña mientras se edita */
.preview-col { align-self: start; }
@media (min-width: 900px) { .preview-col { position: sticky; top: 16px; } }

/* ---------- Paleta de colores de la tarjeta (el elegido lleva ✓) ---------- */
.color-field { display: grid; gap: 8px; margin: 4px 0 10px; }
.field-label { font-weight: 600; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; width: 40px; height: 40px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); transition: transform .12s; }
.swatch:hover { transform: scale(1.08); }
.swatch:focus-visible, .swatch-custom:focus-within { outline: 2px solid var(--brand); outline-offset: 3px; }
.swatch.on { box-shadow: inset 0 0 0 1px rgba(0,0,0,.15), 0 0 0 3px #fff, 0 0 0 5px var(--brand); }
.swatch.on::after { content: '✓'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--sw-fg); font-weight: 800; font-size: 1.1rem; pointer-events: none; }
/* "Otro color": arcoíris cuando no está elegido; con el color elegido y ✓ cuando sí */
.swatch-custom { background: conic-gradient(#e53935, #fdd835, #43a047, #1e88e5, #8e24aa, #e53935); overflow: hidden; display: block; }
.swatch-custom.on { background: var(--sw); }
.swatch-custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
#kind-hint { display: block; margin-top: 4px; font-weight: 400; }

/* Fila del estilo con foto: nombre (pequeño) con el nº ID debajo · premio y puntos */
.wp-plain { text-transform: none; font-size: 12px !important; font-weight: 500 !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wp-right small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wp-right { min-width: 0; flex: 1.3; }
/* Color exacto: R, G, B y HEX */
.rgb-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.6fr); gap: 8px; margin-top: 4px; }
.rgb-fields label { display: grid; gap: 4px; font-weight: 600; font-size: .85rem; }
.rgb-fields span { display: flex; align-items: center; gap: 6px; }
.rgb-fields span::before { content: ''; width: 10px; height: 10px; border-radius: 50%; }
.rgb-r span::before { background: #e53935; }
.rgb-g span::before { background: #43a047; }
.rgb-b span::before { background: #1e88e5; }
.rgb-hex span::before { display: none; }
.rgb-fields input { width: 100%; min-width: 0; font-variant-numeric: tabular-nums; }
.rgb-hex input { text-transform: lowercase; font-family: ui-monospace, Menlo, monospace; }
.unit-hint { margin: -4px 0 8px; }
