:root {
    --bg: #0c1222;
    --bg-elevated: #131b2e;
    --bg-card: #182236;
    --border: rgba(148, 163, 184, 0.18);
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-soft: rgba(59, 130, 246, 0.14);
    --accent: #22c55e;
    --danger: #ef4444;
    --warn: #f59e0b;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(2, 6, 23, 0.35);
    --header-h: 64px;
    --tabs-h: 52px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Vazirmatn", Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(59, 130, 246, 0.18), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(34, 197, 94, 0.08), transparent);
    pointer-events: none;
    z-index: 0;
}

.app-shell {
    position: relative;
    z-index: 1;
    max-width: 920px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.app-header {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border);
    background: rgba(12, 18, 34, 0.92);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-title {
    font-weight: 700;
    font-size: 1rem;
}

.brand-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    background: var(--primary-soft);
    border: 1px solid rgba(59, 130, 246, 0.25);
    max-width: 55vw;
}

.user-chip.hidden {
    display: none;
}

.user-chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

.user-chip-label {
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
    background: rgba(12, 18, 34, 0.85);
    position: sticky;
    top: var(--header-h);
    z-index: 19;
}

.tab-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.65rem 0.5rem;
    border-radius: 10px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.tab-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.tab-btn.is-active {
    color: var(--text);
    background: var(--primary-soft);
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.25);
}

.app-main {
    flex: 1;
    padding: 1.25rem 1rem 2rem;
}

.view {
    display: none;
    animation: fadeIn 0.22s ease;
}

.view.is-active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.welcome-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.35rem 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}

.welcome-card h1 {
    margin: 0 0 0.4rem;
    font-size: 1.25rem;
    font-weight: 700;
}

.welcome-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}

@media (min-width: 520px) {
    .action-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.action-card {
    text-align: right;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    padding: 1.1rem;
    cursor: pointer;
    color: inherit;
    font-family: inherit;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
    box-shadow: var(--shadow);
}

.action-card:hover {
    transform: translateY(-2px);
    border-color: rgba(59, 130, 246, 0.45);
}

.action-card.accent:hover {
    border-color: rgba(34, 197, 94, 0.45);
}

.action-icon {
    display: inline-flex;
    width: 2.25rem;
    height: 2.25rem;
    color: var(--primary);
    margin-bottom: 0.65rem;
}

.action-card.accent .action-icon {
    color: var(--accent);
}

.action-card.analyzer-card:hover {
    border-color: rgba(245, 158, 11, 0.45);
}

.action-card.analyzer-card .action-icon {
    color: #f59e0b;
}

.action-card.profile-card:hover {
    border-color: rgba(56, 189, 248, 0.45);
}

.action-card.profile-card .action-icon {
    color: #38bdf8;
}

.action-card.public-exams-card:hover {
    border-color: rgba(34, 197, 94, 0.45);
}

.action-card.public-exams-card .action-icon {
    color: #22c55e;
}

.dashboard-datetime-card {
    margin-bottom: 1rem;
    padding: 1rem 1.15rem;
    border-radius: var(--radius);
    border: 1px solid rgba(59, 130, 246, 0.28);
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.92));
    box-shadow: var(--shadow);
}

.dashboard-datetime-clock {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 1rem;
}

.dashboard-weekday {
    font-size: 1.05rem;
    font-weight: 700;
    color: #93c5fd;
}

.dashboard-date {
    font-size: 0.95rem;
    color: #e2e8f0;
    font-variant-numeric: tabular-nums;
}

.dashboard-time {
    margin-inline-start: auto;
    font-size: 1.35rem;
    font-weight: 700;
    color: #f8fafc;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.dashboard-registration-line {
    margin: 0.75rem 0 0;
    padding-top: 0.7rem;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    font-size: 0.86rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.dashboard-registration-line.hidden {
    display: none;
}

.view-subnav {
    margin-bottom: 0.85rem;
}

.view-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.85rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.65);
    color: #cbd5e1;
    font-family: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.view-back-link:hover {
    border-color: rgba(99, 102, 241, 0.55);
    background: rgba(49, 46, 129, 0.35);
    color: #e2e8f0;
}

