/* Matrix bridge — 자료 공유방 톤 */

:root {
  --bg: #111111;
  --bubble-bot: #1a1a1a;
  --text: #f2f2f2;
  --muted: #9a9a9a;
  --accent: #e24b4b;
  --accent-text: #ffffff;
  --line: #2a2a2a;
  --input-bg: #1c1c1c;
  --tap: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
.app::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

body.ghost-empty {
  background: #000;
}
body.ghost-empty .app {
  display: none !important;
}

/* 19세 확인은 인덱스에서. 여기 남으면 결제 화면을 가림 */
body.age-locked .app {
  visibility: hidden;
  pointer-events: none;
  user-select: none;
}

html.age-passed body.age-locked .app {
  visibility: visible;
  pointer-events: auto;
  user-select: auto;
}
html.age-passed .age-gate,
html.age-passed body.age-locked .age-gate {
  display: none !important;
}

body.age-locked .age-gate {
  display: flex;
}

.age-gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  background: rgba(0, 0, 0, 0.45);
}

.age-warn {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--accent);
  word-break: keep-all;
}

.age-body {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.55;
  color: #e8e8e8;
  word-break: keep-all;
  text-align: left;
}

.age-q {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.35;
  word-break: keep-all;
}

.age-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.age-actions .btn {
  min-height: var(--tap);
  width: 100%;
  font-size: 13px;
}

.age-card {
  width: 100%;
  max-width: 320px;
  padding: 22px 18px 18px;
  border-radius: 16px;
  border: 1px solid rgba(226, 75, 75, 0.45);
  background: #161616;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.age-blocked {
  margin: 14px 0 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
  color: #ffb4b4;
  word-break: keep-all;
}

body.age-denied .app {
  filter: blur(8px);
  opacity: 0.55;
  pointer-events: none;
}

.app {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 28px 20px calc(40px + env(safe-area-inset-bottom, 0px));
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
  padding-top: max(28px, env(safe-area-inset-top, 0px));
}

.hero {
  text-align: center;
  margin-bottom: 18px;
}

