/* Website to Software — shared UI + telegramscraper phone shell (Android / iOS).
   Mac / Windows load builder-desktop.css on top for the telegramauto window chrome. */
:root {
  --ios-bg: #f2f2f7;
  --ios-card: #ffffff;
  --ios-ink: #111113;
  --ios-muted: #8e8e93;
  --ios-separator: rgba(60, 60, 67, 0.12);
  --ios-blue: #007aff;
  --ios-green: #34c759;
  --ios-red: #ff3b30;
  --ios-fill: #e5e5ea;
  --ios-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
  --ios-radius: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --phone-max: 430px;
  --blue: var(--ios-blue);
  --green: var(--ios-green);
  --danger: var(--ios-red);
  --text: var(--ios-ink);
  --muted: var(--ios-muted);
  --line: var(--ios-separator);
  --fill: var(--ios-fill);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ios-ink);
  background: #0b0b0f;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--ios-blue); text-decoration: none; }
button, input { font: inherit; }

.ios-stage {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1a2744 0%, transparent 55%),
    linear-gradient(180deg, #0b0b0f, #12121a 60%, #0b0b0f);
}

.app-shell {
  width: min(100%, var(--phone-max));
  height: min(100dvh - 32px, 920px);
  max-height: 100dvh;
  background: var(--ios-bg);
  overflow: hidden;
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
}

/* Phone bezel only for Android / iOS builders */
.ios-phone {
  width: min(100%, var(--phone-max));
  height: min(100dvh - 32px, 920px);
  max-height: 100dvh;
  background: var(--ios-bg);
  border-radius: 42px;
  overflow: hidden;
  position: relative;
  isolation: isolate;
  box-shadow:
    0 0 0 11px #1c1c1e,
    0 0 0 13px #3a3a3c,
    var(--ios-shadow);
  display: flex;
  flex-direction: column;
}

.ios-status {
  height: calc(54px + var(--safe-top));
  padding: calc(12px + var(--safe-top)) 22px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(180deg, rgba(242,242,247,0.96), rgba(242,242,247,0.72));
  backdrop-filter: blur(20px);
  flex-shrink: 0;
  z-index: 20;
}
.ios-status .time { font-variant-numeric: tabular-nums; }
.ios-status .pills { color: var(--ios-muted); }

.ios-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 16px 12px;
  flex-shrink: 0;
}
.ios-nav h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  font-weight: 800;
}
.ios-nav .sub {
  margin: 2px 0 0;
  color: var(--ios-muted);
  font-size: 0.8rem;
  font-weight: 500;
}
.ios-nav .sub a { color: inherit; }
.ios-nav .brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 85, 212, 0.2);
}

.workspace,
.ios-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 14px 16px;
  scroll-behavior: smooth;
  position: relative;
  display: flex;
  flex-direction: column;
}

#chatPane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 8px;
}

.msg { max-width: 92%; animation: rise .28s ease both; }
.msg.agent { align-self: flex-start; }
.msg.user { align-self: flex-end; }
.msg-meta {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ios-muted);
  margin: 0 4px 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.bubble {
  padding: 12px 14px;
  border-radius: 20px;
  font-size: 0.95rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.msg.agent .bubble {
  background: #fff;
  box-shadow: 0 1px 0 var(--ios-separator), 0 8px 24px rgba(0,0,0,0.04);
  border-bottom-left-radius: 8px;
}
.msg.user .bubble {
  background: var(--ios-blue);
  color: #fff;
  border-bottom-right-radius: 8px;
}

.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ios-muted);
  display: block;
  animation: bounce 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

.composer {
  flex-shrink: 0;
  padding: 8px 14px calc(14px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(242,242,247,0), rgba(242,242,247,0.96) 24%, #f2f2f7);
  z-index: 30;
}
.composer-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #fff;
  border-radius: 24px;
  padding: 8px 8px 8px 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
  border: 1px solid var(--ios-separator);
}
.composer input[type="text"],
.composer input[type="email"],
.composer input[type="url"] {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1rem;
  padding: 8px 0;
  min-width: 0;
  color: var(--ios-ink);
}
.composer .send,
.composer .primary {
  border: 0;
  border-radius: 16px;
  min-height: 40px;
  padding: 0 14px;
  background: var(--ios-blue);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  white-space: nowrap;
}
.composer .primary {
  width: 100%;
}
.hint {
  margin: 8px 4px 0;
  font-size: 12px;
  color: var(--ios-muted);
}
.error {
  margin-top: 8px;
  color: var(--ios-red);
  font-size: 13px;
  font-weight: 600;
  display: none;
}
.error.show { display: block; }

