/* blute - 스타일시트 (index.html에서 분리) */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── 뉴트럴 (스튜디오 잉크) ── */
  --ink:     #08090f;
  --bg:      #08090f;
  --shell:   #0e1018;
  --panel:   #13151f;   /* 카드 */
  --panel2:  #1a1d29;   /* 입력/컨트롤 */
  --panel3:  #232636;
  --line:    rgba(255,255,255,.07);
  --line-2:  rgba(255,255,255,.12);
  --text:    #eceef6;
  --sub:     #9298ad;
  --faint:   #565c75;

  /* ── 시그니처 (아이리스) ── */
  --accent:       #7b6cff;
  --accent-2:     #9a8bff;
  --accent-soft:  rgba(123,108,255,.14);
  --accent-line:  rgba(123,108,255,.40);
  --accent-glow:  rgba(123,108,255,.55);

  /* ── 상태 (JS가 var(--good/warn/bad/sub) 참조) ── */
  --good: #34d9a0;
  --warn: #f6c453;
  --bad:  #fb7185;

  /* ── 플랫폼 ── */
  --chzzk:   #00e59b;
  --youtube: #ff4d4d;
  --twitch:  #a974ff;

  --radius: 14px;
  --r-sm: 10px;
  --r-lg: 20px;
  --r-pill: 999px;

  --sh-1: 0 1px 2px rgba(0,0,0,.4);
  --sh-2: 0 14px 36px -16px rgba(0,0,0,.6);
  --sh-3: 0 36px 90px -34px rgba(0,0,0,.72);

  --sans: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-soft); }

.eyebrow {
  font-size: 10.5px; font-weight: 700; letter-spacing: .13em;
  text-transform: uppercase; color: var(--faint);
}

/* ══════════════════ 광고 레이아웃 ══════════════════ */
.page { display: flex; flex-direction: column; height: 100vh; overflow: hidden; background: var(--ink); }

.ad-top {
  flex: 0 0 auto; min-height: 92px;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(60% 140% at 50% 0%, rgba(123,108,255,.05), transparent 70%),
    var(--ink);
  border-bottom: 1px solid var(--line);
  overflow: hidden; padding: 8px 16px;
}
.middle-row {
  flex: 1; display: grid;
  grid-template-columns: 188px minmax(0, 1fr) 188px;
  gap: 16px; padding: 16px;
  min-height: 0;
}
.ad-rail {
  display: flex; align-items: flex-start; justify-content: center;
  overflow: hidden; padding-top: 4px;
}

.ad-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 7px; width: 100%;
  border: 1px dashed var(--line-2); border-radius: var(--radius);
  color: var(--faint); font-size: 11px; text-align: center;
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,.012) 0 10px, transparent 10px 20px);
}
.ad-placeholder .ad-label { font-weight: 700; letter-spacing: .04em; color: var(--sub); }
.ad-placeholder .ad-size { font-size: 10px; opacity: .65; line-height: 1.5; }
.ad-top .ad-placeholder { max-width: 980px; height: 76px; }
.ad-rail .ad-placeholder { height: 600px; max-height: 100%; }

/* ══════════════════ 콘솔(앱 본체) ══════════════════ */
.app-shell {
  display: grid;
  grid-template-columns: 408px 1fr;
  grid-template-rows: 60px 1fr;
  height: 100%; min-height: 0;
  background: var(--shell);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  overflow: hidden;
}

.topbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px 0 16px; gap: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,.025), transparent), var(--shell);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark { width: 38px; height: 38px; flex-shrink: 0; filter: drop-shadow(0 6px 14px var(--accent-glow)); }
.brand-mark svg { display: block; width: 100%; height: 100%; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-size: 14.5px; font-weight: 800; letter-spacing: -.01em; }
.brand-sub { font-size: 10.5px; color: var(--faint); font-weight: 500; letter-spacing: .02em; }

.status-pill {
  display: inline-flex; align-items: center; gap: 7px; margin-left: 4px;
  font-size: 11px; color: var(--sub); font-weight: 600;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: var(--r-pill); padding: 5px 11px 5px 9px; white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sub); flex-shrink: 0; box-shadow: 0 0 0 3px rgba(255,255,255,.04); transition: background .3s, box-shadow .3s; }