.view-back-icon {
    display: inline-flex;
    font-size: 1rem;
    line-height: 1;
    opacity: 0.9;
}

.section-head-compact {
    margin-bottom: 0.85rem;
}

.section-head-compact h2 {
    margin-top: 0;
}

.profile-section-head .profile-back-btn {
    display: inline-flex;
    align-items: center;
    margin-bottom: 0.65rem;
    padding: 0.4rem 0.7rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.82rem;
    cursor: pointer;
}

.profile-section-head .profile-back-btn:hover {
    color: #e2e8f0;
    border-color: rgba(59, 130, 246, 0.45);
}

.profile-content {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.profile-hero {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 1.1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.9));
    box-shadow: var(--shadow);
}

.profile-avatar {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    font-weight: 700;
    color: #e0f2fe;
    background: linear-gradient(135deg, #1d4ed8, #38bdf8);
    flex-shrink: 0;
}

.profile-name {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.profile-username {
    margin: 0.2rem 0 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.profile-code-card {
    padding: 0.9rem 1rem;
    border-radius: var(--radius);
    border: 1px dashed rgba(56, 189, 248, 0.45);
    background: rgba(15, 23, 42, 0.65);
}

.profile-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.profile-code-value {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: #7dd3fc;
    word-break: break-all;
    font-family: ui-monospace, Consolas, monospace;
    direction: ltr;
    text-align: left;
}

.action-card.ai-chat-card:hover {
    border-color: rgba(168, 85, 247, 0.45);
}

.action-card.ai-chat-card .action-icon {
    color: #c084fc;
}

.action-card.ai-reports-card:hover {
    border-color: rgba(167, 139, 250, 0.45);
}

.action-card.ai-reports-card .action-icon {
    color: #c4b5fd;
}

.ai-reports-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.ai-report-card {
    width: 100%;
    text-align: right;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(165deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.92));
    padding: 0.85rem 1rem;
    font: inherit;
    color: inherit;
    transition: border-color 0.15s ease;
}

.ai-report-card:hover {
    border-color: rgba(129, 140, 248, 0.35);
}

.ai-report-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.35rem 0.75rem;
    margin-bottom: 0.35rem;
}

.ai-report-card-title {
    font-size: 0.95rem;
    color: #e2e8f0;
}

.ai-report-star {
    color: #fbbf24;
    margin-inline-end: 0.15rem;
}

.ai-report-card-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.ai-report-card-preview {
    margin: 0 0 0.45rem;
    font-size: 0.82rem;
    line-height: 1.55;
    color: #94a3b8;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ai-report-card-open {
    display: inline-flex;
    margin-top: 0.35rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid rgba(129, 140, 248, 0.45);
    border-radius: 8px;
    background: rgba(49, 46, 129, 0.35);
    color: #c7d2fe;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.ai-report-card-open:hover:not(:disabled) {
    background: rgba(67, 56, 202, 0.45);
    color: #e0e7ff;
}


.ai-report-loading {
    text-align: center;
    color: var(--text-muted);
    padding: 1.5rem;
}

.empty-reports {
    text-align: center;
}

body.ai-report-detail-open {
    overflow: hidden;
}

.ai-chat-shell {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    min-height: min(70vh, 560px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    overflow: hidden;
}

.ai-chat-messages {
    flex: 1;
    min-height: 280px;
    max-height: min(58vh, 480px);
    overflow-y: auto;
    padding: 0.85rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.ai-chat-hint {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.55;
}

.ai-chat-bubble {
    max-width: 92%;
    padding: 0.55rem 0.75rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-chat-bubble-user {
    align-self: flex-end;
    background: rgba(59, 130, 246, 0.22);
    border: 1px solid rgba(96, 165, 250, 0.35);
    color: #e2e8f0;
}

.ai-chat-bubble-assistant {
    align-self: flex-start;
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid var(--border);
    color: #cbd5e1;
}

.ai-chat-bubble-assistant.is-loading {
    color: var(--text-muted);
    font-style: italic;
}

.ai-chat-bubble-assistant.is-error {
    border-color: rgba(248, 113, 113, 0.45);
    color: #fecaca;
}

.ai-chat-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem;
    border-top: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.65);
}

.ai-chat-form.hidden {
    display: none;
}

.ai-chat-input {
    flex: 1;
    min-height: 2.6rem;
    max-height: 8rem;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #0f172a;
    color: inherit;
    font: inherit;
    padding: 0.5rem 0.65rem;
}

.ai-chat-send {
    flex-shrink: 0;
    align-self: flex-end;
    border: none;
    border-radius: 10px;
    background: #4f46e5;
    color: #fff;
    font: inherit;
    font-weight: 600;
    padding: 0.55rem 1rem;
    cursor: pointer;
}

.ai-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-chat-subtitle {
    margin: 0;
}

.ai-report-detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0.75rem;
    background: rgba(2, 6, 23, 0.75);
    backdrop-filter: blur(4px);
}

.ai-report-detail-overlay.hidden {
    display: none !important;
}

.ai-report-detail-overlay.is-open {
    display: flex !important;
}

.ai-report-detail-sheet {
    width: min(42rem, 100%);
    max-height: min(90vh, 760px);
    display: flex;
    flex-direction: column;
    border-radius: 16px 16px 12px 12px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    overflow: hidden;
}

.ai-report-detail-head {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.85rem 1rem 0.5rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.ai-report-detail-kicker {
    margin: 0 0 0.15rem;
    font-size: 0.72rem;
    color: #a5b4fc;
}

.ai-report-detail-head h3 {
    margin: 0;
    font-size: 1rem;
}

.ai-report-detail-meta {
    margin: 0.2rem 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.ai-report-detail-close {
    border: none;
    background: rgba(148, 163, 184, 0.12);
    color: inherit;
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    font-size: 1.25rem;
    cursor: pointer;
}

.ai-report-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.85rem 1rem 1.25rem;
    -webkit-overflow-scrolling: touch;
}

.ai-report-md-body {
    font-size: 0.9rem;
    line-height: 1.75;
    color: #e2e8f0;
}

.ai-report-md-h3 {
    margin: 1rem 0 0.4rem;
    font-size: 1rem;
    color: #c7d2fe;
}

.ai-report-md-h4 {
    margin: 0.7rem 0 0.3rem;
    font-size: 0.92rem;
    color: #93c5fd;
}

.ai-report-md-list {
    margin: 0 0 0.65rem;
    padding-right: 1.1rem;
}

.ai-report-error {
    color: #fca5a5;
}

@media (min-width: 640px) {
    .ai-report-detail-overlay {
        align-items: center;
    }

    .ai-report-detail-sheet {
        border-radius: var(--radius);
    }
}

.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 0.65rem;
}

.profile-stat-card {
    text-align: center;
    padding: 0.85rem 0.65rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.profile-stat-card.accent {
    border-color: rgba(34, 197, 94, 0.35);
    background: linear-gradient(160deg, rgba(34, 197, 94, 0.1), rgba(15, 23, 42, 0.85));
}

.profile-stat-value {
    display: block;
    font-size: 1.45rem;
    font-weight: 700;
    color: #f8fafc;
}

.profile-stat-label {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.74rem;
    color: var(--text-muted);
}

.profile-detail-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.profile-detail-item {
    padding: 0.8rem 0.95rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.profile-detail-label {
    display: block;
    font-size: 0.74rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.profile-detail-value {
    display: block;
    font-size: 0.92rem;
    color: #f1f5f9;
}

.profile-detail-meta {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.78rem;
    color: #94a3b8;
}

.analyzer-entry {
    text-align: center;
    padding: 1.5rem 1rem 2rem;
}

.analyzer-entry-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    max-width: 340px;
    margin: 0 auto;
}

.analyzer-primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    width: 100%;
    max-width: 320px;
    padding: 0.85rem 1.25rem;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #d97706, #f59e0b);
    color: #0f172a;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.analyzer-primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(245, 158, 11, 0.45);
}

.analyzer-secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    width: 100%;
    max-width: 320px;
    padding: 0.8rem 1.2rem;
    border-radius: 14px;
    border: 1px solid rgba(59, 130, 246, 0.45);
    background: linear-gradient(135deg, rgba(30, 58, 138, 0.9), rgba(37, 99, 235, 0.75));
    color: #e0f2fe;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.analyzer-secondary-btn:hover {
    transform: translateY(-2px);
    border-color: rgba(96, 165, 250, 0.7);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
    color: #fff;
}

.analyzer-primary-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.analyzer-entry-hint {
    margin: 0.85rem auto 0;
    max-width: 360px;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.55;
}

.analyzer-picker.hidden {
    display: none;
}

.analyzer-entry.hidden {
    display: none;
}

.analyzer-back-btn {
    display: inline-flex;
    align-items: center;
    margin-bottom: 0.75rem;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.82rem;
    cursor: pointer;
}

.analyzer-back-btn:hover {
    color: #e2e8f0;
    border-color: rgba(59, 130, 246, 0.4);
}

.analyzer-picker-title {
    margin: 0 0 0.85rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #e2e8f0;
}

.quiz-item-analyzer .quiz-item-go {
    color: #fbbf24;
}

.action-icon svg {
    width: 100%;
    height: 100%;
}

.action-title {
    display: block;
    font-weight: 600;
    font-size: 0.98rem;
    margin-bottom: 0.2rem;
}

.action-desc {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.65rem;
    margin-top: 1rem;
}

.stats-row.hidden {
    display: none;
}

.stat-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem;
    text-align: center;
}

