:root {
  --bg: #12181a;
  --bg-2: #182124;
  --card: #1c2629;
  --line: rgba(232, 220, 196, 0.1);
  --ink: #f1e9da;
  --muted: #a69f92;
  --brass: #c9a25e;
  --brass-2: #e2c48a;
  --green: #5ed68d;
  --red: #e0796b;
  --radius: 22px;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(201, 162, 94, 0.16), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.wrap {
  max-width: 460px;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 100dvh;
}

/* Cabecera */
.brand { text-align: center; padding-top: 8px; }
.brand .ring {
  width: 54px; height: 54px; margin: 0 auto 14px;
  border: 1.5px solid var(--brass); border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--serif); font-weight: 600; color: var(--brass); font-size: 19px; letter-spacing: 0.02em;
}
.brand h1 {
  font-family: var(--serif); font-weight: 500; font-size: clamp(30px, 8vw, 38px);
  margin: 0; letter-spacing: -0.01em; line-height: 1.05;
}
.brand p {
  margin: 8px 0 0; color: var(--muted); font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase;
}

/* Estado */
.status {
  background: linear-gradient(180deg, var(--card), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 34px 24px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.lamp {
  width: 92px; height: 92px; margin: 0 auto 20px; border-radius: 50%;
  position: relative; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, #3a4346, #22292b);
  transition: background 600ms var(--ease);
}
.lamp::after {
  content: ''; width: 26px; height: 26px; border-radius: 50%;
  background: #4c5457; transition: background 600ms var(--ease), box-shadow 600ms var(--ease);
}
.is-open .lamp { background: radial-gradient(circle at 50% 40%, rgba(94, 214, 141, 0.28), rgba(94, 214, 141, 0.06)); }
.is-open .lamp::after { background: var(--green); box-shadow: 0 0 22px 6px rgba(94, 214, 141, 0.55); }
.is-open .lamp::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid rgba(94, 214, 141, 0.5);
  animation: pulse 2.4s var(--ease) infinite;
}
@keyframes pulse {
  from { transform: scale(1); opacity: 0.9; }
  to { transform: scale(1.55); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .is-open .lamp::before { animation: none; } }

.status h2 {
  font-family: var(--serif); font-weight: 500; font-size: 30px; margin: 0;
}
.status .since { color: var(--muted); font-size: 14px; margin-top: 6px; min-height: 1.3em; }
.note {
  margin-top: 20px; padding: 14px 16px; border-radius: 14px;
  background: rgba(201, 162, 94, 0.09); border: 1px solid rgba(201, 162, 94, 0.22);
  color: var(--brass-2); font-size: 15px; line-height: 1.45;
}
.note[hidden] { display: none; }

/* Suscripción */
.subscribe { text-align: center; }
.btn {
  appearance: none; border: 0; cursor: pointer; width: 100%; text-decoration: none;
  font: 600 16px/1 var(--sans); letter-spacing: 0.01em;
  padding: 19px 20px; border-radius: 16px;
  background: var(--brass); color: #1a1408;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform 160ms var(--ease), background 200ms var(--ease), opacity 200ms;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
@media (hover: hover) { .btn:hover { background: var(--brass-2); } }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
@media (hover: hover) { .btn.ghost:hover { background: rgba(255, 255, 255, 0.04); } }
.btn.green { background: var(--green); color: #0b2416; }
.btn.red { background: transparent; color: var(--red); border: 1px solid rgba(224, 121, 107, 0.4); }

.done {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 18px; border-radius: 16px; border: 1px solid rgba(94, 214, 141, 0.35);
  background: rgba(94, 214, 141, 0.07); color: var(--green); font-weight: 600;
}
.link { background: none; border: 0; color: var(--muted); font: 13px var(--sans); text-decoration: underline; margin-top: 12px; cursor: pointer; padding: 8px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 14px 4px 0; }

.ios {
  text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px;
}
.ios h3 { font-family: var(--serif); font-weight: 500; margin: 0 0 12px; font-size: 20px; }
.ios ol { margin: 0; padding-left: 20px; color: var(--ink); line-height: 1.7; font-size: 15px; }
.ios .share-ic { display: inline-block; vertical-align: -3px; width: 17px; height: 17px; }

footer { margin-top: auto; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.6; opacity: 0.8; }

[hidden] { display: none !important; }

/* ---------- Panel del bar ---------- */
.panel .status { padding: 26px 22px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 13px; color: var(--muted); letter-spacing: 0.04em; }
input[type='text'], input[type='password'], textarea {
  width: 100%; font: 16px var(--sans); color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 15px 16px; outline: none;
  transition: border-color 200ms;
}
input:focus, textarea:focus { border-color: var(--brass); }
textarea { resize: vertical; min-height: 84px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: 14px var(--sans); color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  padding: 9px 13px; border-radius: 999px; cursor: pointer; touch-action: manipulation;
  transition: border-color 160ms, transform 160ms var(--ease);
}
.chip:active { transform: scale(0.96); }
@media (hover: hover) { .chip:hover { border-color: var(--brass); } }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--ink); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--brass); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.card h3 { font-family: var(--serif); font-weight: 500; margin: 0; font-size: 21px; }
.stat { display: flex; align-items: baseline; gap: 10px; }
.stat b { font-family: var(--serif); font-size: 42px; font-weight: 500; color: var(--brass-2); }
.stat span { color: var(--muted); }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.history li { display: flex; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 14px; }
.history li:first-child { border-top: 0; }
.history .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--muted); }
.history .open .dot { background: var(--green); }
.history .notice .dot { background: var(--brass); }
.history small { color: var(--muted); display: block; margin-top: 2px; }
.qr { background: #fff; border-radius: 16px; padding: 16px; width: 200px; margin: 0 auto; }
.qr img { display: block; width: 100%; }
.row { display: flex; gap: 10px; }
.row .btn { padding: 15px; font-size: 15px; }

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 13px 18px; border-radius: 14px; font-weight: 600; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity 220ms var(--ease), transform 220ms var(--ease);
  max-width: calc(100% - 40px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Póster QR imprimible */
@media print {
  body { background: #fff; color: #111; }
  .wrap > *:not(.print-poster) { display: none !important; }
  .print-poster { display: flex !important; }
}
.print-poster {
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  min-height: 95vh; text-align: center; color: #111;
}
.print-poster h1 { font-family: var(--serif); font-weight: 500; font-size: 48px; margin: 0; }
.print-poster p { font-size: 22px; margin: 0; max-width: 14cm; line-height: 1.4; }
.print-poster img { width: 9cm; height: 9cm; }