.tab-group { display: flex; gap: 3px; margin-left: auto; background: var(--panel2); padding: 3px; border-radius: var(--r-pill); border: 1px solid var(--line); }
.tab-btn {
  padding: 5px 15px; border-radius: var(--r-pill);
  border: none; background: transparent; color: var(--sub);
  font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit;
  transition: color .15s, background .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { background: var(--accent); color: #0a0b13; box-shadow: 0 2px 10px -2px var(--accent-glow); }

/* ── 사이드바 ── */
.sidebar {
  overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
  border-right: 1px solid var(--line);
  background: var(--bg);
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--panel3); border-radius: 8px; border: 2px solid var(--bg); }
.sidebar::-webkit-scrollbar-thumb:hover { background: #2e3247; }

/* ══════════════════ 카드 ══════════════════ */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--sh-1);
}
.card.highlight {
  border-color: var(--accent-line);
  background:
    radial-gradient(120% 80% at 0% 0%, var(--accent-soft), transparent 60%),
    var(--panel);
  box-shadow: 0 0 0 1px var(--accent-soft), var(--sh-2);
}

.sec-head { display: flex; align-items: center; gap: 9px; margin-bottom: 13px; }
.sec-title { font-size: 13px; font-weight: 800; letter-spacing: -.01em; color: var(--text); }
.sec-aux { margin-left: auto; font-size: 10.5px; color: var(--faint); font-weight: 500; }
.step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; flex-shrink: 0;
  border-radius: 7px; font-size: 11.5px; font-weight: 800;
  color: #0a0b13; background: linear-gradient(160deg, var(--accent-2), var(--accent));
  box-shadow: 0 3px 10px -3px var(--accent-glow);
}

.card h2 {
  font-size: 10.5px; font-weight: 700; color: var(--faint);
  text-transform: uppercase; letter-spacing: .12em; margin-bottom: 11px;
}

.hint { color: var(--sub); font-size: 11.5px; line-height: 1.65; }
.hint + .hint { margin-top: 7px; }
.hint-inline { color: var(--faint); font-size: 11px; }
.row { display: flex; gap: 8px; }

/* ── 폼 ── */
input, select, textarea {
  flex: 1; min-width: 0; width: 100%;
  padding: 9px 11px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--panel2);
  color: var(--text); font-size: 12.5px; font-family: inherit;
  outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
input:hover, select:hover { border-color: var(--line-2); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); background: #0e1018;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--faint); }
select {
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239298ad' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px;
}
code { font-family: var(--mono); font-size: 11px; background: var(--panel2); padding: 1px 6px; border-radius: 5px; color: var(--accent-2); border: 1px solid var(--line); }

button {
  padding: 9px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  font-size: 12.5px; font-weight: 700; cursor: pointer; white-space: nowrap;
  font-family: inherit; transition: background .14s, border-color .14s, transform .08s, box-shadow .14s;
}
button:hover:not(:disabled) { background: var(--panel3); border-color: var(--line-2); }
button:active:not(:disabled) { transform: translateY(1px); }
button.primary {
  background: linear-gradient(160deg, var(--accent-2), var(--accent));
  border-color: transparent; color: #0a0b13;
  box-shadow: 0 6px 18px -8px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.22);
}
button.primary:hover:not(:disabled) { box-shadow: 0 8px 24px -8px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.3); filter: brightness(1.05); }
button:disabled { opacity: .42; cursor: default; }
button.mini { padding: 7px 11px; font-size: 11.5px; }
button.danger { background: transparent; border-color: rgba(251,113,133,.32); color: var(--bad); }
button.danger:hover:not(:disabled) { background: rgba(251,113,133,.12); border-color: var(--bad); }

button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, .swatch:focus-visible {
  outline: 2px solid var(--accent-2); outline-offset: 2px;
}

.toast { margin-top: 9px; font-size: 11.5px; color: var(--good); font-weight: 600; opacity: 0; transform: translateY(-3px); transition: opacity .2s, transform .2s; height: 16px; display: flex; align-items: center; gap: 5px; }
.toast::before { content: "✓"; font-weight: 800; }
.toast.show { opacity: 1; transform: translateY(0); }

