:root {
  --fondo: #0d0c0b;
  --fondo-2: #171513;
  --tarjeta: #1d1a17;
  --borde: #2e2a25;
  --texto: #efe9df;
  --suave: #a39a8d;
  --luz: #f3dcb0;
  --luz-fuerte: #ffd98f;
  --acento: #e9c27a;
  --ok: #8fcf9a;
  --radio: 14px;
  --seguro-arriba: var(--tg-content-safe-area-inset-top, 0px);
  --seguro-abajo: var(--tg-content-safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body { min-height: 100vh; padding-bottom: calc(24px + var(--seguro-abajo)); overflow-x: hidden; }

/* Contraluz cálido detrás de la cabecera, como en el logo */
.halo {
  position: fixed; inset: -30vh -20vw auto; height: 70vh; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse at 50% 60%, rgba(255, 217, 143, .22), rgba(255, 217, 143, .06) 40%, transparent 70%);
}

header.top, .tabs, main { position: relative; z-index: 1; }

header.top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(16px + var(--seguro-arriba)) 16px 10px;
}
.logo { border-radius: 50%; box-shadow: 0 0 0 1px var(--borde), 0 0 24px rgba(255, 217, 143, .35); }
h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: .2px; }
h2 { margin: 6px 0 6px; font-size: 19px; font-weight: 650; }
.saludo, .texto-suave { margin: 0; color: var(--suave); }

.tabs {
  display: flex; gap: 6px; margin: 6px 16px 14px; padding: 4px;
  background: var(--fondo-2); border: 1px solid var(--borde); border-radius: 12px;
}
.tab {
  flex: 1; padding: 9px 4px; border: 0; border-radius: 9px; background: transparent;
  color: var(--suave); font: inherit; font-weight: 600; cursor: pointer;
}
.tab.activa { background: var(--tarjeta); color: var(--texto); box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 0 0 1px var(--borde); }

main { padding: 0 16px; }

/* Catálogo */
.rejilla { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.figura {
  display: block; width: 100%; padding: 0; border: 1px solid var(--borde); border-radius: var(--radio);
  background: var(--tarjeta); color: inherit; font: inherit; text-align: left; overflow: hidden; cursor: pointer;
  transition: transform .15s ease, border-color .15s ease;
}
.figura:active { transform: scale(.98); border-color: var(--acento); }
.figura img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--fondo-2); }
.figura span { display: block; padding: 10px 12px 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Detalle */
.detalle-foto {
  margin: 0 -16px 12px; background: var(--fondo-2);
  box-shadow: 0 30px 60px -30px rgba(255, 217, 143, .25);
}
.detalle-foto img { display: block; width: 100%; max-height: 52vh; object-fit: contain; }

.campo { display: block; margin: 16px 0; }
.campo-titulo { display: block; margin-bottom: 8px; font-weight: 600; }
.campo-titulo em { color: var(--suave); font-style: normal; font-weight: 400; }

input[type=text], input[type=number], textarea {
  width: 100%; padding: 12px; border: 1px solid var(--borde); border-radius: 12px;
  background: var(--fondo-2); color: var(--texto); font: inherit; resize: vertical;
}
input:focus, textarea:focus { outline: none; border-color: var(--acento); }

.altura { display: flex; align-items: center; gap: 12px; }
.altura input[type=range] { flex: 1; accent-color: var(--acento); }
.altura-num { display: flex; align-items: center; gap: 6px; width: 104px; }
.altura-num input { text-align: center; padding: 10px 6px; }
.altura-num span { color: var(--suave); }

.aviso {
  margin: 4px 0 16px; padding: 12px; border-radius: 12px; font-size: 13.5px; color: var(--suave);
  background: rgba(233, 194, 122, .07); border: 1px solid rgba(233, 194, 122, .18);
}

/* Adjuntos de la idea */
.adjuntar { display: flex; gap: 8px; }
.boton-adj {
  flex: 1; padding: 11px 6px; border-radius: 12px; border: 1px dashed #4a4239;
  background: var(--fondo-2); color: var(--texto); font: inherit; font-weight: 600; cursor: pointer;
}
.boton-adj:active { border-color: var(--acento); }
.adjuntos { list-style: none; margin: 10px 0 0; padding: 0; }
.adjuntos li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 6px;
  border: 1px solid var(--borde); border-radius: 10px; background: var(--tarjeta);
}
.adjuntos .ico { font-size: 18px; }
.adjuntos .nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adjuntos .tam { color: var(--suave); font-size: 12.5px; }
.adjuntos button { border: 0; background: none; color: var(--suave); font-size: 18px; padding: 0 4px; cursor: pointer; }
.nota-adj { margin: 6px 0 0; color: var(--suave); font-size: 12.5px; }
.progreso {
  position: relative; height: 34px; margin: 4px 0 14px; border-radius: 10px; overflow: hidden;
  background: var(--fondo-2); border: 1px solid var(--borde);
}
.progreso i { position: absolute; inset: 0 auto 0 0; width: 0; background: rgba(233, 194, 122, .35); transition: width .2s; }
.progreso span { position: relative; display: block; line-height: 32px; text-align: center; font-size: 13.5px; }

