/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ── Theme tokens ────────────────────────────────────────────────────────── */
:root {
  --bg:         var(--tg-theme-bg-color,            #17212b);
  --secondary:  var(--tg-theme-secondary-bg-color,  #232e3c);
  --text:       var(--tg-theme-text-color,           #f5f5f5);
  --hint:       var(--tg-theme-hint-color,           #708499);
  --link:       var(--tg-theme-link-color,           #5288c1);
  --accent:     var(--tg-theme-button-color,         #5288c1);
  --accent-txt: var(--tg-theme-button-text-color,    #ffffff);
  --danger:     var(--tg-theme-destructive-text-color, #ec3942);
  --separator:  var(--tg-theme-section-separator-color, rgba(255,255,255,0.05));

  --r-sm:  8px;
  --r-md:  14px;
  --r-lg:  18px;
  --r-xl:  22px;

  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);

  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

html, body { height: 100%; }

body {
  min-height: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior: none;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

#screen { width: 100%; }

/* ── Loader ──────────────────────────────────────────────────────────────── */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 2.5px solid rgba(128,128,128,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

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

/* ── Content wrapper ─────────────────────────────────────────────────────── */
.content {
  padding: 16px 16px 32px;
}

/* ── Section title ───────────────────────────────────────────────────────── */
.section-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin: 18px 0 8px 2px;
}

.section-title:first-child { margin-top: 0; }

/* ── Status card ─────────────────────────────────────────────────────────── */
.status-card {
  border-radius: var(--r-xl);
  padding: 20px 20px 18px;
  margin-bottom: 12px;
  color: #fff;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s var(--ease);
}

.status-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.06);
  border-radius: inherit;
  pointer-events: none;
}

.status-card.active   { background: linear-gradient(135deg, #2563eb 0%, #6d28d9 100%); }
.status-card.trial    { background: linear-gradient(135deg, #059669 0%, #0d9488 100%); }
.status-card.expiring { background: linear-gradient(135deg, #d97706 0%, #dc2626 100%); }
.status-card.expired,
.status-card.inactive { background: linear-gradient(135deg, #374151 0%, #1f2937 100%); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  opacity: 0.8;
  margin-bottom: 10px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-dot.blink { animation: blink 2s ease infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.25} }

.status-days {
  font-size: 56px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -3px;
  margin-bottom: 3px;
}

.status-label {
  font-size: 14px;
  opacity: 0.75;
  margin-bottom: 16px;
  font-weight: 500;
}

.traffic-bar-track {
  background: rgba(255,255,255,0.22);
  border-radius: 100px;
  height: 5px;
  margin-bottom: 8px;
  overflow: hidden;
}

.traffic-bar-fill {
  height: 100%;
  border-radius: 100px;
  background: rgba(255,255,255,0.9);
  transition: width 0.7s var(--ease);
  min-width: 2px;
}

.traffic-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  opacity: 0.72;
  font-weight: 500;
}

/* ── Stat row ────────────────────────────────────────────────────────────── */
.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.stat-card {
  background: var(--secondary);
  border-radius: var(--r-lg);
  padding: 15px 14px 13px;
  cursor: pointer;
  transition: transform 0.12s var(--ease), opacity 0.12s;
}

.stat-card:active { transform: scale(0.97); opacity: 0.85; }

.stat-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.8px;
  line-height: 1;
  margin-bottom: 5px;
}

.stat-label {
  font-size: 12px;
  color: var(--hint);
  font-weight: 500;
}

/* ── Action grid ─────────────────────────────────────────────────────────── */
.action-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--secondary);
  border: none;
  border-radius: var(--r-md);
  padding: 14px 6px 12px;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s var(--ease), opacity 0.12s;
  user-select: none;
}

.action-btn:active { transform: scale(0.93); opacity: 0.8; }

.action-btn .a-icon {
  font-size: 26px;
  line-height: 1;
}

.action-btn .a-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--hint);
  text-align: center;
  white-space: nowrap;
}

/* ── List ────────────────────────────────────────────────────────────────── */
.list {
  background: var(--secondary);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 12px;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 0.5px solid var(--separator);
  cursor: pointer;
  transition: background 0.1s;
}

.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--separator); }

.li-icon {
  font-size: 20px;
  width: 30px;
  text-align: center;
  flex-shrink: 0;
}

.li-body { flex: 1; min-width: 0; }

.li-title {
  font-size: 15px;
  font-weight: 500;
}

.li-sub {
  font-size: 13px;
  color: var(--hint);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.li-right {
  font-size: 13px;
  color: var(--hint);
  flex-shrink: 0;
}

.chevron { opacity: 0.35; font-size: 20px; margin-left: 2px; }

/* ── Info block ──────────────────────────────────────────────────────────── */
.info-block {
  background: var(--secondary);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 12px;
}

.info-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--separator);
  gap: 12px;
}

.info-row:last-child { border-bottom: none; }

.info-label {
  font-size: 14px;
  color: var(--hint);
  flex-shrink: 0;
}

.info-value {
  font-size: 14px;
  font-weight: 500;
  text-align: right;
  word-break: break-word;
}

/* ── Tier tabs ──────────────────────────────────────────────────────────── */
.tier-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tier-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--secondary);
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  padding: 12px 8px;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.15s, transform 0.12s var(--ease);
}

.tier-tab:active { transform: scale(0.97); }
.tier-tab.active { border-color: var(--accent); }

.tier-name {
  font-size: 16px;
  font-weight: 700;
}

.tier-sub {
  font-size: 12px;
  color: var(--hint);
}

.tier-tab.active .tier-name { color: var(--accent); }

/* ── Tariff cards ────────────────────────────────────────────────────────── */
.tariff-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.tariff-card {
  background: var(--secondary);
  border-radius: var(--r-lg);
  padding: 15px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: border-color 0.15s, transform 0.12s var(--ease);
  position: relative;
  overflow: hidden;
}

.tariff-card:active { transform: scale(0.985); }
.tariff-card.selected { border-color: var(--accent); }
.tariff-card.popular  { border-color: rgba(234,179,8,0.5); }
.tariff-card.dimmed   { opacity: 0.45; }

.t-badge {
  position: absolute;
  top: 0;
  right: 0;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 0 var(--r-lg) 0 var(--r-sm);
  letter-spacing: 0.3px;
  line-height: 1.6;
}

.t-badge.popular  { background: #eab308; color: #000; }
.t-badge.discount { background: var(--accent); color: var(--accent-txt); }

.t-body { flex: 1; }

.t-title {
  font-size: 16px;
  font-weight: 600;
}

.t-meta {
  font-size: 13px;
  color: var(--hint);
  margin-top: 2px;
}

.t-price {
  text-align: right;
}

.t-price-val {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.t-price-hint {
  font-size: 11px;
  color: var(--hint);
  margin-top: 2px;
}

/* ── Amount selector ─────────────────────────────────────────────────────── */
.amount-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.amount-chip {
  background: var(--secondary);
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  padding: 12px 4px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, color 0.15s, transform 0.12s var(--ease);
}

.amount-chip:active { transform: scale(0.94); }
.amount-chip.selected { border-color: var(--accent); color: var(--accent); }

.custom-input {
  width: 100%;
  background: var(--secondary);
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  appearance: textfield;
  -moz-appearance: textfield;
}

.custom-input::-webkit-inner-spin-button,
.custom-input::-webkit-outer-spin-button { display: none; }

.custom-input:focus { border-color: var(--accent); }
.custom-input::placeholder { color: var(--hint); font-weight: 400; font-size: 15px; }

/* ── Payment method buttons ──────────────────────────────────────────────── */
.method-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.method-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--secondary);
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  padding: 15px 16px;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.15s, transform 0.12s var(--ease);
}

.method-btn:active { transform: scale(0.985); }
.method-btn.selected { border-color: var(--accent); }

.m-icon { font-size: 28px; width: 36px; text-align: center; flex-shrink: 0; }
.m-body { flex: 1; }
.m-title { font-size: 16px; font-weight: 600; }
.m-sub   { font-size: 13px; color: var(--hint); margin-top: 1px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
  display: block;
  width: 100%;
  background: var(--accent);
  color: var(--accent-txt);
  border: none;
  border-radius: var(--r-md);
  padding: 15px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: opacity 0.15s, transform 0.12s var(--ease);
  letter-spacing: -0.1px;
}

.btn-primary:active  { opacity: 0.82; transform: scale(0.99); }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

.btn-secondary {
  display: block;
  width: 100%;
  background: var(--secondary);
  color: var(--text);
  border: none;
  border-radius: var(--r-md);
  padding: 14px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: opacity 0.15s;
  margin-top: 10px;
}

.btn-secondary:active { opacity: 0.7; }

/* ── Mono / Code ─────────────────────────────────────────────────────────── */
.code-block {
  background: var(--secondary);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-family: 'SF Mono', 'Menlo', 'Courier New', monospace;
  font-size: 13px;
  color: var(--accent);
  word-break: break-all;
  margin-bottom: 8px;
}

.copy-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: var(--secondary);
  border: none;
  border-radius: var(--r-md);
  padding: 12px 16px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  margin-bottom: 6px;
}

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

.btn-row {
  display: flex;
  gap: 8px;
}
.btn-row .copy-btn {
  flex: 1;
  margin-bottom: 0;
  justify-content: center;
}

/* ── Alert ───────────────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--r-md);
  padding: 12px 15px;
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 12px;
}

.alert.warn    { background: rgba(217,119,6,0.15);  color: #f59e0b; }
.alert.info    { background: rgba(82,136,193,0.15);  color: var(--link); }
.alert.success { background: rgba(5,150,105,0.2);   color: #34d399; }
.alert.danger  { background: rgba(220,38,38,0.15);  color: #f87171; }

/* ── Server dot ──────────────────────────────────────────────────────────── */
.srv-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.srv-dot.online  { background: #34d399; box-shadow: 0 0 6px rgba(52,211,153,0.5); }
.srv-dot.offline { background: var(--danger); }
.srv-dot.unknown { background: var(--hint); }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 56px 16px 32px;
}

.empty .e-icon { font-size: 56px; margin-bottom: 16px; }
.empty h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.empty p  { font-size: 14px; color: var(--hint); line-height: 1.6; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--secondary);
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  border: 0.5px solid var(--separator);
  padding: 9px 18px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s, transform 0.2s var(--ease);
  z-index: 9999;
  white-space: nowrap;
  max-width: calc(100vw - 40px);
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Divider ─────────────────────────────────────────────────────────────── */
.gap { height: 10px; }
.gap-lg { height: 16px; }

/* ── Balance big display ─────────────────────────────────────────────────── */
.balance-display {
  text-align: center;
  padding: 28px 16px 22px;
  background: var(--secondary);
  border-radius: var(--r-xl);
  margin-bottom: 12px;
}

.balance-amount {
  font-size: 52px;
  font-weight: 900;
  letter-spacing: -3px;
  line-height: 1;
  margin-bottom: 6px;
}

.balance-hint {
  font-size: 14px;
  color: var(--hint);
}

/* ── Success screen ──────────────────────────────────────────────────────── */
.success-screen {
  text-align: center;
  padding: 52px 16px 24px;
}

.success-icon  { font-size: 72px; margin-bottom: 20px; }
.success-title { font-size: 24px; font-weight: 800; margin-bottom: 10px; letter-spacing: -0.5px; }
.success-sub   { font-size: 15px; color: var(--hint); line-height: 1.6; }

/* ── QR code ─────────────────────────────────────────────────────────────── */
.qr-wrap {
  display: flex;
  justify-content: center;
  padding: 20px 0 8px;
}

.qr-box {
  background: #ffffff;
  border-radius: var(--r-lg);
  padding: 16px;
  display: inline-block;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
}

.qr-box canvas,
.qr-box img {
  display: block;
  border-radius: 4px;
}

.qr-hint {
  text-align: center;
  font-size: 13px;
  color: var(--hint);
  margin-top: 10px;
  margin-bottom: 4px;
}

/* ── Referral block ──────────────────────────────────────────────────────── */
.referral-block {
  background: var(--secondary);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.ref-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
}

.ref-count {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1px;
}

.ref-label {
  font-size: 11px;
  color: var(--hint);
  margin-top: 3px;
}

.ref-btns {
  display: flex;
  flex: 1;
  gap: 8px;
}

.ref-share-btn {
  flex: 1;
  background: rgba(82,136,193,0.15);
  border: none;
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  text-align: center;
  transition: opacity 0.15s;
}

.ref-share-btn:active { opacity: 0.65; }

.ref-copy-btn {
  flex: 0 0 auto;
  background: rgba(82,136,193,0.15);
  border: none;
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: 16px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.ref-copy-btn:active { opacity: 0.65; }

.ref-hint {
  font-size: 13px;
  color: var(--hint);
  line-height: 1.5;
  margin-bottom: 10px;
}

/* ── Connection hint ────────────────────────────────────────────────────── */
.hint-block {
  background: var(--secondary);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.hint-step {
  font-size: 13px;
  color: var(--hint);
  line-height: 1.6;
  margin-bottom: 4px;
}

.hint-apps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 8px 4px;
}

.hint-app {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  background: rgba(82,136,193,0.12);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  transition: opacity 0.15s;
}

.hint-app:active { opacity: 0.6; }

/* ── Skeleton loading ────────────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -500px 0; }
  100% { background-position: 500px 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--secondary) 25%,
    var(--separator) 50%,
    var(--secondary) 75%
  );
  background-size: 500px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-md);
}

.sk-status-card { height: 152px; border-radius: var(--r-xl); margin-bottom: 12px; }
.sk-stat        { height: 72px;  border-radius: var(--r-lg); }
.sk-action      { height: 78px;  border-radius: var(--r-md); }
.sk-list-row    { height: 54px;  border-radius: 0; border-bottom: 0.5px solid var(--separator); }
.sk-list-row:first-child { border-radius: var(--r-lg) var(--r-lg) 0 0; }
.sk-list-row:last-child  { border-radius: 0 0 var(--r-lg) var(--r-lg); border-bottom: none; }

.sk-list-wrap { background: var(--secondary); border-radius: var(--r-lg); overflow: hidden; margin-bottom: 12px; }

/* ── Status card shine animation ─────────────────────────────────────────── */
@keyframes cardShine {
  0%   { left: -80%; }
  60%, 100% { left: 130%; }
}

.status-card::before {
  content: '';
  position: absolute;
  top: -20%;
  left: -80%;
  width: 35%;
  height: 140%;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.13) 50%, transparent 60%);
  transform: skewX(-15deg);
  animation: cardShine 4s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}

/* ── Stagger animation for lists/grid ────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stagger > * {
  animation: fadeUp 0.22s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}

/* ── Page animation ──────────────────────────────────────────────────────── */
@keyframes pgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);   }
}

