:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7f1;
  --bg-transparent: #f5f7f1ef;
  --card: #fff;
  --border: #23321422;
  --text: #182016;
  --muted: #60695b;
  --soft: #607d1510;
}
:root[data-theme="light"] .badge,
:root[data-theme="light"] .pill,
:root[data-theme="light"] .nav button.active,
:root[data-theme="light"] .chip.selected {
  color: #3b590c;
}
body {
  background: var(--bg) !important;
}
.shell {
  border-color: var(--border) !important;
  background: var(--bg) !important;
}
.telegram-bar {
  color: var(--muted);
}
[hidden] {
  display: none !important;
}
progress {
  width: 100%;
  height: 8px;
  accent-color: #83ad35;
}
button:focus-visible,
a:focus-visible,
select:focus-visible {
  outline: 3px solid #84ac3e;
  outline-offset: 3px;
}
.switch-row {
  align-items: flex-start;
}
.switch-row input {
  flex-shrink: 0;
}
.avatar {
  color: var(--text);
  background: var(--card);
}
.nav button,
.avatar {
  min-height: 44px;
  min-width: 44px;
}
.button {
  margin-top: 10px;
}
.error-box {
  padding: 15px;
  border: 1px solid #bd5959;
  border-radius: 12px;
  margin: 10px 0;
  color: var(--text);
}
.plan-warning {
  display: grid;
  gap: 16px;
  width: 100%;
  margin: 0 0 16px;
  padding: 18px;
  border: 1px solid #ff878f55;
  border-radius: 24px;
  background: #ff878f18;
  color: #ffb1b7;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
}
.plan-warning-copy { display: grid; gap: 6px; }
.plan-warning strong { font-size: 16px; }
.plan-warning-action {
  margin: 0;
  background: transparent;
  color: inherit;
  border-color: #ff878f55;
}
.plan-warning .setup-icon { flex-shrink: 0; width: 24px; height: 24px; }
:root[data-theme="light"] .plan-warning {
  background: #fff0f1;
  border-color: #e9a3ad;
  color: #9c2938;
}
input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: #6b931b;
}
select {
  width: 100%;
  background: var(--card);
  color: var(--text);
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.theme-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.theme-options button {
  min-height: 48px;
}
.welcome {
  padding: 25px 0;
}
.welcome h1 {
  font-size: 44px;
}
.welcome .hero {
  margin-top: 35px;
}
.plan {
  text-align: left;
  color: var(--text);
  width: 100%;
}
.spinner {
  padding: 40px 0;
  text-align: center;
  color: var(--muted);
}
.link-button {
  display: block;
  text-align: center;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin: 10px 0;
}
.qr-image {
  display: block;
  width: min(100%, 260px);
  margin: 20px auto;
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

.switch-row.checkout-check { padding: 8px 0; margin: 4px 0; border: 0; gap: 10px; min-height: 0; }
.renew-toggle { display: inline-flex; align-items: center; padding: 0; margin: 0; border: 0; border-radius: 0; background: var(--bg); color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; min-height: 36px; }
.renew-details { margin: 4px 0 8px; }

.checkout-plan { margin-bottom: 0; }
.switch-row.checkout-check { font-size: 12px; }

.checkout-check input[type="checkbox"] {
  accent-color: color-mix(in srgb, var(--bg) 65%, #000 35%);
}

/* Keep the complete period choice and its actions within a mobile viewport. */
.shell:has(.period-picker) {
  width: 100%;
  max-width: 520px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 20px calc(80px + env(safe-area-inset-bottom));
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}
.shell:has(.period-picker) .header { height: 60px; }
.shell:has(.period-picker) .telegram-bar { height: 44px; }
.period-picker h1 { font-size: 28px; margin: 5px 0 8px; }
.period-picker > .muted { font-size: 13px; margin: 0 0 12px; }
.period-options { display: grid; gap: 8px; }
.period-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  align-content: center;
  column-gap: 10px;
  padding: 9px 14px;
  margin: 0;
  border-radius: 16px;
  min-height: clamp(64px, calc((100dvh - 380px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) / 3), 128px);
}
.period-choice {
  grid-row: 1 / 3;
  width: 16px;
  height: 16px;
  border: 1px solid var(--muted);
  border-radius: 50%;
}
.selected .period-choice { border: 5px solid var(--accent); }
.period-name { grid-row: 1 / 3; font-size: 16px; font-weight: 650; }
.period-price { text-align: right; font-size: 22px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.period-note { grid-column: 3; text-align: right; font-size: 11px; color: var(--muted); }
.period-picker.has-renewal-notice > .muted { font-size: 12px; line-height: 18px; }
.has-renewal-notice .period-option {
  padding-block: 6px;
  min-height: clamp(52px, calc((100dvh - 430px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) / 3), 128px);
}
.period-actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 12px; }
.period-actions .button { margin: 0; min-height: 46px; padding: 10px; }
.shell:has(.period-picker) #environment { margin-top: 8px; }
.shell:has(.period-picker) .nav {
  left: 50%;
  bottom: 0;
  width: min(100%, 520px);
  border-radius: 0;
  padding: 8px 18px calc(8px + env(safe-area-inset-bottom));
}
.shell:has(.period-picker) .nav button { line-height: 1.2; }
.shell:has(.period-picker) .nav button span { line-height: 1; }

/* Telegram's compact desktop WebView can be shorter than a phone screen. */
@media (max-height: 520px) {
  .shell:has(.period-picker) { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .shell:has(.period-picker) .header { height: 44px; }
  .period-picker .eyebrow { font-size: 10px; line-height: 15px; }
  .period-picker h1 { font-size: 24px; margin: 4px 0 6px; }
  .period-picker > .muted,
  .period-picker.has-renewal-notice > .muted { font-size: 11px; line-height: 15px; margin-bottom: 8px; }
  .period-options { gap: 6px; }
  .period-option,
  .has-renewal-notice .period-option { min-height: 52px; padding: 6px 10px; }
  .period-price { font-size: 20px; }
  .period-note { font-size: 10px; }
  .period-actions { margin-top: 10px; }
  .period-actions .button { min-height: 44px; padding: 8px; }
}

.connection-shortcuts { display: grid; grid-template-columns: minmax(100px, 1fr) minmax(0, 1.7fr); gap: 10px; margin: 16px 0 20px; }
.connection-tile {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
}
.connection-tile svg { width: 24px; height: 24px; flex-shrink: 0; }
.connection-tile .link-accent { stroke: var(--accent); }
.connection-tile:hover { border-color: var(--accent); }
.connection-tile:active { background: var(--soft); }

.connect-step { padding: 16px; border-radius: 18px; }
.connect-step h2 { font-size: 16px; margin: 0; line-height: 1.35; }
.connect-step-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.connect-step-heading h2 { flex: 1; }
.connect-step-heading select { width: auto; max-width: 42%; min-height: 40px; padding: 8px; font-size: 12px; }
.step-number { color: var(--muted); margin-right: 4px; }
.page-placeholder { padding-top: 12px; }
#environment:not([hidden]) { display: block; text-align: center; color: var(--muted); font-size: 9px; margin-top: 24px; }
.placeholder-line { width: 55%; height: 26px; margin: 20px 0; border-radius: 8px; background: var(--card); }
.placeholder-card { height: 100px; margin-bottom: 14px; border-radius: 18px; background: var(--card); border: 1px solid var(--border); }
.profile-menu { padding: 0 18px; margin-bottom: 14px; }
.profile-menu .list-item { min-height: 78px; padding: 18px 0; font-size: 16px; font-weight: 400; line-height: 1.4; }
.profile-menu .list-item .icon { flex-shrink: 0; border-radius: 12px; }
.profile-menu .list-item .grow { min-width: 0; }
.profile-menu .list-item small { margin-top: 5px; font-size: 12px; }
.profile-menu .list-item .arrow { flex-shrink: 0; }
.renewal-setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; }
.renewal-setting h2 { margin: 0 0 5px; font-size: 17px; }
.renewal-switch { flex-shrink: 0; width: 44px; height: 26px; padding: 3px; border: 0; border-radius: 20px; background: var(--muted); cursor: pointer; }
.renewal-switch span { display: block; width: 20px; height: 20px; border-radius: 50%; background: var(--bg); transition: transform .15s ease; }
.renewal-switch[aria-checked="true"] { background: var(--accent); }
.renewal-switch[aria-checked="true"] span { transform: translateX(18px); background: #263516; }
.renewal-switch:disabled { opacity: .6; cursor: wait; }
.current-plan { display: block; width: 100%; text-align: left; color: var(--text); }
.current-plan:hover { border-color: var(--accent); }
.tariff-option { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-content: center; min-height: 104px; padding: 16px; margin: 0; border-radius: 16px; text-align: left; }
.tariff-option h2 { grid-column: 1; margin: 0 0 5px; font-size: 17px; }
.tariff-option p { grid-column: 1; margin: 0; font-size: 12px; line-height: 1.4; }
.tariff-option .price { grid-column: 2; grid-row: 1 / span 3; align-self: center; text-align: right; font-size: 23px; }
.tariff-option .price small { display: block; margin-top: 4px; }
@media (max-width: 360px) { .tariff-option { padding: 12px; column-gap: 8px; } .tariff-option .price { font-size: 20px; } .tariff-option h2 { font-size: 15px; } }
.profile-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.profile-stat { padding: 12px; border: 1px solid color-mix(in srgb, var(--stat-color) 30%, transparent); border-radius: 12px; background: color-mix(in srgb, var(--stat-color) 8%, var(--card)); min-width: 0; }
.profile-stat-user { --stat-color: #459eea; }
.profile-stat-status { --stat-color: #39bf71; }
.profile-stat-expiry { --stat-color: #e87883; }
.profile-stat-traffic { --stat-color: #d5a61a; }
.profile-stat-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.profile-stat-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-stat-icon { flex-shrink: 0; width: 20px; height: 20px; color: var(--stat-color); }
.profile-stat strong { display: block; font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; }
.connect-step h2 { display: flex; align-items: center; gap: 10px; }
.setup-icon { width: 21px; height: 21px; flex-shrink: 0; }
.setup-icon-badge { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; background: var(--soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.install-options .link-button { display: flex; align-items: center; justify-content: center; gap: 8px; }
.client-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 14px; }
.client-choice { min-height: 40px; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font-size: 13px; text-align: left; }
.client-choice.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--soft); }
.client-choice { position: relative; overflow: hidden; }
.client-choice span { position: relative; z-index: 1; }
.client-mark { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; opacity: .16; pointer-events: none; }
.client-choice.selected .client-mark { color: var(--accent); opacity: .28; }
.install-options { display: grid; gap: 6px; }
.install-options .link-button { margin: 0; padding: 10px; font-size: 14px; font-weight: 650; min-height: 40px; background: var(--accent); color: #1c260e; border-color: transparent; }
.download-unavailable { padding: 8px 10px; font-size: 12px; color: var(--muted); }
.download-unavailable small { display: block; margin-top: 2px; font-size: 11px; }
.store-region-help { margin-top: 12px; }
.store-region-help p { margin: 0 0 10px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.store-region-help .button { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; }
.store-region-help .button.secondary { background: color-mix(in srgb, var(--text) 7%, var(--card)); color: var(--text); }
.connect-step .button { font-size: 14px; min-height: 44px; padding: 10px; }
.connect-hint { margin: 10px 0 0; }
.manual-step h2 { font-size: 15px; }
.manual-step p { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.subscription-title { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; }
.subscription-period { font-size: 16px; font-weight: 500; line-height: 1.3; letter-spacing: 0; color: var(--muted); padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; white-space: nowrap; }
.payment-return { padding-top: 48px; }

/* Telegram controls overlay iOS fullscreen content. Keep them outside our
   fixed-height header; padding inside that header would still overlap h1. */
.in-telegram {
  --blisc-safe-top: calc(var(--blisc-system-top, env(safe-area-inset-top, 0px)) + var(--blisc-controls-top, 0px));
  --blisc-safe-bottom: calc(var(--blisc-system-bottom, env(safe-area-inset-bottom, 0px)) + var(--blisc-controls-bottom, 0px));
}
.in-telegram .shell {
  padding-top: var(--blisc-safe-top);
  padding-bottom: calc(125px + var(--blisc-safe-bottom));
  padding-left: calc(22px + var(--blisc-system-left, 0px) + var(--blisc-controls-left, 0px));
  padding-right: calc(22px + var(--blisc-system-right, 0px) + var(--blisc-controls-right, 0px));
}
.in-telegram .header { padding-top: 0; }
.in-telegram .telegram-bar { display: none; }
.in-telegram .shell .nav { padding-bottom: calc(24px + var(--blisc-safe-bottom)); }
.in-telegram #toast { bottom: calc(105px + var(--blisc-safe-bottom)); }
.in-telegram .period-option {
  min-height: clamp(64px, calc((100dvh - 380px - var(--blisc-safe-top) - var(--blisc-safe-bottom)) / 3), 128px);
}
.in-telegram .has-renewal-notice .period-option {
  min-height: clamp(52px, calc((100dvh - 430px - var(--blisc-safe-top) - var(--blisc-safe-bottom)) / 3), 128px);
}
.import-page { padding-top: env(safe-area-inset-top, 0px); }
.import-page .header { padding-top: 0; }
.import-page .url { width: 100%; margin-top: 12px; }