.room-tag {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.avatar {
  width: 56px;
  height: 56px;
  margin: 0 auto 10px;
  border-radius: 18px;
  background: #2a2a2a;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  color: #ddd;
  line-height: 1;
}

.name {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.name-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 10px;
  margin: 0 0 8px;
}

.room-id {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  word-break: break-all;
}

.room-id:not([hidden])::before {
  content: "·";
  margin-right: 8px;
  opacity: 0.5;
}

.lang-btn {
  margin: 0;
  margin-left: 2px;
  padding: 6px 10px;
  min-height: 32px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bubble-bot);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.lang-btn[aria-expanded="true"] {
  border-color: rgba(226, 75, 75, 0.7);
  background: rgba(226, 75, 75, 0.12);
}

.lang-sheet {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 14px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #151515;
}

.lang-sheet[hidden] {
  display: none !important;
}

.lang-opt {
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bubble-bot);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.lang-opt.is-on {
  border-color: rgba(226, 75, 75, 0.8);
  background: rgba(226, 75, 75, 0.12);
  color: #ffb4b4;
}

/* 아랍어 RTL */
html[dir="rtl"] .name-row,
body.lang-rtl .name-row {
  direction: rtl;
}

html[dir="rtl"] .wait-steps li,
body.lang-rtl .wait-steps li {
  text-align: right;
  padding: 8px 28px 8px 10px;
}

html[dir="rtl"] .wait-steps li::before,
body.lang-rtl .wait-steps li::before {
  left: auto;
  right: 10px;
}

html[dir="rtl"] .age-body,
html[dir="rtl"] .mx-setup-msg,
html[dir="rtl"] .lead,
html[dir="rtl"] .field span,
body.lang-rtl .age-body,
body.lang-rtl .mx-setup-msg,
body.lang-rtl .lead,
body.lang-rtl .field span {
  text-align: right;
}

.slug {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
}

.lead {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
  word-break: keep-all;
}

.lead strong {
  color: var(--text);
  font-weight: 700;
}

.section-label {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.tiers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 14px;
}

.tier {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  min-height: 68px;
  padding: 12px 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bubble-bot);
  color: inherit;
  text-align: center;
  cursor: pointer;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.tier.is-on {
  border-color: rgba(226, 75, 75, 0.85);
  background: rgba(226, 75, 75, 0.1);
  box-shadow: none;
}

.tier-label {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}

.tier-meta {
  display: none;
}

.tier-price {
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  color: var(--muted);
}

.tier-list {
  text-decoration: line-through;
  opacity: 0.55;
  font-weight: 500;
}

.tier-sale {
  font-weight: 700;
  color: var(--text);
}

.tier.is-on .tier-price {
  color: #ff9a9a;
}

.tier.is-on .tier-sale {
  color: #ff9a9a;
}

.pay-card {
  padding: 14px 14px;
  margin-bottom: 14px;
  border-radius: 14px;
  background: var(--bubble-bot);
  border: 1px solid var(--line);
  text-align: center;
}

.pay-label {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.pay-amount {
  margin: 6px 0 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.pay-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  word-break: keep-all;
}

.form {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.field {
  display: grid;
  gap: 6px;
  text-align: left;
}

.field span {
  font-size: 12px;
  color: var(--muted);
}

.field input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  outline: none;
}

.field input:focus {
  border-color: rgba(229, 9, 20, 0.65);
  box-shadow: 0 0 0 1px rgba(229, 9, 20, 0.25);
}

.actions {
  display: grid;
  gap: 10px;
}

.btn {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 18px;
  border-radius: 20px;
  border: none;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-weight: 600;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.refund {
  margin: 14px 0 0;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--accent);
}

.enter-panel {
  margin-top: 8px;
  padding: 16px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bubble-bot);
}

.mismatch-panel {
  margin-top: 12px;
  padding: 16px 14px;
  border-radius: 14px;
  border: 1px solid rgba(229, 9, 20, 0.55);
  background: rgba(229, 9, 20, 0.12);
}

.mismatch-msg {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  color: #ffd0d0;
  word-break: keep-all;
  text-align: center;
}

.enter-lead {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  word-break: keep-all;
  text-align: center;
}

.mx-setup {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.mx-setup-msg {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  word-break: keep-all;
  text-align: left;
}

.mx-setup-msg strong {
  color: var(--text);
}

.mx-setup .btn {
  display: block;
  text-align: center;
  text-decoration: none;
  margin-bottom: 8px;
}

.mx-setup .btn:last-child {
  margin-bottom: 0;
}

.status {
  margin: 12px 0 0;
  min-height: 1.3em;
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  word-break: keep-all;
}

.wait-gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1100;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  background: rgba(0, 0, 0, 0.55);
}

body.wait-open .wait-gate {
  display: flex;
}

.wait-card {
  width: 100%;
  max-width: 320px;
  padding: 24px 18px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #161616;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.wait-spin {
  width: 42px;
  height: 42px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  animation: wait-spin 0.85s linear infinite;
}

body.wait-done .wait-spin {
  animation: none;
  border-color: rgba(80, 200, 120, 0.35);
  border-top-color: #50c878;
  background: rgba(80, 200, 120, 0.15);
}

@keyframes wait-spin {
  to { transform: rotate(360deg); }
}

.wait-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 800;
  word-break: keep-all;
}

.wait-sub {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
  word-break: keep-all;
}

.wait-steps {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  text-align: left;
}

.wait-steps li {
  position: relative;
  padding: 8px 10px 8px 28px;
  margin-bottom: 4px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
}

.wait-steps li::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  background: #333;
}

.wait-steps li.is-on {
  color: var(--text);
  background: rgba(226, 75, 75, 0.1);
}

.wait-steps li.is-on::before {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(226, 75, 75, 0.25);
}

.wait-steps li.is-done {
  color: #9fdfb2;
}

.wait-steps li.is-done::before {
  background: #50c878;
}

.wait-close {
  width: 100%;
  margin-bottom: 8px;
}

.wait-hint {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  word-break: keep-all;
}

.install-card {
  margin: 12px 0 16px;
  padding: 16px 14px;
  border-radius: 14px;
  border: 1px solid rgba(226, 75, 75, 0.4);
  background: rgba(226, 75, 75, 0.08);
  text-align: center;
}
.install-lead {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
  color: #f2f3f5;
  word-break: keep-all;
}
.install-card .btn {
  width: 100%;
  min-height: 48px;
  font-size: 15px;
  font-weight: 800;
}
.install-guide {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  word-break: keep-all;
}