.page-enter { animation: pgIn 0.2s var(--ease) both; }

/* ── View Transitions API ────────────────────────────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) {
    animation: 0.16s ease both vtFadeOut;
  }
  ::view-transition-new(root) {
    animation: 0.22s ease both vtSlideIn;
  }
}

@keyframes vtFadeOut {
  to { opacity: 0; transform: translateY(-5px); }
}
@keyframes vtSlideIn {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Buy page skeleton ───────────────────────────────────────────────────── */
.sk-buy-title     { height: 56px; border-radius: var(--r-md); margin-bottom: 4px; }
.sk-tariff-card   { height: 74px; border-radius: var(--r-lg); }
.sk-servers-title { height: 56px; border-radius: var(--r-md); margin-bottom: 4px; }

/* ── Language segment switch ───────────────────────────────────────────── */
.lang-switch-wrap {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.lang-switch {
  position: relative;
  display: inline-flex;
  background: var(--secondary);
  border-radius: 10px;
  padding: 3px;
  gap: 0;
}

.lang-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  background: var(--accent);
  border-radius: 8px;
  transition: transform 0.25s var(--ease);
  pointer-events: none;
  z-index: 0;
}

.lang-seg {
  position: relative;
  z-index: 1;
  border: none;
  background: none;
  color: var(--hint);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 7px 22px;
  cursor: pointer;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.lang-seg.active {
  color: var(--accent-txt);
}

/* ── FAQ accordion ──────────────────────────────────────────────────────── */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.faq-item {
  background: var(--secondary);
  border-radius: var(--r-lg);
  overflow: hidden;
  animation: cardUp 0.35s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 0.04s);
}

