/* Pantalla principal (proyector) */
body.stage {
  background: var(--mat);
  color: var(--ink);
  height: 100vh; height: 100dvh;
  overflow: hidden;
  --gut: clamp(16px, 2.2vw, 44px);
  --board-w: clamp(330px, 31vw, 580px);
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; }

/* --- Rótulo de plano (título + total) --- */
.rotulo {
  position: fixed; top: var(--gut); left: var(--gut);
  width: min(35vw, 640px);
  padding: clamp(14px, 1.4vw, 26px) clamp(16px, 1.6vw, 30px) clamp(14px, 1.3vw, 24px);
  background: color-mix(in srgb, var(--mat) 84%, transparent);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .55);
  animation: rise .9s var(--ease) both .15s;
}
.rotulo h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3.05vw, 3.7rem);
  line-height: .98;
  font-weight: 800;
  font-variation-settings: "wdth" 116;
  letter-spacing: -0.025em;
  text-wrap: balance;
}
.rotulo .sub {
  margin: .55em 0 0; color: var(--ink-2);
  font-size: clamp(.9rem, 1.05vw, 1.25rem); font-weight: 500;
}
.total {
  display: grid; grid-template-columns: auto 1fr; align-items: end; gap: clamp(12px, 1.3vw, 24px);
  margin-top: clamp(14px, 1.5vw, 26px); padding-top: clamp(12px, 1.2vw, 20px);
  border-top: 1px solid var(--line);
}
.pct { display: flex; align-items: flex-start; line-height: .8; color: var(--balsa); }
.pct #pct { font-size: clamp(3rem, 5.4vw, 6rem); font-weight: 850; font-variation-settings: "wdth" 120; letter-spacing: -0.04em; }
.pct-sign { font-size: clamp(1.2rem, 1.9vw, 2.2rem); font-weight: 700; margin: .12em 0 0 .08em; }
.total-meta { display: grid; gap: 8px; padding-bottom: 4px; min-width: 0; }
.total-label { font-family: var(--f-hand); font-size: clamp(1rem, 1.2vw, 1.45rem); color: var(--ink); line-height: 1.1; }
.total-rule { height: 10px; }
.total-detail { color: var(--ink-2); font-size: clamp(.82rem, .92vw, 1.08rem); }