/* ══════════════════ 플랫폼 선택 ══════════════════ */
.platform-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 13px; }
.platform-seg button {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 4px 10px; border-radius: var(--r-sm);
  background: var(--panel2); border: 1px solid var(--line); color: var(--sub);
  font-size: 11.5px; font-weight: 700; position: relative; overflow: hidden;
  transition: all .16s;
}
.platform-seg button .pf-ico { display: flex; color: currentColor; transition: color .16s; }
.platform-seg button:hover { border-color: var(--line-2); color: var(--text); transform: translateY(-1px); }
.platform-seg button.sel { background: var(--panel3); }
.platform-seg button.sel.chzzk   { color: var(--chzzk);   border-color: rgba(0,229,155,.5); }
.platform-seg button.sel.youtube { color: var(--youtube); border-color: rgba(255,77,77,.5); }
.platform-seg button.sel.twitch  { color: var(--twitch);  border-color: rgba(169,116,255,.5); }
.platform-seg button.sel.chzzk   { border-color: color-mix(in srgb, var(--chzzk) 55%, transparent);   box-shadow: 0 0 0 1px color-mix(in srgb, var(--chzzk) 45%, transparent) inset, 0 6px 18px -10px var(--chzzk); }
.platform-seg button.sel.youtube { border-color: color-mix(in srgb, var(--youtube) 55%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--youtube) 45%, transparent) inset, 0 6px 18px -10px var(--youtube); }
.platform-seg button.sel.twitch  { border-color: color-mix(in srgb, var(--twitch) 55%, transparent);  box-shadow: 0 0 0 1px color-mix(in srgb, var(--twitch) 45%, transparent) inset, 0 6px 18px -10px var(--twitch); }