.faq-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 15px 16px;
  cursor: pointer;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  gap: 12px;
  -webkit-tap-highlight-color: transparent;
}

.faq-header:active {
  opacity: 0.7;
}

.faq-q {
  flex: 1;
}

.faq-chevron {
  font-size: 20px;
  color: var(--hint);
  transition: transform 0.25s var(--ease);
  flex-shrink: 0;
}

.faq-header.open .faq-chevron {
  transform: rotate(90deg);
}

.faq-answer {
  padding: 0 16px 15px;
}

.faq-line {
  font-size: 14px;
  color: var(--hint);
  line-height: 1.65;
}

.faq-spacer {
  height: 8px;
}

/* ── Support ────────────────────────────────────────────────────────────── */
.support-textarea {
  width: 100%;
  background: var(--secondary);
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color 0.15s;
  min-height: 100px;
}

.support-textarea.small {
  min-height: 70px;
}

.support-textarea:focus {
  border-color: var(--accent);
}

.support-textarea::placeholder {
  color: var(--hint);
}

.support-err {
  font-size: 13px;
  color: var(--danger);
  min-height: 18px;
  margin-top: 6px;
}

.support-status-badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 100px;
  margin-bottom: 16px;
}

.support-status-badge.open {
  background: rgba(217,119,6,0.15);
  color: #f59e0b;
}