.stat-box strong {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-box span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stat-box-last-attempt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.stat-box-last-attempt .stat-last-date {
    font-size: 0.88rem;
    font-weight: 700;
    color: #e2e8f0;
    line-height: 1.35;
    font-variant-numeric: tabular-nums;
}

.stat-box-last-attempt .stat-last-elapsed {
    font-size: 0.72rem;
    color: #93c5fd;
}

.stat-box-last-attempt .stat-last-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.section-head {
    margin-bottom: 1rem;
}

.section-head h2 {
    margin: 0 0 0.25rem;
    font-size: 1.15rem;
    font-weight: 700;
}

.section-head p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.quiz-list {
    display: grid;
    gap: 0.75rem;
}

.quiz-tag-filter-bar {
    margin-bottom: 0.75rem;
}

.quiz-tag-filter-bar.hidden {
    display: none;
}

.quiz-tag-active-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius);
    border: 1px dashed rgba(59, 130, 246, 0.45);
    background: rgba(59, 130, 246, 0.08);
}

.quiz-tag-active-label {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.quiz-item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.45rem;
}

.quiz-tag-chip {
    border: 1px solid rgba(56, 189, 248, 0.35);
    background: rgba(56, 189, 248, 0.1);
    color: #7dd3fc;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.12s;
    font-family: inherit;
}

