:root {
  --ch-ground: #0d0d0d;
  --ch-surface: #17181c;
  --ch-card: #25262d;
  --ch-text: #ffffff;
  --ch-muted: #ffffffa3;
  --ch-desc: #ffffff8c;
  --ch-pattern-1: rgba(80, 91, 199, 0.3);
  --ch-pattern-2: rgba(80, 91, 199, 0.3);
  --ch-btn: radial-gradient(
    136.12% 140.74% at 99.77% 99.04%,
    #8d28c8 0%,
    #7c42fa 20%,
    #007aff 80%,
    #609ceb 100%
  );
  --font-roboto: roboto, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

html,
body.channel-body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-roboto);
  color: var(--ch-text);
  background: var(--ch-ground) !important;
  overflow-x: hidden;
  overflow-y: auto !important;
  width: 100% !important;
}

.channel-app {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 68px 1fr;
  background: var(--ch-ground);
}

.channel-header {
  z-index: 3;
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: var(--ch-surface);
  border-bottom: 1px solid #ffffff12;
}

.channel-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ch-text);
}

.channel-logo__icon {
  width: 32px;
  height: 32px;
  background: url('auth-logo.png') center/contain no-repeat;
}

.channel-logo__text {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.channel-content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}

.channel-pattern {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(28deg, var(--ch-pattern-1) 8.03%, var(--ch-pattern-2) 91.51%);
  -webkit-mask-image: url('space.svg');
  mask-image: url('space.svg');
  -webkit-mask-repeat: repeat;
  mask-repeat: repeat;
}

.channel-main {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 40px;
}

.channel-card {
  width: min(440px, 100%);
  background: var(--ch-card);
  border-radius: 24px;
  border: 1px solid #ffffff14;
  box-shadow: 0 12px 40px #00000055;
  overflow: hidden;
  transition: width .35s cubic-bezier(.22, 1, .36, 1), box-shadow .35s ease;
}

.channel-card--auth {
  width: min(460px, 100%);
  box-shadow: 0 16px 48px #00000066;
}

.channel-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 36px 28px 0;
  gap: 0;
  transition: padding .38s cubic-bezier(.22, 1, .36, 1), flex-direction .38s cubic-bezier(.22, 1, .36, 1), align-items .38s cubic-bezier(.22, 1, .36, 1), border-color .3s;
}

.channel-card--compact .channel-identity {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #ffffff10;
  text-align: left;
}

.channel-identity__text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  transition: transform .38s cubic-bezier(.22, 1, .36, 1);
}

.channel-card--compact .channel-identity__text {
  flex: 1;
  align-items: flex-start;
  gap: 0;
}

.channel-identity__name {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.channel-card--compact .channel-identity__name {
  align-items: flex-start;
}

.channel-card__stack {
  position: relative;
}

.card-view {
  position: relative;
  padding: 24px 28px 28px;
  text-align: center;
  animation: card-view-in .34s cubic-bezier(.22, 1, .36, 1);
}

.card-view.hidden {
  display: none;
}

@keyframes card-view-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.channel-avatar {
  width: 120px;
  height: 120px;
  margin: 0 0 20px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid #ffffff14;
  box-shadow: 0 4px 20px #00000045;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  transition: width .38s cubic-bezier(.22, 1, .36, 1), height .38s cubic-bezier(.22, 1, .36, 1), margin .38s cubic-bezier(.22, 1, .36, 1), box-shadow .38s ease;
}

.channel-avatar--placeholder {
  background-color: #000;
}

.channel-card--compact .channel-avatar {
  width: 44px;
  height: 44px;
  margin: 0;
  box-shadow: 0 2px 10px #00000055;
}

.channel-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  transition: font-size .38s cubic-bezier(.22, 1, .36, 1);
}

.channel-card--compact .channel-title {
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-username {
  margin: 0;
  font-size: 13px;
  font-weight: 400;
  line-height: 16px;
  color: rgba(255, 255, 255, 0.52);
}

.channel-card--compact .channel-username {
  display: none;
}

.channel-desc {
  margin: 0 auto;
  max-width: 340px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ch-desc);
  font-weight: 400;
  max-height: 120px;
  opacity: 1;
  overflow: hidden;
  transition: max-height .32s ease, opacity .28s ease, margin .32s ease;
}

.channel-card--compact .channel-desc {
  max-height: 0;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}

#viewChannel.card-view {
  padding: 16px 28px 28px;
}

#viewChannel .channel-join {
  margin-top: 0;
}

.channel-card--compact .card-view {
  padding-top: 16px;
}

.card-heading {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.card-sub {
  margin: 10px auto 0;
  max-width: 300px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ch-muted);
}

