:root {
    --bg: #FBFBFC;
    --surface: #FFFFFF;
    --sunk: #F5F6F8;
    --ink: #101418;
    --muted: #5E6772;
    --faint: #6E747D;
    --line: #EAECEF;
    --line-2: #DFE2E7;
    --accent: #2E5BFF;
    --accent-ink: #1C3ED6;
    --accent-wash: #EFF2FF;
    --accent-edge: rgba(46, 91, 255, 0.18);
    --live: #0FA152;
    --live-ink: #0A7A3D;
    --danger: #C0392B;
    --danger-ink: #9C2B1F;
    --telegram-blue: #0088cc;
    --r: 14px;
    --r-lg: 20px;
    --sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--ink);
    font-weight: 400;
    line-height: 1.55;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 56px 16px 72px;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 460px;
    background: radial-gradient(900px 340px at 50% -130px, rgba(46, 91, 255, 0.10) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.login-container {
    position: relative;
    z-index: 1;
    text-align: center;
    width: 100%;
    max-width: 520px;
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-back {
    display: inline-block;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    margin-bottom: 26px;
    transition: color 0.15s;
}
.login-back:hover { color: var(--ink); }

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    margin: 0 auto 18px;
    color: var(--accent);
    background: var(--accent-wash);
    border: 1px solid var(--accent-edge);
    border-radius: 16px;
    box-shadow: 0 14px 30px -20px rgba(46, 91, 255, 0.9);
}

.eyebrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    margin: 0 auto 14px;
    gap: 9px;
    font-family: var(--mono);
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent-ink);
}
.eyebrow::before, .eyebrow::after {
    content: "";
    width: 22px;
    height: 1px;
    background: var(--accent);
    opacity: 0.7;
}

h1 {
    font-size: clamp(1.85rem, 4vw, 2.35rem);
    line-height: 1.06;
    font-weight: 800;
    letter-spacing: -0.035em;
    color: var(--ink);
    margin-bottom: 14px;
    text-wrap: balance;
}

.subtitle {
    color: var(--muted);
    font-size: 1.04rem;
    line-height: 1.55;
    margin: 0 auto 34px;
    max-width: 40ch;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-radius: var(--r-lg);
    padding: 32px 34px;
    text-align: left;
    box-shadow: 0 1px 2px rgba(16, 20, 24, 0.04), 0 30px 60px -34px rgba(16, 20, 24, 0.22);
}

.card-title {
    font-size: 1.16rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
    color: var(--ink);
}

.card-subtitle {
    color: var(--muted);
    font-size: 0.92rem;
    margin-bottom: 22px;
    line-height: 1.55;
}

/* Telegram Login Widget block */
.tg-widget-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 0 auto 18px;
    padding: 20px 16px;
    background: var(--sunk);
    border: 1px solid var(--line);
    border-radius: var(--r);
}

.tg-login-widget {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    width: 100%;
}

/* Telegram-issued iframe respects its own width — center it */
.tg-login-widget iframe {
    margin: 0 auto !important;
    display: block !important;
}

.tg-widget-hint {
    font-size: 0.78rem;
    color: var(--faint);
    line-height: 1.5;
    text-align: center;
}

.tg-widget-block .tg-widget-status { color: var(--muted); }
.tg-widget-block .tg-widget-status.is-error { color: var(--danger); }
.tg-widget-block .tg-widget-retry {
    background: var(--surface);
    border-color: var(--line-2);
    border-radius: 9px;
    color: var(--ink);
    font-weight: 600;
}
.tg-widget-block .tg-widget-retry:hover {
    border-color: var(--accent);
    color: var(--accent-ink);
}

/* Trust list */
.trust-list {
    list-style: none;
    margin: 0 0 20px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.trust-list li {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    background: var(--sunk);
    border: 1px solid var(--line);
    border-radius: var(--r);
    transition: border-color 0.15s, transform 0.12s ease, box-shadow 0.2s ease;
}

.trust-list li:hover {
    border-color: var(--line-2);
    transform: translateY(-1px);
    box-shadow: 0 14px 28px -24px rgba(16, 20, 24, 0.55);
}

.trust-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--accent);
    background: var(--surface);
    border: 1px solid var(--accent-edge);
    border-radius: 10px;
}
.trust-icon svg { width: 18px; height: 18px; }

.trust-title {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--ink);
    margin-bottom: 4px;
}

.trust-text {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.55;
}