.quiz-tag-chip:hover {
    border-color: rgba(56, 189, 248, 0.65);
    background: rgba(56, 189, 248, 0.18);
    color: #bae6fd;
    transform: translateY(-1px);
}

.quiz-tag-chip.is-active {
    border-color: rgba(34, 197, 94, 0.55);
    background: rgba(34, 197, 94, 0.16);
    color: #86efac;
}

.quiz-tag-filter-clear {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.76rem;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    font-family: inherit;
}

.quiz-tag-filter-clear:hover {
    color: #e2e8f0;
}

.quiz-item-row {
    display: flex;
    align-items: stretch;
    gap: 0.45rem;
}

.quiz-pin-btn {
    flex-shrink: 0;
    align-self: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.quiz-pin-btn:hover {
    border-color: rgba(245, 158, 11, 0.45);
    color: #fbbf24;
}

.quiz-pin-btn.is-pinned {
    border-color: rgba(245, 158, 11, 0.55);
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
}

.quiz-item-row .quiz-item {
    flex: 1;
    min-width: 0;
}

.quiz-item.is-pinned-quiz {
    border-color: rgba(245, 158, 11, 0.35);
}

.quiz-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, transform 0.15s;
}

.quiz-item:hover {
    border-color: rgba(59, 130, 246, 0.5);
    transform: translateX(-3px);
}

.quiz-item-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.2rem;
}