/* --- Herramientas arriba a la derecha --- */
.tools {
  position: fixed; top: var(--gut); right: var(--gut);
  display: flex; align-items: center; gap: 10px;
  animation: rise .9s var(--ease) both .25s;
}
.tool {
  display: grid; place-items: center; width: 46px; height: 46px;
  border-radius: 50%; border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--mat) 80%, transparent); color: var(--ink);
  transition: background .2s, border-color .2s;
}
.tool:hover { background: var(--mat-3); border-color: var(--ink-3); }
.tool[aria-pressed="false"] { color: var(--wait); border-color: var(--wait); }
.btn-see {
  display: inline-flex; align-items: center; gap: 10px;
  height: 46px; padding: 0 20px 0 16px; border-radius: 999px;
  background: var(--balsa); color: #2a1f0e; text-decoration: none;
  font-weight: 700; font-size: 1rem; font-variation-settings: "wdth" 108;
  box-shadow: 0 8px 22px -10px rgba(0, 0, 0, .6);
  transition: background .2s, transform .2s var(--ease);
}
.btn-see:hover { background: #f6e6c6; transform: translateY(-1px); }
.net {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  background: #3b2b0c; color: #ffd98a; font-size: .9rem; font-weight: 600;
}

/* --- Tablero de 7 escalímetros --- */
.board {
  position: fixed; right: var(--gut); top: calc(var(--gut) + 64px);
  width: var(--board-w);
  max-height: calc(100vh - var(--gut) * 2 - 64px - clamp(124px, 7.6vw + 30px, 180px) - 18px);
  padding: clamp(6px, .6vw, 12px) clamp(14px, 1.3vw, 24px);
  background: color-mix(in srgb, var(--mat) 84%, transparent);
  border: 1px solid var(--line-strong); border-radius: 3px;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .55);
  animation: rise .9s var(--ease) both .35s;
}
.board ol { list-style: none; margin: 0; padding: 0; height: 100%; display: grid; grid-auto-rows: 1fr; }
.row {
  --c: var(--balsa);
  display: grid; grid-template-columns: clamp(34px, 3vw, 56px) 1fr; align-items: center; column-gap: clamp(10px, 1vw, 18px);
  padding: clamp(4px, .75vh, 11px) 0;
  border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row .n {
  font-size: clamp(1.9rem, 2.9vw, 3.4rem); font-weight: 850; font-variation-settings: "wdth" 125;
  line-height: .85; color: var(--ink-c, var(--c)); letter-spacing: -0.04em; text-align: center;
  transition: transform .5s var(--ease);
}
.row-main { min-width: 0; display: grid; gap: clamp(4px, .55vh, 8px); }
.row-head { display: flex; align-items: baseline; gap: 12px; }
.row .name {
  flex: 1; min-width: 0; font-weight: 650; font-variation-settings: "wdth" 96;
  font-size: clamp(.95rem, 1.18vw, 1.45rem); line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row .count { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: clamp(.9rem, 1.05vw, 1.3rem); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.row .count b { color: var(--ink); font-weight: 800; font-size: 1.25em; }
.row .rule { height: clamp(9px, 1.2vh, 15px); }
.row .meta { display: flex; justify-content: space-between; gap: 10px; font-size: clamp(.78rem, .86vw, 1.02rem); color: var(--ink-3); }
.row .piece { font-family: var(--f-hand); color: var(--ink-2); }
.row .wait-n { color: var(--wait); font-weight: 600; }
.row .check { display: none; width: 1.15em; height: 1.15em; color: var(--c); }
.row.done .check { display: block; }
.row.done .name { color: var(--ink); }
.row.bump .n { animation: bump .9s var(--ease); }

/* --- Última propuesta aprobada --- */
.feed {
  position: fixed; left: var(--gut); bottom: var(--gut);
  width: min(44vw, 760px);
  animation: rise .9s var(--ease) both .45s;
}
.feed-card {
  position: relative; min-height: 3em;
  padding: clamp(14px, 1.3vw, 24px) clamp(16px, 1.5vw, 28px);
  background: color-mix(in srgb, var(--mat) 84%, transparent);
  border: 1px solid var(--line-strong); border-radius: 3px;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .55);
}
.feed-empty { margin: 0; color: var(--ink-2); font-size: clamp(1rem, 1.25vw, 1.4rem); max-width: 46ch; }
.feed-item { display: grid; grid-template-columns: auto 1fr; gap: clamp(12px, 1.1vw, 20px); align-items: start; }
.feed-item.in { animation: feedIn .8s var(--ease) both; }
.feed-chip {
  display: grid; place-items: center; width: clamp(38px, 3.2vw, 58px); aspect-ratio: 1; border-radius: 50%;
  background: var(--c); color: #fff; font-weight: 850; font-variation-settings: "wdth" 120; font-size: clamp(1.2rem, 1.7vw, 2rem);
}
.feed-text {
  margin: 0; font-size: clamp(1.1rem, 1.62vw, 1.95rem); font-weight: 560; line-height: 1.22;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; text-wrap: pretty;
}
.feed-by { margin: .45em 0 0; font-family: var(--f-hand); color: var(--ink-2); font-size: clamp(.95rem, 1.15vw, 1.35rem); }
.feed-by b { color: var(--ink-c); font-weight: 400; }
.feed-dots { position: absolute; right: 14px; top: 12px; display: flex; gap: 5px; }
.feed-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.feed-dots i.on { background: var(--ink); }

/* --- Código QR --- */
.qr {
  position: fixed; right: var(--gut); bottom: var(--gut);
  display: flex; align-items: center; gap: clamp(12px, 1.1vw, 20px);
  padding: clamp(10px, .9vw, 16px);
  padding-right: clamp(16px, 1.5vw, 28px);
  background: var(--paper); color: var(--paper-ink); text-decoration: none;
  border-radius: 4px;
  box-shadow: 0 2px 0 rgba(0,0,0,.08), 0 22px 40px -16px rgba(0, 0, 0, .7);
  transform: rotate(-1.2deg);
  animation: tag 1s var(--ease) both .55s;
  max-width: var(--board-w);
}
.qr-code { width: clamp(100px, 7.6vw, 150px); aspect-ratio: 1; }
.qr-code svg { width: 100%; height: 100%; }
.qr-text { display: grid; gap: 6px; min-width: 0; }
.qr-text strong { font-size: clamp(1.15rem, 1.6vw, 1.95rem); line-height: 1; font-weight: 850; font-variation-settings: "wdth" 112; letter-spacing: -0.02em; }
.qr-url { font-size: clamp(.78rem, .82vw, .98rem); color: var(--paper-ink-2); word-break: break-all; }
.qr-text .hand { font-family: var(--f-hand); font-size: clamp(.9rem, 1vw, 1.15rem); color: var(--paper-ink-2); }

/* --- Anotaciones a mano que siguen a la pieza --- */
.callouts { position: fixed; inset: 0; pointer-events: none; }
.callout {
  position: absolute; left: 0; top: 0;
  font-family: var(--f-hand); font-size: clamp(1.15rem, 1.6vw, 2rem); color: #fff; white-space: nowrap;
  will-change: transform, opacity; opacity: 0; transition: opacity .5s;
}
.callout.show { opacity: 1; }
.callout .lead { position: absolute; left: 0; top: 0; width: 70px; height: 2px; background: currentColor; transform-origin: 0 50%; transform: rotate(-38deg); opacity: .9; }
.callout .dot { position: absolute; left: -6px; top: -6px; width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px #fff; }
.callout .lbl {
  position: absolute; left: 50px; top: -74px; padding: 4px 12px 6px; border-radius: 3px;
  background: var(--c); color: #fff; box-shadow: 0 10px 24px -10px rgba(0,0,0,.6);
}

/* --- Avisos de nueva aprobación --- */
.toasts {
  position: fixed; top: var(--gut);
  left: calc(var(--gut) + min(35vw, 640px) + 24px); right: calc(var(--board-w) + var(--gut) + 24px);
  max-width: 560px; display: grid; gap: 10px; pointer-events: none;
}
.toast {
  display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center;
  padding: 12px 18px 12px 12px; border-radius: 4px;
  background: var(--paper); color: var(--paper-ink);
  box-shadow: 0 22px 40px -16px rgba(0, 0, 0, .7);
  animation: toastIn .7s var(--ease) both;
}
.toast.out { animation: toastOut .5s var(--ease) both; }
.toast .feed-chip { width: 44px; font-size: 1.35rem; }
.toast p { margin: 0; }
.toast .t1 { font-weight: 750; font-size: 1.02rem; font-variation-settings: "wdth" 104; }
.toast .t2 { color: var(--paper-ink-2); font-size: .95rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* --- Final --- */
.finale {
  position: fixed; left: 0; right: calc(var(--board-w) + var(--gut)); top: 66%;
  text-align: center; pointer-events: none;
  animation: finale 1.2s var(--ease) both;
}
.finale-title {
  margin: 0; font-size: clamp(2.6rem, 6vw, 6rem); font-weight: 900; font-variation-settings: "wdth" 125; letter-spacing: -0.04em; line-height: .9;
  color: #fff; text-shadow: 0 6px 30px rgba(0, 0, 0, .55);
}
.finale-sub { margin: .4em 0 0; font-family: var(--f-hand); font-size: clamp(1.2rem, 2vw, 2.2rem); color: var(--balsa); text-shadow: 0 2px 14px rgba(0, 0, 0, .6); }

@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
@keyframes tag { from { opacity: 0; transform: translateY(30px) rotate(4deg); } }
@keyframes bump { 30% { transform: scale(1.35); } }
@keyframes feedIn { from { opacity: 0; transform: translateY(10px); filter: blur(4px); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-24px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-16px); } }
@keyframes finale { from { opacity: 0; transform: scale(.8); filter: blur(10px); } }

/* --- Pantallas angostas (si alguien la abre en el teléfono) --- */
@media (max-width: 900px), (max-aspect-ratio: 1/1) {
  body.stage { height: auto; overflow: auto; --board-w: 100%; }
  #scene { position: relative; height: 62vh; }
  .rotulo, .tools, .board, .feed, .qr { position: relative; inset: auto; width: auto; max-width: none; max-height: none; margin: 0 16px 14px; transform: none; }
  .rotulo { margin-top: 14px; }
  .tools { position: absolute; top: 12px; right: 0; left: 0; margin: 0 12px; justify-content: flex-end; }
  #scene { margin-top: 0; }
  body.stage { display: flex; flex-direction: column; }
  #scene { order: 0; } .tools { order: -1; } .rotulo { order: 1; } .board { order: 2; } .feed { order: 3; } .qr { order: 4; margin-bottom: 24px; }
  .tool { display: none; }
  .row .name { white-space: normal; }
  .toasts { left: 16px; right: 16px; top: 70px; }
  .finale { right: 0; top: 18vh; }
}
