/* Simulador de merch (docs/simulador-merch.md). Móvil primero; sin dependencias externas ni estilos en línea (CSP 'self').
   ESTÉTICA ARACNE DEL PANEL DE STOCK (K-006-503): mismos tokens, tipografía, barra superior, tarjetas, botones, pestañas e
   inputs que sered/stockapp/public/assets/app.css (stock.aracnestudio.es): página oscura (#0f0f0f), tarjetas #1c1c1c con borde
   sutil y radio 14, barra superior y botones principales claros, acento verde ácido #91d500 y azul Klein #00109e, tipografía de
   sistema. Un solo aspecto en todos los dispositivos (sin variante clara). Si app.css cambia sus tokens, cambian aquí
   (test_simmerch_estetica compara los valores). */
:root {
  color-scheme: dark;
  --bg: #0f0f0f;
  --card: #1c1c1c;
  --text: #f2f2f2;
  --muted: #a3a3a3;
  --line: #333333;
  --primary: #f2f2f2;
  --primary-text: #111111;
  --accent: #91d500;
  --accent-text: #000000;
  --klein: #00109e;
  --danger: #ff8a80;
  --panel: #282828;
  --panel-line: #444444;
  --radius: 14px;
  /* alias que usan el editor y los estados */
  --fg: var(--text); --soft: var(--panel); --err: var(--danger); --ok: var(--accent); --warn: #ffc46b; --accent-fg: var(--accent-text);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font-sans); }
a { color: inherit; }
h1, h2 { margin: 0 0 6px; line-height: 1.2; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1.15rem; }
h3 { font-weight: 700; margin: 0 0 6px; }
*:focus-visible { outline: 2px solid #4d5bff; outline-offset: 2px; }

/* ---- barra superior (como .topbar de app.css): clara, logo a la izquierda y nombre de sección centrado ---- */
.sm-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 6px; min-height: 56px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--primary); color: var(--primary-text);
  box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.sm-marca { display: flex; align-items: center; color: var(--primary-text); text-decoration: none; font-weight: 700; letter-spacing: .02em; }
.sm-marca .brand-logo { height: 34px; width: auto; display: block; }
.sm-top-title { position: absolute; left: 50%; transform: translateX(-50%); font-size: 1rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; pointer-events: none; white-space: nowrap; }
.sm-who { margin-left: auto; color: #444; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28vw; font-size: .9rem; }
.sm-top .sm-link { color: var(--primary-text); }
@media (max-width: 520px) { .sm-who { display: none; } .sm-top .sm-link:first-of-type { margin-left: auto; } .sm-marca .brand-logo { height: 28px; } }
@media (max-width: 400px) { .sm-top-title { font-size: .9rem; letter-spacing: .06em; } }

/* ---- botones (como .btn / .btn-primary / .btn-secondary / .btn-ghost de app.css) ---- */
button { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--primary); background: var(--primary); color: var(--primary-text); font: inherit; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .45; cursor: not-allowed; }
.sm-secondary { background: transparent; color: var(--text); border-color: var(--line); }
.sm-link { background: none; border: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; padding: 0 8px; min-height: 40px; }
.sm-row { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }
.sm-inline { display: inline; margin: 0; }

/* ---- campos (como input/select de app.css) ---- */
label { display: block; margin: 0 0 .8rem; font-weight: 600; font-size: .85rem; color: var(--muted); }
input, select, textarea { display: block; width: 100%; margin-top: 4px; min-height: 48px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 16px; }
input[type=file] { padding: 8px 12px; }
.sm-check { display: flex; gap: .6rem; align-items: center; font-weight: 400; font-size: .95rem; color: var(--text); }
.sm-check input { width: auto; min-height: 0; margin: 0; accent-color: var(--accent); }

/* ---- páginas de acceso (como body.login / .login-box) ---- */
.sm-auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.sm-card { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 22px; }
.sm-auth .brand-logo { display: block; height: 44px; width: auto; margin: 0 0 14px; color: var(--text); }
.sm-auth form > button[type=submit], .sm-auth .sm-card > form button { width: 100%; margin-top: 16px; background: #000000; color: var(--accent); border-color: #000000; }
.sm-legal { max-width: 640px; }
.sm-sub, .sm-note { color: var(--muted); font-size: .92rem; }
.sm-sub { margin: 0 0 1rem; }
.sm-error { color: var(--danger); font-weight: 600; }
.sm-ok { color: var(--accent); font-weight: 600; }
.sm-auth .sm-error { background: #3a1513; color: #ffb4ab; border: 1px solid #5c211d; padding: 10px 12px; border-radius: 10px; }

#smMain { padding: 16px; max-width: 1100px; margin: 0 auto; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text); width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.6); }

/* ---- tarjetas, secciones y cuadrículas ---- */
.sm-section { margin: 0 0 1.5rem; }
.sm-bar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin: 0 0 1rem; }
.sm-bar h2 { margin: 0 auto 0 0; }
.sm-bar select { width: auto; flex: 1 1 140px; margin: 0; }
.sm-bar input[type=file] { width: auto; flex: 1 1 200px; min-width: 0; max-width: 100%; margin: 0; font-size: .85rem; }
.sm-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.sm-tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.sm-tile img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 10px; background: repeating-conic-gradient(#d4d4d4 0 25%, #ececec 0 50%) 0 0/16px 16px; }
.sm-tile .sm-note { margin: 0; overflow-wrap: anywhere; }
.sm-tile button { min-height: 40px; }
.sm-meter { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; } .sm-meter > i { display: block; height: 100%; background: var(--accent); }
.sm-ph { aspect-ratio: 1; display: grid; place-items: center; background: var(--panel); color: var(--muted); border-radius: 10px; }
.sm-diseno { max-width: none; margin: 0 0 12px; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; }
.sm-diseno h3 { margin: 0 0 .25rem; font-size: 1rem; }
.sm-mockimg { width: 100%; max-width: 420px; display: block; margin: .5rem 0; border-radius: 10px; }
.sm-legal-txt { border: 1px solid var(--panel-line); padding: 10px 12px; margin: 0 0 .8rem; background: var(--panel); border-radius: 12px; font-size: .88rem; font-weight: 400; color: var(--text); }
.sm-legal-txt p { margin: 0 0 .4rem; }

/* ---- vista de prenda con su zona ---- */
.sm-mock { position: relative; }
.sm-mock img { width: 100%; height: auto; display: block; }
.sm-vista { max-width: 560px; margin: 0 auto; }
.sm-zona-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.sm-zona { fill: rgba(255,255,255,.06); stroke: #fff; stroke-width: 1.5; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 1px #000); }

/* ---- selector de prendas base: tarjetas con miniatura, nombre y bolitas de color ---- */
.sm-catalogo { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0 0 1.25rem; }
.sm-prenda { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.sm-prenda.sm-on { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.sm-prenda-btn { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 8px; padding: 8px; border: 0; border-radius: 0;
  background: transparent; color: var(--text); text-align: left; min-height: 0; font-weight: 600; }
.sm-prenda-btn img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: center 30%; background: var(--panel); border-radius: 10px; display: block; }
.sm-prenda-n { font-weight: 600; font-size: .95rem; line-height: 1.2; }
.sm-muestras { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px 10px; }
.sm-muestra { width: 28px; height: 28px; min-height: 28px; padding: 0; border-radius: 50%; border: 1px solid var(--panel-line); background: #cfcfcf;
  box-shadow: inset 0 0 0 2px var(--card); position: relative; }
.sm-muestra[aria-pressed=true] { outline: 2px solid var(--primary); outline-offset: 2px; }
.sm-muestra::after { content: ''; position: absolute; inset: -8px; }   /* área táctil de 44 px sin agrandar la bolita */
.sm-muestras-g { padding: 0; gap: 12px; margin: 0 0 .75rem; }
.sm-muestra-i { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; font-size: .75rem; color: var(--muted); }
.sm-muestra-g { width: 36px; height: 36px; min-height: 36px; }
.sm-probador { display: flex; flex-direction: column; gap: 16px; margin: 0 0 1.5rem; }
.sm-pr-lienzo { min-width: 0; }
.sm-pr-lados { display: flex; gap: 8px; margin: 0 0 10px; overflow-x: auto; scrollbar-width: none; }   /* pestañas como .tabs/.tab */
.sm-pr-lados:empty { display: none; }
.sm-pr-lados button { flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: .92rem; font-weight: 400; }
.sm-pr-lados button[aria-selected=true] { background: var(--primary); color: var(--primary-text); border-color: var(--primary); font-weight: 600; }
.sm-pr-stage { max-width: 560px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.sm-pr-nota { margin: .5rem 0 0; text-align: center; }
.sm-pr-titulo { margin: 0 0 .5rem; font-size: 1.15rem; font-weight: 700; }
.sm-pr-panel { min-width: 0; }
.sm-disenar { background: var(--primary); border-color: var(--primary); color: var(--primary-text); width: 100%; min-height: 56px; font-size: 1.05rem; margin: .75rem 0 .4rem; }
@media (min-width: 640px) { .sm-catalogo { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); } }
@media (min-width: 900px) {
  .sm-probador { flex-direction: row; align-items: flex-start; gap: 28px; }
  .sm-pr-lienzo { flex: 1 1 55%; }
  .sm-pr-panel { flex: 1 1 40%; position: sticky; top: 76px; }
}

/* ---- editor de capas (Konva): mismo aspecto que el panel ---- */
body.sm-ed-abierto { overflow: hidden; }
.sm-ed { position: fixed; inset: 0; z-index: 40; background: var(--bg); color: var(--text); display: flex; flex-direction: column;
  overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: env(safe-area-inset-bottom); }
.sm-ed-top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  min-height: 56px; background: var(--primary); color: var(--primary-text); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.sm-ed-back { background: none; border: 0; color: var(--primary-text); padding: 0 6px; min-height: 40px; }
.sm-ed-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.sm-ed-title strong { font-weight: 700; font-size: 1rem; }
.sm-ed-title span { color: #444; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-ed-save { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #444; white-space: nowrap; }
.sm-ed-body { display: flex; flex-direction: column; gap: 12px; padding: 12px 16px 24px; width: 100%; max-width: 1280px; margin: 0 auto; }
.sm-ed-lienzo { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.sm-ed-lados { display: flex; gap: 8px; align-self: flex-start; }
.sm-ed-lados button { min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-weight: 400; font-size: .92rem; }
.sm-ed-lados button[aria-selected=true] { background: var(--primary); color: var(--primary-text); border-color: var(--primary); font-weight: 600; }
.sm-ed-stage { width: 100%; display: flex; justify-content: center; touch-action: none; user-select: none; -webkit-user-select: none; }
.sm-ed-stage > div { background: var(--panel); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.sm-ed-zona { margin: 0; font-size: .8rem; color: var(--muted); text-align: center; }
.sm-ed-panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.sm-ed-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.sm-ed-tools > button { flex: 1 1 auto; min-height: 44px; padding: 0 14px; }
.sm-ed-ico { min-width: 44px; padding: 0 10px; background: transparent; color: var(--text); border: 1px solid var(--line); font-size: 1rem; line-height: 1; }
.sm-ed-tools > .sm-ed-ico { flex: 0 0 44px; }
.sm-ed-aviso { margin: 0; font-size: .88rem; color: var(--muted); }
.sm-ed-aviso:empty { display: none; }
.sm-ed-aviso button { margin: .4rem .4rem 0 0; min-height: 40px; }
.sm-ed-link { margin-top: .4rem; font-size: .85rem; }
.sm-ed-h { display: block; margin: 4px 0 0; font-size: .85rem; font-weight: 700; color: var(--muted); }
.sm-ed-prenda, .sm-ed-galeria, .sm-ed-sel { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--card); }
.sm-ed-prenda select { margin: .4rem 0 .7rem; }
.sm-ed-prenda .sm-muestras-g { margin: 0; gap: 10px; flex-wrap: wrap; }
.sm-ed-galeria .sm-note { margin: 0 0 8px; }
.sm-ed-subida { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 10px; }
.sm-ed-subida input[type=file] { margin: 0; font-size: .85rem; }
.sm-ed-subida .sm-note { margin: 0; }
.sm-ed-subida .sm-check { margin: 0; }
.sm-ed-legal { font-size: .85rem; color: var(--muted); }
.sm-ed-legal summary { cursor: pointer; min-height: 36px; display: flex; align-items: center; font-weight: 600; }
.sm-ed-legal .sm-legal-txt { margin: .4rem 0 0; }
.sm-ed-stage.sm-ed-drop { outline: 3px dashed var(--accent); outline-offset: -3px; }
.sm-ed-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.sm-ed-thumb { padding: 0; min-height: 0; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--panel-line);
  background: repeating-conic-gradient(#d4d4d4 0 25%, #ececec 0 50%) 0 0/12px 12px; }
.sm-ed-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.sm-ed-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.sm-ed-row button { flex: 1 1 auto; min-height: 40px; padding: 0 12px; }
.sm-ed-sel .sm-ed-h { margin-top: 0; }
.sm-ed-capas { list-style: none; margin: 0; padding: 0; border: 1px solid var(--panel-line); border-radius: 12px; overflow: hidden; background: var(--panel); }
.sm-ed-capas li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--panel-line); }
.sm-ed-capas li:last-child { border-bottom: 0; }
.sm-ed-capas li.sm-on { box-shadow: inset 3px 0 0 var(--accent); padding-left: 12px; background: #313131; }
.sm-ed-capas li.sm-oculta img { opacity: .35; }
.sm-ed-capas li > img { width: 44px; height: 44px; object-fit: contain; flex: none; border-radius: 8px; background: repeating-conic-gradient(#d4d4d4 0 25%, #ececec 0 50%) 0 0/10px 10px; }
.sm-ed-cn { flex: 1; min-width: 0; display: flex; flex-direction: column; cursor: pointer; }
.sm-ed-cn b { font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-ed-cn small { color: var(--muted); font-size: .78rem; }
.sm-ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; margin: auto; }
.sm-ed-acc { display: flex; gap: 4px; width: 100%; padding-left: 52px; }
.sm-ed-acc .sm-ed-ico { flex: 1 1 0; min-width: 0; min-height: 40px; padding: 0; border-radius: 10px; }
.sm-ed-acc .sm-ico { width: 16px; height: 16px; }
.sm-ed-ico:disabled { opacity: .3; }
.sm-ed-vacio { color: var(--muted); font-size: .88rem; }
.sm-dpi { font-style: normal; font-size: .72rem; font-weight: 700; letter-spacing: .04em; margin-top: 2px; }
.sm-dpi-ok { color: var(--accent); } .sm-dpi-medio { color: var(--muted); } .sm-dpi-bajo { color: var(--warn); } .sm-dpi-malo { color: var(--danger); }
.sm-ed-ro .sm-ed-capas li { cursor: default; }
@media (min-width: 900px) {
  .sm-ed-body { flex-direction: row; align-items: flex-start; padding: 16px 24px; gap: 24px; }
  .sm-ed-lienzo { flex: 1; }
  .sm-ed-lados { align-self: center; }
  .sm-ed-panel { width: 380px; flex: none; position: sticky; top: 72px; }
  .sm-ed-capas li { flex-wrap: nowrap; }
  .sm-ed-acc { width: auto; padding-left: 0; }
  .sm-ed-acc .sm-ed-ico { flex: none; width: 34px; min-height: 34px; }
}
