:root {
  --app-height: 100dvh;
  --bg: #0b1017;
  --panel: #141c27;
  --panel-2: #1a2431;
  --border: #2a3749;
  --text: #e7edf6;
  --muted: #98a8bf;
  --accent: #4f8cff;
  --accent-2: #3f78e0;
  --ok: #47c97e;
  --danger: #ff5d75;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: var(--app-height);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 380px at 50% -20%, #162233 0%, transparent 62%), var(--bg);
  overflow-x: hidden;
}

html,
body {
  scrollbar-width: none;
  overflow-x: clip;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 0;
  height: 0;
}

* {
  scrollbar-width: none;
}

*::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

.screen {
  max-width: 560px;
  margin: 0 auto;
  min-height: var(--app-height);
  padding: calc(14px + env(safe-area-inset-top, 0px)) 12px calc(22px + env(safe-area-inset-bottom, 0px));
}

.hidden {
  display: none !important;
}

body.noScroll {
  overflow: hidden;
}

body.booting #authScreen,
body.booting #appScreen {
  visibility: hidden;
}

.authScreen {
  margin-top: 32px;
  border-radius: 16px;
  background: var(--panel);
  padding: 20px 16px;
  text-align: center;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.28);
}

.logoGlow {
  width: 58px;
  height: 58px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: linear-gradient(145deg, #78a7ff, #4b86ff);
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 24px rgba(36, 80, 160, 0.24);
}

.logoGlow img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.authScreen h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
}

.authText {
  margin: 10px 0 14px;
  color: var(--muted);
  line-height: 1.4;
}

