/* ============================================================
   Telegram 前端：登录页门面（仿 web.telegram.org/a）+ 「通行证」式激活弹窗
   弹窗排版沿用原 ticket 版式，仅替换图标与配色为 Telegram 蓝
   ============================================================ */
:root {
  --ink:     #0f1419;
  --muted:   #536471;
  --muted-2: #7d8a95;
  --blue:    #3390ec;    /* Telegram 主蓝 */
  --blue-d:  #2b7cd3;
  --line:    #eff3f4;
  --border:  #cfd9de;
  --danger:  #f4212e;
  --paper:   #fafbfc;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: #ffffff;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
}
body.locked { overflow: hidden; }
button { font-family: inherit; }
svg { display: block; }
.tg-logo { display: block; }

/* ============================================================
   一、登录页（Telegram Web A 门面）
   ============================================================ */
.tg-app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px calc(32px + env(safe-area-inset-bottom));
  background: var(--paper);
}

.tg-page {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.tg-head { display: flex; flex-direction: column; align-items: center; }
.tg-head .tg-logo { width: 150px; height: 150px; }
.tg-title {
  margin: 14px 0 0;
  font-size: 32px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.4px;
  color: var(--ink);
}
.tg-slogan {
  margin: 10px 0 0;
  font-size: 16px;
  line-height: 1.45;
  color: var(--muted);
}

.tg-actions {
  width: 100%;
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tg-btn {
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  width: 100%;
  min-height: 52px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease;
}
.tg-btn svg { width: 20px; height: 20px; flex: 0 0 auto; fill: currentColor; }
.tg-btn svg[stroke] { fill: none; }
/* 线框图标：统一 stroke 渲染，避免默认 fill 把内部填实 */
.tg-btn svg.ico-phone,
.tg-btn svg.ico-key,
.tg-btn svg.ico-signup { fill: none; stroke: currentColor; }
/* 二维码图标：实心方块 + 中心镂空 */
.tg-btn svg.ico-qr .cut { fill: #fff; }
.tg-btn:hover { background: #f5f8fa; }
.tg-btn:active { transform: scale(.995); background: #eef3f6; }
.tg-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.tg-btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 600;
}
.tg-btn-primary:hover { background: var(--blue-d); border-color: var(--blue-d); }

.tg-or {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted-2);
  font-size: 14px;
  line-height: 1;
  padding: 2px 0;
}
.tg-or::before, .tg-or::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--line); }
.tg-or span { padding: 0 12px; }

.tg-legal {
  margin: 26px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  text-align: center;
  text-wrap: balance;
}
.tg-legal a, .ticket-legal a { color: var(--blue); text-decoration: none; }
.tg-legal a:hover, .ticket-legal a:hover { text-decoration: underline; }

/* ============================================================
   二、激活弹窗 —— 通行证 / 票据造型（原排版，Telegram 配色）
   ============================================================ */
.gate-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  background: rgba(15, 20, 25, .42);
  opacity: 0;
  transition: opacity .22s ease;
}
.gate-mask[hidden] { display: none; }
.gate-mask.on { opacity: 1; }

.ticket {
  position: relative;
  width: min(444px, 100%);
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #ffffff;
  border-radius: 22px;
  padding: 28px 30px 26px;
  box-shadow:
    0 1px 4px rgba(15, 20, 25, .07),
    0 36px 80px -30px rgba(15, 20, 25, .48);
  transform: translateY(15px) scale(.978);
  transition: transform .3s cubic-bezier(.2, .85, .25, 1);
  will-change: transform;
}
.gate-mask.on .ticket { transform: none; }

/* 顶部品牌渐变条：Telegram 蓝 → 天蓝 */
.ticket-ribbon {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 4px;
  border-radius: 22px 22px 0 0;
  background: linear-gradient(90deg, #279AD1 0%, #38AEEB 46%, #6ec6f5 100%);
}

.ticket-x {
  position: absolute;
  top: 13px;
  right: 13px;
  width: 32px; height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #93a1ad;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.ticket-x svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2.1; stroke-linecap: round; }
.ticket-x:hover { background: #f1f4f6; color: var(--ink); }
.ticket-x:active { background: #e6ebef; }

.ticket-body { display: block; }

/* 眉标 */
.ticket-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  padding-right: 34px;
}
.ticket-mark { color: var(--ink); }
.ticket-mark .tg-logo { width: 20px; height: 20px; }
.ticket-eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: #a2aeb8;
}

/* 标题区（左对齐是刻意的，与常见弹窗区分开） */
.ticket-h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.32;
  font-weight: 700;
  letter-spacing: -.5px;
  color: var(--ink);
}
.ticket-sub {
  margin: 9px 0 0;
  font-size: 14px;
  line-height: 1.6;
  color: #6b7a86;
}

/* 输入：带 KEY 前缀的序列号输入条 */
.ticket-form { margin-top: 24px; }

.keybox {
  display: flex;
  align-items: center;
  height: 58px;
  padding: 0 6px;
  border: 1.5px solid #e3e9ee;
  border-radius: 13px;
  background: var(--paper);
  transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease;
}
.keybox-pre {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 9px;
  display: flex;
  align-items: center;
  border-radius: 8px;
  background: #eaf3fb;
  color: #3d8fd0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .13em;
}
.keybox input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0 8px;
  border: 0;
  background: transparent;
  outline: none;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 17.5px;
  font-weight: 600;
  letter-spacing: .085em;
  text-transform: uppercase;
  text-align: left;
}
.keybox input::placeholder {
  color: #b5c0c9;
  font-weight: 400;
  letter-spacing: .07em;
}
.keybox:focus-within {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(51, 144, 236, .12);
}
.keybox.is-bad {
  border-color: var(--danger);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(244, 33, 46, .10);
}

