:root {
  color-scheme: light dark;
  --background: #ffffff;
  --foreground: #18191b;
  --muted: #62666b;
  --telegram: #007ab8;
  --telegram-hover: #006ba3;
  --focus: #007ab8;
  --border: #dedfe1;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--background);
  color: var(--foreground);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
}

::selection { background: #c5e7fa; color: #102b3b; }

.channel-landing {
  display: grid;
  grid-template-rows: 1fr auto;
}

.channel-main {
  display: grid;
  grid-auto-rows: 1fr;
}

.channel-panel {
  --panel-padding: 18px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: var(--panel-padding) max(24px, env(safe-area-inset-right)) var(--panel-padding) max(24px, env(safe-area-inset-left));
  text-align: center;
}

.channel-panel:first-of-type { padding-top: max(var(--panel-padding), env(safe-area-inset-top)); }

.channel-panel--tokenosfera {
  --foreground: #f2f3f5;
  --muted: #b2b8b0;
  --focus: #72eb59;
  border-block-start: 1px solid var(--border);
  background: #000;
  color: var(--foreground);
}

.channel-logo {
  display: block;
  width: 80px;
  width: clamp(64px, 12svh, 112px);
  height: auto;
  filter: invert(1);
  mix-blend-mode: multiply;
  user-select: none;
}

.channel-panel--tokenosfera .channel-logo { filter: none; mix-blend-mode: normal; }

.channel-title {
  margin: 0;
  font-size: clamp(27px, 5vw, 48px);
  line-height: 1.1;
  letter-spacing: -.035em;
}

.channel-description {
  max-width: 34ch;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
  text-wrap: pretty;
}

.channel-description strong { color: var(--foreground); font-weight: 600; }

.nickname-copy { display: none; }

.telegram-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(100%, 280px);
  min-height: 48px;
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--telegram);
  color: #ffffff;
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
  text-align: center;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background-color 160ms ease, transform 160ms cubic-bezier(.2, .8, .2, 1);
}

.telegram-button img { flex: 0 0 24px; }
.telegram-label-short { display: none; }

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 5px;
}

.telegram-button:active {
  background: var(--telegram-hover);
  transform: translateY(1px) scale(.985);
}

.telegram-help {
  max-width: 38ch;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.telegram-help[hidden],
.browser-hint[hidden] { display: none; }

.help-title { margin: 0 0 8px; }
.browser-hint { margin: 0 0 12px; text-wrap: pretty; }
.help-links { display: flex; flex-wrap: wrap; justify-content: center; column-gap: 20px; }
.help-links a { display: inline-flex; align-items: center; min-height: 44px; color: var(--foreground); text-underline-offset: 4px; text-decoration-thickness: 1px; }

.copy-link {
  min-height: 44px;
  padding: 8px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
  touch-action: manipulation;
}

.copy-status { margin: 0; overflow-wrap: anywhere; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.channel-footer {
  display: grid;
  justify-items: center;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--border);
}

.channel-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--muted);
  font-size: 13px;
  text-underline-offset: 4px;
}

.privacy-page { max-width: 680px; margin: 0 auto; padding: 64px 24px; line-height: 1.7; }
.privacy-page h1 { margin: 24px 0; font-size: clamp(28px, 5vw, 36px); line-height: 1.2; }
.privacy-page p { color: var(--muted); }
.privacy-page a { color: var(--foreground); text-underline-offset: 4px; }

@media (max-width: 719px) and (max-height: 650px) {
  .channel-panel { --panel-padding: 12px; gap: 8px; }
  .channel-description { font-size: 15px; }
}

