:root {
  color-scheme: dark;
  --bg: #0b0c10;
  --surface: #17191f;
  --text: #f5f5f7;
  --muted: #a9aebd;
  --line: #2c303c;
  --accent: #ff2945;
  --green: #59d68c;
  --safe-top: 0px;
  --safe-bottom: 0px;
  --safe-left: 0px;
  --safe-right: 0px;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
a {
  -webkit-tap-highlight-color: transparent;
}
button,
input,
select {
  font: inherit;
}
button,
a {
  touch-action: manipulation;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: wait;
  opacity: 0.55;
}
button {
  color: inherit;
}
a {
  color: #94cfff;
  text-decoration: none;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid #94cfff;
  outline-offset: 4px;
}
[hidden] {
  display: none !important;
}
.app-shell {
  max-width: 640px;
  margin: auto;
  padding: calc(24px + max(env(safe-area-inset-top), var(--safe-top)))
    calc(24px + max(env(safe-area-inset-right), var(--safe-right)))
    calc(112px + max(env(safe-area-inset-bottom), var(--safe-bottom)))
    calc(24px + max(env(safe-area-inset-left), var(--safe-left)));
  min-height: 100dvh;
}
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  min-height: 48px;
  gap: 16px;
}
#loading {
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
  color: var(--muted);
}
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: loading-spin 0.8s linear infinite;
}
#content.is-opening {
  animation: app-open 240ms ease-out both;
}
#retry-account {
  margin-bottom: 12px;
}
#retry-account:not([hidden]) + a.primary {
  background: var(--surface);
  color: var(--text);
}
@keyframes loading-spin {
  to { transform: rotate(360deg); }
}
@keyframes app-open {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .loading-spinner, #content.is-opening { animation: none; }
}
.app-header .logo {
  width: 120px;
  height: 40px;
  object-fit: contain;
}
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 10px;
  border: 0;
  background: transparent;
  border-radius: 8px;
}
.icon-button:hover {
  background: var(--surface);
}
.hint-button {
  color: var(--muted);
  flex-shrink: 0;
}
.hint-button svg {
  width: 18px;
  height: 18px;
  color: inherit;
}
.hint-button:hover,
.hint-button[aria-expanded="true"] {
  color: #94cfff;
}
.title-with-help {
  display: flex;
  align-items: center;
  min-width: 0;
}
.account-access {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}
.account-access svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
}
svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  stroke-width: 1.8;
}
h1 {
  font-size: 28px;
  line-height: 1.2;
  margin: 0 0 18px;
  font-weight: 700;
}
h2 {
  font-size: 19px;
  line-height: 1.35;
  margin: 0;
  font-weight: 600;
}
p {
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
}
#pro-status {
  line-height: 1.5;
}
.is-active {
  color: var(--green);
}
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 44px;
  border: 0;
  background: transparent;
  font-size: 14px;
  padding: 8px;
  color: var(--muted);
}
.text-button svg {
  width: 18px;
}
.text-button:hover {
  color: var(--text);
}
label {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin: 18px 0 8px;
}
input {
  background: var(--surface);
  color: var(--text);
  border: 1px solid #72798a;
  border-radius: 8px;
  width: 100%;
  height: 50px;
  padding: 12px;
  font-size: 16px;
  min-width: 0;
}
input::placeholder {
  color: #969cae;
}
.code-field {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 16px;
}
#connect-form {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}
.code-digit {
  aspect-ratio: 1;
  height: auto;
  padding: 0;
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  border-color: #4c5363;
  border-radius: 6px;
  caret-color: var(--accent);
}
.code-digit:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: transparent;
  background: #20242e;
}
.code-digit[aria-invalid="true"] {
  border-color: #f17889;
  background: #23151c;
}
.code-help {
  display: flex;
  width: 100%;
  margin-top: 8px;
  gap: 8px;
}
.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  margin-top: 14px;
}
.primary:hover {
  background: #e9233d;
}
.device-section {
  margin-top: 32px;
}
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 16px;
}
#device-count {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}
.device-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 64px 44px;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  background: #12151b;
  border: 1px solid #222630;
  border-radius: 8px;
  min-height: 78px;
}
#device-list {
  display: grid;
  gap: 8px;
}
.device-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px;
  gap: 10px;
  margin-bottom: 12px;
}
.device-search {
  position: relative;
  min-width: 0;
}
.device-search > svg {
  position: absolute;
  left: 12px;
  top: 13px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}
