/* -----------------------------------------
   CryptoPizza — Theme tokens (dark default + light)
----------------------------------------- */
:root, [data-theme="dark"] {
    --bg-grad: radial-gradient(circle at 10% 20%, #0a0f1a, #05070c);
    --surface: rgba(18, 22, 32, 0.7);
    --surface-2: rgba(255, 255, 255, 0.03);
    --text: #eef2ff;
    --text-muted: #b0c4de;
    --text-faint: #7e8b9c;
    --border-accent: rgba(255, 152, 0, 0.2);
    --border-accent-strong: rgba(255, 152, 0, 0.5);
    --accent: #ff9800;
    --accent-2: #FFD966;
    --on-accent: #0a0f1a;
    --input-bg: rgba(0, 0, 0, 0.6);
    --shadow: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
    --bg-grad: radial-gradient(circle at 10% 20%, #f6f8fc, #e9eef6);
    --surface: rgba(255, 255, 255, 0.9);
    --surface-2: rgba(0, 0, 0, 0.03);
    --text: #1a2230;
    --text-muted: #44546a;
    --text-faint: #6b7a90;
    --border-accent: rgba(230, 137, 0, 0.35);
    --border-accent-strong: rgba(230, 137, 0, 0.6);
    --accent: #e8820a;
    --accent-2: #c9710a;
    --on-accent: #ffffff;
    --input-bg: rgba(0, 0, 0, 0.05);
    --shadow: rgba(120, 130, 150, 0.25);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-grad);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.5;
    scroll-behavior: smooth;
    transition: background 0.3s, color 0.3s;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px 24px;
}

/* Header — карточка */
header {
    background: var(--surface);
    backdrop-filter: blur(8px);
    border-radius: 28px;
    border: 1px solid var(--border-accent);
    padding: 10px 28px;
    margin-bottom: 32px;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header:hover {
    border-color: var(--border-accent-strong);
    box-shadow: 0 12px 28px var(--shadow);
}

/* Логотип: значок и текст */
h1 a {
    display: flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo-text {
    background: linear-gradient(135deg, #FFD966, #FF8C00);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Эмодзи пиццы */
.pizza-emoji {
    font-size: inherit;
    display: inline-block;
    color: #FFD966;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-right a, .user-email {
    text-decoration: none;
    font-weight: 500;
    transition: 0.2s;
}

.login-link {
    color: #ff9800;
    background: transparent;
    padding: 8px 20px;
    border-radius: 40px;
    border: 1px solid #ff9800;
    height: 42px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
}

.login-link:hover {
    background: #ff9800;
    color: #0a0f1a;
    border-color: #ff9800;
}

.register-link {
    color: #0a0f1a;
    background: #ff9800;
    padding: 8px 20px;
    border-radius: 40px;
    border: 1px solid transparent;
    font-weight: 600;
    height: 42px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
}

.register-link:hover {
    background: #e68900;
    color: #0a0f1a;
}

.logout-btn {
    color: #ffaa66;
}

.lang-switch select {
    background: var(--input-bg);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 40px;
    padding: 8px 20px;
    cursor: pointer;
    font-size: inherit;
    font-weight: 500;
    transition: 0.2s;
    -webkit-appearance: none;
    appearance: none;
    line-height: 1.4;
    height: 42px;
    box-sizing: border-box;
}

.lang-switch select:hover {
    background: #ff9800;
    color: #0a0f1a;
}

.sound-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.4rem;
    transition: 0.2s;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
}

.sound-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Cards */
.card {
    background: var(--surface);
    backdrop-filter: blur(8px);
    border-radius: 28px;
    border: 1px solid var(--border-accent);
    padding: 32px;
    margin-bottom: 36px;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.card:hover {
    border-color: var(--border-accent-strong);
    box-shadow: 0 12px 28px var(--shadow);
}

/* Buttons */
.btn-primary {
    background: linear-gradient(90deg, #ff9800 0%, #ffc107 100%);
    color: #0a0f1a;
    border: none;
    padding: 12px 32px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 44px;
    display: inline-block;
    text-decoration: none;
    transition: 0.3s;
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}

.btn-secondary,
.btn-tertiary {
    display: inline-block;
    width: 100%;
    padding: 12px 32px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 44px;
    text-decoration: none;
    text-align: center;
    transition: 0.3s;
    border: 1px solid rgba(255, 152, 0, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.btn-secondary:hover,
.btn-tertiary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 152, 0, 0.2);
}

.btn-tertiary {
    background: transparent;
    color: #fff;
}

/* Hero section */
.hero {
    background: var(--surface);
    backdrop-filter: blur(8px);
    border-radius: 28px;
    border: 1px solid var(--border-accent);
    text-align: center;
    padding: 60px 20px;
    margin-bottom: 36px;
}

.hero h2 {
    font-size: 3.2rem;
    font-weight: 800;
    margin-bottom: 20px;
    background: linear-gradient(120deg, #ffffff, #ffb347);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero p {
    font-size: 1.2rem;
    color: var(--text-muted);
    max-width: 700px;
    margin: 0 auto 32px;
}

/* Features grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 28px;
    margin: 32px 0 16px;
}

.feature-card {
    background: var(--surface-2);
    border-radius: 24px;
    padding: 28px 20px;
    text-align: center;
    transition: 0.2s;
    border: 1px solid var(--border-accent);
}

.feature-card:hover {
    background: rgba(255, 152, 0, 0.05);
    border-color: #ff9800;
    transform: translateY(-4px);
}

.feature-card h3 {
    font-size: 1.6rem;
    margin: 16px 0 8px;
    color: #ffb347;
}

.feature-icon {
    font-size: 2.2rem;
    margin-bottom: 12px;
}

/* How it works */
.how-it-works {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 28px;
    margin: 32px 0;
}

.step {
    flex: 1 1 calc(33.333% - 19px);
    min-width: 220px;
    background: var(--surface-2);
    border-radius: 24px;
    padding: 28px;
    text-align: center;
    border: 1px solid var(--border-accent);
    transition: all 0.2s ease;
}

.step:hover {
    background: rgba(255, 152, 0, 0.08);
    border-color: #ff9800;
    transform: translateY(-4px);
}

.step strong {
    font-size: 1.4rem;
    color: #ff9800;
    display: block;
    margin-bottom: 12px;
}

.step span {
    white-space: pre-line;
}

/* Footer */
.footer {
    text-align: center;
    padding: 32px;
    color: var(--text-faint);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-accent);
    margin-top: 48px;
}

.footer a {
    color: #ffaa66;
    text-decoration: none;
}

/* Responsive */
@media (max-width: 768px) {
    .container { padding: 16px; }
    .hero h2 { font-size: 2rem; }
    .how-it-works { flex-direction: column; }
    .step { margin-bottom: 16px; }
    .feature-card, .step { padding: 20px; }
    .feature-icon { font-size: 1.8rem; }

    /* Header — адаптив: каждый элемент в своей строке */
    header {
        flex-direction: column;
        gap: 10px;
        padding: 12px 16px;
        border-radius: 20px;
    }
    .header-left { width: 100%; text-align: center; }
    .header-left h1 { margin: 0; }
    .header-left a { justify-content: center; }
    .header-right {
        width: 100%;
        max-width: calc(100vw - 96px);
        margin: 0 auto;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .lang-switch { width: 100%; }
    .header-right a, .lang-switch select,
    .login-link, .register-link {
        display: block;
        text-align: center;
        width: 100% !important;
        font-size: 0.9rem !important;
        padding: 12px 16px !important;
        box-sizing: border-box !important;
        margin: 0;
        line-height: 1.4;
        border-radius: 40px;
        font-weight: 500;
        height: auto;
    }
    .lang-switch select {
        border: 1px solid #ff9800;
        background: rgba(0,0,0,0.6);
        color: #ff9800;
    }
    .sound-btn { margin: 0 auto; }
    h1 a { font-size: 1.5rem; }

    /* Таблицы — горизонтальный скролл */
    table, .table-wrap { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100vw; }
}

@media (max-width: 480px) {
    header { padding: 10px; border-radius: 16px; gap: 8px; }
    .header-right { gap: 10px; max-width: calc(100vw - 96px); }
    .header-right a, .lang-switch select,
    .login-link, .register-link { font-size: 0.85rem !important; width: 100% !important; padding: 10px 12px !important; }
    h1 a { font-size: 1.3rem; }
}

/* Login/Register cards */
.centered-login {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 70vh;
}

/* Анимация появления */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-card {
    background: var(--surface);
    backdrop-filter: blur(8px);
    border-radius: 28px;
    border: 1px solid var(--border-accent-strong);
    padding: 40px;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
}

.login-card h2 {
    text-align: center;
    margin-bottom: 24px;
    color: #ffb347;
}

.login-card .form-group {
    margin-bottom: 20px;
}

.login-card label {
    display: block;
    margin-bottom: 8px;
    color: #ffb347;
}

.login-card input {
    width: 100%;
    padding: 12px;
    background: var(--input-bg);
    border: 1px solid var(--border-accent);
    border-radius: 12px;
    color: var(--text);
}

.login-card input:focus {
    outline: none;
    border-color: #ff9800;
}

.login-card button {
    width: 100%;
    margin-top: 10px;
}

.register-link-bottom {
    text-align: center;
    margin-top: 24px;
}

.register-link-bottom a {
    color: #ff9800;
    text-decoration: none;
}

/* Simple header for login/register pages */
.simple-header {
    text-align: center;
    margin: 20px 0 40px;
}

.logo-link {
    font-size: 2rem;
    font-weight: 800;
    text-decoration: none;
    background: linear-gradient(135deg, #ffffff, #ffb347);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -0.5px;
}

/* Перенос длинных ссылок и текста в блоке последней сводки */
#digest-content pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 12px;
}

/* Автоматический перенос длинных ссылок в блоке последней сводки */
#digest-content {
    word-wrap: break-word;      /* Перенос длинных слов */
    overflow-wrap: break-word;  /* Современный стандарт */
    white-space: normal;        /* Обычный перенос строк */
}

/* Принудительный перенос длинных ссылок в дайджесте */
#digest-content,
#digest-content * {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-all;
    max-width: 100%;
}

/* Увеличение заголовков блоков и отступов */
.card h4 {
    font-size: 1.4rem;
    margin-bottom: 20px;
    margin-top: 0;
    color: #ffb347;
}

/* Дополнительный отступ перед первым заголовком в карточке профиля */
.card h4:first-of-type {
    margin-top: 0;
}

/* Стиль для заголовков Welcome и Latest Digest */
.card h2, .card h3 {
    font-size: 1.4rem;
    margin-bottom: 20px;
    color: #ffb347;
    font-weight: 600;
}

/* Убираем лишний отступ сверху у первого элемента в карточке */
.card h2:first-child, .card h3:first-child {
    margin-top: 0;
}

/* Стили для кнопок на странице привязки Telegram */
.telegram-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}
.telegram-buttons .btn-primary,
.telegram-buttons .btn-secondary {
    width: 100%;
    text-align: center;
    margin: 0;
}

/* -----------------------------------------
   Светлая тема: правки, которые нельзя свести к переменным
   (градиентные заголовки с белым цветом стали бы невидимы на светлом фоне)
----------------------------------------- */
[data-theme="light"] .hero h2,
[data-theme="light"] .logo-link {
    background: linear-gradient(120deg, #e8820a, #b85c00);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
[data-theme="light"] .btn-secondary,
[data-theme="light"] .btn-tertiary {
    color: var(--text);
    background: rgba(0, 0, 0, 0.06);
}
/* Светло-оранжевый текст заголовков → чуть темнее для контраста на светлом фоне */
[data-theme="light"] .feature-card h3,
[data-theme="light"] .step strong,
[data-theme="light"] .login-card h2,
[data-theme="light"] .login-card label,
[data-theme="light"] .card h4,
[data-theme="light"] .card h2,
[data-theme="light"] .card h3 {
    color: #c9710a;
}

/* -----------------------------------------
   Темизируемые компоненты (вместо хардкод inline-стилей)
----------------------------------------- */
/* Баннер триала/уведомления */
.trial-banner {
    background: var(--surface-2);
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 15px 20px;
    margin-bottom: 20px;
    text-align: center;
}
.trial-banner .muted { color: var(--text-muted); }

/* Лента дайджестов */
.digest-item {
    position: relative;
    background: var(--surface-2);
    border-left: 3px solid var(--accent);
    padding: 12px 15px 30px 15px;
    margin-top: 20px;
    border-radius: 0 8px 8px 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: hidden;
}
.digest-item .digest-time {
    position: absolute;
    bottom: 6px;
    right: 12px;
    opacity: 0.5;
}
/* Ссылки внутри дайджестов — бренд-акцент на обеих темах (вместо синих по умолчанию) */
.digest-item a { color: var(--accent); }

/* Светлая тема: приподнимаем карточки тенью — иначе сливаются с почти-белым фоном */
[data-theme="light"] .card,
[data-theme="light"] header,
[data-theme="light"] .hero,
[data-theme="light"] .login-card,
[data-theme="light"] .feature-card,
[data-theme="light"] .step {
    box-shadow: 0 2px 12px rgba(120, 130, 150, 0.14);
}

/* Поля форм — единый стиль под обе темы */
.card input[type="text"],
.card input[type="email"],
.card input[type="password"],
.card input[type="number"],
.card select,
.card textarea {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border-accent);
    border-radius: 10px;
    padding: 10px 12px;
}
.card input:focus,
.card select:focus,
.card textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* Таблицы (рейтинги/точность) */
table { color: var(--text); border-collapse: collapse; }
th { color: var(--accent); }
td, th { border-bottom: 1px solid var(--border-accent); padding: 8px 10px; }

.muted { color: var(--text-muted); }

/* Семантические цвета точности (hit-rate) — читаемы на обеих темах */
.hit-good { color: #1f9d57; font-weight: 600; }
.hit-mid  { color: #c79100; font-weight: 600; }
.hit-bad  { color: #e0463a; font-weight: 600; }
[data-theme="light"] .hit-good { color: #1b7a43; }
[data-theme="light"] .hit-mid  { color: #9a6a00; }
[data-theme="light"] .hit-bad  { color: #c62828; }