.platform-fields { display: none; }
.platform-fields.show { display: block; animation: fade-slide .25s ease; }
@keyframes fade-slide { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.field { margin-bottom: 9px; }
.field:last-child { margin-bottom: 0; }
.field-label { font-size: 11px; color: var(--sub); margin-bottom: 5px; display: block; font-weight: 600; }

.login-btn {
  width: 100%; margin-bottom: 11px; padding: 11px 14px; border: none; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 800; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 6px 16px -8px rgba(0,0,0,.6);
}
.login-btn::before { content: ""; width: 16px; height: 16px; background: currentColor; -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
.twitch-btn { background: var(--twitch); }
.youtube-btn { background: var(--youtube); }
.login-btn:hover { filter: brightness(1.07); }
.login-btn:active { transform: translateY(1px); }

.note-badge {
  display: flex; align-items: flex-start; gap: 6px;
  font-size: 10.5px; line-height: 1.5; padding: 7px 9px; border-radius: var(--r-sm); margin-top: 9px;
  font-weight: 500;
}
.note-badge.ok   { background: rgba(52,217,160,.10); color: #6ee7bf; border: 1px solid rgba(52,217,160,.2); }
.note-badge.warn { background: rgba(246,196,83,.09); color: #f2cf7a; border: 1px solid rgba(246,196,83,.2); }

/* ── 오버레이 주소 ── */
.overlay-url-box { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line-2); }
.url-readonly {
  width: 100%; margin-bottom: 9px;
  font-family: var(--mono); font-size: 11px; letter-spacing: -.01em;
  color: var(--accent-2); background: #0a0c12; border-color: var(--line);
  padding: 11px; line-height: 1.5; word-break: break-all;
}
.url-readonly:focus { color: var(--accent-2); }
.url-readonly.flash { animation: url-flash 1.6s ease; }
@keyframes url-flash {
  0%, 100% { border-color: var(--line); box-shadow: none; }
  20%      { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), 0 0 22px -4px var(--accent-glow); }
}
@media (prefers-reduced-motion: reduce) { .url-readonly.flash { animation: none; } }

/* ══════════════════ 아바타 그리드 ══════════════════ */
.avatar-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.avatar-card, .avatar-add-card {
  position: relative; aspect-ratio: 1; border-radius: 11px;
  border: 1px solid var(--line); background: var(--panel2);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  transition: border-color .14s, transform .1s;
}
.avatar-card:hover { border-color: var(--line-2); transform: translateY(-2px); }
.avatar-card img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.avatar-card .remove-btn {
  position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; padding: 0;
  border-radius: 50%; background: rgba(8,9,15,.75); border: 1px solid var(--line-2); color: #fff;
  font-size: 11px; line-height: 1; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .14s;
}
.avatar-card:hover .remove-btn { opacity: 1; }
.avatar-card .url-tag {
  position: absolute; bottom: 3px; left: 3px;
  font-size: 8px; background: var(--accent); color: #0a0b13;
  padding: 1px 5px; border-radius: 5px; font-weight: 800; letter-spacing: .04em;
}
.avatar-add-card { color: var(--faint); font-size: 20px; background: transparent; border-style: dashed; border-color: var(--line-2); cursor: pointer; }
.avatar-add-card:hover { color: var(--accent-2); border-color: var(--accent); background: var(--accent-soft); }
.avatar-actions { display: flex; gap: 8px; margin-top: 10px; }
.url-add-row { display: none; gap: 8px; margin-top: 10px; }
.url-add-row.show { display: flex; }

/* ══════════════════ 설정 행 ══════════════════ */
.customize { display: flex; flex-direction: column; }
.customize-toggle {
  list-style: none; cursor: pointer; user-select: none;
  padding: 14px 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel);
  font-size: 13px; font-weight: 800; display: flex; align-items: center; gap: 9px;
  box-shadow: var(--sh-1); transition: border-color .14s;
}
.customize-toggle::-webkit-details-marker { display: none; }
.customize-toggle::after { content: ""; margin-left: auto; width: 9px; height: 9px; border-right: 2px solid var(--sub); border-bottom: 2px solid var(--sub); transform: rotate(45deg); transition: transform .22s; }
.customize[open] > .customize-toggle::after { transform: rotate(225deg); }
.customize-toggle:hover { border-color: var(--accent-line); }
.customize > .card { margin-top: 10px; }
.reset-row { margin-top: 12px; text-align: center; }

.setting-row { display: flex; align-items: center; gap: 11px; margin-bottom: 11px; }
.setting-row:last-child { margin-bottom: 0; }
.setting-row > label { flex: 0 0 76px; color: var(--sub); font-size: 11.5px; font-weight: 500; }
.setting-row input[type="range"] { flex: 1; padding: 0; background: transparent; border: none; height: 18px; cursor: pointer; }
.setting-row input[type="range"]:focus { box-shadow: none; }
.setting-row select { flex: 1; padding: 7px 10px; }
.setting-row input[type="checkbox"] { flex: 0 0 18px; width: 18px; height: 18px; padding: 0; cursor: pointer; border: none; background: none; accent-color: var(--accent); }
.setting-row input[type="color"] { flex: 0 0 40px; height: 28px; padding: 2px; border-radius: 8px; cursor: pointer; }
.setting-val { flex: 0 0 44px; text-align: right; font-size: 11px; font-family: var(--mono); color: var(--sub); }
.num-input { flex: 0 0 54px !important; text-align: center; padding: 6px !important; font-family: var(--mono); }
.setting-sep { flex: 0 0 auto; color: var(--faint); font-size: 11px; }

/* 슬라이더 트랙/썸 (webkit) */
input[type="range"]::-webkit-slider-runnable-track { height: 5px; border-radius: 3px; background: var(--panel3); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 15px; height: 15px; margin-top: -5px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.4); transition: transform .1s; }
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.18); }
input[type="range"]::-moz-range-track { height: 5px; border-radius: 3px; background: var(--panel3); }
input[type="range"]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); }