/* 输入进度：一条细线，随字符填充 */
.keybar {
  height: 2px;
  margin: 9px 2px 0;
  border-radius: 2px;
  background: #eef2f5;
  overflow: hidden;
}
.keybar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--blue), #38AEEB);
  transition: width .15s ease;
}

.msg {
  min-height: 16px;
  margin: 8px 0 0;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--danger);
}

/* 主按钮：Telegram 蓝方角矩形，带箭头 */
.ticket-go {
  width: 100%;
  height: 54px;
  margin-top: 18px;
  border: 0;
  border-radius: 13px;
  background: var(--blue);
  color: #fff;
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: .01em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .15s ease, transform .07s ease;
}
.ticket-go svg {
  width: 17px; height: 17px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  transition: transform .18s ease;
}
.ticket-go:hover { background: var(--blue-d); }
.ticket-go:hover svg { transform: translateX(3px); }
.ticket-go:active { transform: scale(.99); }
.ticket-go:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.ticket-go[disabled] { opacity: .6; cursor: default; }

/* 标题行：右侧「获取激活码」红色小按钮 */
.ticket-title-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.ticket-title-row .ticket-h1 { flex: 1 1 auto; min-width: 0; }

.ticket-buy {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  margin-top: 0;
  padding: 0 14px;
  border: 1.5px solid #e5352b;
  border-radius: 10px;
  background: linear-gradient(180deg, #f4443a 0%, #e02b21 100%);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .01em;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 3px 10px -4px rgba(224, 43, 33, .7);
  transition: background-color .16s ease, border-color .16s ease,
              box-shadow .16s ease, transform .07s ease;
}
.ticket-buy svg {
  width: 15px; height: 15px;
  flex: 0 0 auto;
  stroke: currentColor; fill: none;
  stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round;
}
.ticket-buy:hover {
  background: linear-gradient(180deg, #e53a30 0%, #c92117 100%);
  border-color: #c92117;
  box-shadow: 0 6px 16px -4px rgba(224, 43, 33, .65);
}
.ticket-buy:active { transform: scale(.97); background: linear-gradient(180deg, #cf2e24 0%, #b71c13 100%); }
.ticket-buy:focus-visible { outline: 2px solid #e5352b; outline-offset: 3px; }

/* 次级入口 */
.ticket-alt {
  margin-top: 15px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #7d8a95;
}
.ticket-link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ticket-link:hover { text-decoration: underline; }

/* 条款：虚线分隔，像票根下缘 */
.ticket-legal {
  margin: 20px 0 0;
  padding-top: 16px;
  border-top: 1px dashed #e6ecf1;
  font-size: 11.5px;
  line-height: 1.7;
  color: #93a1ad;
  text-wrap: balance;
}

/* 校验失败：整张票抖一下 */
.shake { animation: shake .42s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}

/* 成功态：整块替换掉表单区 */
.ticket-body.is-done .ticket-head,
.ticket-body.is-done #intro,
.ticket-body.is-done .ticket-form,
.ticket-body.is-done .ticket-alt,
.ticket-body.is-done .ticket-legal { display: none; }

.ticket-done {
  text-align: center;
  padding: 26px 0 10px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .38s ease, transform .38s ease;
  cursor: pointer;              /* 整块可点，点了就跳 */
  -webkit-tap-highlight-color: transparent;
}
.ticket-done[hidden] { display: none; }
.ticket-done.in { opacity: 1; transform: none; }

.tick svg { width: 62px; height: 62px; display: inline-block; }
.tick-c {
  fill: none; stroke: var(--blue); stroke-width: 2.4;
  stroke-dasharray: 150; stroke-dashoffset: 150;
  animation: draw .62s ease forwards;
}
.tick-p {
  fill: none; stroke: var(--blue); stroke-width: 3;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 40; stroke-dashoffset: 40;
  animation: draw .42s .42s ease forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

.done-t { margin: 16px 0 0; font-size: 22px; font-weight: 700; letter-spacing: -.4px; color: var(--ink); }
.done-s { margin: 8px 0 0; font-size: 13.5px; line-height: 1.6; color: #6b7a86; }
.done-go {
  margin: 20px auto 0;
  height: 50px;
  padding: 0 26px;
  border-radius: 13px;
  border: 0;
  background: var(--blue);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .15s ease, transform .07s ease;
}
.done-go:hover { background: var(--blue-d); }
.done-go:active { transform: scale(.98); }
.done-go svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.done-note { margin: 13px 0 0; font-size: 11.5px; color: #a2aeb8; }

/* VPN / 跳转提醒：琥珀色，醒目但不抢成功动画的戏 */
.done-vpn {
  margin: 14px auto 0;
  max-width: 260px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 14px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #b45309;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
}
.done-vpn[hidden] { display: none; }
.done-vpn svg { width: 15px; height: 15px; flex-shrink: 0; fill: #f59e0b; }
.done-vpn span { word-break: break-word; }

/* 自动跳转被打断时：按钮呼吸光圈 + 提示变强调色，告诉用户「点这里」 */
.ticket-done.is-stuck .done-go {
  animation: goPulse 1.5s ease-in-out infinite;
}
@keyframes goPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(51, 144, 236, .5); }
  55%      { box-shadow: 0 0 0 13px rgba(51, 144, 236, 0); }
}
.ticket-done.is-stuck .done-note {
  color: var(--blue);
  font-weight: 600;
  font-size: 12.5px;
}

.bar { height: 3px; width: 120px; margin: 20px auto 0; background: #eef2f5; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--blue); border-radius: 99px; animation: fill 2.9s .15s linear forwards; }
@keyframes fill { to { width: 100%; } }

/* ============================================================
   三、获取激活码 弹层
   ============================================================ */
.mini {
  position: fixed;
  inset: 0;
  z-index: 140;
  background: rgba(15, 20, 25, .38);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade .2s ease;
}
.mini[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.mini-card {
  width: min(380px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 26px 24px 20px;
  text-align: center;
  box-shadow: 0 30px 70px -24px rgba(0, 0, 0, .45);
  animation: pop .3s cubic-bezier(.2, .85, .25, 1) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }

.mini-card h3 { margin: 0 0 12px; font-size: 18px; font-weight: 700; letter-spacing: -.2px; }
.mini-body { color: var(--muted); font-size: 14px; line-height: 1.75; word-break: break-word; user-select: all; }
.mini-go {
  width: 100%; height: 48px; margin-top: 18px;
  border-radius: 12px; background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 650; text-decoration: none;
}
.mini-go:hover { background: var(--blue-d); }
.mini-close {
  width: 100%; height: 48px; margin-top: 10px;
  border-radius: 12px; border: 1px solid var(--border); background: #fff;
  color: var(--ink); font-size: 15px; font-weight: 600; cursor: pointer;
}

/* 客服弹窗 */
.mini-kefu { padding-top: 30px; }
.kefu-avatar {
  width: 56px; height: 56px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: linear-gradient(180deg, #38AEEB, #279AD1);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
}
.mini-kefu h3 { margin-bottom: 10px; }
.kefu-qr {
  width: 168px; max-width: 62%;
  margin: 16px auto 0;
}
.kefu-qr img {
  width: 100%; height: auto; display: block;
  border-radius: 10px; border: 1px solid var(--border);
}

/* ============================================================
   四、响应式
   ============================================================ */
@media (max-width: 520px) {
  .tg-app { padding: 28px 22px calc(26px + env(safe-area-inset-bottom)); }
  .tg-page { max-width: 100%; }
  .tg-head { margin-top: 4vh; }
  .tg-head .tg-logo { width: 124px; height: 124px; }
  .tg-title { font-size: 28px; }
  .tg-slogan { font-size: 15px; }
  .tg-actions { margin-top: 32px; }
  .tg-btn { min-height: 50px; }

  .gate-mask { padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }
  .ticket { border-radius: 20px; max-height: calc(100dvh - 24px); padding: 24px 20px 22px; }
  .ticket-ribbon { border-radius: 20px 20px 0 0; }
  .ticket-head { margin-bottom: 20px; }
  .ticket-h1 { font-size: 22px; }
  .ticket-sub { font-size: 13.5px; margin-top: 8px; }
  .ticket-form { margin-top: 20px; }
  .keybox { height: 54px; border-radius: 12px; }
  .keybox input { font-size: 15.5px; letter-spacing: .06em; }
  .ticket-go { height: 50px; margin-top: 16px; border-radius: 12px; }
  .ticket-title-row { gap: 8px; }
  .ticket-buy { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 9px; }
  .ticket-buy svg { width: 14px; height: 14px; }
  .ticket-legal { margin-top: 17px; padding-top: 14px; font-size: 11px; }
  .ticket-done { padding-top: 18px; }
}

@media (min-width: 900px) {
  body.tg-body {
    background: radial-gradient(120% 55% at 50% 0%, #f4f9fd 0%, #ffffff 62%);
  }
  .tg-head .tg-logo { width: 164px; height: 164px; }
  .tg-actions { margin-top: 46px; }
}

@media (max-height: 700px) {
  .tg-head .tg-logo { width: 116px; height: 116px; }
  .tg-actions { margin-top: 26px; }
  .ticket { padding-top: 22px; padding-bottom: 18px; }
  .ticket-head { margin-bottom: 16px; }
  .ticket-form { margin-top: 16px; }
  .ticket-go { margin-top: 14px; }
  .ticket-legal { margin-top: 14px; padding-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