.device-search input {
  height: 44px;
  padding-left: 38px;
  border-color: var(--line);
  border-radius: 6px;
}
.device-tools select {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}
.device-pages {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}
.device-pages > span {
  color: var(--muted);
  font-size: 13px;
}
.device-pages nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
#device-page-number {
  min-width: 52px;
  text-align: center;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.device-pages button:disabled {
  cursor: default;
}
@media (max-width: 600px), (min-width: 900px) and (max-width: 1099px) {
  .device-tools {
    grid-template-columns: minmax(0, 1fr);
  }
}
.device-state {
  text-align: right;
}
.device-row > .device-icon {
  color: #bec4d3;
  width: 26px;
}
.device-copy {
  flex: 1;
  min-width: 0;
}
.device-name {
  font-size: 16px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.device-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
  line-height: 1.45;
}
.device-state {
  color: var(--green);
  font-size: 12px;
  white-space: nowrap;
}
.device-state.inactive {
  color: var(--muted);
}
.device-row .icon-button {
  color: var(--muted);
}
.help-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 62px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 14px 0;
  text-align: left;
  font-size: 15px;
}
.help-row span {
  flex: 1;
  min-width: 0;
}
.help-row svg {
  color: #b3bacb;
}
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 640px;
  margin: auto;
  display: flex;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 8px max(12px, var(--safe-right))
    calc(10px + max(env(safe-area-inset-bottom), var(--safe-bottom)))
    max(12px, var(--safe-left));
  z-index: 3;
}
.bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  min-height: 54px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.bottom-nav button[aria-current="page"] {
  color: var(--accent);
}
.pro-summary {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  padding: 0 0 24px;
}
.pro-summary > svg {
  color: var(--accent);
  width: 36px;
  height: 36px;
  grid-row: span 2;
}
.pro-summary h2 {
  font-size: 28px;
}
.pro-summary p {
  margin: 4px 0 0;
  font-size: 14px;
}
.details {
  margin: 0 0 24px;
}
.details > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
dt {
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 140px;
}
dd {
  margin: 0;
  text-align: right;
}
.pro-benefits {
  list-style: none;
  padding: 0;
  margin: 28px 0 0;
  border-top: 1px solid var(--line);
}
.pro-benefits li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 44px;
  align-items: flex-start;
  gap: 16px;
  min-height: 94px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}
.pro-benefits li > div {
  flex: 1;
  min-width: 0;
}
.pro-benefits li > svg {
  width: 28px;
  height: 28px;
  color: #94cfff;
  margin-top: 2px;
}
.pro-benefits li:nth-child(2) > svg {
  color: var(--green);
}
.pro-benefits li:nth-child(3) > svg {
  color: #ffbf69;
}
.pro-benefits li:nth-child(4) > svg {
  color: #fd8295;
}
.pro-benefits h3 {
  font-size: 17px;
  line-height: 1.4;
  margin: 0;
  font-weight: 600;
}
.pro-benefits p {
  font-size: 14px;
  margin: 4px 0 0;
}
.pro-benefits .hint-button {
  margin-top: -8px;
}
.help-title {
  margin-top: 30px;
}
.support-link {
  margin-top: 28px;
}
.inline-feedback {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: #ffabb7;
  background: #271820;
  border: 1px solid #56303c;
  border-radius: 6px;
  padding: 10px 12px;
  margin: 12px 0;
  font-size: 14px;
  line-height: 1.5;
}
.inline-feedback [data-feedback-text] {
  min-width: 0;
  overflow-wrap: anywhere;
}
.inline-feedback svg {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  display: none;
}
.inline-feedback[data-kind="error"] [data-feedback-icon="error"],
.inline-feedback[data-kind="success"] [data-feedback-icon="success"],
.inline-feedback[data-kind="info"] [data-feedback-icon="info"] {
  display: block;
}
.inline-feedback[data-kind="success"] {
  color: #8de0ae;
  background: #14251d;
  border-color: #2c4d3a;
}
.inline-feedback[data-kind="info"] {
  color: #b3d8f6;
  background: #17232e;
  border-color: #334453;
}
#loading {
  color: var(--muted);
  padding: 48px 0;
}
.empty {
  padding: 20px 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}
dialog {
  width: calc(100% - 32px);
  max-width: 400px;
  max-height: calc(100dvh - 60px);
  overflow: auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}
