/* USMLE app shell — sidebar + main (Consology-like structure, stud.kg styles) */

/* Alias: в проекте основной текст — --text-color */
.usmle-app,
.flashcards-page {
    --text-primary: var(--text-color);
}

.usmle-app {
    display: flex;
    min-height: 100dvh;
    background: var(--bg-secondary);
    color: var(--text-color);
}

body:has(.usmle-app) {
    margin: 0;
    background: var(--bg-secondary);
}

.usmle-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #1e40af 0%, #1d4ed8 55%, #2563eb 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100dvh;
    max-height: 100dvh;
    align-self: flex-start;
    z-index: 100;
    box-shadow: 2px 0 16px rgba(15, 23, 42, 0.12);
}

.usmle-sidebar-brand {
    padding: 1.25rem 1rem 1rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.usmle-sidebar-logo {
    width: 52px;
    height: 52px;
    margin: 0 auto 0.5rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    overflow: hidden;
}

.usmle-sidebar-logo img {
    width: 52px;
    height: 52px;
    object-fit: contain;
    display: block;
}

.usmle-sidebar-brand h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.usmle-sidebar-step {
    margin-top: 0.35rem;
    font-size: 0.78rem;
    opacity: 0.85;
    font-weight: 600;
}

.usmle-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0;
}

.usmle-nav a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 1.15rem;
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}

.usmle-nav a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.usmle-nav a.active {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    border-left-color: #fff;
    font-weight: 700;
}

.usmle-nav a.disabled {
    opacity: 0.45;
    pointer-events: none;
}

.usmle-nav-icon {
    width: 1.25rem;
    height: 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.usmle-ico {
    width: 1.15rem;
    height: 1.15rem;
    display: block;
}

.usmle-icon-btn,
.usmle-topbar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
}

.usmle-icon-btn .usmle-ico,
.usmle-topbar-toggle .usmle-ico {
    width: 1.2rem;
    height: 1.2rem;
}

.usmle-nav-badge {
    margin-left: auto;
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
}

.usmle-sidebar-user {
    padding: 0.85rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.82rem;
}

.usmle-sidebar-user strong {
    display: block;
    font-size: 0.9rem;
}

.usmle-sidebar-user span {
    opacity: 0.8;
    font-size: 0.75rem;
}

.usmle-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

.usmle-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.5rem;
    padding-top: max(0.85rem, env(safe-area-inset-top, 0px));
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 80;
    flex-shrink: 0;
}

.usmle-topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.usmle-topbar-toggle {
    display: none;
    border: none;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 0.4rem 0.55rem;
    cursor: pointer;
    font-size: 1.1rem;
}

.usmle-topbar h1 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-color);
}

.usmle-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.usmle-content {
    flex: 1;
    padding: 1.5rem;
    overflow-x: auto;
}

/* Welcome stats */
.usmle-stats-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1rem;
}

.usmle-stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg, 12px);
    padding: 1.15rem 1.25rem;
    box-shadow: var(--shadow);
}

.usmle-stat-card h3 {
    margin: 0 0 0.85rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-color);
}