.quiz-item-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    flex-shrink: 0;
}

.quiz-access-badge {
    flex-shrink: 0;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.18rem 0.45rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.28);
    color: #cbd5e1;
    white-space: nowrap;
}

.quiz-access-badge.is-public {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.32);
    color: #86efac;
}

.quiz-item-body h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    flex: 1;
    min-width: 0;
}

.quiz-type-badge {
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.28);
    color: #93c5fd;
    white-space: nowrap;
}

.quiz-item-body p {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.quiz-item-stats {
    margin-top: 0.2rem !important;
    font-size: 0.76rem !important;
}

.quiz-item-body .quiz-item-tags {
    margin-top: 0.35rem;
}

.quiz-item-go {
    flex-shrink: 0;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
}

.history-timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
    padding-right: 1.5rem;
}

.history-timeline::before {
    content: "";
    position: absolute;
    right: 0.45rem;
    top: 0.5rem;
    bottom: 0.5rem;
    width: 2px;
    background: linear-gradient(180deg, var(--primary), rgba(59, 130, 246, 0.1));
    border-radius: 2px;
}

.history-entry {
    position: relative;
    margin-bottom: 1rem;
    padding: 1rem 1rem 1rem 0;
}

.history-entry::before {
    content: "";
    position: absolute;
    right: -1.28rem;
    top: 1.35rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--bg);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.history-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.history-card.great {
    border-color: rgba(34, 197, 94, 0.35);
}

.history-card.ok {
    border-color: rgba(245, 158, 11, 0.35);
}

.history-card.low {
    border-color: rgba(239, 68, 68, 0.35);
}

.history-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
}

.history-top h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.history-date {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.history-score {
    display: inline-flex;
    align-items: baseline;
    gap: 0.15rem;
    padding: 0.35rem 0.65rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1.05rem;
    background: var(--primary-soft);
    color: #93c5fd;
}

.history-card.great .history-score {
    background: rgba(34, 197, 94, 0.15);
    color: #86efac;
}

.history-card.low .history-score {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

.history-score small {
    font-size: 0.72rem;
    font-weight: 500;
    opacity: 0.85;
}

.history-score-dual {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex-shrink: 0;
}

.history-score-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.35rem;
    padding: 0.2rem 0.45rem;
    border-radius: 8px;
    background: var(--primary-soft);
    font-size: 0.72rem;
    min-width: 4.5rem;
}

.history-score-line span {
    color: var(--text-muted);
    font-weight: 500;
}

.history-score-line strong {
    color: #93c5fd;
    font-size: 0.85rem;
}

.history-score-line strong small {
    font-size: 0.65rem;
}

.history-score-line.negative {
    background: rgba(245, 158, 11, 0.12);
}

.history-score-line.negative strong {
    color: #fcd34d;
}

.history-card.great .history-score-line {
    background: rgba(34, 197, 94, 0.12);
}

.history-card.great .history-score-line strong {
    color: #86efac;
}

.history-card.low .history-score-line {
    background: rgba(239, 68, 68, 0.12);
}

.history-card.low .history-score-line strong {
    color: #fca5a5;
}

.history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.meta-tag {
    font-size: 0.72rem;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.history-wrong {
    margin: 0;
    font-size: 0.84rem;
    color: var(--text-muted);
}

.history-wrong strong {
    color: #fca5a5;
    font-weight: 600;
}

.history-delete-btn {
    margin-top: 0.75rem;
    width: 100%;
    border: 1px solid rgba(239, 68, 68, 0.45);
    background: rgba(127, 29, 29, 0.35);
    color: #fecaca;
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.history-delete-btn:hover:not(:disabled) {
    background: rgba(153, 27, 27, 0.55);
    border-color: #ef4444;
}

.history-delete-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.state-card {
    text-align: center;
    padding: 2.5rem 1.5rem;
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.state-card h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}

.state-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.state-card.error p {
    color: #fca5a5;
}

.state-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 640px) {
    .action-grid {
        grid-template-columns: 1fr;
    }

    .stats-row {
        grid-template-columns: 1fr;
    }

    .history-top {
        flex-direction: column;
    }
}