.color-row { align-items: flex-start; }
.swatches { flex: 1; display: flex; flex-wrap: wrap; gap: 7px; }
.swatch { width: 25px; height: 25px; padding: 0; border-radius: 50%; border: 2px solid var(--line-2); background: var(--c, #fff); cursor: pointer; transition: transform .1s, box-shadow .12s; }
.swatch:hover { transform: scale(1.15); }
.swatch.selected { border-color: var(--shell); box-shadow: 0 0 0 2px var(--accent); }
.swatch-custom { position: relative; overflow: hidden; border: none; background: conic-gradient(from 210deg, #ff476f, #ffd166, #06d6a0, #4cc9f0, #7b6cff, #b388ff, #ff476f); }
.swatch-custom input[type="color"] { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); padding: 0; margin: 0; border: none; background: transparent; opacity: 0; cursor: pointer; }

.fmt-input { font-size: 12.5px; }

.font-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.font-chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 7px 5px 11px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--panel2); font-size: 11px; }
.font-del { width: 16px; height: 16px; padding: 0; line-height: 1; border-radius: 50%; border: none; background: rgba(255,255,255,.08); color: var(--sub); font-size: 11px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.font-del:hover { background: var(--bad); color: #fff; }

/* ══════════════════ 미리보기 패널 ══════════════════ */
.preview-panel { display: flex; flex-direction: column; overflow: hidden; background: var(--ink); min-width: 0; }
.preview-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--shell);
  flex-shrink: 0; flex-wrap: wrap;
}
.test-row { display: flex; gap: 8px; 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;
}
.test-group .tg-ico { display: flex; align-items: center; padding: 0 8px; font-size: 13px; background: var(--panel3); color: var(--sub); }
.test-group input { border: none; border-radius: 0; background: transparent; padding: 7px 8px; font-size: 11.5px; box-shadow: none !important; }
.test-group input:focus { background: rgba(255,255,255,.03); }
.test-group input.w-nick { width: 78px; }
.test-group input.w-msg { width: 92px; }
.test-group input.w-num { width: 56px; }
.test-group .tg-go {
  border: none; border-radius: 0; border-left: 1px solid var(--line);
  background: transparent; color: var(--accent-2); font-size: 11.5px; font-weight: 700; padding: 0 12px;
}
.test-group .tg-go:hover { background: var(--accent-soft); color: var(--accent-2); }

.test-obs-row { flex-basis: 100%; display: flex; align-items: center; gap: 10px; margin-top: 2px; padding-top: 10px; border-top: 1px dashed 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: 54px; padding: 5px 14px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--panel2); color: var(--sub); font-size: 11.5px; font-weight: 800; letter-spacing: .08em; cursor: pointer; transition: background .15s, color .15s, border-color .15s, box-shadow .15s; }
.tobs-toggle:hover { border-color: var(--line-2); color: var(--text); }
.tobs-toggle.on { background: var(--good); border-color: var(--good); color: #05221a; box-shadow: 0 0 0 3px rgba(52,217,160,.18); }
#tobs-hint { color: var(--faint); }

.stage-wrapper {
  flex: 1; position: relative; overflow: hidden;
  background:
    radial-gradient(110% 70% at 50% 116%, rgba(123,108,255,.20), transparent 56%),
    radial-gradient(70% 50% at 50% -8%, rgba(123,108,255,.05), transparent 60%),
    linear-gradient(180deg, #0b0c14 0%, #0d0f18 56%, #08090f 100%);
}
.stage-wrapper::after {
  content: ""; position: absolute; left: 50%; bottom: -2px; width: 240%; height: 46%;
  transform: translateX(-50%) perspective(360px) rotateX(64deg); transform-origin: bottom center;
  z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(90deg, rgba(123,108,255,.18) 1px, transparent 1px),
    linear-gradient(0deg, rgba(123,108,255,.18) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(82% 100% at 50% 100%, #000 8%, transparent 70%);
  mask-image: radial-gradient(82% 100% at 50% 100%, #000 8%, transparent 70%);
}
.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: #cfd4e6; background: rgba(8,9,15,.55); backdrop-filter: blur(10px);
  border: 1px solid var(--line-2); padding: 6px 12px 6px 10px; border-radius: var(--r-pill);
  pointer-events: none;
}
.tally-led { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 9px var(--accent-glow); animation: tally-pulse 2.4s ease-in-out infinite; }
@keyframes tally-pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ══════════════════ 오버레이 캐릭터 (엔진 — 출력 유지) ══════════════════ */
#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; }
}