/* 홈화면 설치 진행 (블랙 대신) */
.install-progress {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 3200;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  background: #0a0a0a;
}
body.install-progress-on .install-progress {
  display: flex;
}
body.install-progress-on .age-gate,
body.install-progress-on .wait-gate,
body.install-progress-on .app,
body.install-progress-on .install-gate {
  visibility: hidden !important;
}
.install-progress-card {
  width: min(340px, 100%);
  text-align: center;
}
.install-progress-ring {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent, #e24b4b);
  position: relative;
  animation: install-spin 0.9s linear infinite;
}
.install-progress.is-done .install-progress-ring {
  animation: none;
  border-color: rgba(80, 200, 120, 0.45);
  background: rgba(80, 200, 120, 0.12);
}
.install-progress-orb {
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.25), transparent 55%),
    rgba(226, 75, 75, 0.35);
}
.install-progress.is-done .install-progress-orb {
  background: rgba(80, 200, 120, 0.4);
}
.install-progress.is-done .install-progress-orb::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  color: #7dffb0;
}
@keyframes install-spin {
  to { transform: rotate(360deg); }
}
.install-progress-title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  word-break: keep-all;
}
.install-progress-sub {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted, #9aa0a6);
  word-break: keep-all;
}
.install-progress-steps {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  display: flex;
  gap: 6px;
  justify-content: center;
}
.install-progress-steps li {
  flex: 1;
  padding: 8px 4px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted, #9aa0a6);
  background: rgba(255, 255, 255, 0.04);
}
.install-progress-steps li.is-on {
  color: #fff;
  background: rgba(226, 75, 75, 0.22);
  box-shadow: inset 0 0 0 1px rgba(226, 75, 75, 0.45);
}
.install-progress.is-done .install-progress-steps li.is-on {
  background: rgba(80, 200, 120, 0.2);
  box-shadow: inset 0 0 0 1px rgba(80, 200, 120, 0.45);
}
.install-progress-bar {
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-bottom: 14px;
}
.install-progress-bar i {
  display: block;
  height: 100%;
  width: 12%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e24b4b, #ff8a7a);
  animation: install-bar 1.6s ease-in-out infinite;
}
.install-progress.is-done .install-progress-bar i {
  width: 100%;
  animation: none;
  background: #50c878;
}
@keyframes install-bar {
  0% { width: 10%; transform: translateX(0); }
  50% { width: 55%; }
  100% { width: 18%; transform: translateX(180%); }
}
.install-progress-hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #c8c8c8;
  word-break: keep-all;
}

/* PC 차단 (텔레그램 미니앱과 동일 정책) */
.pc-gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  background: #0a0a0a;
}
body.pc-blocked .pc-gate {
  display: flex;
}
body.pc-blocked .age-gate,
body.pc-blocked .wait-gate,
body.pc-blocked .app,
body.share-blocked .age-gate,
body.share-blocked .wait-gate,
body.share-blocked .app {
  display: none !important;
}
body.install-enter-blocked .age-gate,
body.install-enter-blocked .wait-gate,
body.install-enter-blocked .app {
  display: none !important;
}
body.install-enter-blocked .install-gate {
  display: flex;
}
.install-gate .btn {
  margin-top: 16px;
  width: 100%;
}
.demo-banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #2a1810;
  color: #ffb070;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

/* 캡처·녹화 억제 */
html.mx-secure-screen,
html.mx-secure-screen body {
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
}
html.mx-secure-screen img,
html.mx-secure-screen video {
  -webkit-user-drag: none;
  pointer-events: none;
}
html.mx-secure-veiled body > *:not(#mx-secure-veil):not(#pc-gate):not(#share-gate):not(#install-gate):not(#install-progress) {
  visibility: hidden !important;
}

.pc-card {
  max-width: 320px;
  text-align: center;
}
.pc-emoji {
  margin: 0 0 12px;
  font-size: 36px;
  line-height: 1;
}
.pc-title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 800;
  color: #f2f3f5;
  word-break: keep-all;
}
.pc-sub {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #9aa0ab;
  word-break: keep-all;
}

/* Element 상단 위젯 — 미니앱 전체화면이 아니라 상단 패널 */
html:has(body.in-widget),
body.in-widget {
  height: 100%;
  min-height: 100%;
  overflow: auto;
  background: #0c0d10;
}
body.in-widget.age-locked {
  position: relative;
  overflow: hidden;
}
body.in-widget .age-gate {
  position: absolute;
  inset: 0;
  padding: 10px;
  background: rgba(0, 0, 0, 0.55);
}
body.in-widget .age-card {
  max-width: 100%;
  padding: 14px 12px 12px;
  border-radius: 12px;
}
body.in-widget .age-warn {
  font-size: 12px;
  margin-bottom: 6px;
}
body.in-widget .age-body {
  font-size: 11px;
  margin-bottom: 8px;
  line-height: 1.4;
}
body.in-widget .age-q {
  font-size: 14px;
  margin-bottom: 10px;
}
body.in-widget .age-actions .btn {
  min-height: 40px;
  font-size: 12px;
}
body.in-widget .app {
  min-height: 0;
  padding: 8px 10px 12px;
}
body.in-widget .hero {
  margin-bottom: 8px;
}
body.in-widget .hero .name {
  font-size: 18px;
}
body.in-widget .lead {
  font-size: 12px;
}
body.in-widget .avatar {
  width: 44px;
  height: 44px;
}
