:root {
    /* Фоны */
    --bg-primary: #0F172A;
    --bg-surface: #1E293B;
    --bg-code: #0B1120;
    --bg-elevated: #334155;

    /* Текст */
    --text-primary: #E2E8F0;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;

    /* Акценты */
    --accent-primary: #2DD4BF;
    --accent-hover: #14B8A6;
    --accent-light: #5EEAD4;

    /* Статусы */
    --success: #34D399;
    --success-bg: rgba(52, 211, 153, 0.15);
    --error: #FB7185;
    --error-bg: rgba(251, 113, 133, 0.15);
    --warning: #FBBF24;
    --warning-bg: rgba(251, 191, 36, 0.15);
    --info: #60A5FA;
    --info-bg: rgba(96, 165, 250, 0.15);

    /* Границы */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(45, 212, 191, 0.5);
    --divider: rgba(255, 255, 255, 0.05);

    /* Сложность */
    --difficulty-easy: #34D399;
    --difficulty-easy-bg: rgba(52, 211, 153, 0.15);
    --difficulty-easy-border: rgba(52, 211, 153, 0.3);
    --difficulty-medium: #FBBF24;
    --difficulty-medium-bg: rgba(251, 191, 36, 0.15);
    --difficulty-medium-border: rgba(251, 191, 36, 0.3);
    --difficulty-hard: #FB7185;
    --difficulty-hard-bg: rgba(251, 113, 133, 0.15);
    --difficulty-hard-border: rgba(251, 113, 133, 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 24px;
    line-height: 1.6;
}

/* ---------- Контейнеры ---------- */
.container {
    background: var(--bg-surface);
    padding: 32px;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    max-width: 720px;
    margin: 40px auto;
}

.container-wide {
    max-width: 960px;
}

/* ---------- Типографика ---------- */
h1 {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

h2 {
    font-size: 18px;
    margin: 24px 0 16px;
    color: var(--text-secondary);
}

p { margin: 8px 0; }

a {
    color: var(--accent-primary);
    text-decoration: none;
}

a:hover {
    color: var(--accent-light);
    text-decoration: underline;
}

/* ---------- Формы ---------- */
input, textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    background: var(--bg-code);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    font-size: 15px;
    color: var(--text-primary);
    font-family: inherit;
}

input:focus, textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
    outline: none;
}

input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

/* ---------- Кнопки ---------- */
button {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--accent-primary);
    color: var(--bg-primary);
    width: 100%;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* ---------- Сообщения ---------- */
.error {
    color: var(--error);
    background: var(--error-bg);
    padding: 10px 14px;
    border-radius: 6px;
    margin-top: 12px;
    min-height: 20px;
}

.success {
    color: var(--success);
    background: var(--success-bg);
    padding: 10px 14px;
    border-radius: 6px;
    margin-top: 12px;
}

.info {
    color: var(--info);
    background: var(--info-bg);
    padding: 10px 14px;
    border-radius: 6px;
    margin-top: 12px;
}

.hint {
    margin-top: 24px;
    padding: 12px;
    background: var(--bg-code);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ---------- Профиль ---------- */
#profile p { margin: 8px 0; }

#subscriptions {
    list-style: none;
    margin-bottom: 24px;
}

#subscriptions li {
    padding: 12px;
    background: var(--bg-code);
    border-radius: 6px;
    margin-bottom: 8px;
    border-left: 3px solid var(--success);
}

/* ---------- Список задач ---------- */
.task-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.task-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 16px 20px;
    display: block;
    color: var(--text-primary);
    transition: border-color 0.15s, transform 0.1s;
    cursor: pointer;
}

.task-card:hover {
    border-color: var(--accent-primary);
    text-decoration: none;
    transform: translateY(-1px);
}

.task-card.easy { border-left: 3px solid var(--difficulty-easy); }
.task-card.medium { border-left: 3px solid var(--difficulty-medium); }
.task-card.hard { border-left: 3px solid var(--difficulty-hard); }

.task-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.task-card-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
}

.task-card-preview {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.task-card.locked {
    opacity: 0.55;
    cursor: not-allowed;
}

.task-card.locked:hover {
    transform: none;
    border-color: var(--border-subtle);
}

.lock-icon {
    color: var(--warning);
    font-size: 14px;
}

/* ---------- Бейджи ---------- */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge.easy {
    background: var(--difficulty-easy-bg);
    color: var(--difficulty-easy);
    border: 1px solid var(--difficulty-easy-border);
}

.badge.medium {
    background: var(--difficulty-medium-bg);
    color: var(--difficulty-medium);
    border: 1px solid var(--difficulty-medium-border);
}

.badge.hard {
    background: var(--difficulty-hard-bg);
    color: var(--difficulty-hard);
    border: 1px solid var(--difficulty-hard-border);
}

/* ---------- Страница задачи ---------- */
.task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--divider);
}

.task-condition {
    background: var(--bg-code);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
    font-size: 15px;
    line-height: 1.7;
    white-space: pre-wrap;
}

.answer-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.field-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: block;
}

.field-result {
    font-size: 13px;
    margin-top: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

.field-result.correct {
    color: var(--success);
    background: var(--success-bg);
}

.field-result.wrong {
    color: var(--error);
    background: var(--error-bg);
}

/* ---------- Действия с задачей ---------- */
.task-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
    margin-bottom: 24px;
}

.task-actions button {
    flex: 1;
    min-width: 160px;
}

/* ---------- Решение ---------- */
.solution-block {
    background: var(--bg-code);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 20px;
    margin-top: 16px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 14px;
    white-space: pre-wrap;
    color: var(--text-primary);
}

.locked-message {
    background: var(--warning-bg);
    color: var(--warning);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid rgba(251, 191, 36, 0.3);
    text-align: center;
}

.locked-message button {
    margin-top: 12px;
    background: var(--warning);
    color: var(--bg-primary);
}

/* ---------- Попытки ---------- */
.attempts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.attempt-item {
    background: var(--bg-code);
    border-radius: 8px;
    padding: 12px 16px;
    border-left: 3px solid var(--text-muted);
}

.attempt-item.correct {
    border-left-color: var(--success);
}

.attempt-item.wrong {
    border-left-color: var(--error);
}

.attempt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.attempt-status {
    font-weight: 600;
}

.attempt-status.correct { color: var(--success); }
.attempt-status.wrong { color: var(--error); }

.attempt-note {
    font-style: italic;
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

.attempt-answers {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.attempt-label {
    color: var(--text-muted);
    margin-right: 4px;
}


/* ---------- Ссылки-кнопки ---------- */
.link-back {
    display: inline-block;
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.link-back:hover {
    color: var(--accent-primary);
    text-decoration: none;
}

/* ---------- Мобильные ---------- */
@media (max-width: 600px) {
    body { padding: 12px; }

    .container {
        padding: 20px;
        margin: 12px auto;
        border-radius: 8px;
    }

    .task-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .task-actions button {
        min-width: 100%;
    }
}