.support-status-badge.closed {
  background: rgba(5,150,105,0.2);
  color: #34d399;
}

/* ── Chat thread ── */
.support-thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.msg-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 14px;
  line-height: 1.5;
}

.msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-txt);
  border-bottom-right-radius: 4px;
}

.msg-admin {
  align-self: flex-start;
  background: var(--secondary);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.msg-author {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.7;
  margin-bottom: 2px;
}

.msg-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-time {
  font-size: 11px;
  opacity: 0.5;
  margin-top: 4px;
  text-align: right;
}

.support-reply-form {
  border-top: 1px solid var(--separator);
  padding-top: 12px;
}

/* ── Support admin filters ── */
.support-filters {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.support-filter-btn {
  flex: 1;
  background: var(--secondary);
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  padding: 10px 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--hint);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.support-filter-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.support-ai-hint {
  margin: -4px 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--separator);
  border-radius: var(--r-md);
  background: var(--secondary);
  color: var(--hint);
  font-size: 13px;
  line-height: 1.35;
}

/* ── Onboarding steps ──────────────────────────────────────────────────── */
.ob-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ob-step {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--separator);
}

.ob-step:last-child {
  border-bottom: none;
}

.ob-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-txt);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.ob-body {
  flex: 1;
  min-width: 0;
}