@media (min-width: 720px), (min-width: 600px) and (orientation: landscape) {
  .channel-main {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: 1fr repeat(5, auto) 1fr;
    grid-auto-rows: auto;
    reading-flow: grid-rows;
  }

  .channel-panel {
    --panel-padding: 24px;
    grid-row: 1 / -1;
    grid-template-rows: subgrid;
    align-items: start;
    row-gap: 14px;
    padding-top: max(var(--panel-padding), env(safe-area-inset-top));
  }

  .channel-panel--tokenosfera {
    grid-column: 2;
    border-block-start: 0;
    border-inline-start: 1px solid var(--border);
  }

  .channel-panel--hlibshe { grid-column: 1; }

  .channel-logo { grid-row: 2; }
  .channel-title { grid-row: 3; }
  .channel-description { grid-row: 4; }
  .telegram-button { grid-row: 5; }
  .telegram-help { grid-row: 6; }
}

@media (min-width: 600px) and (max-height: 450px) and (orientation: landscape) {
  .channel-panel { --panel-padding: 16px; row-gap: 8px; }
}

@media (max-width: 599px),
       (max-width: 719px) and (orientation: portrait),
       (max-width: 950px) and (max-height: 520px) and (orientation: landscape) and (pointer: coarse) {
  .channel-main {
    grid-template: 1fr auto / minmax(0, 1fr);
    grid-auto-rows: auto;
  }

  .channel-panel {
    grid-area: auto;
    grid-template-rows: none;
  }

  .channel-panel > * { grid-row: auto; }

  .channel-panel--tokenosfera {
    --panel-padding: 18px;
    gap: 10px;
    border: 0;
  }

  .channel-panel--tokenosfera .channel-logo {
    width: clamp(84px, 26svh, 212px);
    margin-block: -12px;
  }

  .channel-panel--tokenosfera .channel-title { font-size: clamp(30px, 8vw, 44px); }
  .channel-panel--tokenosfera .telegram-button { margin-top: 6px; }

  .channel-nickname {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px 12px;
  }

  .nickname-copy:not([hidden]) {
    display: inline-block;
    min-width: 108px;
    min-height: 44px;
    padding: 6px 10px;
    border: 1px solid #565656;
    border-radius: 8px;
    background: transparent;
    color: var(--foreground);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    touch-action: manipulation;
  }

  .nickname-copy:active { background: #242424; }

  .channel-panel--hlibshe {
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
    border-block-start: 1px solid var(--border);
    text-align: start;
  }

  .channel-panel--hlibshe .channel-logo { width: 40px; }

  .channel-panel--hlibshe .channel-title {
    justify-self: start;
    font-size: 18px;
    letter-spacing: -.02em;
  }

  .channel-panel--hlibshe .channel-description,
  .channel-panel--hlibshe .telegram-button img,
  .telegram-label-full { display: none; }

  .telegram-label-short { display: inline; }

  .channel-panel--hlibshe .telegram-button {
    --telegram: var(--background);
    --telegram-hover: var(--background);
    width: auto;
    min-height: 44px;
    padding: 8px 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--foreground);
    font-size: 14px;
    line-height: 20px;
  }

  .channel-panel--hlibshe .telegram-help { grid-column: 1 / -1; }
}

@media (max-width: 950px) and (max-height: 420px) and (orientation: landscape) and (pointer: coarse) {
  .channel-panel--tokenosfera { gap: 6px; }
}

@media (hover: hover) and (pointer: fine) {
  .telegram-button:hover { background: var(--telegram-hover); transform: translateY(-1px); }
  .telegram-button:active { transform: translateY(1px) scale(.985); }
  .help-links a:hover, .copy-link:hover, .channel-footer a:hover { color: var(--foreground); }
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #0e0e0f;
    --foreground: #f2f3f5;
    --muted: #a1a4a9;
    --focus: #66bdf0;
    --border: #34363a;
  }
  .channel-logo { filter: none; mix-blend-mode: screen; }
  ::selection { background: #174c69; color: #ffffff; }
}

@media (prefers-reduced-motion: reduce) {
  .telegram-button { transition: none; }
  .telegram-button:is(:hover, :active) { transform: none; }
}

@media (forced-colors: active) {
  .channel-logo { filter: none; mix-blend-mode: normal; }
  .telegram-button { border: 2px solid ButtonText; }
}
