.card {
    margin-bottom: 1.1rem;
    padding: clamp(1rem, 2.5vw, 1.5rem);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.stat__label {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.stat__value {
    font-size: clamp(1.35rem, 3vw, 1.8rem);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.recommendations {
    margin: 0 0 1rem;
    padding-left: 1.2rem;
}

.recommendations li {
    margin-bottom: 0.35rem;
}

/* Chart */

.chart {
    display: flex;
    align-items: flex-end;
    gap: clamp(4px, 1vw, 10px);
    height: 170px;
    padding-top: 0.5rem;
}

.bar {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    gap: 0.35rem;
}

.bar__value {
    width: 100%;
    min-height: 2px;
    border-radius: 6px 6px 2px 2px;
    background: linear-gradient(180deg, #6d63f0, var(--accent));
}

.bar__label {
    color: var(--muted);
    font-size: 0.68rem;
    font-variant-numeric: tabular-nums;
}

/* Questions */

.question-list {
    display: grid;
    gap: 0.8rem;
}

.question-card {
    padding: 1rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.question-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.question-card__head .markdown {
    flex: 1;
    font-weight: 600;
}

.question-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.6rem;
    color: var(--muted);
    font-size: 0.84rem;
}

.question-card__actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.8rem;
}

.editor {
    margin-top: 1.4rem;
}

.editor__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.editor__actions .btn {
    flex: 0 0 auto;
}

.settings-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.2rem;
}

.settings-actions .btn {
    flex: 0 0 auto;
}

.options-list {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.option-row input[type="text"] {
    flex: 1;
}

.options {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.option {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.option:hover {
    border-color: var(--accent);
}

.option:has(input:checked) {
    border-color: var(--accent);
    background: rgba(79, 70, 229, 0.06);
}

.option input {
    margin-top: 0.25rem;
    accent-color: var(--accent);
}

.result-options {
    margin: 0.6rem 0 0;
    padding-left: 1.1rem;
}

.result-options li {
    margin-bottom: 0.3rem;
}

.result-options li.correct {
    color: var(--ok);
    font-weight: 600;
}

.result-options li.wrong {
    color: var(--muted);
    text-decoration: line-through;
}

/* Session */

.session__head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.session__progress {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.session__timer {
    margin-left: auto;
    padding: 0.18rem 0.6rem;
    border-radius: 999px;
    background: rgba(192, 57, 43, 0.12);
    color: var(--danger);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.session__prompt {
    margin-bottom: 1rem;
    font-size: 1.12rem;
    font-weight: 600;
}

.session__tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
}

.grade-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin: 1rem 0 0.5rem;
}

.result {
    margin-top: 1.2rem;
    padding-top: 1.1rem;
    border-top: 1px dashed var(--border);
}

.summary-stats {
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    font-weight: 600;
}

.review-list {
    display: grid;
    gap: 0.8rem;
}

.review-item {
    padding: 0.9rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.review-item .badge {
    margin-bottom: 0.4rem;
}

/* Learned */

.learned-groups {
    display: grid;
    gap: 1rem;
}

.learned-group {
    padding: 1rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.learned-group__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.6rem;
}

.learned-group__head .section-title {
    margin: 0;
    font-size: 1.05rem;
}

.learned-row {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.6rem 0;
    border-top: 1px solid var(--border);
    cursor: pointer;
}

.learned-row input {
    margin-top: 0.35rem;
    accent-color: var(--accent);
}

.learned-row__body {
    flex: 1;
}

.learned-row__body .muted {
    font-size: 0.82rem;
}

@media (max-width: 620px) {
    .grade-buttons {
        grid-template-columns: 1fr;
    }

    .question-card__head {
        flex-direction: column;
        gap: 0.4rem;
    }
}

/* Two-phase answer: reveal, grading, hints */

.option--correct {
    border-color: var(--ok);
    background: rgba(15, 138, 95, 0.08);
    box-shadow: 0 0 0 2px rgba(15, 138, 95, 0.35);
}

.option--correct::after {
    content: "верно";
    margin-left: auto;
    color: var(--ok);
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.option--wrong {
    border-color: var(--danger);
    background: rgba(192, 57, 43, 0.07);
    box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.3);
}

.option--wrong::after {
    content: "ваш выбор";
    margin-left: auto;
    color: var(--danger);
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.option--correct,
.option--wrong {
    cursor: default;
}

.reveal-panel {
    margin-top: 1rem;
}

.reveal {
    padding: 0.8rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
}

.reveal + .reveal {
    margin-top: 0.6rem;
}

.reveal > summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--text);
    list-style: none;
}

.reveal > summary::-webkit-details-marker {
    display: none;
}

.reveal > summary::before {
    content: "▸";
    display: inline-block;
    width: 1rem;
    color: var(--muted);
    transition: transform 0.15s ease;
}

.reveal[open] > summary::before {
    transform: rotate(90deg);
}

.reveal[open] > summary {
    margin-bottom: 0.7rem;
}

.hint {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.15rem;
    height: 1.15rem;
    margin-left: 0.2rem;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    cursor: help;
    vertical-align: middle;
}

.hint::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    z-index: 20;
    width: 250px;
    max-width: min(250px, 80vw);
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius-sm);
    background: var(--text);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.35;
    text-align: left;
    transform: translateX(-50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    box-shadow: 0 8px 24px rgba(28, 32, 51, 0.25);
}

.hint:hover::after,
.hint:focus-visible::after {
    opacity: 1;
}

.grade {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.grade .btn {
    flex: 1;
}

/* LLM: настройки и AI-помощник */
.mono {
    font-family: var(--mono);
}

.status {
    margin: 0.5rem 0;
    font-weight: 600;
}

.status--ok {
    color: var(--ok);
}

.status--error {
    color: var(--danger);
}

.ai-block {
    display: grid;
    gap: 0.8rem;
}

.ai-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.ai-row .input {
    flex: 1 1 auto;
    min-width: 0;
}

.ai-answer {
    white-space: pre-wrap;
    background: var(--surface-soft);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 0.8rem 1rem;
}

.ai-feedback {
    margin: 0.6rem 0 0;
}

.ai-missing {
    margin: 0.3rem 0 0.6rem 1.2rem;
    padding: 0;
}

.ai-suggestion {
    margin: 0.4rem 0 0;
    font-weight: 600;
}

.grade-suggested {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.code {
    overflow-x: auto;
    padding: .85rem 1rem;
    border-radius: 12px;
    background: var(--surface-2, #f4f5fb);
    font-size: .82rem;
    line-height: 1.45;
}


.issues {
    margin: 0.75rem 0 0;
    padding-left: 1.25rem;
    color: var(--danger, #b42318);
    font-size: 0.9rem;
}

.issues li {
    margin-bottom: 0.35rem;
}

.exam-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1rem 0;
}

.exam-item {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    background: var(--surface);
}

.exam-item__head {
    font-weight: 600;
    color: var(--muted);
    margin-bottom: .5rem;
}

.exam-item__prompt {
    margin-bottom: .75rem;
}

.exam-item__text {
    width: 100%;
    margin-bottom: .5rem;
}

.exam-item__self {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--muted);
}

.summary-percent {
    font-size: 1.25rem;
    font-weight: 700;
    margin: .5rem 0 1rem;
}