.ob-step-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 3px;
}

.ob-step-hint {
  font-size: 13px;
  color: var(--hint);
  line-height: 1.5;
}

/* ── Pull-to-refresh ───────────────────────────────────────────────────── */
.ptr-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  height: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

/* ── Save access block (onboarding) ── */
.ob-save-block {
  margin-top: 20px;
  padding: 16px;
  background: var(--secondary);
  border-radius: var(--r-md);
  border: 1px solid rgba(82,136,193,0.2);
  text-align: center;
}
.ob-save-icon { font-size: 28px; margin-bottom: 8px; }
.ob-save-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.ob-save-hint { font-size: 13px; color: var(--hint); line-height: 1.5; margin-bottom: 12px; }
.ob-save-btn { width: 100%; }

/* ── Save access card (subscription page) ── */
.save-access-card { display: flex; flex-direction: column; align-items: flex-start; }
.alert.info { background: rgba(82,136,193,0.1); border: 1px solid rgba(82,136,193,0.2); border-radius: var(--r-md); padding: 12px 14px; font-size: 13px; color: var(--hint); line-height: 1.5; }
.alert.success { background: rgba(76,175,80,0.1); border: 1px solid rgba(76,175,80,0.2); border-radius: var(--r-md); padding: 12px 14px; font-size: 13px; color: var(--text); line-height: 1.5; }