.usmle-donut-wrap {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.usmle-donut {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    color: var(--primary-color);
    background: conic-gradient(var(--primary-color) var(--pct, 0%), var(--border-light) 0);
    position: relative;
}

.usmle-donut::after {
    content: '';
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    background: var(--card-bg);
}

.usmle-donut span {
    position: relative;
    z-index: 1;
    font-size: 0.85rem;
}

.usmle-stat-rows {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    font-size: 0.88rem;
}

.usmle-stat-row {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.usmle-stat-row strong {
    color: var(--text-color);
}

.usmle-stats-span-3 { grid-column: span 3; }
.usmle-stats-span-4 { grid-column: span 4; }
.usmle-stats-span-6 { grid-column: span 6; }
.usmle-stats-span-12 { grid-column: span 12; }

.usmle-curve-box {
    min-height: 220px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 1rem 0 0;
    position: relative;
}

.usmle-curve-svg {
    width: 100%;
    max-width: 720px;
    height: 180px;
}

.usmle-curve-marker {
    position: absolute;
    bottom: 2.5rem;
    transform: translateX(-50%);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* History table */
.usmle-table-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.usmle-table-wrap {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg, 12px);
    overflow: auto;
    box-shadow: var(--shadow);
}

.usmle-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.usmle-table th,
.usmle-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.usmle-table th {
    background: var(--bg-secondary);
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.usmle-table tr:hover td {
    background: color-mix(in srgb, var(--primary-color) 4%, var(--card-bg));
}

.usmle-score-ring {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--primary-color);
    background: conic-gradient(var(--primary-color) var(--pct, 0%), var(--border-light) 0);
    position: relative;
}

.usmle-score-ring::after {
    content: '';
    position: absolute;
    inset: 5px;
    border-radius: 50%;
    background: var(--card-bg);
}

.usmle-score-ring span {
    position: relative;
    z-index: 1;
}

.usmle-action-btns {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.usmle-action-btn {
    border: 1px solid var(--border-light);
    background: var(--bg-secondary);
    border-radius: 6px;
    padding: 0.4rem 0.5rem;
    cursor: pointer;
    line-height: 1;
    color: var(--text-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.usmle-action-btn .usmle-ico {
    width: 1.05rem;
    height: 1.05rem;
}

.usmle-action-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.usmle-sidebar-backdrop {
    display: none;
}

.usmle-banks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.usmle-bank-card {
    border-radius: 1rem;
    padding: 1.15rem 1.25rem;
    cursor: pointer;
    transition: transform .15s, box-shadow .18s;
    border: 1.5px solid var(--border-light);
    background: var(--card-bg);
    color: var(--text-color);
    box-shadow: var(--shadow);
    min-height: 140px;
    display: flex;
    flex-direction: column;
}

.usmle-bank-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(37, 99, 235, .14);
    border-color: var(--primary-color);
}

.usmle-bank-card.active-bank {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

@media (max-width: 1100px) {
    .usmle-stats-span-3,
    .usmle-stats-span-4 {
        grid-column: span 6;
    }
}

@media (max-width: 900px) {
    .usmle-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: min(280px, 86vw);
        height: 100dvh;
        max-height: 100dvh;
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        box-shadow: none;
        padding-top: env(safe-area-inset-top, 0px);
    }

    .usmle-sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 28px rgba(15, 23, 42, 0.28);
    }

    .usmle-sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 90;
        border: none;
        padding: 0;
        margin: 0;
        cursor: pointer;
    }

    .usmle-sidebar-backdrop.show {
        display: block;
    }

    .usmle-topbar-toggle {
        display: inline-flex;
    }

    .usmle-topbar {
        padding: 0.75rem max(1rem, env(safe-area-inset-right, 0px)) 0.75rem max(1rem, env(safe-area-inset-left, 0px));
        padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
        position: sticky;
        top: 0;
        z-index: 80;
    }

    .usmle-topbar h1 {
        font-size: 1rem;
        line-height: 1.3;
    }

    .usmle-topbar-actions .btn {
        padding: 0.45rem 0.75rem;
        font-size: 0.85rem;
        min-height: 44px;
    }

    .usmle-content {
        padding: 1rem;
    }

    .usmle-stats-span-3,
    .usmle-stats-span-4,
    .usmle-stats-span-6,
    .usmle-stats-span-12 {
        grid-column: span 12;
    }

    .usmle-curve-box {
        min-height: 160px;
    }

    .usmle-curve-svg {
        height: 130px;
    }

    .usmle-table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .usmle-table-toolbar label {
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
        width: 100%;
    }

    .usmle-table-toolbar input[type="search"] {
        width: 100%;
        box-sizing: border-box;
    }

    /* History: card layout on tablet/mobile */
    .usmle-table thead {
        display: none;
    }

    .usmle-table,
    .usmle-table tbody,
    .usmle-table tr,
    .usmle-table td {
        display: block;
        width: 100%;
    }

    .usmle-table tr {
        padding: 0.85rem 1rem;
        border-bottom: 1px solid var(--border-light);
    }

    .usmle-table td {
        padding: 0.35rem 0;
        border-bottom: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.75rem;
    }

    .usmle-table td::before {
        content: attr(data-label);
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: var(--text-muted);
        flex-shrink: 0;
    }

    .usmle-table td:first-child {
        justify-content: flex-start;
        gap: 0.85rem;
        margin-bottom: 0.35rem;
    }

    .usmle-table td:first-child::before {
        content: none;
    }

    .usmle-banks-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .usmle-topbar-actions .btn-hide-sm {
        display: none;
    }

    .usmle-topbar {
        gap: 0.5rem;
        padding: 0.55rem max(0.65rem, env(safe-area-inset-right, 0px)) 0.55rem max(0.65rem, env(safe-area-inset-left, 0px));
        padding-top: max(0.55rem, env(safe-area-inset-top, 0px));
    }

    .usmle-topbar h1 {
        font-size: 0.92rem;
    }

    .usmle-topbar-toggle {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    .usmle-content {
        padding: 0.65rem;
    }

    .usmle-stat-card {
        padding: 0.85rem;
    }

    .usmle-donut {
        width: 68px;
        height: 68px;
    }

    .usmle-sidebar {
        width: min(270px, 92vw);
    }

    .usmle-nav a {
        min-height: 44px;
        padding: 0.65rem 0.85rem;
        font-size: 0.9rem;
    }

    .usmle-sidebar-step {
        font-size: 0.72rem;
        line-height: 1.35;
        padding: 0 0.25rem;
    }

    .usmle-app {
        min-height: 100dvh;
    }

    .usmle-banks-grid {
        gap: 0.65rem;
    }
}

.flashcards-page {
    max-width: 1320px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

.flashcards-ready-decks .hidden {
    display: none !important;
}

.fc-tabs {
    display: flex;
    gap: 1.25rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 1rem;
}

.fc-tab {
    border: none;
    background: transparent;
    padding: 0.65rem 0.15rem 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.fc-tab.active {
    color: var(--text-color);
    border-bottom-color: var(--primary-color);
}

.fc-search-bar {
    margin-bottom: 1.25rem;
}

.fc-search-input {
    width: 100%;
    border: 1px solid var(--border-light);
    border-radius: 0.55rem;
    padding: 0.7rem 0.9rem;
    font-size: 0.95rem;
    background: var(--card-bg);
    color: var(--text-color);
}

.fc-search-input::placeholder {
    color: var(--text-muted);
}

.fc-search-input:focus {
    outline: none;
    border-color: color-mix(in srgb, var(--primary-color) 55%, var(--border-light));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 18%, transparent);
}

.fc-browse-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.fc-topic-section {
    min-width: 0;
}

.fc-topic-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
}

.fc-topic-title {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 700;
    font-size: 0.98rem;
    color: var(--text-color);
    min-width: 0;
}

.fc-topic-badge {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.fc-see-all {
    border: none;
    background: transparent;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    white-space: nowrap;
    padding: 0.2rem 0.1rem;
}

.fc-see-all:hover {
    text-decoration: underline;
}

.fc-deck-row {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.75rem;
}

.fc-deck-card {
    aspect-ratio: 3 / 4;
    border: 1px solid var(--border-light);
    border-radius: 0.45rem;
    background: var(--card-bg);
    color: var(--text-color);
    padding: 0.7rem;
    text-align: left;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fc-deck-card:hover {
    border-color: color-mix(in srgb, var(--primary-color) 45%, var(--border-light));
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.fc-deck-card-text {
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--text-color);
    display: -webkit-box;
    -webkit-line-clamp: 8;
    -webkit-box-orient: vertical;
    overflow: hidden;
    width: 100%;
    word-break: break-word;
}

.fc-deck-card-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    background: var(--bg-secondary);
    border-radius: 0.25rem;
}

.fc-study-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.fc-study-topic-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.flashcards-card-shell {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: 0.35rem;
    min-height: 480px;
    display: flex;
    flex-direction: column;
    box-shadow: none;
    color: var(--text-color);
}

.fc-session-card {
    position: relative;
    height: min(84vh, 960px);
    min-height: 560px;
    overflow: hidden;
}

.fc-session-card.has-media {
    height: auto;
    min-height: min(84vh, 960px);
    max-height: none;
    overflow: visible;
}

@media (min-width: 1100px) {
    .fc-session-card {
        height: min(88vh, 1080px);
        min-height: 640px;
    }

    .fc-session-card.has-media {
        min-height: min(88vh, 1080px);
    }

    .flashcards-card-shell {
        min-height: 560px;
    }
}

.flashcards-card-head {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem 0.35rem;
    border-bottom: none;
    flex-shrink: 0;
}

.flashcards-category {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.92rem;
    font-weight: 500;
    min-width: 0;
    color: var(--text-color);
}

.flashcards-category-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flashcard-tag-badge {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: var(--primary-color);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.flashcards-side-toggle {
    display: inline-flex;
    gap: 0.35rem;
    border: none;
    border-radius: 0;
    overflow: visible;
    flex-shrink: 0;
}

.flashcards-side-toggle button {
    border: 1px solid var(--border-light);
    background: var(--card-bg);
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text-color);
    border-radius: 0.2rem;
    min-width: 4.2rem;
}

.flashcards-side-toggle button.active {
    background: #e8eaed;
    border-color: #c5c9d1;
    color: #1f2937;
    font-weight: 600;
}

html[data-theme="dark"] .flashcards-side-toggle button.active,
[data-theme="dark"] .flashcards-side-toggle button.active {
    background: #334155;
    border-color: #475569;
    color: #f8fafc;
}

.flashcards-card-body {
    flex: 1;
    padding: 0.5rem 1.35rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.85rem;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.fc-session-card.has-media .flashcards-card-body {
    padding-top: 0.35rem;
    overflow: visible;
    flex: 1 1 auto;
    min-height: auto;
}

.flashcard-image-wrap {
    margin: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 0.15rem;
    overflow: hidden;
    flex: 0 0 auto;
    min-height: 0;
    contain: layout paint;
}

.flashcard-image {
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: min(70vh, 720px);
    object-fit: contain;
    object-position: center;
    border: none;
    border-radius: 0;
    background: #fff;
    cursor: zoom-in;
}

@media (min-width: 1100px) {
    .flashcard-image {
        max-height: min(72vh, 800px);
    }
}

.flashcard-text {
    font-size: 1.05rem;
    line-height: 1.7;
    text-align: left;
    width: 100%;
    color: var(--text-color);
}

.flashcard-text.has-image {
    padding-top: 0.25rem;
}

.fc-blank,
.fc-choice {
    color: var(--primary-color);
    font-weight: 600;
}

.flashcard-answer-highlight {
    color: var(--primary-color);
    font-weight: 700;
    background: transparent;
    border-radius: 0;
    padding: 0;
}

.fc-session-meta {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.fc-session-view-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.fc-session-close {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.6rem;
    line-height: 1;
    width: 2rem;
    height: 2rem;
    cursor: pointer;
    border-radius: 0.25rem;
}

.fc-session-close:hover {
    color: var(--text-color);
    background: var(--bg-secondary);
}

.fc-session-footer {
    position: relative;
    margin-top: 1.1rem;
    text-align: center;
    padding-bottom: 0.5rem;
}

.fc-session-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.45rem;
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.85rem;
}

.fc-stat-sep {
    color: var(--text-muted);
    font-weight: 500;
}

.fc-session-actions {
    display: flex;
    justify-content: center;
}

.fc-show-answer-btn {
    min-width: 160px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-color);
    border-radius: 999px;
    padding: 0.65rem 1.4rem;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
}

.fc-show-answer-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.fc-session-timer {
    position: absolute;
    right: 0;
    bottom: 0.15rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

.fc-rate-box {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.fc-rate-btn {
    min-width: 88px;
    border: 1.5px solid;
    border-radius: 0.35rem;
    padding: 0.45rem 0.9rem 0.55rem;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.fc-rate-interval {
    font-size: 0.72rem;
    font-weight: 500;
    opacity: 0.85;
}

.fc-rate-label {
    font-size: 0.95rem;
}

.fc-rate-again {
    border-color: #ef4444;
    color: #ef4444;
}

.fc-rate-good {
    border-color: #3b82f6;
    color: #3b82f6;
}

.fc-rate-easy {
    border-color: #22c55e;
    color: #22c55e;
}

.fc-rate-again:hover,
.fc-rate-good:hover,
.fc-rate-easy:hover {
    filter: brightness(0.92);
    background: color-mix(in srgb, currentColor 8%, transparent);
}

.flashcards-counter {
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-color);
}

.flashcards-nav {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.flashcard-empty {
    color: var(--text-muted);
    text-align: center;
}

.fc-study-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-light);
    border-radius: 0.65rem;
    background: var(--card-bg);
    color: var(--text-color);
}

.fc-study-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

.fc-study-table th,
.fc-study-table td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.fc-study-table th {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: color-mix(in srgb, var(--bg-secondary) 70%, var(--card-bg));
}

.fc-study-table tbody tr:last-child td {
    border-bottom: none;
}

.fc-study-table tbody tr:hover {
    background: color-mix(in srgb, var(--primary-color) 10%, var(--card-bg));
    cursor: pointer;
}

.fc-deck-name {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 600;
    color: var(--text-color);
}

.fc-col-stat {
    font-weight: 700;
    font-size: 1.05rem;
    white-space: nowrap;
}

.fc-stat-new { color: var(--primary-color); }
.fc-stat-learning { color: var(--warning-color); }
.fc-stat-review { color: var(--success-color); }

.fc-col-last {
    color: var(--text-secondary);
    white-space: nowrap;
    font-size: 0.9rem;
}

.fc-col-actions {
    text-align: right;
    width: 56px;
}

.fc-deck-action {
    border: none;
    background: transparent;
    color: var(--primary-color);
    width: 36px;
    height: 36px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.fc-deck-action:hover {
    background: color-mix(in srgb, var(--primary-color) 12%, transparent);
}

@media (max-width: 1100px) {
    .fc-deck-row {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .flashcards-page {
        max-width: 100%;
        padding: 0 0.15rem;
        width: 100%;
        box-sizing: border-box;
    }

    .fc-tabs {
        gap: 1rem;
        margin-bottom: 1rem;
        -webkit-overflow-scrolling: touch;
    }

    .fc-tab {
        padding: 0.75rem 0.45rem 0.85rem;
        font-size: 1rem;
        min-height: 48px;
    }

    .fc-search-bar { margin-bottom: 1rem; }

    .fc-search-input {
        font-size: 16px;
        min-height: 48px;
        padding: 0.85rem 1rem;
    }

    .fc-deck-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .fc-deck-card {
        padding: 1rem 1.1rem;
        aspect-ratio: auto;
        min-height: 140px;
        align-items: flex-start;
        justify-content: flex-start;
    }

    .fc-deck-card-text {
        -webkit-line-clamp: 12;
        font-size: 0.95rem;
        line-height: 1.5;
    }

    .fc-deck-card-img {
        max-height: 220px;
        width: 100%;
    }

    .fc-study-table-wrap {
        width: 100%;
        max-width: 100%;
        overflow: visible;
        border: none;
        border-radius: 0;
        background: transparent;
    }

    .fc-study-table,
    .fc-study-table thead,
    .fc-study-table tbody,
    .fc-study-table tr,
    .fc-study-table th,
    .fc-study-table td {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .fc-study-table {
        table-layout: auto;
        border-collapse: separate;
        border-spacing: 0;
    }

    .fc-study-table thead { display: none; }

    .fc-study-table tbody {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .fc-study-table tbody tr.fc-deck-row-item {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "deck play"
            "stats play";
        gap: 0.55rem 0.75rem;
        align-items: center;
        padding: 1rem 1.05rem;
        border: 1px solid var(--border-light);
        border-radius: 0.85rem;
        background: var(--card-bg);
        box-shadow: var(--shadow);
    }

    .fc-study-table tbody tr.fc-deck-row-item:hover {
        background: var(--card-bg);
    }

    .fc-study-table th,
    .fc-study-table td {
        padding: 0;
        border: none;
        font-size: 1rem;
    }

    .fc-study-table th:nth-child(5),
    .fc-study-table td.fc-col-last { display: none; }

    .fc-col-deck {
        grid-area: deck;
        width: auto;
    }

    .fc-col-stat {
        display: none;
        width: auto;
        text-align: left;
        white-space: normal;
        font-size: 0.92rem;
    }

    .fc-col-stat.fc-stat-new {
        display: inline;
        grid-area: stats;
    }

    .fc-deck-row-item .fc-col-stat.fc-stat-new::before {
        content: "Новые ";
        font-weight: 600;
        color: var(--text-secondary);
    }

    .fc-deck-row-item .fc-col-stat.fc-stat-learning,
    .fc-deck-row-item .fc-col-stat.fc-stat-review {
        display: inline;
        margin-left: 0.65rem;
    }

    .fc-deck-row-item .fc-col-stat.fc-stat-learning::before {
        content: "Изуч. ";
        font-weight: 600;
        color: var(--text-secondary);
    }

    .fc-deck-row-item .fc-col-stat.fc-stat-review::before {
        content: "Повтор ";
        font-weight: 600;
        color: var(--text-secondary);
    }

    .fc-col-actions {
        grid-area: play;
        width: auto;
        text-align: right;
        align-self: center;
    }

    .fc-deck-name {
        gap: 0.65rem;
        font-size: 1.05rem;
        line-height: 1.45;
        align-items: flex-start;
    }

    .fc-deck-name > span:last-child {
        overflow: visible;
        text-overflow: unset;
        display: block;
        -webkit-line-clamp: unset;
        white-space: normal;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .fc-topic-badge {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
        margin-top: 0.1rem;
        flex-shrink: 0;
    }

    .fc-deck-action {
        width: 48px;
        height: 48px;
    }

    .fc-session-meta {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 0.65rem;
        margin-bottom: 0.85rem;
    }

    .fc-session-view-label { display: none; }

    .flashcards-category-name {
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        word-break: break-word;
        font-size: 1rem;
        line-height: 1.4;
    }

    .fc-session-card {
        height: auto;
        min-height: min(52vh, 480px);
        max-height: none;
        overflow: visible;
    }

    .fc-session-card.has-media {
        height: auto;
        min-height: 240px;
        overflow: visible;
    }

    .flashcards-card-shell { min-height: 240px; }

    .flashcards-card-head {
        padding: 0.75rem 0.85rem 0.5rem;
    }

    .flashcards-side-toggle button {
        min-height: 40px;
        padding: 0.45rem 1rem;
        font-size: 0.9rem;
    }

    .flashcards-card-body {
        padding: 0.85rem 1.05rem 1.35rem;
        overflow-y: visible;
        gap: 1rem;
    }

    .flashcard-image { max-height: min(48vh, 420px); }

    .flashcard-text {
        font-size: 1.08rem;
        line-height: 1.65;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .fc-session-footer {
        margin-top: 1rem;
        padding: 0.75rem 0 max(1rem, env(safe-area-inset-bottom, 0px));
        position: sticky;
        bottom: 0;
        background: linear-gradient(180deg, transparent, var(--bg-color) 22%);
        z-index: 5;
    }

    .fc-show-answer-btn {
        min-width: 0;
        min-height: 52px;
        width: 100%;
        max-width: none;
        font-size: 1.05rem;
        border-radius: 0.85rem;
    }

    .fc-rate-box {
        gap: 0.55rem;
        width: 100%;
        flex-wrap: nowrap;
    }

    .fc-rate-btn {
        flex: 1 1 0;
        min-width: 0;
        min-height: 72px;
        padding: 0.6rem 0.4rem;
        border-radius: 0.75rem;
    }

    .fc-rate-interval { font-size: 0.78rem; }

    .fc-rate-label {
        font-size: 0.92rem;
        white-space: normal;
        line-height: 1.2;
    }

    .fc-session-timer {
        position: static;
        display: block;
        margin-top: 0.75rem;
        text-align: center;
    }

    .fc-topic-section { margin-bottom: 1.5rem; }

    .fc-topic-head {
        margin-bottom: 0.75rem;
        gap: 0.65rem;
        align-items: flex-start;
    }

    .fc-topic-title {
        font-size: 1.05rem;
        line-height: 1.35;
        white-space: normal;
        word-break: break-word;
    }
}
}

/* ── Dark theme: USMLE shell + flashcards ── */
html[data-theme="dark"] .usmle-app,
[data-theme="dark"] .usmle-app {
    background: var(--bg-color);
}

html[data-theme="dark"] .usmle-sidebar,
[data-theme="dark"] .usmle-sidebar {
    background: linear-gradient(180deg, #0f172a 0%, #1e3a8a 48%, #1d4ed8 100%);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .usmle-topbar,
[data-theme="dark"] .usmle-topbar {
    background: var(--card-bg);
    border-bottom-color: var(--border-color);
}

html[data-theme="dark"] .usmle-topbar h1,
[data-theme="dark"] .usmle-topbar h1 {
    color: var(--text-color);
}

html[data-theme="dark"] .usmle-content,
[data-theme="dark"] .usmle-content {
    color: var(--text-color);
}

html[data-theme="dark"] .fc-tabs,
[data-theme="dark"] .fc-tabs {
    border-bottom-color: var(--border-color);
}

html[data-theme="dark"] .fc-tab,
[data-theme="dark"] .fc-tab {
    color: var(--text-muted);
}

html[data-theme="dark"] .fc-tab.active,
[data-theme="dark"] .fc-tab.active {
    color: var(--text-color);
}

html[data-theme="dark"] .fc-search-input,
[data-theme="dark"] .fc-search-input {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-color);
}

html[data-theme="dark"] .fc-deck-card,
[data-theme="dark"] .fc-deck-card {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

html[data-theme="dark"] .fc-deck-card:hover,
[data-theme="dark"] .fc-deck-card:hover {
    border-color: color-mix(in srgb, var(--primary-color) 55%, var(--border-color));
    background: color-mix(in srgb, var(--primary-color) 8%, var(--bg-secondary));
}

html[data-theme="dark"] .fc-deck-card-img,
[data-theme="dark"] .fc-deck-card-img,
html[data-theme="dark"] .flashcard-image,
[data-theme="dark"] .flashcard-image {
    background: #0b1220;
    border-color: var(--border-color);
}

html[data-theme="dark"] .flashcard-image-wrap,
[data-theme="dark"] .flashcard-image-wrap {
    background: #0b1220;
    border-color: var(--border-color);
}

html[data-theme="dark"] .flashcards-card-shell,
[data-theme="dark"] .flashcards-card-shell {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

html[data-theme="dark"] .flashcards-side-toggle button,
[data-theme="dark"] .flashcards-side-toggle button {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

html[data-theme="dark"] .flashcards-side-toggle button.active,
[data-theme="dark"] .flashcards-side-toggle button.active {
    background: color-mix(in srgb, var(--primary-color) 18%, var(--bg-secondary));
    border-color: var(--primary-color);
    color: #93c5fd;
}

html[data-theme="dark"] .fc-blank,
html[data-theme="dark"] .fc-choice,
html[data-theme="dark"] .flashcard-answer-highlight,
[data-theme="dark"] .fc-blank,
[data-theme="dark"] .fc-choice,
[data-theme="dark"] .flashcard-answer-highlight {
    color: #60a5fa;
    background: transparent;
}

html[data-theme="dark"] .fc-show-answer-btn,
[data-theme="dark"] .fc-show-answer-btn {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-color);
}

html[data-theme="dark"] .fc-rate-again,
[data-theme="dark"] .fc-rate-again {
    background: transparent;
    border-color: #f87171;
    color: #f87171;
}

html[data-theme="dark"] .fc-rate-good,
[data-theme="dark"] .fc-rate-good {
    background: transparent;
    border-color: #60a5fa;
    color: #60a5fa;
}

html[data-theme="dark"] .fc-rate-easy,
[data-theme="dark"] .fc-rate-easy {
    background: transparent;
    border-color: #34d399;
    color: #34d399;
}

html[data-theme="dark"] .fc-study-table-wrap,
[data-theme="dark"] .fc-study-table-wrap {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

html[data-theme="dark"] .fc-study-table th,
[data-theme="dark"] .fc-study-table th {
    background: color-mix(in srgb, var(--bg-color) 55%, var(--bg-secondary));
    color: var(--text-muted);
}

html[data-theme="dark"] .fc-study-table th,
html[data-theme="dark"] .fc-study-table td,
[data-theme="dark"] .fc-study-table th,
[data-theme="dark"] .fc-study-table td {
    border-bottom-color: var(--border-color);
}

html[data-theme="dark"] .fc-study-table tbody tr:hover,
[data-theme="dark"] .fc-study-table tbody tr:hover {
    background: color-mix(in srgb, var(--primary-color) 14%, var(--bg-secondary));
}

html[data-theme="dark"] .fc-stat-new,
[data-theme="dark"] .fc-stat-new {
    color: #60a5fa;
}

html[data-theme="dark"] .fc-stat-learning,
[data-theme="dark"] .fc-stat-learning {
    color: #fb923c;
}

html[data-theme="dark"] .fc-stat-review,
[data-theme="dark"] .fc-stat-review {
    color: #34d399;
}

html[data-theme="dark"] .fc-deck-action:hover,
[data-theme="dark"] .fc-deck-action:hover {
    background: color-mix(in srgb, var(--primary-color) 20%, transparent);
}

html[data-theme="dark"] .usmle-stat-card,
html[data-theme="dark"] .usmle-table-wrap,
[data-theme="dark"] .usmle-stat-card,
[data-theme="dark"] .usmle-table-wrap {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

html[data-theme="dark"] .usmle-donut::after,
[data-theme="dark"] .usmle-donut::after {
    background: var(--bg-secondary);
}

body.usmle-nav-open {
    overflow: hidden;
}