.channel-join {
  margin-top: 28px;
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 15px 20px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  background: var(--ch-btn);
  box-shadow: 0 8px 24px #007aff35;
  transition: transform .15s, box-shadow .15s;
}

.channel-join:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px #007aff45;
}

.gate-icon {
  width: 64px;
  height: 64px;
  margin: 4px auto 14px;
  border-radius: 18px;
  overflow: hidden;
  flex-shrink: 0;
}

.gate-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 18px;
}

.auth-shell-mini {
  padding-top: 12px;
}

.auth-shell-mini .stage-info {
  width: 100%;
  max-width: 100%;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.auth-shell-mini .stage-info h1 {
  width: 100%;
  margin: 0;
  padding: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0;
  text-align: left;
}

.auth-shell-mini .stage-info p {
  width: 100%;
  margin: 8px 0 0;
  padding: 0;
  font-size: 13px;
  line-height: 1.4;
  letter-spacing: 0;
  color: var(--ch-muted);
  text-align: left;
}

.auth-shell-mini .primary-button {
  width: 100%;
  margin-top: 16px;
}

/* Auth fields inside channel card */
.channel-card .auth-shell-mini {
  width: 100%;
  max-width: 100%;
  padding-top: 4px;
}

/* Override auth.css fixed widths (326px / 358px + padding) — they skew titles */
.channel-card .auth-shell-mini .phone-info,
.channel-card .auth-shell-mini .code-info,
.channel-card .auth-shell-mini .password-info,
.channel-card .auth-shell-mini .success-info,
.channel-card .auth-shell-mini .stage-info {
  width: 100% !important;
  max-width: 100% !important;
  padding: 0 !important;
  margin-bottom: 18px;
}

.channel-card .auth-shell-mini .phone-info p,
.channel-card .auth-shell-mini .code-info p {
  margin-top: 8px !important;
}

.channel-card .auth-shell-mini .stage-info h1 {
  font-size: 17px;
}

.channel-card .auth-shell-mini .code-phone {
  font-weight: 500;
  color: #ffffffc8;
}

.channel-card .phone-control-wrap {
  width: 100%;
}

.channel-card .phone-control {
  width: 100%;
  height: 54px;
  padding: 0 14px 0 8px;
  gap: 0;
  border-radius: 14px;
  background: #ffffff10;
  border: 1px solid #ffffff14;
  align-items: center;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

.channel-card .phone-control:focus-within {
  background: #ffffff14;
  border-color: #007aff55;
  box-shadow: 0 0 0 3px #007aff22;
}

.channel-card .country-trigger {
  height: 100%;
  padding: 0 12px 0 4px;
  margin-right: 10px;
  border-right: 1px solid #ffffff18;
  gap: 6px;
}

.channel-card .country-trigger span {
  font-size: 16px;
  font-weight: 500;
}

.channel-card .phone-control > input {
  height: 100%;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.channel-card .phone-error,
.channel-card .code-error {
  margin: 8px 0 0;
  text-align: center;
  font-size: 13px;
  line-height: 1.35;
  min-height: 0;
}

.channel-card .code-form {
  width: 100%;
  margin: 0;
}

.channel-card .code-control {
  width: 100%;
  max-width: none;
  height: auto;
  margin-top: 0;
  gap: 8px;
  justify-content: center;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.channel-card .code-cell {
  width: 100%;
  min-width: 0;
  max-width: none;
  height: 52px;
  border-radius: 12px;
  background: #ffffff10;
  border: 1px solid #ffffff12;
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
  padding: 0;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

.channel-card .code-cell:focus {
  outline: none;
  border-color: #007aff;
  background: #ffffff14;
  box-shadow: 0 0 0 3px #007aff28;
}

.channel-card .code-cell.code-cell--error {
  border-color: #ce4257;
  background: #ce425718;
}

.channel-card .password-control {
  width: 100%;
  height: 54px;
  border-radius: 14px;
  background: #ffffff10;
  border: 1px solid #ffffff14;
  padding: 0 8px 0 14px;
  display: flex;
  align-items: center;
}

.channel-card .password-control > input {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: transparent;
  border: 0;
  outline: 0;
  color: #fff;
  font-size: 16px;
}

.channel-card .password-control:focus-within {
  border-color: #007aff55;
  box-shadow: 0 0 0 3px #007aff22;
}

.channel-card .password-toggle {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 16px;
  line-height: 1;
}

.channel-card .primary-button {
  width: 100%;
  height: 52px;
  margin-top: 20px;
  border: 0;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  background: var(--ch-btn);
  box-shadow: 0 6px 20px #007aff30;
  transition: transform .15s, opacity .15s, box-shadow .15s;
}

.channel-card .primary-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px #007aff40;
}

.channel-card .primary-button:disabled {
  opacity: 0.42;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.hidden { display: none !important; }