/* ── Email input (used in web_access page) ── */
.web-login-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--secondary);
  border: 1px solid var(--separator);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}
.web-login-input:focus { border-color: var(--accent); }
.web-login-input::placeholder { color: var(--hint); }

/* ─── AI Chat ──────────────────────────────────────────────────────────────── */
.ai-chat-content {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 16px);
  height: calc(100dvh - 16px);
  padding-bottom: 0;
}
.ai-chat-header {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--separator);
  margin-bottom: 10px;
  flex: 0 0 auto;
}
.ai-chat-log {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 2px 12px;
  scrollbar-width: thin;
}
.ai-msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: ai-msg-in 0.18s ease-out;
}
@keyframes ai-msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ai-msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-txt);
  border-bottom-right-radius: 4px;
}
.ai-msg-assistant {
  align-self: flex-start;
  background: var(--secondary);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.ai-examples {
  align-self: stretch;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 0 4px;
}
.ai-examples-title {
  flex: 0 0 100%;
  color: var(--hint);
  font-size: 13px;
  line-height: 1.3;
}
.ai-example-chip {
  flex: 0 1 auto;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--separator);
  border-radius: var(--r-md);
  background: var(--secondary);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
}
.ai-example-chip:active {
  transform: scale(0.98);
}
.ai-typing {
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
}
.ai-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--hint);
  animation: ai-dot 0.9s infinite ease-in-out;
}
.ai-dot:nth-child(2) { animation-delay: 0.15s; }
.ai-dot:nth-child(3) { animation-delay: 0.30s; }
@keyframes ai-dot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40%           { opacity: 1.0; transform: scale(1.05); }
}
.ai-chat-inputbar {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 0 max(10px, env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--separator);
}
.ai-chat-input {
  flex: 1 1 auto;
  resize: none;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--separator);
  border-radius: var(--r-md);
  background: var(--secondary);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}
.ai-chat-input:focus { border-color: var(--accent); }
.ai-chat-input::placeholder { color: var(--hint); }
.ai-chat-send-btn {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-txt);
  font-size: 18px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.08s;
}
.ai-chat-send-btn:active { transform: scale(0.92); }
.ai-chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── AI Chat — attachments ───────────────────────────────────────────────── */
.ai-chat-attach-btn {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid var(--separator);
  border-radius: 50%;
  background: var(--secondary);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.08s, background 0.15s;
}
.ai-chat-attach-btn:active { transform: scale(0.92); }
.ai-chat-attach-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ai-chat-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-top: 6px;
  background: var(--secondary);
  border: 1px solid var(--separator);
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--text);
}
.ai-chat-preview-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-chat-preview-remove {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,0.06);
  color: var(--hint); cursor: pointer;
  font-size: 13px;
}
.ai-chat-preview-remove:hover { color: var(--danger); }