.trust-yes {
    color: var(--live-ink);
    font-weight: 700;
}

.trust-no {
    color: var(--danger-ink);
    font-weight: 700;
    display: inline-block;
    margin-top: 2px;
}

/* Details */
.trust-details {
    margin: 0 0 20px;
    padding: 0;
    border-top: 1px solid var(--line);
}

.trust-details summary {
    cursor: pointer;
    padding: 14px 0 12px;
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--muted);
    list-style: none;
    user-select: none;
    transition: color 0.15s;
}
.trust-details summary::-webkit-details-marker { display: none; }
.trust-details summary::before {
    content: '▸';
    display: inline-block;
    margin-right: 8px;
    color: var(--accent);
    transition: transform 0.2s;
}
.trust-details[open] summary::before { transform: rotate(90deg); }
.trust-details summary:hover { color: var(--ink); }

.trust-details p {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: 10px;
}
.trust-details p:last-child { margin-bottom: 12px; }
.trust-details strong { color: var(--ink); font-weight: 700; }
.trust-details code {
    background: var(--sunk);
    border: 1px solid var(--line);
    padding: 1px 6px;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--accent-ink);
}
.trust-details a {
    color: var(--accent-ink);
    font-weight: 500;
    text-decoration: underline;
    text-decoration-color: rgba(46, 91, 255, 0.3);
    text-underline-offset: 2px;
}
.trust-details a:hover { text-decoration-color: var(--accent); }

/* Form */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 13px 15px;
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-radius: 11px;
    color: var(--ink);
    font-family: inherit;
    font-size: 1rem;
    letter-spacing: -0.01em;
    transition: border-color 0.15s, box-shadow 0.2s;
}

.form-group input::placeholder { color: var(--faint); }

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(46, 91, 255, 0.16);
}

.field-hint {
    font-size: 0.78rem;
    color: var(--faint);
    margin-top: 8px;
    line-height: 1.5;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 20px;
    border: 1px solid transparent;
    border-radius: 11px;
    font-family: inherit;
    font-size: 0.98rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 2px rgba(46, 91, 255, 0.28), 0 8px 24px -8px rgba(46, 91, 255, 0.5);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(46, 91, 255, 0.3), 0 14px 30px -8px rgba(46, 91, 255, 0.55);
}

.btn-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line-2);
    margin-top: 8px;
}

.btn-secondary:hover {
    border-color: var(--faint);
}

.btn:focus-visible, a:focus-visible, summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.error-msg {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 8px;
    min-height: 1.2em;
}

.info-text {
    color: var(--faint);
    font-size: 0.84rem;
    line-height: 1.6;
    text-align: center;
    margin-top: 16px;
}
.info-text a {
    color: var(--muted);
    text-decoration: underline;
    text-decoration-color: var(--line-2);
    text-underline-offset: 2px;
}
.info-text a:hover { color: var(--accent-ink); text-decoration-color: var(--accent); }

.step { display: none; }
.step.active { display: block; animation: stepIn 0.3s ease-out; }

@keyframes stepIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.back-link {
    color: var(--muted);
    font-size: 0.88rem;
    cursor: pointer;
    text-align: center;
    margin-top: 14px;
    transition: color 0.15s;
}
.back-link:hover { color: var(--accent-ink); }

/* Footer */
.card-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    align-items: center;
    text-align: center;
}

.lock-line {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 0.78rem;
}

.lock-icon {
    color: var(--live);
    flex-shrink: 0;
}

.github-line {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--faint);
    font-family: var(--mono);
    font-size: 0.74rem;
    letter-spacing: 0;
    text-decoration: none;
    transition: color 0.15s;
}
.github-line:hover { color: var(--accent-ink); }

@media (max-width: 560px) {
    body { padding: 32px 14px 56px; }
    .card { padding: 24px 20px; }
    .trust-list li { padding: 12px 14px; gap: 12px; }
    .trust-icon { width: 30px; height: 30px; }
    .trust-icon svg { width: 16px; height: 16px; }
    .subtitle { font-size: 0.97rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; }
}

/* Запасной выход с логин-стены: демо без входа */
.demo-escape {
  display: block;
  text-align: center;
  margin: 2px 0 20px;
  padding: 11px 14px;
  border: 1px dashed rgba(46, 91, 255, 0.45);
  border-radius: 11px;
  color: var(--accent-ink);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color .15s, background .15s;
}
.demo-escape:hover { border-color: var(--accent); background: var(--accent-wash); }
