/* blute - 미리보기/스테이지/엔진/반응형 (styles.css에서 분리) */
/* ══════════════════ 미리보기 패널 ══════════════════ */
.preview-panel { display: flex; flex-direction: column; overflow: hidden; background: var(--ink); min-width: 0; }
.preview-toolbar {
  display: flex; align-items: center; gap: 10px 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.025), transparent 60%), var(--shell);
  box-shadow: inset 0 -1px 0 rgba(0,0,0,.25);
  flex-shrink: 0; flex-wrap: wrap;
}
.preview-toolbar > .eyebrow { flex-shrink: 0; align-self: center; padding: 4px 10px; border-radius: var(--r-pill); color: var(--sub); background: var(--panel2); border: 1px solid var(--line); font-size: 9.5px; letter-spacing: .16em; }
.test-row { display: flex; gap: 7px; flex: 1; flex-wrap: wrap; }
.test-group {
  display: flex; gap: 0; align-items: stretch;
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.test-group:hover { border-color: var(--line-2); }
.test-group:focus-within { border-color: var(--accent); background: #0e1018; box-shadow: 0 0 0 3px var(--accent-soft); }
.test-group .tg-ico { display: flex; align-items: center; padding: 0 8px; font-size: 12.5px; background: transparent; color: var(--sub); border-right: 1px solid var(--line); transition: color var(--t-fast) var(--ease); }
.test-group:focus-within .tg-ico { color: var(--accent-2); }
.test-group input { border: none; border-radius: 0; background: transparent; padding: 8px 9px; font-size: 11.5px; box-shadow: none !important; }
.test-group input:focus { background: transparent; }
.test-group input.w-nick { width: 66px; }
.test-group input.w-msg { width: 84px; }
.test-group input.w-num { width: 48px; text-align: center; font-family: var(--mono); }
.test-group .tg-go {
  border: none; border-radius: 0; border-left: 1px solid var(--line);
  background: var(--accent-soft); color: var(--accent-2); font-size: 11.5px; font-weight: 800; letter-spacing: .02em; padding: 0 11px;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform .08s var(--ease);
}
.test-group .tg-go:hover, .test-group:focus-within .tg-go { background: linear-gradient(160deg, var(--accent-2), var(--accent)); color: #0a0b13; }
.test-group .tg-go:active { transform: scale(.94); }

.test-obs-row { flex-basis: 100%; display: flex; align-items: center; gap: 10px; margin-top: 4px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--panel); border: 1px solid var(--line); }
.tobs-label { font-size: 11.5px; color: var(--sub); font-weight: 600; }
.tobs-label b { color: var(--text); font-weight: 700; }
.tobs-toggle { min-width: 60px; padding: 6px 16px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--panel2); color: var(--sub); font-size: 11px; font-weight: 800; letter-spacing: .12em; cursor: pointer; transition: background .18s, color .18s, border-color .18s, box-shadow .18s; }
.tobs-toggle:hover { border-color: var(--line-2); color: var(--text); background: var(--panel3); }
.tobs-toggle.on { background: linear-gradient(160deg, #3fe6ad, var(--good)); border-color: var(--good); color: #05221a; box-shadow: 0 0 0 3px rgba(52,217,160,.18), 0 4px 14px -6px var(--good); }
#tobs-hint { color: var(--faint); }

.stage-wrapper {
  flex: 1; position: relative; overflow: hidden;
  background:
    radial-gradient(120% 78% at 50% 120%, rgba(123,108,255,.24), transparent 58%),
    radial-gradient(74% 52% at 50% -10%, rgba(123,108,255,.07), transparent 62%),
    linear-gradient(180deg, #0b0c14 0%, #0d0f18 56%, #08090f 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.03), inset 0 1px 0 rgba(255,255,255,.05);
}
.stage-wrapper::before {
  content: ""; position: absolute; inset: 0; z-index: 5; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 42%, transparent 52%, rgba(0,0,0,.32) 100%);
}
.stage-wrapper::after {
  content: ""; position: absolute; left: 50%; bottom: -2px; width: 240%; height: 48%;
  transform: translateX(-50%) perspective(420px) rotateX(66deg); transform-origin: bottom center;
  z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(90deg, rgba(154,139,255,.22) 1px, transparent 1px),
    linear-gradient(0deg, rgba(154,139,255,.22) 1px, transparent 1px),
    radial-gradient(60% 38% at 50% 100%, rgba(123,108,255,.22), transparent 70%);
  background-size: 48px 48px, 48px 48px, 100% 100%;
  -webkit-mask-image: radial-gradient(86% 100% at 50% 100%, #000 4%, transparent 76%);
  mask-image: radial-gradient(86% 100% at 50% 100%, #000 4%, transparent 76%);
}
.tally {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 6;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 10px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase;
  color: #dfe3f2;
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(8,9,15,.5));
  backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(255,255,255,.14); padding: 6px 12px 6px 10px; border-radius: var(--r-pill);
  box-shadow: 0 8px 24px -10px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.12);
  pointer-events: none;
}
.tally-led { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 10px var(--accent-glow), 0 0 0 3px rgba(123,108,255,.16); animation: tally-pulse 2s ease-in-out infinite; }
@keyframes tally-pulse { 0%,100% { opacity: 1; box-shadow: 0 0 10px var(--accent-glow), 0 0 0 3px rgba(123,108,255,.16); } 50% { opacity: .55; box-shadow: 0 0 6px var(--accent-glow), 0 0 0 5px rgba(123,108,255,.06); } }

/* ══════════════════ 오버레이 캐릭터 (엔진 — 출력 유지) ══════════════════ */
#stage { position: absolute; left: 50%; bottom: 0; transform-origin: bottom center; z-index: 1; will-change: transform; }
.avatar { position: absolute; bottom: 14px; width: 162px; height: 210px; transform-origin: bottom center; pointer-events: none; }
.avatar .body { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; gap: var(--name-gap, 2px); }
.img-wrap { width: 157px; display: flex; align-items: flex-end; justify-content: center; }
.img-wrap img { max-width: 100%; max-height: 178px; object-fit: contain; display: block; filter: drop-shadow(0 6px 6px rgba(0,0,0,.35)); transform-origin: center bottom; }
.name-tag { position: relative; z-index: 2; font-size: var(--name-size, 12px); font-family: var(--name-font, inherit); font-weight: 700; line-height: 1; color: #fff; background: rgba(0,0,0,.45); padding: 3px 9px; border-radius: 11px; white-space: nowrap; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
#stage.name-above .body, #overlay-stage.name-above .body { flex-direction: column-reverse; }

@keyframes spawn-pop { from { transform: scale(0) translateY(20px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
.avatar.spawn-in .body { animation: spawn-pop .4s cubic-bezier(.34,1.56,.64,1); }
@keyframes leave-fall { to { transform: translateY(30px) scale(.75); opacity: 0; } }
.avatar.leaving .body { animation: leave-fall .55s ease-in forwards; }
@keyframes bounce-jump { 0% { transform: translateY(0) scale(1,1);} 30% { transform: translateY(-16px) scale(1,1.05);} 55% { transform: translateY(0) scale(1.05,.92);} 75% { transform: translateY(-4px);} 100% { transform: translateY(0);} }
.img-wrap.jump img { animation: bounce-jump .5s ease-out; }
@keyframes dono-pulse { 0%,100% { transform: scale(1); filter: drop-shadow(0 0 10px #ffd166) drop-shadow(0 0 4px #fff);} 50% { transform: scale(1.18); filter: drop-shadow(0 0 22px #ff8c42) drop-shadow(0 0 8px #fff);} }
.donation-glow .img-wrap img { animation: dono-pulse .55s ease-in-out infinite; }
@keyframes sub-glow { 0%,100% { filter: drop-shadow(0 0 8px #7dd3fc);} 50% { filter: drop-shadow(0 0 20px #a78bfa);} }
.sub-sparkle .img-wrap img { animation: sub-glow .9s ease-in-out infinite; }

.bubble {
  position: absolute; z-index: 4; top: calc(-1 * var(--bubble-offset, 8px)); left: 50%;
  transform-origin: bottom center; transform: translate(-50%, -100%) scale(.85);
  box-sizing: border-box;
  min-width: calc(var(--bubble-width, 440px) * 0.4); max-width: var(--bubble-width, 440px); min-height: var(--bubble-height, 50px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bubble-bg, #fff); color: var(--bubble-fg, #222);
  font-size: 21px; font-weight: 600; line-height: 1.35; padding: 10px 16px; border-radius: 16px;
  text-align: center; box-shadow: 0 4px 14px rgba(0,0,0,.25); opacity: 0;
  transition: opacity .25s ease, transform .25s ease; pointer-events: none;
}
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%); border-width: 8px 7px 0 7px; border-style: solid; border-color: var(--bubble-bg, #fff) transparent transparent transparent; }
.bubble.show { opacity: 1; transform: translate(-50%, -100%) scale(1); }
#stage.bubble-sharp .bubble, #overlay-stage.bubble-sharp .bubble { border-radius: 3px; }

.effect-layer { position: absolute; z-index: 3; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; }
.confetti-piece { position: absolute; top: 30%; width: 9px; height: 14px; opacity: 1; animation: confetti-fall 1s ease-out forwards; }
@keyframes confetti-fall { to { transform: translate(var(--dx), 140px) rotate(var(--rot)); opacity: 0; } }
.sparkle-piece { position: absolute; color: #fff7ae; font-size: 20px; text-shadow: 0 0 6px #fff, 0 0 10px #a78bfa; opacity: 0; animation: sparkle-pop 1s ease-out forwards; }
@keyframes sparkle-pop { 0% { opacity: 0; transform: scale(.2) translateY(0);} 30% { opacity: 1; transform: scale(1.2) translateY(-6px);} 100% { opacity: 0; transform: scale(.6) translateY(-30px);} }

/* ══════════════════ 오버레이 모드 ══════════════════ */
#overlay-mode { position: fixed; inset: 0; }
#overlay-stage-wrapper { position: absolute; inset: 0; overflow: hidden; }
#overlay-stage { position: absolute; left: 0; bottom: 0; transform-origin: bottom left; pointer-events: none; }
#overlay-badge {
  position: fixed; left: 10px; bottom: 10px; z-index: 9999;
  font-size: 11px; padding: 5px 10px; border-radius: 8px; font-weight: 600;
  background: rgba(8,9,15,.72); color: #fff; font-family: var(--sans);
  border: 1px solid rgba(255,255,255,.12);
  opacity: 0; transition: opacity .3s; pointer-events: none;
}
#overlay-badge.show { opacity: 1; }

/* ══════════════════ 진입 모션 ══════════════════ */
@media (prefers-reduced-motion: no-preference) {
  .app-shell { animation: shell-in .5s cubic-bezier(.22,.61,.36,1) both; }
  @keyframes shell-in { from { opacity: 0; transform: translateY(10px) scale(.995); } to { opacity: 1; transform: none; } }
  .sidebar > * { animation: card-in .45s ease both; }
  .sidebar > *:nth-child(1) { animation-delay: .06s; }
  .sidebar > *:nth-child(2) { animation-delay: .12s; }
  .sidebar > *:nth-child(3) { animation-delay: .18s; }
  @keyframes card-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

@media (prefers-reduced-motion: reduce) {
  .tally-led { animation: none; }
  .platform-fields.show { animation: none; }
  * { scroll-behavior: auto; }
}

/* ══════════════════ 반응형 ══════════════════ */
@media (max-width: 1180px) { .ad-rail { display: none; } .middle-row { grid-template-columns: 1fr; } }
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: 60px auto 1fr; }
  .preview-panel { min-height: 320px; }
  .middle-row { padding: 12px; }
}
@media (max-width: 520px) {
  .platform-seg { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
}