/* Botones propios: solo se ven fuera de Telegram; dentro se usa el botón principal nativo */
.boton-web, .boton-sec {
  display: block; width: 100%; padding: 14px; border: 0; border-radius: 12px; cursor: pointer;
  font: inherit; font-weight: 650;
}
.boton-web { background: var(--acento); color: #1a1408; }
.boton-sec { margin-top: 18px; background: var(--tarjeta); color: var(--texto); border: 1px solid var(--borde); }
.boton-link { margin-top: 10px; padding: 10px; border: 0; background: none; color: var(--suave); font: inherit; cursor: pointer; }
body.en-telegram .boton-web { display: none; }

/* Pedidos */
.pedido {
  margin-bottom: 12px; padding: 14px; border: 1px solid var(--borde); border-radius: var(--radio); background: var(--tarjeta);
}
.pedido-cab { display: flex; gap: 12px; align-items: center; }
.pedido-cab img, .pedido-cab .sin-foto {
  width: 52px; height: 52px; flex: none; border-radius: 10px; object-fit: cover; background: var(--fondo-2);
  display: grid; place-items: center; font-size: 22px;
}
.pedido-titulo { font-weight: 650; }
.pedido-sub { color: var(--suave); font-size: 13.5px; }
.pasos { display: flex; gap: 4px; margin: 14px 0 8px; }
.pasos i { flex: 1; height: 4px; border-radius: 2px; background: var(--borde); }
.pasos i.hecho { background: var(--acento); box-shadow: 0 0 8px rgba(255, 217, 143, .45); }
.pedido-estado { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.pedido-estado b { font-weight: 600; }
.pedido-estado span { color: var(--luz); text-align: right; }
.pedido.cerrado { opacity: .6; }
.boton-cancelar {
  margin-top: 12px; padding: 9px 12px; border-radius: 10px; border: 1px solid #5a3a32;
  background: transparent; color: #f0a99a; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.boton-cancelar:active { background: rgba(240, 169, 154, .08); }
.titulo-seccion { margin: 22px 0 10px; color: var(--suave); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }

/* Estados vacíos */
.vacio { padding: 48px 12px; text-align: center; }
.vacio-icono { font-size: 42px; margin-bottom: 8px; filter: drop-shadow(0 0 18px rgba(255, 217, 143, .35)); }
.vacio p { color: var(--suave); margin: 0 auto; max-width: 30ch; }

.spinner {
  width: 28px; height: 28px; margin: 80px auto; border-radius: 50%;
  border: 3px solid var(--borde); border-top-color: var(--acento); animation: giro .8s linear infinite;
}
@keyframes giro { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + var(--seguro-abajo)); z-index: 5;
  padding: 12px 14px; border-radius: 12px; background: #2a1d1a; border: 1px solid #5a3a32; color: #ffd9cf;
}

@media (min-width: 560px) {
  main, .tabs { max-width: 560px; margin-left: auto; margin-right: auto; }
  .rejilla { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