dialog::backdrop {
  background: #000b;
}
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
#help-dialog {
  max-width: 440px;
}
#help-dialog-content p:first-child {
  margin-top: 16px;
}
#help-dialog-content p:last-child {
  margin-bottom: 0;
}
.hint-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-size: 14px;
  line-height: 1.5;
}
.hint-link svg {
  width: 18px;
  height: 18px;
}
.danger {
  border: 0;
  background: transparent;
  color: #ff8192;
  width: 100%;
  min-height: 44px;
  margin-top: 12px;
}
#cancel-delete {
  width: 100%;
  margin-top: 8px;
}
@media (min-width: 900px) {
  .app-shell {
    max-width: 1280px;
    padding: calc(32px + max(env(safe-area-inset-top), var(--safe-top)))
      calc(48px + max(env(safe-area-inset-right), var(--safe-right)))
      calc(112px + max(env(safe-area-inset-bottom), var(--safe-bottom)))
      calc(48px + max(env(safe-area-inset-left), var(--safe-left)));
  }
  .bottom-nav {
    max-width: none;
    justify-content: center;
    gap: 32px;
  }
  .bottom-nav button {
    flex: 0 1 180px;
    flex-direction: row;
    gap: 12px;
    font-size: 14px;
  }
  .app-header {
    margin-bottom: 40px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--line);
  }
  .account-access {
    font-size: 14px;
  }
  [data-view] {
    display: grid;
    grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.3fr);
    column-gap: 48px;
    align-items: start;
  }
  [data-view="devices"] {
    grid-template-areas: "connect devices";
  }
  #connect-form {
    grid-area: connect;
    margin: 0;
  }
  .device-section {
    grid-area: devices;
    margin-top: 0;
    min-width: 0;
  }
  .device-row {
    min-height: 88px;
    gap: 16px;
  }
  .device-meta,
  .device-state {
    font-size: 13px;
  }
  [data-view="subscription"] {
    align-items: stretch;
    grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.3fr);
  }
  .plan-overview {
    padding-right: 0;
  }
  .pro-benefits {
    margin: 0;
    padding-left: 0;
    border-left: 0;
    border-top: 0;
  }
  .pro-benefits li:first-child {
    padding-top: 0;
  }
  [data-view="help"] {
    grid-template-areas:
      "intro guides"
      "faq guides"
      "support guides";
    grid-template-rows: auto auto 1fr;
  }
  .help-intro {
    grid-area: intro;
  }
  .help-faq {
    grid-area: faq;
  }
  .help-guides {
    grid-area: guides;
    min-width: 0;
    padding-left: 0;
  }
  .help-title {
    margin: 0 0 16px;
  }
  .support-link {
    grid-area: support;
    margin-top: 20px;
  }
  #gate {
    max-width: 640px;
  }
}
@media (min-width: 900px) and (min-height: 501px) {
  body[data-telegram-layout="window"] .app-shell {
    width: calc(100% - 48px);
    max-width: 1040px;
    height: min(780px, calc(100dvh - 48px));
    min-height: 0;
    margin: 24px auto;
    padding: 24px 32px 0;
    display: flex;
    flex-direction: column;
  }
  body[data-telegram-layout="window"] .app-header {
    flex-shrink: 0;
    margin-bottom: 24px;
  }
  body[data-telegram-layout="window"] main {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 4px 4px 24px;
    scrollbar-gutter: stable;
  }
  body[data-telegram-layout="window"] .bottom-nav {
    position: static;
    flex-shrink: 0;
    width: 100%;
    margin: 0;
  }
  body[data-telegram-layout="window"] [data-view] {
    column-gap: 32px;
  }
}
@media (max-width: 359px) {
  .app-shell {
    padding-left: 16px;
    padding-right: 16px;
  }
  .device-row {
    gap: 8px;
  }
  .device-state {
    font-size: 11px;
  }
  .account-access {
    gap: 4px;
    font-size: 11px;
  }
  .account-access svg {
    display: none;
  }
  .device-row {
    padding-left: 8px;
    padding-right: 4px;
  }
  h1 {
    font-size: 26px;
  }
  dt {
    min-width: 128px;
  }
  .pro-benefits li {
    column-gap: 10px;
  }
}
@media (max-width: 600px) {
  .device-row {
    grid-template-columns: 24px minmax(0, 1fr) 44px;
    row-gap: 4px;
  }
  .device-row > .device-icon {
    grid-column: 1;
    grid-row: 1 / span 2;
  }
  .device-copy {
    grid-column: 2;
    grid-row: 1;
  }
  .device-row > .device-state {
    grid-column: 2;
    grid-row: 2;
    text-align: left;
  }
  .device-row > .icon-button {
    grid-column: 3;
    grid-row: 1 / span 2;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
@media (max-height: 500px) {
  .app-header {
    margin-bottom: 16px;
  }
  .bottom-nav {
    position: static;
    margin-top: 24px;
  }
  .app-shell {
    padding-bottom: 24px;
  }
}