.file-pick { display: flex; flex-direction: column; gap: 10px; }
.file-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1.5px dashed rgba(0,0,0,0.16);
  border-radius: 16px;
  padding: 16px;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
}
.file-btn input { display: none; }
.file-btn.has-file {
  border-style: solid;
  border-color: rgba(52, 199, 89, 0.45);
  background: rgba(52, 199, 89, 0.08);
}

.tabbar { display: none !important; }

.app-shell.preview-mode .ios-nav,
.app-shell.preview-mode .composer { display: none !important; }
.app-shell.preview-mode .workspace { padding: 0; }

.splash-screen {
  display: none;
  flex: 1;
  min-height: 0;
  place-items: center;
  text-align: center;
  padding: 32px 24px;
  background:
    radial-gradient(circle at 50% 30%, rgba(0, 122, 255, 0.12), transparent 55%),
    linear-gradient(180deg, #fbfbfd 0%, #f0f0f5 100%);
}
.splash-screen.show { display: grid; animation: fadeIn .25s ease both; }
.splash-logo {
  width: 96px; height: 96px; border-radius: 24px;
  overflow: hidden; margin: 0 auto;
  background: var(--ios-blue); color: #fff;
  display: grid; place-items: center;
  font-size: 28px; font-weight: 800;
  box-shadow: 0 14px 36px rgba(0,0,0,0.14);
}
.splash-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.splash-screen h2 { margin: 18px 0 8px; font-size: 28px; letter-spacing: -0.03em; }
.splash-screen p { margin: 0; color: var(--ios-muted); font-size: 14px; }
.splash-loader {
  width: 36px; height: 36px; margin: 22px auto 0; border-radius: 50%;
  border: 3px solid rgba(0,0,0,0.08); border-top-color: var(--ios-blue);
  animation: spin .8s linear infinite;
}

.preview-wrap {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  padding: 0;
  gap: 0;
  overflow: auto;
}
.preview-wrap.show { display: flex; }
.preview-frame {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
}
.preview-body { flex: 1; min-height: 0; position: relative; background: #fff; }
.preview-body iframe { width: 100%; height: 100%; border: 0; display: block; }

.preview-fallback-home {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  text-align: center;
  padding: 48px 28px 64px;
  z-index: 2;
  background:
    radial-gradient(ellipse 80% 50% at 50% 28%, rgba(0, 122, 255, 0.08), transparent 70%),
    linear-gradient(180deg, #f7f8fa 0%, #eef0f4 100%);
}
.preview-fallback-home.show { display: grid; }
.preview-fallback-home .app-home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  max-width: 280px;
  width: 100%;
  margin-top: -24px;
}
.preview-fallback-home img,
.preview-fallback {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.55) inset,
    0 14px 36px rgba(15, 23, 42, 0.14),
    0 4px 10px rgba(15, 23, 42, 0.06);
}
.preview-fallback {
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #3da0ff 0%, #007aff 55%, #0062e0 100%);
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.preview-fallback-home h3 {
  margin: 0;
  max-width: 100%;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
  color: var(--ios-ink);
  overflow-wrap: anywhere;
}
.preview-fallback-home p { display: none; }

.download-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px 16px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid var(--ios-separator);
  backdrop-filter: saturate(180%) blur(16px);
  box-shadow: 0 -8px 28px rgba(15, 23, 42, 0.04);
}
.download-bar > div { min-width: 0; flex: 1; }
.download-bar strong {
  display: block;
  color: var(--ios-ink);
  font-size: 14px;
  font-weight: 750;
  letter-spacing: -0.01em;
}
.download-bar p {
  margin: 3px 0 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--ios-muted);
  font-weight: 500;
}
.btn-download {
  border: 0;
  background: var(--ios-blue);
  color: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(0, 122, 255, 0.28);
  transition: background .15s ease, transform .12s ease;
}
.btn-download:hover { background: #0066d6; }
.btn-download:active { transform: scale(0.98); }

.payment-overlay {
  display: none; position: absolute; inset: 0;
  background: #f2f2f7; z-index: 50; overflow: auto; padding: 16px 14px 28px;
}
.payment-overlay.show { display: block; }
.payment-card {
  background: #fff; border-radius: 18px; border: 1px solid var(--ios-separator);
  padding: 18px; text-align: left;
}
.payment-card.center { text-align: center; }
.payment-card h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.02em; }
.payment-card .pay-sub { margin: 0 0 14px; color: var(--ios-muted); font-size: 14px; }
.payment-back {
  border: 0; background: var(--ios-fill); width: 34px; height: 34px;
  border-radius: 10px; font-size: 22px; line-height: 1; cursor: pointer; margin-bottom: 12px;
}
.pay-once-banner {
  display: grid;
  gap: 2px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(0, 122, 255, 0.08);
  border: 1px solid rgba(0, 122, 255, 0.18);
  text-align: left;
}
.pay-once-banner strong {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ios-blue);
}
.pay-once-banner span {
  font-size: 12px;
  line-height: 1.4;
  color: var(--ios-ink);
  font-weight: 600;
}
.plan-list {
  display: grid;
  gap: 10px;
  margin: 0 0 12px;
}
.plan-card {
  width: 100%;
  text-align: left;
  border: 1.5px solid var(--ios-separator);
  background: #fff;
  border-radius: 16px;
  padding: 14px;
  cursor: pointer;
  color: var(--ios-ink);
  display: grid;
  gap: 4px;
}
.plan-card.is-on {
  border-color: var(--ios-blue);
  background: rgba(0, 122, 255, 0.06);
  box-shadow: 0 0 0 1px rgba(0, 122, 255, 0.18);
}
.plan-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.plan-top strong { font-size: 15px; font-weight: 800; }
.plan-price {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ios-ink);
}
.plan-card.is-on .plan-price { color: var(--ios-blue); }
.plan-blurb {
  font-size: 13px;
  color: var(--ios-muted);
  font-weight: 600;
}
.plan-note {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ios-ink);
  font-weight: 600;
}
.plan-help {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ios-muted);
}
.pay-list {
  background: #fff; border-radius: 16px; overflow: hidden; border: 1px solid var(--ios-separator);
}
.pay-list button.row {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px;
  border: 0; background: #fff; border-bottom: 1px solid var(--ios-separator);
  text-align: left; cursor: pointer; color: var(--ios-ink);
}
.pay-list button.row:last-child { border-bottom: 0; }
.pay-list .glyph {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  color: #fff; font-weight: 800; flex-shrink: 0;
}
.pay-list .glyph.green { background: #34c759; }
.pay-list .glyph.blue { background: #0070ba; }
.pay-list .meta { flex: 1; min-width: 0; }
.pay-list .meta strong { display: block; font-size: 15px; }
.pay-list .meta span { color: var(--ios-muted); font-size: 12px; }
.pay-list .chev { color: var(--ios-muted); font-size: 18px; }
.coin-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 14px; }
.coin-tab {
  border: 1px solid var(--ios-separator); background: var(--ios-fill);
  border-radius: 14px; padding: 10px 8px; font-weight: 700; font-size: 13px;
  color: var(--ios-muted); cursor: pointer;
}
.coin-tab.is-on { background: #111113; color: #fff; border-color: #111113; }
.coin-tab small { display: block; font-weight: 600; font-size: 10px; opacity: .75; margin-top: 2px; }
.payment-card .qr {
  width: 180px; height: 180px; object-fit: cover; border-radius: 16px;
  background: #fff; padding: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.06);
  margin: 0 auto 14px; display: block;
}
.wallet {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; background: var(--ios-fill); border-radius: 10px;
  padding: 12px; word-break: break-all; text-align: left; font-weight: 650;
}
.pay-amount-box {
  margin: 14px 0 0; padding: 12px; border-radius: 16px;
  background: rgba(0,122,255,0.08); border: 1px solid rgba(0,122,255,0.14); text-align: left;
}
.pay-amount-box .crypto-amt { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.03em; }
.pay-amount-box .fiat-amt, .pay-amount-box .rate-line { margin-top: 4px; color: var(--ios-muted); font-size: 13px; }
.pay-secondary-btn, .pay-primary-btn {
  border: 0; width: 100%; margin-top: 10px; border-radius: 14px;
  padding: 13px 14px; font-weight: 700; cursor: pointer;
}
.pay-secondary-btn { background: var(--ios-fill); color: var(--ios-ink); }
.pay-primary-btn { background: var(--ios-blue); color: #fff; }
.wait-card { margin-top: 12px; text-align: center; }
.wait-card .big-count { font-size: 2rem; font-weight: 800; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.wait-progress { margin-top: 14px; height: 6px; border-radius: 999px; background: rgba(0,0,0,0.08); overflow: hidden; }
.wait-progress > i { display: block; height: 100%; width: 100%; background: var(--ios-blue); border-radius: inherit; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40% { transform: translateY(-4px); opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 520px) {
  body.platform-android .ios-stage,
  body.platform-ios .ios-stage { padding: 0; background: var(--ios-bg); }
  body.platform-android .ios-phone,
  body.platform-ios .ios-phone {
    width: 100%; height: 100dvh; max-height: 100dvh;
    border-radius: 0; box-shadow: none;
  }
}