.authProviders {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.authProviderBtn {
  width: 100%;
  min-height: 54px;
  border: 1px solid #2d405a;
  border-radius: 12px;
  background: linear-gradient(180deg, #1a2433 0%, #151f2c 100%);
  color: #ecf2fc;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 16px;
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.authProviderBtn:hover {
  transform: translateY(-1px);
  border-color: #47638a;
}

.authProviderBtn:disabled {
  opacity: 0.68;
  cursor: wait;
}

.authProviderIcon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 34px;
  color: #10151d;
  background: #eef2f7;
  border: 1px solid rgba(17, 23, 33, 0.08);
}

.authProviderIconGoogle {
  font-size: 22px;
  font-weight: 800;
}

.authProviderIconTelegram svg {
  width: 18px;
  height: 18px;
}

.authLegal {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.authLegal a {
  color: #a9c4ff;
  text-decoration: none;
}

.authError {
  margin: 10px 0 0;
  color: var(--danger);
  min-height: 18px;
}

.tgWidgetWrap {
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #27384f;
  background: rgba(22, 34, 52, 0.58);
}

.tgBrowserFallback {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #26384f;
  background: rgba(18, 28, 42, 0.58);
  display: grid;
  gap: 10px;
}

.authFallbackText {
  margin: 0;
  color: #bdd0ea;
  line-height: 1.4;
  font-size: 14px;
}

.authFallbackBtn {
  width: 100%;
}

.authWidgetTitle {
  margin-bottom: 10px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

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

.btnMain {
  background: var(--accent);
  border-color: var(--accent-2);
  color: #f5f9ff;
}

.btnMain:hover {
  background: #5a95ff;
}

.btnSoft {
  margin-top: 8px;
  background: #263a56;
  border-color: #304968;
  color: #e8f1ff;
}

.btnSoft:hover {
  background: #30486a;
}

.btnDangerSoft {
  background: rgba(92, 32, 43, 0.3);
  border-color: rgba(149, 61, 78, 0.58);
  color: #ffc7d0;
}

.btnDangerSoft:hover {
  background: rgba(110, 38, 52, 0.42);
}

.btnGhost {
  background: #1b2a3f;
  border-color: #304867;
  color: #d8e6ff;
}

.btnGhost:hover {
  background: #23354d;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
}

.headerMain {
  min-width: 0;
}

.headerActions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 0 0 auto;
}

.iconOnlyBtn {
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  flex: 0 0 44px;
}

.iconOnlyBtn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.header h2 {
  margin: 0;
  font-size: 31px;
  font-weight: 800;
}

.subtle {
  margin: 6px 0 0;
  color: var(--muted);
}

.list {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.subCard {
  background: var(--panel);
  border-radius: 13px;
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}

.flag {
  width: 31px;
  height: 31px;
  border-radius: 50%;
  border: 1px solid #394a62;
  background: #0f1622;
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  overflow: hidden;
}

.flag img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.flagFallback {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #dce8ff;
}

.subBody {
  flex: 1;
  min-width: 0;
}

.subTitle {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.subMeta {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.3;
}

.subMeta .ok {
  color: var(--ok);
}

.arrowBtn {
  border: none;
  background: transparent;
  color: #8db3ff;
  font-size: 27px;
  cursor: pointer;
}

.emptyBlock {
  min-height: 48vh;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 8px;
}

.emptyBlock h3 {
  margin: 0;
  font-size: 31px;
  font-weight: 800;
}

.emptyHint {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.emptyBlock .btn {
  min-width: 220px;
  margin-top: 10px;
}

.actionBar {
  margin-top: 12px;
}

.actionBar .btn {
  width: 100%;
}

input,
select {
  width: 100%;
  border: none;
  border-radius: 10px;
  background: #0f1723;
  color: var(--text);
  padding: 10px;
  font: inherit;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100dvh;
  height: 100dvh;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 12px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(2, 4, 8, 0.66);
  overflow-y: auto;
}

.settingsModal {
  gap: 14px;
}

.settingsSection {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.settingsFeedback {
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(153, 69, 83, 0.55);
  background: rgba(86, 29, 39, 0.34);
  color: #ffd6dd;
  line-height: 1.4;
  font-size: 14px;
}

.settingsFeedback.success {
  border-color: rgba(77, 156, 105, 0.48);
  background: rgba(32, 76, 49, 0.34);
  color: #bff3d0;
}

.accountProviderCard {
  background: rgba(24, 34, 48, 0.86);
  border: 1px solid rgba(53, 78, 111, 0.82);
  border-radius: 16px;
  padding: 12px 12px 13px;
  display: grid;
  gap: 9px;
}

.accountProviderHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.accountProviderTitleWrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.accountProviderTitleWrap h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 750;
}

.accountProviderMeta {
  margin: 3px 0 0;
  color: #aebfd7;
  line-height: 1.35;
  word-break: break-word;
}

.accountProviderBadge {
  min-width: fit-content;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.accountProviderBadge.connected {
  background: rgba(71, 201, 126, 0.16);
  color: #7ce3a4;
}

.accountProviderIcon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  flex: 0 0 40px;
  border-radius: 13px;
  background: rgba(234, 240, 250, 0.92);
  color: #0f1723;
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: grid;
  place-items: center;
  box-shadow: inset 0 -1px 0 rgba(15, 23, 35, 0.08);
}

.accountProviderIcon svg {
  width: 20px;
  height: 20px;
}

.accountProviderIconGoogle svg {
  width: 19px;
  height: 19px;
}

.accountProviderIconTelegram svg {
  width: 23px;
  height: 23px;
  transform: translate(-1px, 1px);
}

.accountProviderHint {
  margin: 0;
  color: #8ea4c3;
  font-size: 13px;
  line-height: 1.35;
}

.accountProviderActions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.accountProviderActions .btn {
  margin-top: 0;
  flex: 1 1 180px;
}

.accountDangerZone {
  border-radius: 14px;
  border: 1px solid rgba(149, 61, 78, 0.42);
  background: rgba(69, 25, 34, 0.22);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.accountDangerZone h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #ffe0e5;
}

.accountDangerText {
  margin: 0;
  color: #dcb3bd;
  line-height: 1.4;
  font-size: 14px;
}

.accountDeleteBtn {
  width: 100%;
  margin-top: 0;
}

.modal {
  width: min(500px, 94vw);
  background: var(--panel);
  border-radius: 15px;
  padding: 14px;
  color: var(--text);
  box-shadow: 0 22px 44px rgba(0, 0, 0, 0.34);
  margin-top: 0;
  max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}

.modal::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.welcomeNoticeModal {
  width: min(460px, 92vw);
  padding: 18px;
  border: 1px solid rgba(91, 142, 255, 0.36);
  background:
    radial-gradient(circle at 18% 0%, rgba(85, 139, 255, 0.26), transparent 36%),
    linear-gradient(180deg, #172438 0%, #101923 100%);
}

.welcomeNoticeIcon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, #78a4ff, #4c83ff);
  color: #fff;
  font-weight: 900;
  font-size: 22px;
  box-shadow: 0 12px 28px rgba(76, 131, 255, 0.32);
  margin-bottom: 12px;
}

.welcomeNoticeModal h3 {
  margin: 0 0 10px;
  font-size: 24px;
  line-height: 1.12;
}

.welcomeNoticeModal p {
  margin: 0;
  color: #c7d5e8;
  line-height: 1.5;
}

.inlineLinkBtn {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: #76a9ff;
  font: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.welcomeImportant {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 197, 95, 0.24);
  border-radius: 14px;
  background: rgba(255, 174, 66, 0.09);
  color: #f5d7a6;
  line-height: 1.45;
  font-size: 14px;
}

.welcomeImportant strong {
  color: #ffe0a3;
}

.welcomeNoticeActions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 16px;
}

.welcomeNoticeActions .btnMain,
.welcomeNoticeActions .btnSoft {
  min-height: 46px;
  box-shadow: none;
}

.welcomeNoticeActions .btn:first-child {
  background: rgba(44, 68, 101, 0.92);
  border: 1px solid rgba(100, 146, 220, 0.38);
}

.modalHead {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.modalHead h3 {
  margin: 0;
  font-size: 28px;
  line-height: 1.12;
  color: var(--text);
}

.iconBtn {
  border: none;
  background: #1a2534;
  color: #eaf0fa;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  cursor: pointer;
}

.field {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  color: #d6e2f3;
}

.copyLine {
  display: flex;
  gap: 8px;
  align-items: center;
}

#connUri {
  font-size: 14px;
  line-height: 1.24;
}

#rawUriBtn {
  margin-top: 8px;
}

.statusOk {
  margin-top: 12px;
  padding: 10px;
  border-radius: 10px;
  background: #143723;
  color: var(--ok);
}
.statusOk.offline {
  background: #3a171d;
  color: #ff9ca8;
}

.switchPanel {
  margin-top: 12px;
  border-radius: 10px;
  padding: 10px;
  background: #101923;
}

.confirm {
  margin: 10px 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #dce7f5;
}

.confirm input[type="checkbox"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.confirm span {
  line-height: 1.3;
}

.createForm {
  margin-top: 8px;
}

.choiceBlock {
  border: none;
  border-radius: 10px;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.choiceBlock legend {
  color: #b8c9df;
  padding: 0;
  margin: 0 0 2px;
}

.choiceStack {
  display: grid;
  gap: 8px;
}

.choiceItem,
.choiceInline,
.planItem,
.locationItem {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  margin: 0;
  cursor: pointer;
  border: none;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--panel-2);
  padding: 10px;
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
  color: #dde9f9;
}

#locationOptions,
#protocolOptions {
  display: grid;
  gap: 8px;
}

.choiceItem input,
.choiceInline input,
.planItem input,
.locationItem input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choiceItem.selected,
.choiceInline.selected,
.planItem.selected,
.locationItem.selected {
  background: #2b4466;
  border-color: #4f8cff;
  box-shadow: none;
  transform: none;
}

.choiceLabel {
  font-weight: 600;
  letter-spacing: 0;
  font-size: 20px;
  color: var(--text);
}

.choiceHint {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.choiceInlineHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.choiceInlineTitle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.modalLocationOption {
  padding: 8px 10px;
}

.modalLocationHead {
  align-items: flex-start;
  width: 100%;
}

.modalLocationTitle {
  align-items: flex-start;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}

.modalLocationFlag {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  background: #101722;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.modalLocationTextWrap {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.modalLocationText {
  font-size: 15px;
  line-height: 1.2;
  font-weight: 650;
  color: var(--text);
}

.modalLocationHint {
  margin-top: 0;
  font-size: 13px;
  line-height: 1.3;
}

.currentBadge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 18px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(79, 140, 255, 0.18);
  border: 1px solid rgba(79, 140, 255, 0.36);
  color: #cfe0ff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.locationItem {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
}

.locationFlag {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #101722;
  display: grid;
  place-items: center;
  font-size: 17px;
  overflow: hidden;
}

.locationFlag img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.locationText {
  font-size: 17px;
  color: var(--text);
}

.locationItem .choiceHint {
  grid-column: 2;
}

.locationItem.isDisabled,
.choiceItem.isDisabled,
.choiceInline.isDisabled,
.planItem.isDisabled {
  opacity: 0.46;
  background: #080e17;
  border-color: #111d2d;
  filter: saturate(0.2) brightness(0.54);
  cursor: not-allowed;
}

.locationItem.isDisabled .locationText,
.choiceItem.isDisabled .choiceLabel,
.choiceInline.isDisabled span,
.planItem.isDisabled span,
.locationItem.isDisabled .choiceHint,
.choiceItem.isDisabled .choiceHint {
  color: #8092ad;
}

.planTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.planMain {
  display: inline-flex;
  gap: 6px;
  align-items: baseline;
  font-size: 18px;
  color: #e7effa;
}

.planPrice {
  font-size: 26px;
  font-weight: 800;
  color: #f3f7ff;
  line-height: 1;
}

.planBadge {
  font-size: 12px;
  color: #a8bad8;
  background: rgba(84, 109, 146, 0.22);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.planMeta {
  margin-top: 5px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.planMuted {
  color: #8ca0bc;
  font-size: 13px;
}

.planMuted:first-child {
  text-decoration: line-through;
}

.planSub {
  margin-top: 4px;
  color: #8ca0bc;
  font-size: 13px;
}

.planItem.bestPlan {
  background: var(--panel-2);
}

.planItem.bestPlan:not(.selected) .planBadge {
  opacity: 0.9;
}

.payHint {
  margin: 12px 0 0;
  color: #8ca0bc;
  line-height: 1.4;
  font-size: 13px;
}

.payLegal {
  margin: 8px 0 0;
  color: #9eb0ca;
  line-height: 1.42;
  font-size: 12px;
}

.payLegal a {
  color: #b9d0ff;
  text-decoration: none;
  border-bottom: 1px solid rgba(185, 208, 255, 0.35);
}

.payLegal a:hover {
  color: #d7e4ff;
  border-bottom-color: rgba(215, 228, 255, 0.65);
}

#submitCreateBtn {
  margin-top: 14px;
  width: 100%;
}

.uiToast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 120;
  max-width: min(92vw, 520px);
  padding: 11px 14px;
  border-radius: 12px;
  background: rgba(18, 28, 42, 0.97);
  border: 1px solid #2f4668;
  color: #eaf1ff;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.34);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.uiToast.show {
  opacity: 1;
}

.uiDialog {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(3, 7, 13, 0.72);
}

.uiDialogCard {
  width: min(520px, 94vw);
  border-radius: 14px;
  border: 1px solid #2c405d;
  background: linear-gradient(180deg, #17253a 0%, #121f31 100%);
  padding: 14px;
}

.uiDialogCard h4 {
  margin: 0;
  font-size: 18px;
}

.uiDialogCard p {
  margin: 8px 0 0;
  color: #c8d7ec;
  line-height: 1.35;
}

.uiDialogActions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.uiDialogActions .btn {
  min-width: 96px;
}

@media (max-width: 520px) {
  .header {
    flex-direction: row;
    align-items: flex-start;
  }

  .header .btn:not(.iconOnlyBtn) {
    width: 100%;
  }

  .header h2 {
    font-size: 28px;
  }

  .iconOnlyBtn {
    align-self: flex-start;
    margin-top: 2px;
  }

  .headerActions {
    gap: 6px;
  }

  .accountProviderActions .btn {
    flex-basis: 100%;
  }

  .settingsModal {
    padding-top: 16px;
  }

  .settingsModal .modalHead {
    align-items: center;
    margin-bottom: 4px;
  }

  .settingsModal .modalHead h3 {
    max-width: calc(100vw - 96px);
  }

  .accountProviderCard {
    padding: 11px;
  }

  .accountProviderIcon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    flex-basis: 38px;
    border-radius: 12px;
  }

  .accountProviderIconTelegram svg {
    width: 22px;
    height: 22px;
  }

  .welcomeNoticeModal {
    padding: 18px 16px;
  }

  .welcomeNoticeActions {
    grid-template-columns: 1fr;
  }

  .subTitle {
    font-size: 22px;
  }

  .modalHead h3 {
    font-size: 24px;
  }
}
